babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615
  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/Maths/math.scalar" {
  517. /**
  518. * Scalar computation library
  519. */
  520. export class Scalar {
  521. /**
  522. * Two pi constants convenient for computation.
  523. */
  524. static TwoPi: number;
  525. /**
  526. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  527. * @param a number
  528. * @param b number
  529. * @param epsilon (default = 1.401298E-45)
  530. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  531. */
  532. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  533. /**
  534. * Returns a string : the upper case translation of the number i to hexadecimal.
  535. * @param i number
  536. * @returns the upper case translation of the number i to hexadecimal.
  537. */
  538. static ToHex(i: number): string;
  539. /**
  540. * Returns -1 if value is negative and +1 is value is positive.
  541. * @param value the value
  542. * @returns the value itself if it's equal to zero.
  543. */
  544. static Sign(value: number): number;
  545. /**
  546. * Returns the value itself if it's between min and max.
  547. * Returns min if the value is lower than min.
  548. * Returns max if the value is greater than max.
  549. * @param value the value to clmap
  550. * @param min the min value to clamp to (default: 0)
  551. * @param max the max value to clamp to (default: 1)
  552. * @returns the clamped value
  553. */
  554. static Clamp(value: number, min?: number, max?: number): number;
  555. /**
  556. * the log2 of value.
  557. * @param value the value to compute log2 of
  558. * @returns the log2 of value.
  559. */
  560. static Log2(value: number): number;
  561. /**
  562. * Loops the value, so that it is never larger than length and never smaller than 0.
  563. *
  564. * This is similar to the modulo operator but it works with floating point numbers.
  565. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  566. * With t = 5 and length = 2.5, the result would be 0.0.
  567. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  568. * @param value the value
  569. * @param length the length
  570. * @returns the looped value
  571. */
  572. static Repeat(value: number, length: number): number;
  573. /**
  574. * Normalize the value between 0.0 and 1.0 using min and max values
  575. * @param value value to normalize
  576. * @param min max to normalize between
  577. * @param max min to normalize between
  578. * @returns the normalized value
  579. */
  580. static Normalize(value: number, min: number, max: number): number;
  581. /**
  582. * Denormalize the value from 0.0 and 1.0 using min and max values
  583. * @param normalized value to denormalize
  584. * @param min max to denormalize between
  585. * @param max min to denormalize between
  586. * @returns the denormalized value
  587. */
  588. static Denormalize(normalized: number, min: number, max: number): number;
  589. /**
  590. * Calculates the shortest difference between two given angles given in degrees.
  591. * @param current current angle in degrees
  592. * @param target target angle in degrees
  593. * @returns the delta
  594. */
  595. static DeltaAngle(current: number, target: number): number;
  596. /**
  597. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  598. * @param tx value
  599. * @param length length
  600. * @returns The returned value will move back and forth between 0 and length
  601. */
  602. static PingPong(tx: number, length: number): number;
  603. /**
  604. * Interpolates between min and max with smoothing at the limits.
  605. *
  606. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  607. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  608. * @param from from
  609. * @param to to
  610. * @param tx value
  611. * @returns the smooth stepped value
  612. */
  613. static SmoothStep(from: number, to: number, tx: number): number;
  614. /**
  615. * Moves a value current towards target.
  616. *
  617. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  618. * Negative values of maxDelta pushes the value away from target.
  619. * @param current current value
  620. * @param target target value
  621. * @param maxDelta max distance to move
  622. * @returns resulting value
  623. */
  624. static MoveTowards(current: number, target: number, maxDelta: number): number;
  625. /**
  626. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  627. *
  628. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  629. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  630. * @param current current value
  631. * @param target target value
  632. * @param maxDelta max distance to move
  633. * @returns resulting angle
  634. */
  635. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  636. /**
  637. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  638. * @param start start value
  639. * @param end target value
  640. * @param amount amount to lerp between
  641. * @returns the lerped value
  642. */
  643. static Lerp(start: number, end: number, amount: number): number;
  644. /**
  645. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  646. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  647. * @param start start value
  648. * @param end target value
  649. * @param amount amount to lerp between
  650. * @returns the lerped value
  651. */
  652. static LerpAngle(start: number, end: number, amount: number): number;
  653. /**
  654. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  655. * @param a start value
  656. * @param b target value
  657. * @param value value between a and b
  658. * @returns the inverseLerp value
  659. */
  660. static InverseLerp(a: number, b: number, value: number): number;
  661. /**
  662. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  663. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  664. * @param value1 spline value
  665. * @param tangent1 spline value
  666. * @param value2 spline value
  667. * @param tangent2 spline value
  668. * @param amount input value
  669. * @returns hermite result
  670. */
  671. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  672. /**
  673. * Returns a random float number between and min and max values
  674. * @param min min value of random
  675. * @param max max value of random
  676. * @returns random value
  677. */
  678. static RandomRange(min: number, max: number): number;
  679. /**
  680. * This function returns percentage of a number in a given range.
  681. *
  682. * RangeToPercent(40,20,60) will return 0.5 (50%)
  683. * RangeToPercent(34,0,100) will return 0.34 (34%)
  684. * @param number to convert to percentage
  685. * @param min min range
  686. * @param max max range
  687. * @returns the percentage
  688. */
  689. static RangeToPercent(number: number, min: number, max: number): number;
  690. /**
  691. * This function returns number that corresponds to the percentage in a given range.
  692. *
  693. * PercentToRange(0.34,0,100) will return 34.
  694. * @param percent to convert to number
  695. * @param min min range
  696. * @param max max range
  697. * @returns the number
  698. */
  699. static PercentToRange(percent: number, min: number, max: number): number;
  700. /**
  701. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  702. * @param angle The angle to normalize in radian.
  703. * @return The converted angle.
  704. */
  705. static NormalizeRadians(angle: number): number;
  706. }
  707. }
  708. declare module "babylonjs/Maths/math.constants" {
  709. /**
  710. * Constant used to convert a value to gamma space
  711. * @ignorenaming
  712. */
  713. export const ToGammaSpace: number;
  714. /**
  715. * Constant used to convert a value to linear space
  716. * @ignorenaming
  717. */
  718. export const ToLinearSpace = 2.2;
  719. /**
  720. * Constant used to define the minimal number value in Babylon.js
  721. * @ignorenaming
  722. */
  723. let Epsilon: number;
  724. export { Epsilon };
  725. }
  726. declare module "babylonjs/Maths/math.viewport" {
  727. /**
  728. * Class used to represent a viewport on screen
  729. */
  730. export class Viewport {
  731. /** viewport left coordinate */
  732. x: number;
  733. /** viewport top coordinate */
  734. y: number;
  735. /**viewport width */
  736. width: number;
  737. /** viewport height */
  738. height: number;
  739. /**
  740. * Creates a Viewport object located at (x, y) and sized (width, height)
  741. * @param x defines viewport left coordinate
  742. * @param y defines viewport top coordinate
  743. * @param width defines the viewport width
  744. * @param height defines the viewport height
  745. */
  746. constructor(
  747. /** viewport left coordinate */
  748. x: number,
  749. /** viewport top coordinate */
  750. y: number,
  751. /**viewport width */
  752. width: number,
  753. /** viewport height */
  754. height: number);
  755. /**
  756. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  757. * @param renderWidth defines the rendering width
  758. * @param renderHeight defines the rendering height
  759. * @returns a new Viewport
  760. */
  761. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  762. /**
  763. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  764. * @param renderWidth defines the rendering width
  765. * @param renderHeight defines the rendering height
  766. * @param ref defines the target viewport
  767. * @returns the current viewport
  768. */
  769. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  770. /**
  771. * Returns a new Viewport copied from the current one
  772. * @returns a new Viewport
  773. */
  774. clone(): Viewport;
  775. }
  776. }
  777. declare module "babylonjs/Misc/arrayTools" {
  778. /**
  779. * Class containing a set of static utilities functions for arrays.
  780. */
  781. export class ArrayTools {
  782. /**
  783. * Returns an array of the given size filled with element built from the given constructor and the paramters
  784. * @param size the number of element to construct and put in the array
  785. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  786. * @returns a new array filled with new objects
  787. */
  788. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  789. }
  790. }
  791. declare module "babylonjs/Maths/math.like" {
  792. import { float, int, DeepImmutable } from "babylonjs/types";
  793. /**
  794. * @hidden
  795. */
  796. export interface IColor4Like {
  797. r: float;
  798. g: float;
  799. b: float;
  800. a: float;
  801. }
  802. /**
  803. * @hidden
  804. */
  805. export interface IColor3Like {
  806. r: float;
  807. g: float;
  808. b: float;
  809. }
  810. /**
  811. * @hidden
  812. */
  813. export interface IVector4Like {
  814. x: float;
  815. y: float;
  816. z: float;
  817. w: float;
  818. }
  819. /**
  820. * @hidden
  821. */
  822. export interface IVector3Like {
  823. x: float;
  824. y: float;
  825. z: float;
  826. }
  827. /**
  828. * @hidden
  829. */
  830. export interface IVector2Like {
  831. x: float;
  832. y: float;
  833. }
  834. /**
  835. * @hidden
  836. */
  837. export interface IMatrixLike {
  838. toArray(): DeepImmutable<Float32Array>;
  839. updateFlag: int;
  840. }
  841. /**
  842. * @hidden
  843. */
  844. export interface IViewportLike {
  845. x: float;
  846. y: float;
  847. width: float;
  848. height: float;
  849. }
  850. /**
  851. * @hidden
  852. */
  853. export interface IPlaneLike {
  854. normal: IVector3Like;
  855. d: float;
  856. normalize(): void;
  857. }
  858. }
  859. declare module "babylonjs/Maths/math.vector" {
  860. import { Viewport } from "babylonjs/Maths/math.viewport";
  861. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  862. import { IPlaneLike } from "babylonjs/Maths/math.like";
  863. /**
  864. * Class representing a vector containing 2 coordinates
  865. */
  866. export class Vector2 {
  867. /** defines the first coordinate */
  868. x: number;
  869. /** defines the second coordinate */
  870. y: number;
  871. /**
  872. * Creates a new Vector2 from the given x and y coordinates
  873. * @param x defines the first coordinate
  874. * @param y defines the second coordinate
  875. */
  876. constructor(
  877. /** defines the first coordinate */
  878. x?: number,
  879. /** defines the second coordinate */
  880. y?: number);
  881. /**
  882. * Gets a string with the Vector2 coordinates
  883. * @returns a string with the Vector2 coordinates
  884. */
  885. toString(): string;
  886. /**
  887. * Gets class name
  888. * @returns the string "Vector2"
  889. */
  890. getClassName(): string;
  891. /**
  892. * Gets current vector hash code
  893. * @returns the Vector2 hash code as a number
  894. */
  895. getHashCode(): number;
  896. /**
  897. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  898. * @param array defines the source array
  899. * @param index defines the offset in source array
  900. * @returns the current Vector2
  901. */
  902. toArray(array: FloatArray, index?: number): Vector2;
  903. /**
  904. * Copy the current vector to an array
  905. * @returns a new array with 2 elements: the Vector2 coordinates.
  906. */
  907. asArray(): number[];
  908. /**
  909. * Sets the Vector2 coordinates with the given Vector2 coordinates
  910. * @param source defines the source Vector2
  911. * @returns the current updated Vector2
  912. */
  913. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Sets the Vector2 coordinates with the given floats
  916. * @param x defines the first coordinate
  917. * @param y defines the second coordinate
  918. * @returns the current updated Vector2
  919. */
  920. copyFromFloats(x: number, y: number): Vector2;
  921. /**
  922. * Sets the Vector2 coordinates with the given floats
  923. * @param x defines the first coordinate
  924. * @param y defines the second coordinate
  925. * @returns the current updated Vector2
  926. */
  927. set(x: number, y: number): Vector2;
  928. /**
  929. * Add another vector with the current one
  930. * @param otherVector defines the other vector
  931. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  932. */
  933. add(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @param result defines the target vector
  938. * @returns the unmodified current Vector2
  939. */
  940. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  941. /**
  942. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. addVector3(otherVector: Vector3): Vector2;
  953. /**
  954. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  955. * @param otherVector defines the other vector
  956. * @returns a new Vector2
  957. */
  958. subtract(otherVector: Vector2): Vector2;
  959. /**
  960. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  961. * @param otherVector defines the other vector
  962. * @param result defines the target vector
  963. * @returns the unmodified current Vector2
  964. */
  965. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  966. /**
  967. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns the current updated Vector2
  970. */
  971. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  972. /**
  973. * Multiplies in place the current Vector2 coordinates by the given ones
  974. * @param otherVector defines the other vector
  975. * @returns the current updated Vector2
  976. */
  977. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  978. /**
  979. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  980. * @param otherVector defines the other vector
  981. * @returns a new Vector2
  982. */
  983. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  986. * @param otherVector defines the other vector
  987. * @param result defines the target vector
  988. * @returns the unmodified current Vector2
  989. */
  990. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  991. /**
  992. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  993. * @param x defines the first coordinate
  994. * @param y defines the second coordinate
  995. * @returns a new Vector2
  996. */
  997. multiplyByFloats(x: number, y: number): Vector2;
  998. /**
  999. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1000. * @param otherVector defines the other vector
  1001. * @returns a new Vector2
  1002. */
  1003. divide(otherVector: Vector2): Vector2;
  1004. /**
  1005. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1006. * @param otherVector defines the other vector
  1007. * @param result defines the target vector
  1008. * @returns the unmodified current Vector2
  1009. */
  1010. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1011. /**
  1012. * Divides the current Vector2 coordinates by the given ones
  1013. * @param otherVector defines the other vector
  1014. * @returns the current updated Vector2
  1015. */
  1016. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1017. /**
  1018. * Gets a new Vector2 with current Vector2 negated coordinates
  1019. * @returns a new Vector2
  1020. */
  1021. negate(): Vector2;
  1022. /**
  1023. * Multiply the Vector2 coordinates by scale
  1024. * @param scale defines the scaling factor
  1025. * @returns the current updated Vector2
  1026. */
  1027. scaleInPlace(scale: number): Vector2;
  1028. /**
  1029. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1030. * @param scale defines the scaling factor
  1031. * @returns a new Vector2
  1032. */
  1033. scale(scale: number): Vector2;
  1034. /**
  1035. * Scale the current Vector2 values by a factor to a given Vector2
  1036. * @param scale defines the scale factor
  1037. * @param result defines the Vector2 object where to store the result
  1038. * @returns the unmodified current Vector2
  1039. */
  1040. scaleToRef(scale: number, result: Vector2): Vector2;
  1041. /**
  1042. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1043. * @param scale defines the scale factor
  1044. * @param result defines the Vector2 object where to store the result
  1045. * @returns the unmodified current Vector2
  1046. */
  1047. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1048. /**
  1049. * Gets a boolean if two vectors are equals
  1050. * @param otherVector defines the other vector
  1051. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1052. */
  1053. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1054. /**
  1055. * Gets a boolean if two vectors are equals (using an epsilon value)
  1056. * @param otherVector defines the other vector
  1057. * @param epsilon defines the minimal distance to consider equality
  1058. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1059. */
  1060. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1061. /**
  1062. * Gets a new Vector2 from current Vector2 floored values
  1063. * @returns a new Vector2
  1064. */
  1065. floor(): Vector2;
  1066. /**
  1067. * Gets a new Vector2 from current Vector2 floored values
  1068. * @returns a new Vector2
  1069. */
  1070. fract(): Vector2;
  1071. /**
  1072. * Gets the length of the vector
  1073. * @returns the vector length (float)
  1074. */
  1075. length(): number;
  1076. /**
  1077. * Gets the vector squared length
  1078. * @returns the vector squared length (float)
  1079. */
  1080. lengthSquared(): number;
  1081. /**
  1082. * Normalize the vector
  1083. * @returns the current updated Vector2
  1084. */
  1085. normalize(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 copied from the Vector2
  1088. * @returns a new Vector2
  1089. */
  1090. clone(): Vector2;
  1091. /**
  1092. * Gets a new Vector2(0, 0)
  1093. * @returns a new Vector2
  1094. */
  1095. static Zero(): Vector2;
  1096. /**
  1097. * Gets a new Vector2(1, 1)
  1098. * @returns a new Vector2
  1099. */
  1100. static One(): Vector2;
  1101. /**
  1102. * Gets a new Vector2 set from the given index element of the given array
  1103. * @param array defines the data source
  1104. * @param offset defines the offset in the data source
  1105. * @returns a new Vector2
  1106. */
  1107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1108. /**
  1109. * Sets "result" from the given index element of the given array
  1110. * @param array defines the data source
  1111. * @param offset defines the offset in the data source
  1112. * @param result defines the target vector
  1113. */
  1114. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1115. /**
  1116. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1117. * @param value1 defines 1st point of control
  1118. * @param value2 defines 2nd point of control
  1119. * @param value3 defines 3rd point of control
  1120. * @param value4 defines 4th point of control
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * 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".
  1127. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1128. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1129. * @param value defines the value to clamp
  1130. * @param min defines the lower limit
  1131. * @param max defines the upper limit
  1132. * @returns a new Vector2
  1133. */
  1134. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1137. * @param value1 defines the 1st control point
  1138. * @param tangent1 defines the outgoing tangent
  1139. * @param value2 defines the 2nd control point
  1140. * @param tangent2 defines the incoming tangent
  1141. * @param amount defines the interpolation factor
  1142. * @returns a new Vector2
  1143. */
  1144. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1145. /**
  1146. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1147. * @param start defines the start vector
  1148. * @param end defines the end vector
  1149. * @param amount defines the interpolation factor
  1150. * @returns a new Vector2
  1151. */
  1152. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1153. /**
  1154. * Gets the dot product of the vector "left" and the vector "right"
  1155. * @param left defines first vector
  1156. * @param right defines second vector
  1157. * @returns the dot product (float)
  1158. */
  1159. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1160. /**
  1161. * Returns a new Vector2 equal to the normalized given vector
  1162. * @param vector defines the vector to normalize
  1163. * @returns a new Vector2
  1164. */
  1165. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1166. /**
  1167. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1168. * @param left defines 1st vector
  1169. * @param right defines 2nd vector
  1170. * @returns a new Vector2
  1171. */
  1172. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1173. /**
  1174. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1175. * @param left defines 1st vector
  1176. * @param right defines 2nd vector
  1177. * @returns a new Vector2
  1178. */
  1179. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1180. /**
  1181. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1182. * @param vector defines the vector to transform
  1183. * @param transformation defines the matrix to apply
  1184. * @returns a new Vector2
  1185. */
  1186. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1187. /**
  1188. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1189. * @param vector defines the vector to transform
  1190. * @param transformation defines the matrix to apply
  1191. * @param result defines the target vector
  1192. */
  1193. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1194. /**
  1195. * Determines if a given vector is included in a triangle
  1196. * @param p defines the vector to test
  1197. * @param p0 defines 1st triangle point
  1198. * @param p1 defines 2nd triangle point
  1199. * @param p2 defines 3rd triangle point
  1200. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1201. */
  1202. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1203. /**
  1204. * Gets the distance between the vectors "value1" and "value2"
  1205. * @param value1 defines first vector
  1206. * @param value2 defines second vector
  1207. * @returns the distance between vectors
  1208. */
  1209. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1210. /**
  1211. * Returns the squared distance between the vectors "value1" and "value2"
  1212. * @param value1 defines first vector
  1213. * @param value2 defines second vector
  1214. * @returns the squared distance between vectors
  1215. */
  1216. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1217. /**
  1218. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1219. * @param value1 defines first vector
  1220. * @param value2 defines second vector
  1221. * @returns a new Vector2
  1222. */
  1223. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1224. /**
  1225. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1226. * @param p defines the middle point
  1227. * @param segA defines one point of the segment
  1228. * @param segB defines the other point of the segment
  1229. * @returns the shortest distance
  1230. */
  1231. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1232. }
  1233. /**
  1234. * Classed used to store (x,y,z) vector representation
  1235. * A Vector3 is the main object used in 3D geometry
  1236. * It can represent etiher the coordinates of a point the space, either a direction
  1237. * Reminder: js uses a left handed forward facing system
  1238. */
  1239. export class Vector3 {
  1240. /**
  1241. * Defines the first coordinates (on X axis)
  1242. */
  1243. x: number;
  1244. /**
  1245. * Defines the second coordinates (on Y axis)
  1246. */
  1247. y: number;
  1248. /**
  1249. * Defines the third coordinates (on Z axis)
  1250. */
  1251. z: number;
  1252. private static _UpReadOnly;
  1253. private static _ZeroReadOnly;
  1254. /**
  1255. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1256. * @param x defines the first coordinates (on X axis)
  1257. * @param y defines the second coordinates (on Y axis)
  1258. * @param z defines the third coordinates (on Z axis)
  1259. */
  1260. constructor(
  1261. /**
  1262. * Defines the first coordinates (on X axis)
  1263. */
  1264. x?: number,
  1265. /**
  1266. * Defines the second coordinates (on Y axis)
  1267. */
  1268. y?: number,
  1269. /**
  1270. * Defines the third coordinates (on Z axis)
  1271. */
  1272. z?: number);
  1273. /**
  1274. * Creates a string representation of the Vector3
  1275. * @returns a string with the Vector3 coordinates.
  1276. */
  1277. toString(): string;
  1278. /**
  1279. * Gets the class name
  1280. * @returns the string "Vector3"
  1281. */
  1282. getClassName(): string;
  1283. /**
  1284. * Creates the Vector3 hash code
  1285. * @returns a number which tends to be unique between Vector3 instances
  1286. */
  1287. getHashCode(): number;
  1288. /**
  1289. * Creates an array containing three elements : the coordinates of the Vector3
  1290. * @returns a new array of numbers
  1291. */
  1292. asArray(): number[];
  1293. /**
  1294. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1295. * @param array defines the destination array
  1296. * @param index defines the offset in the destination array
  1297. * @returns the current Vector3
  1298. */
  1299. toArray(array: FloatArray, index?: number): Vector3;
  1300. /**
  1301. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1302. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1303. */
  1304. toQuaternion(): Quaternion;
  1305. /**
  1306. * Adds the given vector to the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the current updated Vector3
  1309. */
  1310. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Adds the given coordinates to the current Vector3
  1313. * @param x defines the x coordinate of the operand
  1314. * @param y defines the y coordinate of the operand
  1315. * @param z defines the z coordinate of the operand
  1316. * @returns the current updated Vector3
  1317. */
  1318. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1319. /**
  1320. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1321. * @param otherVector defines the second operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1327. * @param otherVector defines the second operand
  1328. * @param result defines the Vector3 object where to store the result
  1329. * @returns the current Vector3
  1330. */
  1331. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1332. /**
  1333. * Subtract the given vector from the current Vector3
  1334. * @param otherVector defines the second operand
  1335. * @returns the current updated Vector3
  1336. */
  1337. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1338. /**
  1339. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1340. * @param otherVector defines the second operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1344. /**
  1345. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1346. * @param otherVector defines the second operand
  1347. * @param result defines the Vector3 object where to store the result
  1348. * @returns the current Vector3
  1349. */
  1350. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1351. /**
  1352. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1353. * @param x defines the x coordinate of the operand
  1354. * @param y defines the y coordinate of the operand
  1355. * @param z defines the z coordinate of the operand
  1356. * @returns the resulting Vector3
  1357. */
  1358. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1359. /**
  1360. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1361. * @param x defines the x coordinate of the operand
  1362. * @param y defines the y coordinate of the operand
  1363. * @param z defines the z coordinate of the operand
  1364. * @param result defines the Vector3 object where to store the result
  1365. * @returns the current Vector3
  1366. */
  1367. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1368. /**
  1369. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1370. * @returns a new Vector3
  1371. */
  1372. negate(): Vector3;
  1373. /**
  1374. * Multiplies the Vector3 coordinates by the float "scale"
  1375. * @param scale defines the multiplier factor
  1376. * @returns the current updated Vector3
  1377. */
  1378. scaleInPlace(scale: number): Vector3;
  1379. /**
  1380. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1381. * @param scale defines the multiplier factor
  1382. * @returns a new Vector3
  1383. */
  1384. scale(scale: number): Vector3;
  1385. /**
  1386. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1387. * @param scale defines the multiplier factor
  1388. * @param result defines the Vector3 object where to store the result
  1389. * @returns the current Vector3
  1390. */
  1391. scaleToRef(scale: number, result: Vector3): Vector3;
  1392. /**
  1393. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1394. * @param scale defines the scale factor
  1395. * @param result defines the Vector3 object where to store the result
  1396. * @returns the unmodified current Vector3
  1397. */
  1398. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1399. /**
  1400. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1401. * @param otherVector defines the second operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1405. /**
  1406. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1407. * @param otherVector defines the second operand
  1408. * @param epsilon defines the minimal distance to define values as equals
  1409. * @returns true if both vectors are distant less than epsilon
  1410. */
  1411. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1412. /**
  1413. * Returns true if the current Vector3 coordinates equals the given floats
  1414. * @param x defines the x coordinate of the operand
  1415. * @param y defines the y coordinate of the operand
  1416. * @param z defines the z coordinate of the operand
  1417. * @returns true if both vectors are equals
  1418. */
  1419. equalsToFloats(x: number, y: number, z: number): boolean;
  1420. /**
  1421. * Multiplies the current Vector3 coordinates by the given ones
  1422. * @param otherVector defines the second operand
  1423. * @returns the current updated Vector3
  1424. */
  1425. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1426. /**
  1427. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1428. * @param otherVector defines the second operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1432. /**
  1433. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1434. * @param otherVector defines the second operand
  1435. * @param result defines the Vector3 object where to store the result
  1436. * @returns the current Vector3
  1437. */
  1438. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1439. /**
  1440. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1441. * @param x defines the x coordinate of the operand
  1442. * @param y defines the y coordinate of the operand
  1443. * @param z defines the z coordinate of the operand
  1444. * @returns the new Vector3
  1445. */
  1446. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1447. /**
  1448. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1449. * @param otherVector defines the second operand
  1450. * @returns the new Vector3
  1451. */
  1452. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1453. /**
  1454. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1455. * @param otherVector defines the second operand
  1456. * @param result defines the Vector3 object where to store the result
  1457. * @returns the current Vector3
  1458. */
  1459. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1460. /**
  1461. * Divides the current Vector3 coordinates by the given ones.
  1462. * @param otherVector defines the second operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. divideInPlace(otherVector: Vector3): Vector3;
  1466. /**
  1467. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1468. * @param other defines the second operand
  1469. * @returns the current updated Vector3
  1470. */
  1471. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1472. /**
  1473. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1474. * @param other defines the second operand
  1475. * @returns the current updated Vector3
  1476. */
  1477. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1478. /**
  1479. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1480. * @param x defines the x coordinate of the operand
  1481. * @param y defines the y coordinate of the operand
  1482. * @param z defines the z coordinate of the operand
  1483. * @returns the current updated Vector3
  1484. */
  1485. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1486. /**
  1487. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1488. * @param x defines the x coordinate of the operand
  1489. * @param y defines the y coordinate of the operand
  1490. * @param z defines the z coordinate of the operand
  1491. * @returns the current updated Vector3
  1492. */
  1493. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1494. /**
  1495. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1496. * Check if is non uniform within a certain amount of decimal places to account for this
  1497. * @param epsilon the amount the values can differ
  1498. * @returns if the the vector is non uniform to a certain number of decimal places
  1499. */
  1500. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1501. /**
  1502. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1503. */
  1504. readonly isNonUniform: boolean;
  1505. /**
  1506. * Gets a new Vector3 from current Vector3 floored values
  1507. * @returns a new Vector3
  1508. */
  1509. floor(): Vector3;
  1510. /**
  1511. * Gets a new Vector3 from current Vector3 floored values
  1512. * @returns a new Vector3
  1513. */
  1514. fract(): Vector3;
  1515. /**
  1516. * Gets the length of the Vector3
  1517. * @returns the length of the Vector3
  1518. */
  1519. length(): number;
  1520. /**
  1521. * Gets the squared length of the Vector3
  1522. * @returns squared length of the Vector3
  1523. */
  1524. lengthSquared(): number;
  1525. /**
  1526. * Normalize the current Vector3.
  1527. * Please note that this is an in place operation.
  1528. * @returns the current updated Vector3
  1529. */
  1530. normalize(): Vector3;
  1531. /**
  1532. * Reorders the x y z properties of the vector in place
  1533. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1534. * @returns the current updated vector
  1535. */
  1536. reorderInPlace(order: string): this;
  1537. /**
  1538. * Rotates the vector around 0,0,0 by a quaternion
  1539. * @param quaternion the rotation quaternion
  1540. * @param result vector to store the result
  1541. * @returns the resulting vector
  1542. */
  1543. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1544. /**
  1545. * Rotates a vector around a given point
  1546. * @param quaternion the rotation quaternion
  1547. * @param point the point to rotate around
  1548. * @param result vector to store the result
  1549. * @returns the resulting vector
  1550. */
  1551. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1552. /**
  1553. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1554. * The cross product is then orthogonal to both current and "other"
  1555. * @param other defines the right operand
  1556. * @returns the cross product
  1557. */
  1558. cross(other: Vector3): Vector3;
  1559. /**
  1560. * Normalize the current Vector3 with the given input length.
  1561. * Please note that this is an in place operation.
  1562. * @param len the length of the vector
  1563. * @returns the current updated Vector3
  1564. */
  1565. normalizeFromLength(len: number): Vector3;
  1566. /**
  1567. * Normalize the current Vector3 to a new vector
  1568. * @returns the new Vector3
  1569. */
  1570. normalizeToNew(): Vector3;
  1571. /**
  1572. * Normalize the current Vector3 to the reference
  1573. * @param reference define the Vector3 to update
  1574. * @returns the updated Vector3
  1575. */
  1576. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1577. /**
  1578. * Creates a new Vector3 copied from the current Vector3
  1579. * @returns the new Vector3
  1580. */
  1581. clone(): Vector3;
  1582. /**
  1583. * Copies the given vector coordinates to the current Vector3 ones
  1584. * @param source defines the source Vector3
  1585. * @returns the current updated Vector3
  1586. */
  1587. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1588. /**
  1589. * Copies the given floats to the current Vector3 coordinates
  1590. * @param x defines the x coordinate of the operand
  1591. * @param y defines the y coordinate of the operand
  1592. * @param z defines the z coordinate of the operand
  1593. * @returns the current updated Vector3
  1594. */
  1595. copyFromFloats(x: number, y: number, z: number): Vector3;
  1596. /**
  1597. * Copies the given floats to the current Vector3 coordinates
  1598. * @param x defines the x coordinate of the operand
  1599. * @param y defines the y coordinate of the operand
  1600. * @param z defines the z coordinate of the operand
  1601. * @returns the current updated Vector3
  1602. */
  1603. set(x: number, y: number, z: number): Vector3;
  1604. /**
  1605. * Copies the given float to the current Vector3 coordinates
  1606. * @param v defines the x, y and z coordinates of the operand
  1607. * @returns the current updated Vector3
  1608. */
  1609. setAll(v: number): Vector3;
  1610. /**
  1611. * Get the clip factor between two vectors
  1612. * @param vector0 defines the first operand
  1613. * @param vector1 defines the second operand
  1614. * @param axis defines the axis to use
  1615. * @param size defines the size along the axis
  1616. * @returns the clip factor
  1617. */
  1618. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1619. /**
  1620. * Get angle between two vectors
  1621. * @param vector0 angle between vector0 and vector1
  1622. * @param vector1 angle between vector0 and vector1
  1623. * @param normal direction of the normal
  1624. * @return the angle between vector0 and vector1
  1625. */
  1626. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1627. /**
  1628. * Returns a new Vector3 set from the index "offset" of the given array
  1629. * @param array defines the source array
  1630. * @param offset defines the offset in the source array
  1631. * @returns the new Vector3
  1632. */
  1633. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1636. * This function is deprecated. Use FromArray instead
  1637. * @param array defines the source array
  1638. * @param offset defines the offset in the source array
  1639. * @returns the new Vector3
  1640. */
  1641. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1642. /**
  1643. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1644. * @param array defines the source array
  1645. * @param offset defines the offset in the source array
  1646. * @param result defines the Vector3 where to store the result
  1647. */
  1648. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1649. /**
  1650. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1651. * This function is deprecated. Use FromArrayToRef instead.
  1652. * @param array defines the source array
  1653. * @param offset defines the offset in the source array
  1654. * @param result defines the Vector3 where to store the result
  1655. */
  1656. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1657. /**
  1658. * Sets the given vector "result" with the given floats.
  1659. * @param x defines the x coordinate of the source
  1660. * @param y defines the y coordinate of the source
  1661. * @param z defines the z coordinate of the source
  1662. * @param result defines the Vector3 where to store the result
  1663. */
  1664. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1665. /**
  1666. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1667. * @returns a new empty Vector3
  1668. */
  1669. static Zero(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1672. * @returns a new unit Vector3
  1673. */
  1674. static One(): Vector3;
  1675. /**
  1676. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1677. * @returns a new up Vector3
  1678. */
  1679. static Up(): Vector3;
  1680. /**
  1681. * Gets a up Vector3 that must not be updated
  1682. */
  1683. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1684. /**
  1685. * Gets a zero Vector3 that must not be updated
  1686. */
  1687. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1688. /**
  1689. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1690. * @returns a new down Vector3
  1691. */
  1692. static Down(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1695. * @returns a new forward Vector3
  1696. */
  1697. static Forward(): Vector3;
  1698. /**
  1699. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1700. * @returns a new forward Vector3
  1701. */
  1702. static Backward(): Vector3;
  1703. /**
  1704. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1705. * @returns a new right Vector3
  1706. */
  1707. static Right(): Vector3;
  1708. /**
  1709. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1710. * @returns a new left Vector3
  1711. */
  1712. static Left(): Vector3;
  1713. /**
  1714. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1715. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1716. * @param vector defines the Vector3 to transform
  1717. * @param transformation defines the transformation matrix
  1718. * @returns the transformed Vector3
  1719. */
  1720. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1721. /**
  1722. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1723. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1724. * @param vector defines the Vector3 to transform
  1725. * @param transformation defines the transformation matrix
  1726. * @param result defines the Vector3 where to store the result
  1727. */
  1728. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1729. /**
  1730. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1731. * This method computes tranformed coordinates only, not transformed direction vectors
  1732. * @param x define the x coordinate of the source vector
  1733. * @param y define the y coordinate of the source vector
  1734. * @param z define the z coordinate of the source vector
  1735. * @param transformation defines the transformation matrix
  1736. * @param result defines the Vector3 where to store the result
  1737. */
  1738. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1739. /**
  1740. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1741. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1742. * @param vector defines the Vector3 to transform
  1743. * @param transformation defines the transformation matrix
  1744. * @returns the new Vector3
  1745. */
  1746. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1747. /**
  1748. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1749. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1750. * @param vector defines the Vector3 to transform
  1751. * @param transformation defines the transformation matrix
  1752. * @param result defines the Vector3 where to store the result
  1753. */
  1754. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1755. /**
  1756. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1757. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1758. * @param x define the x coordinate of the source vector
  1759. * @param y define the y coordinate of the source vector
  1760. * @param z define the z coordinate of the source vector
  1761. * @param transformation defines the transformation matrix
  1762. * @param result defines the Vector3 where to store the result
  1763. */
  1764. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1765. /**
  1766. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1767. * @param value1 defines the first control point
  1768. * @param value2 defines the second control point
  1769. * @param value3 defines the third control point
  1770. * @param value4 defines the fourth control point
  1771. * @param amount defines the amount on the spline to use
  1772. * @returns the new Vector3
  1773. */
  1774. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1775. /**
  1776. * 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"
  1777. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1778. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1779. * @param value defines the current value
  1780. * @param min defines the lower range value
  1781. * @param max defines the upper range value
  1782. * @returns the new Vector3
  1783. */
  1784. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1785. /**
  1786. * 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"
  1787. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1788. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1789. * @param value defines the current value
  1790. * @param min defines the lower range value
  1791. * @param max defines the upper range value
  1792. * @param result defines the Vector3 where to store the result
  1793. */
  1794. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1795. /**
  1796. * Checks if a given vector is inside a specific range
  1797. * @param v defines the vector to test
  1798. * @param min defines the minimum range
  1799. * @param max defines the maximum range
  1800. */
  1801. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1802. /**
  1803. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1804. * @param value1 defines the first control point
  1805. * @param tangent1 defines the first tangent vector
  1806. * @param value2 defines the second control point
  1807. * @param tangent2 defines the second tangent vector
  1808. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1809. * @returns the new Vector3
  1810. */
  1811. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1812. /**
  1813. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1814. * @param start defines the start value
  1815. * @param end defines the end value
  1816. * @param amount max defines amount between both (between 0 and 1)
  1817. * @returns the new Vector3
  1818. */
  1819. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1820. /**
  1821. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1822. * @param start defines the start value
  1823. * @param end defines the end value
  1824. * @param amount max defines amount between both (between 0 and 1)
  1825. * @param result defines the Vector3 where to store the result
  1826. */
  1827. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1828. /**
  1829. * Returns the dot product (float) between the vectors "left" and "right"
  1830. * @param left defines the left operand
  1831. * @param right defines the right operand
  1832. * @returns the dot product
  1833. */
  1834. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1835. /**
  1836. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1837. * The cross product is then orthogonal to both "left" and "right"
  1838. * @param left defines the left operand
  1839. * @param right defines the right operand
  1840. * @returns the cross product
  1841. */
  1842. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1843. /**
  1844. * Sets the given vector "result" with the cross product of "left" and "right"
  1845. * The cross product is then orthogonal to both "left" and "right"
  1846. * @param left defines the left operand
  1847. * @param right defines the right operand
  1848. * @param result defines the Vector3 where to store the result
  1849. */
  1850. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1851. /**
  1852. * Returns a new Vector3 as the normalization of the given vector
  1853. * @param vector defines the Vector3 to normalize
  1854. * @returns the new Vector3
  1855. */
  1856. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Sets the given vector "result" with the normalization of the given first vector
  1859. * @param vector defines the Vector3 to normalize
  1860. * @param result defines the Vector3 where to store the result
  1861. */
  1862. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1863. /**
  1864. * Project a Vector3 onto screen space
  1865. * @param vector defines the Vector3 to project
  1866. * @param world defines the world matrix to use
  1867. * @param transform defines the transform (view x projection) matrix to use
  1868. * @param viewport defines the screen viewport to use
  1869. * @returns the new Vector3
  1870. */
  1871. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1872. /** @hidden */
  1873. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1874. /**
  1875. * Unproject from screen space to object space
  1876. * @param source defines the screen space Vector3 to use
  1877. * @param viewportWidth defines the current width of the viewport
  1878. * @param viewportHeight defines the current height of the viewport
  1879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1880. * @param transform defines the transform (view x projection) matrix to use
  1881. * @returns the new Vector3
  1882. */
  1883. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1884. /**
  1885. * Unproject from screen space to object space
  1886. * @param source defines the screen space Vector3 to use
  1887. * @param viewportWidth defines the current width of the viewport
  1888. * @param viewportHeight defines the current height of the viewport
  1889. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1890. * @param view defines the view matrix to use
  1891. * @param projection defines the projection matrix to use
  1892. * @returns the new Vector3
  1893. */
  1894. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1895. /**
  1896. * Unproject from screen space to object space
  1897. * @param source defines the screen space Vector3 to use
  1898. * @param viewportWidth defines the current width of the viewport
  1899. * @param viewportHeight defines the current height of the viewport
  1900. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1901. * @param view defines the view matrix to use
  1902. * @param projection defines the projection matrix to use
  1903. * @param result defines the Vector3 where to store the result
  1904. */
  1905. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1906. /**
  1907. * Unproject from screen space to object space
  1908. * @param sourceX defines the screen space x coordinate to use
  1909. * @param sourceY defines the screen space y coordinate to use
  1910. * @param sourceZ defines the screen space z coordinate to use
  1911. * @param viewportWidth defines the current width of the viewport
  1912. * @param viewportHeight defines the current height of the viewport
  1913. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1914. * @param view defines the view matrix to use
  1915. * @param projection defines the projection matrix to use
  1916. * @param result defines the Vector3 where to store the result
  1917. */
  1918. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1919. /**
  1920. * Gets the minimal coordinate values between two Vector3
  1921. * @param left defines the first operand
  1922. * @param right defines the second operand
  1923. * @returns the new Vector3
  1924. */
  1925. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1926. /**
  1927. * Gets the maximal coordinate values between two Vector3
  1928. * @param left defines the first operand
  1929. * @param right defines the second operand
  1930. * @returns the new Vector3
  1931. */
  1932. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1933. /**
  1934. * Returns the distance between the vectors "value1" and "value2"
  1935. * @param value1 defines the first operand
  1936. * @param value2 defines the second operand
  1937. * @returns the distance
  1938. */
  1939. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1940. /**
  1941. * Returns the squared distance between the vectors "value1" and "value2"
  1942. * @param value1 defines the first operand
  1943. * @param value2 defines the second operand
  1944. * @returns the squared distance
  1945. */
  1946. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1947. /**
  1948. * Returns a new Vector3 located at the center between "value1" and "value2"
  1949. * @param value1 defines the first operand
  1950. * @param value2 defines the second operand
  1951. * @returns the new Vector3
  1952. */
  1953. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1956. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1957. * to something in order to rotate it from its local system to the given target system
  1958. * Note: axis1, axis2 and axis3 are normalized during this operation
  1959. * @param axis1 defines the first axis
  1960. * @param axis2 defines the second axis
  1961. * @param axis3 defines the third axis
  1962. * @returns a new Vector3
  1963. */
  1964. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1965. /**
  1966. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1967. * @param axis1 defines the first axis
  1968. * @param axis2 defines the second axis
  1969. * @param axis3 defines the third axis
  1970. * @param ref defines the Vector3 where to store the result
  1971. */
  1972. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1973. }
  1974. /**
  1975. * Vector4 class created for EulerAngle class conversion to Quaternion
  1976. */
  1977. export class Vector4 {
  1978. /** x value of the vector */
  1979. x: number;
  1980. /** y value of the vector */
  1981. y: number;
  1982. /** z value of the vector */
  1983. z: number;
  1984. /** w value of the vector */
  1985. w: number;
  1986. /**
  1987. * Creates a Vector4 object from the given floats.
  1988. * @param x x value of the vector
  1989. * @param y y value of the vector
  1990. * @param z z value of the vector
  1991. * @param w w value of the vector
  1992. */
  1993. constructor(
  1994. /** x value of the vector */
  1995. x: number,
  1996. /** y value of the vector */
  1997. y: number,
  1998. /** z value of the vector */
  1999. z: number,
  2000. /** w value of the vector */
  2001. w: number);
  2002. /**
  2003. * Returns the string with the Vector4 coordinates.
  2004. * @returns a string containing all the vector values
  2005. */
  2006. toString(): string;
  2007. /**
  2008. * Returns the string "Vector4".
  2009. * @returns "Vector4"
  2010. */
  2011. getClassName(): string;
  2012. /**
  2013. * Returns the Vector4 hash code.
  2014. * @returns a unique hash code
  2015. */
  2016. getHashCode(): number;
  2017. /**
  2018. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2019. * @returns the resulting array
  2020. */
  2021. asArray(): number[];
  2022. /**
  2023. * Populates the given array from the given index with the Vector4 coordinates.
  2024. * @param array array to populate
  2025. * @param index index of the array to start at (default: 0)
  2026. * @returns the Vector4.
  2027. */
  2028. toArray(array: FloatArray, index?: number): Vector4;
  2029. /**
  2030. * Adds the given vector to the current Vector4.
  2031. * @param otherVector the vector to add
  2032. * @returns the updated Vector4.
  2033. */
  2034. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2035. /**
  2036. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2037. * @param otherVector the vector to add
  2038. * @returns the resulting vector
  2039. */
  2040. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2041. /**
  2042. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2043. * @param otherVector the vector to add
  2044. * @param result the vector to store the result
  2045. * @returns the current Vector4.
  2046. */
  2047. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2048. /**
  2049. * Subtract in place the given vector from the current Vector4.
  2050. * @param otherVector the vector to subtract
  2051. * @returns the updated Vector4.
  2052. */
  2053. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2054. /**
  2055. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2056. * @param otherVector the vector to add
  2057. * @returns the new vector with the result
  2058. */
  2059. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2060. /**
  2061. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2062. * @param otherVector the vector to subtract
  2063. * @param result the vector to store the result
  2064. * @returns the current Vector4.
  2065. */
  2066. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2067. /**
  2068. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2069. */
  2070. /**
  2071. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2072. * @param x value to subtract
  2073. * @param y value to subtract
  2074. * @param z value to subtract
  2075. * @param w value to subtract
  2076. * @returns new vector containing the result
  2077. */
  2078. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2081. * @param x value to subtract
  2082. * @param y value to subtract
  2083. * @param z value to subtract
  2084. * @param w value to subtract
  2085. * @param result the vector to store the result in
  2086. * @returns the current Vector4.
  2087. */
  2088. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2089. /**
  2090. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2091. * @returns a new vector with the negated values
  2092. */
  2093. negate(): Vector4;
  2094. /**
  2095. * Multiplies the current Vector4 coordinates by scale (float).
  2096. * @param scale the number to scale with
  2097. * @returns the updated Vector4.
  2098. */
  2099. scaleInPlace(scale: number): Vector4;
  2100. /**
  2101. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2102. * @param scale the number to scale with
  2103. * @returns a new vector with the result
  2104. */
  2105. scale(scale: number): Vector4;
  2106. /**
  2107. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2108. * @param scale the number to scale with
  2109. * @param result a vector to store the result in
  2110. * @returns the current Vector4.
  2111. */
  2112. scaleToRef(scale: number, result: Vector4): Vector4;
  2113. /**
  2114. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector4 object where to store the result
  2117. * @returns the unmodified current Vector4
  2118. */
  2119. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2120. /**
  2121. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2122. * @param otherVector the vector to compare against
  2123. * @returns true if they are equal
  2124. */
  2125. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2126. /**
  2127. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2128. * @param otherVector vector to compare against
  2129. * @param epsilon (Default: very small number)
  2130. * @returns true if they are equal
  2131. */
  2132. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2133. /**
  2134. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2135. * @param x x value to compare against
  2136. * @param y y value to compare against
  2137. * @param z z value to compare against
  2138. * @param w w value to compare against
  2139. * @returns true if equal
  2140. */
  2141. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2142. /**
  2143. * Multiplies in place the current Vector4 by the given one.
  2144. * @param otherVector vector to multiple with
  2145. * @returns the updated Vector4.
  2146. */
  2147. multiplyInPlace(otherVector: Vector4): Vector4;
  2148. /**
  2149. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2150. * @param otherVector vector to multiple with
  2151. * @returns resulting new vector
  2152. */
  2153. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2154. /**
  2155. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2156. * @param otherVector vector to multiple with
  2157. * @param result vector to store the result
  2158. * @returns the current Vector4.
  2159. */
  2160. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2161. /**
  2162. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2163. * @param x x value multiply with
  2164. * @param y y value multiply with
  2165. * @param z z value multiply with
  2166. * @param w w value multiply with
  2167. * @returns resulting new vector
  2168. */
  2169. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2170. /**
  2171. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2172. * @param otherVector vector to devide with
  2173. * @returns resulting new vector
  2174. */
  2175. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2176. /**
  2177. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2178. * @param otherVector vector to devide with
  2179. * @param result vector to store the result
  2180. * @returns the current Vector4.
  2181. */
  2182. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2183. /**
  2184. * Divides the current Vector3 coordinates by the given ones.
  2185. * @param otherVector vector to devide with
  2186. * @returns the updated Vector3.
  2187. */
  2188. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2191. * @param other defines the second operand
  2192. * @returns the current updated Vector4
  2193. */
  2194. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2195. /**
  2196. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2197. * @param other defines the second operand
  2198. * @returns the current updated Vector4
  2199. */
  2200. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2201. /**
  2202. * Gets a new Vector4 from current Vector4 floored values
  2203. * @returns a new Vector4
  2204. */
  2205. floor(): Vector4;
  2206. /**
  2207. * Gets a new Vector4 from current Vector3 floored values
  2208. * @returns a new Vector4
  2209. */
  2210. fract(): Vector4;
  2211. /**
  2212. * Returns the Vector4 length (float).
  2213. * @returns the length
  2214. */
  2215. length(): number;
  2216. /**
  2217. * Returns the Vector4 squared length (float).
  2218. * @returns the length squared
  2219. */
  2220. lengthSquared(): number;
  2221. /**
  2222. * Normalizes in place the Vector4.
  2223. * @returns the updated Vector4.
  2224. */
  2225. normalize(): Vector4;
  2226. /**
  2227. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2228. * @returns this converted to a new vector3
  2229. */
  2230. toVector3(): Vector3;
  2231. /**
  2232. * Returns a new Vector4 copied from the current one.
  2233. * @returns the new cloned vector
  2234. */
  2235. clone(): Vector4;
  2236. /**
  2237. * Updates the current Vector4 with the given one coordinates.
  2238. * @param source the source vector to copy from
  2239. * @returns the updated Vector4.
  2240. */
  2241. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2242. /**
  2243. * Updates the current Vector4 coordinates with the given floats.
  2244. * @param x float to copy from
  2245. * @param y float to copy from
  2246. * @param z float to copy from
  2247. * @param w float to copy from
  2248. * @returns the updated Vector4.
  2249. */
  2250. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2251. /**
  2252. * Updates the current Vector4 coordinates with the given floats.
  2253. * @param x float to set from
  2254. * @param y float to set from
  2255. * @param z float to set from
  2256. * @param w float to set from
  2257. * @returns the updated Vector4.
  2258. */
  2259. set(x: number, y: number, z: number, w: number): Vector4;
  2260. /**
  2261. * Copies the given float to the current Vector3 coordinates
  2262. * @param v defines the x, y, z and w coordinates of the operand
  2263. * @returns the current updated Vector3
  2264. */
  2265. setAll(v: number): Vector4;
  2266. /**
  2267. * Returns a new Vector4 set from the starting index of the given array.
  2268. * @param array the array to pull values from
  2269. * @param offset the offset into the array to start at
  2270. * @returns the new vector
  2271. */
  2272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2273. /**
  2274. * Updates the given vector "result" from the starting index of the given array.
  2275. * @param array the array to pull values from
  2276. * @param offset the offset into the array to start at
  2277. * @param result the vector to store the result in
  2278. */
  2279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2280. /**
  2281. * Updates the given vector "result" from the starting index of the given Float32Array.
  2282. * @param array the array to pull values from
  2283. * @param offset the offset into the array to start at
  2284. * @param result the vector to store the result in
  2285. */
  2286. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2287. /**
  2288. * Updates the given vector "result" coordinates from the given floats.
  2289. * @param x float to set from
  2290. * @param y float to set from
  2291. * @param z float to set from
  2292. * @param w float to set from
  2293. * @param result the vector to the floats in
  2294. */
  2295. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2296. /**
  2297. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2298. * @returns the new vector
  2299. */
  2300. static Zero(): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2303. * @returns the new vector
  2304. */
  2305. static One(): Vector4;
  2306. /**
  2307. * Returns a new normalized Vector4 from the given one.
  2308. * @param vector the vector to normalize
  2309. * @returns the vector
  2310. */
  2311. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2312. /**
  2313. * Updates the given vector "result" from the normalization of the given one.
  2314. * @param vector the vector to normalize
  2315. * @param result the vector to store the result in
  2316. */
  2317. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2318. /**
  2319. * Returns a vector with the minimum values from the left and right vectors
  2320. * @param left left vector to minimize
  2321. * @param right right vector to minimize
  2322. * @returns a new vector with the minimum of the left and right vector values
  2323. */
  2324. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2325. /**
  2326. * Returns a vector with the maximum values from the left and right vectors
  2327. * @param left left vector to maximize
  2328. * @param right right vector to maximize
  2329. * @returns a new vector with the maximum of the left and right vector values
  2330. */
  2331. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2332. /**
  2333. * Returns the distance (float) between the vectors "value1" and "value2".
  2334. * @param value1 value to calulate the distance between
  2335. * @param value2 value to calulate the distance between
  2336. * @return the distance between the two vectors
  2337. */
  2338. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2339. /**
  2340. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2341. * @param value1 value to calulate the distance between
  2342. * @param value2 value to calulate the distance between
  2343. * @return the distance between the two vectors squared
  2344. */
  2345. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2346. /**
  2347. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2348. * @param value1 value to calulate the center between
  2349. * @param value2 value to calulate the center between
  2350. * @return the center between the two vectors
  2351. */
  2352. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2353. /**
  2354. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2355. * This methods computes transformed normalized direction vectors only.
  2356. * @param vector the vector to transform
  2357. * @param transformation the transformation matrix to apply
  2358. * @returns the new vector
  2359. */
  2360. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2361. /**
  2362. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2363. * This methods computes transformed normalized direction vectors only.
  2364. * @param vector the vector to transform
  2365. * @param transformation the transformation matrix to apply
  2366. * @param result the vector to store the result in
  2367. */
  2368. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2369. /**
  2370. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2371. * This methods computes transformed normalized direction vectors only.
  2372. * @param x value to transform
  2373. * @param y value to transform
  2374. * @param z value to transform
  2375. * @param w value to transform
  2376. * @param transformation the transformation matrix to apply
  2377. * @param result the vector to store the results in
  2378. */
  2379. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2380. /**
  2381. * Creates a new Vector4 from a Vector3
  2382. * @param source defines the source data
  2383. * @param w defines the 4th component (default is 0)
  2384. * @returns a new Vector4
  2385. */
  2386. static FromVector3(source: Vector3, w?: number): Vector4;
  2387. }
  2388. /**
  2389. * Class used to store quaternion data
  2390. * @see https://en.wikipedia.org/wiki/Quaternion
  2391. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2392. */
  2393. export class Quaternion {
  2394. /** defines the first component (0 by default) */
  2395. x: number;
  2396. /** defines the second component (0 by default) */
  2397. y: number;
  2398. /** defines the third component (0 by default) */
  2399. z: number;
  2400. /** defines the fourth component (1.0 by default) */
  2401. w: number;
  2402. /**
  2403. * Creates a new Quaternion from the given floats
  2404. * @param x defines the first component (0 by default)
  2405. * @param y defines the second component (0 by default)
  2406. * @param z defines the third component (0 by default)
  2407. * @param w defines the fourth component (1.0 by default)
  2408. */
  2409. constructor(
  2410. /** defines the first component (0 by default) */
  2411. x?: number,
  2412. /** defines the second component (0 by default) */
  2413. y?: number,
  2414. /** defines the third component (0 by default) */
  2415. z?: number,
  2416. /** defines the fourth component (1.0 by default) */
  2417. w?: number);
  2418. /**
  2419. * Gets a string representation for the current quaternion
  2420. * @returns a string with the Quaternion coordinates
  2421. */
  2422. toString(): string;
  2423. /**
  2424. * Gets the class name of the quaternion
  2425. * @returns the string "Quaternion"
  2426. */
  2427. getClassName(): string;
  2428. /**
  2429. * Gets a hash code for this quaternion
  2430. * @returns the quaternion hash code
  2431. */
  2432. getHashCode(): number;
  2433. /**
  2434. * Copy the quaternion to an array
  2435. * @returns a new array populated with 4 elements from the quaternion coordinates
  2436. */
  2437. asArray(): number[];
  2438. /**
  2439. * Check if two quaternions are equals
  2440. * @param otherQuaternion defines the second operand
  2441. * @return true if the current quaternion and the given one coordinates are strictly equals
  2442. */
  2443. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2444. /**
  2445. * Clone the current quaternion
  2446. * @returns a new quaternion copied from the current one
  2447. */
  2448. clone(): Quaternion;
  2449. /**
  2450. * Copy a quaternion to the current one
  2451. * @param other defines the other quaternion
  2452. * @returns the updated current quaternion
  2453. */
  2454. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2455. /**
  2456. * Updates the current quaternion with the given float coordinates
  2457. * @param x defines the x coordinate
  2458. * @param y defines the y coordinate
  2459. * @param z defines the z coordinate
  2460. * @param w defines the w coordinate
  2461. * @returns the updated current quaternion
  2462. */
  2463. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2464. /**
  2465. * Updates the current quaternion from the given float coordinates
  2466. * @param x defines the x coordinate
  2467. * @param y defines the y coordinate
  2468. * @param z defines the z coordinate
  2469. * @param w defines the w coordinate
  2470. * @returns the updated current quaternion
  2471. */
  2472. set(x: number, y: number, z: number, w: number): Quaternion;
  2473. /**
  2474. * Adds two quaternions
  2475. * @param other defines the second operand
  2476. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2477. */
  2478. add(other: DeepImmutable<Quaternion>): Quaternion;
  2479. /**
  2480. * Add a quaternion to the current one
  2481. * @param other defines the quaternion to add
  2482. * @returns the current quaternion
  2483. */
  2484. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2485. /**
  2486. * Subtract two quaternions
  2487. * @param other defines the second operand
  2488. * @returns a new quaternion as the subtraction result of the given one from the current one
  2489. */
  2490. subtract(other: Quaternion): Quaternion;
  2491. /**
  2492. * Multiplies the current quaternion by a scale factor
  2493. * @param value defines the scale factor
  2494. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2495. */
  2496. scale(value: number): Quaternion;
  2497. /**
  2498. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2499. * @param scale defines the scale factor
  2500. * @param result defines the Quaternion object where to store the result
  2501. * @returns the unmodified current quaternion
  2502. */
  2503. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2504. /**
  2505. * Multiplies in place the current quaternion by a scale factor
  2506. * @param value defines the scale factor
  2507. * @returns the current modified quaternion
  2508. */
  2509. scaleInPlace(value: number): Quaternion;
  2510. /**
  2511. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2512. * @param scale defines the scale factor
  2513. * @param result defines the Quaternion object where to store the result
  2514. * @returns the unmodified current quaternion
  2515. */
  2516. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2517. /**
  2518. * Multiplies two quaternions
  2519. * @param q1 defines the second operand
  2520. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2521. */
  2522. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2523. /**
  2524. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2525. * @param q1 defines the second operand
  2526. * @param result defines the target quaternion
  2527. * @returns the current quaternion
  2528. */
  2529. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2530. /**
  2531. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2532. * @param q1 defines the second operand
  2533. * @returns the currentupdated quaternion
  2534. */
  2535. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2536. /**
  2537. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2538. * @param ref defines the target quaternion
  2539. * @returns the current quaternion
  2540. */
  2541. conjugateToRef(ref: Quaternion): Quaternion;
  2542. /**
  2543. * Conjugates in place (1-q) the current quaternion
  2544. * @returns the current updated quaternion
  2545. */
  2546. conjugateInPlace(): Quaternion;
  2547. /**
  2548. * Conjugates in place (1-q) the current quaternion
  2549. * @returns a new quaternion
  2550. */
  2551. conjugate(): Quaternion;
  2552. /**
  2553. * Gets length of current quaternion
  2554. * @returns the quaternion length (float)
  2555. */
  2556. length(): number;
  2557. /**
  2558. * Normalize in place the current quaternion
  2559. * @returns the current updated quaternion
  2560. */
  2561. normalize(): Quaternion;
  2562. /**
  2563. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2564. * @param order is a reserved parameter and is ignore for now
  2565. * @returns a new Vector3 containing the Euler angles
  2566. */
  2567. toEulerAngles(order?: string): Vector3;
  2568. /**
  2569. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2570. * @param result defines the vector which will be filled with the Euler angles
  2571. * @param order is a reserved parameter and is ignore for now
  2572. * @returns the current unchanged quaternion
  2573. */
  2574. toEulerAnglesToRef(result: Vector3): Quaternion;
  2575. /**
  2576. * Updates the given rotation matrix with the current quaternion values
  2577. * @param result defines the target matrix
  2578. * @returns the current unchanged quaternion
  2579. */
  2580. toRotationMatrix(result: Matrix): Quaternion;
  2581. /**
  2582. * Updates the current quaternion from the given rotation matrix values
  2583. * @param matrix defines the source matrix
  2584. * @returns the current updated quaternion
  2585. */
  2586. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2587. /**
  2588. * Creates a new quaternion from a rotation matrix
  2589. * @param matrix defines the source matrix
  2590. * @returns a new quaternion created from the given rotation matrix values
  2591. */
  2592. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2593. /**
  2594. * Updates the given quaternion with the given rotation matrix values
  2595. * @param matrix defines the source matrix
  2596. * @param result defines the target quaternion
  2597. */
  2598. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2599. /**
  2600. * Returns the dot product (float) between the quaternions "left" and "right"
  2601. * @param left defines the left operand
  2602. * @param right defines the right operand
  2603. * @returns the dot product
  2604. */
  2605. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2606. /**
  2607. * Checks if the two quaternions are close to each other
  2608. * @param quat0 defines the first quaternion to check
  2609. * @param quat1 defines the second quaternion to check
  2610. * @returns true if the two quaternions are close to each other
  2611. */
  2612. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2613. /**
  2614. * Creates an empty quaternion
  2615. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2616. */
  2617. static Zero(): Quaternion;
  2618. /**
  2619. * Inverse a given quaternion
  2620. * @param q defines the source quaternion
  2621. * @returns a new quaternion as the inverted current quaternion
  2622. */
  2623. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2624. /**
  2625. * Inverse a given quaternion
  2626. * @param q defines the source quaternion
  2627. * @param result the quaternion the result will be stored in
  2628. * @returns the result quaternion
  2629. */
  2630. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2631. /**
  2632. * Creates an identity quaternion
  2633. * @returns the identity quaternion
  2634. */
  2635. static Identity(): Quaternion;
  2636. /**
  2637. * Gets a boolean indicating if the given quaternion is identity
  2638. * @param quaternion defines the quaternion to check
  2639. * @returns true if the quaternion is identity
  2640. */
  2641. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2642. /**
  2643. * Creates a quaternion from a rotation around an axis
  2644. * @param axis defines the axis to use
  2645. * @param angle defines the angle to use
  2646. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2647. */
  2648. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2649. /**
  2650. * Creates a rotation around an axis and stores it into the given quaternion
  2651. * @param axis defines the axis to use
  2652. * @param angle defines the angle to use
  2653. * @param result defines the target quaternion
  2654. * @returns the target quaternion
  2655. */
  2656. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2657. /**
  2658. * Creates a new quaternion from data stored into an array
  2659. * @param array defines the data source
  2660. * @param offset defines the offset in the source array where the data starts
  2661. * @returns a new quaternion
  2662. */
  2663. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2664. /**
  2665. * Create a quaternion from Euler rotation angles
  2666. * @param x Pitch
  2667. * @param y Yaw
  2668. * @param z Roll
  2669. * @returns the new Quaternion
  2670. */
  2671. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2672. /**
  2673. * Updates a quaternion from Euler rotation angles
  2674. * @param x Pitch
  2675. * @param y Yaw
  2676. * @param z Roll
  2677. * @param result the quaternion to store the result
  2678. * @returns the updated quaternion
  2679. */
  2680. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2681. /**
  2682. * Create a quaternion from Euler rotation vector
  2683. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2684. * @returns the new Quaternion
  2685. */
  2686. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2687. /**
  2688. * Updates a quaternion from Euler rotation vector
  2689. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2690. * @param result the quaternion to store the result
  2691. * @returns the updated quaternion
  2692. */
  2693. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2696. * @param yaw defines the rotation around Y axis
  2697. * @param pitch defines the rotation around X axis
  2698. * @param roll defines the rotation around Z axis
  2699. * @returns the new quaternion
  2700. */
  2701. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2702. /**
  2703. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2704. * @param yaw defines the rotation around Y axis
  2705. * @param pitch defines the rotation around X axis
  2706. * @param roll defines the rotation around Z axis
  2707. * @param result defines the target quaternion
  2708. */
  2709. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2710. /**
  2711. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2712. * @param alpha defines the rotation around first axis
  2713. * @param beta defines the rotation around second axis
  2714. * @param gamma defines the rotation around third axis
  2715. * @returns the new quaternion
  2716. */
  2717. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2720. * @param alpha defines the rotation around first axis
  2721. * @param beta defines the rotation around second axis
  2722. * @param gamma defines the rotation around third axis
  2723. * @param result defines the target quaternion
  2724. */
  2725. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2726. /**
  2727. * 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)
  2728. * @param axis1 defines the first axis
  2729. * @param axis2 defines the second axis
  2730. * @param axis3 defines the third axis
  2731. * @returns the new quaternion
  2732. */
  2733. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2734. /**
  2735. * 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
  2736. * @param axis1 defines the first axis
  2737. * @param axis2 defines the second axis
  2738. * @param axis3 defines the third axis
  2739. * @param ref defines the target quaternion
  2740. */
  2741. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2742. /**
  2743. * Interpolates between two quaternions
  2744. * @param left defines first quaternion
  2745. * @param right defines second quaternion
  2746. * @param amount defines the gradient to use
  2747. * @returns the new interpolated quaternion
  2748. */
  2749. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2750. /**
  2751. * Interpolates between two quaternions and stores it into a target quaternion
  2752. * @param left defines first quaternion
  2753. * @param right defines second quaternion
  2754. * @param amount defines the gradient to use
  2755. * @param result defines the target quaternion
  2756. */
  2757. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2758. /**
  2759. * Interpolate between two quaternions using Hermite interpolation
  2760. * @param value1 defines first quaternion
  2761. * @param tangent1 defines the incoming tangent
  2762. * @param value2 defines second quaternion
  2763. * @param tangent2 defines the outgoing tangent
  2764. * @param amount defines the target quaternion
  2765. * @returns the new interpolated quaternion
  2766. */
  2767. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2768. }
  2769. /**
  2770. * Class used to store matrix data (4x4)
  2771. */
  2772. export class Matrix {
  2773. private static _updateFlagSeed;
  2774. private static _identityReadOnly;
  2775. private _isIdentity;
  2776. private _isIdentityDirty;
  2777. private _isIdentity3x2;
  2778. private _isIdentity3x2Dirty;
  2779. /**
  2780. * Gets the update flag of the matrix which is an unique number for the matrix.
  2781. * It will be incremented every time the matrix data change.
  2782. * You can use it to speed the comparison between two versions of the same matrix.
  2783. */
  2784. updateFlag: number;
  2785. private readonly _m;
  2786. /**
  2787. * Gets the internal data of the matrix
  2788. */
  2789. readonly m: DeepImmutable<Float32Array>;
  2790. /** @hidden */
  2791. _markAsUpdated(): void;
  2792. /** @hidden */
  2793. private _updateIdentityStatus;
  2794. /**
  2795. * Creates an empty matrix (filled with zeros)
  2796. */
  2797. constructor();
  2798. /**
  2799. * Check if the current matrix is identity
  2800. * @returns true is the matrix is the identity matrix
  2801. */
  2802. isIdentity(): boolean;
  2803. /**
  2804. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2805. * @returns true is the matrix is the identity matrix
  2806. */
  2807. isIdentityAs3x2(): boolean;
  2808. /**
  2809. * Gets the determinant of the matrix
  2810. * @returns the matrix determinant
  2811. */
  2812. determinant(): number;
  2813. /**
  2814. * Returns the matrix as a Float32Array
  2815. * @returns the matrix underlying array
  2816. */
  2817. toArray(): DeepImmutable<Float32Array>;
  2818. /**
  2819. * Returns the matrix as a Float32Array
  2820. * @returns the matrix underlying array.
  2821. */
  2822. asArray(): DeepImmutable<Float32Array>;
  2823. /**
  2824. * Inverts the current matrix in place
  2825. * @returns the current inverted matrix
  2826. */
  2827. invert(): Matrix;
  2828. /**
  2829. * Sets all the matrix elements to zero
  2830. * @returns the current matrix
  2831. */
  2832. reset(): Matrix;
  2833. /**
  2834. * Adds the current matrix with a second one
  2835. * @param other defines the matrix to add
  2836. * @returns a new matrix as the addition of the current matrix and the given one
  2837. */
  2838. add(other: DeepImmutable<Matrix>): Matrix;
  2839. /**
  2840. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2841. * @param other defines the matrix to add
  2842. * @param result defines the target matrix
  2843. * @returns the current matrix
  2844. */
  2845. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2846. /**
  2847. * Adds in place the given matrix to the current matrix
  2848. * @param other defines the second operand
  2849. * @returns the current updated matrix
  2850. */
  2851. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2852. /**
  2853. * Sets the given matrix to the current inverted Matrix
  2854. * @param other defines the target matrix
  2855. * @returns the unmodified current matrix
  2856. */
  2857. invertToRef(other: Matrix): Matrix;
  2858. /**
  2859. * add a value at the specified position in the current Matrix
  2860. * @param index the index of the value within the matrix. between 0 and 15.
  2861. * @param value the value to be added
  2862. * @returns the current updated matrix
  2863. */
  2864. addAtIndex(index: number, value: number): Matrix;
  2865. /**
  2866. * mutiply the specified position in the current Matrix by a value
  2867. * @param index the index of the value within the matrix. between 0 and 15.
  2868. * @param value the value to be added
  2869. * @returns the current updated matrix
  2870. */
  2871. multiplyAtIndex(index: number, value: number): Matrix;
  2872. /**
  2873. * Inserts the translation vector (using 3 floats) in the current matrix
  2874. * @param x defines the 1st component of the translation
  2875. * @param y defines the 2nd component of the translation
  2876. * @param z defines the 3rd component of the translation
  2877. * @returns the current updated matrix
  2878. */
  2879. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2880. /**
  2881. * Adds the translation vector (using 3 floats) in the current matrix
  2882. * @param x defines the 1st component of the translation
  2883. * @param y defines the 2nd component of the translation
  2884. * @param z defines the 3rd component of the translation
  2885. * @returns the current updated matrix
  2886. */
  2887. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2888. /**
  2889. * Inserts the translation vector in the current matrix
  2890. * @param vector3 defines the translation to insert
  2891. * @returns the current updated matrix
  2892. */
  2893. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2894. /**
  2895. * Gets the translation value of the current matrix
  2896. * @returns a new Vector3 as the extracted translation from the matrix
  2897. */
  2898. getTranslation(): Vector3;
  2899. /**
  2900. * Fill a Vector3 with the extracted translation from the matrix
  2901. * @param result defines the Vector3 where to store the translation
  2902. * @returns the current matrix
  2903. */
  2904. getTranslationToRef(result: Vector3): Matrix;
  2905. /**
  2906. * Remove rotation and scaling part from the matrix
  2907. * @returns the updated matrix
  2908. */
  2909. removeRotationAndScaling(): Matrix;
  2910. /**
  2911. * Multiply two matrices
  2912. * @param other defines the second operand
  2913. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2914. */
  2915. multiply(other: DeepImmutable<Matrix>): Matrix;
  2916. /**
  2917. * Copy the current matrix from the given one
  2918. * @param other defines the source matrix
  2919. * @returns the current updated matrix
  2920. */
  2921. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2922. /**
  2923. * Populates the given array from the starting index with the current matrix values
  2924. * @param array defines the target array
  2925. * @param offset defines the offset in the target array where to start storing values
  2926. * @returns the current matrix
  2927. */
  2928. copyToArray(array: Float32Array, offset?: number): Matrix;
  2929. /**
  2930. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2931. * @param other defines the second operand
  2932. * @param result defines the matrix where to store the multiplication
  2933. * @returns the current matrix
  2934. */
  2935. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2936. /**
  2937. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2938. * @param other defines the second operand
  2939. * @param result defines the array where to store the multiplication
  2940. * @param offset defines the offset in the target array where to start storing values
  2941. * @returns the current matrix
  2942. */
  2943. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2944. /**
  2945. * Check equality between this matrix and a second one
  2946. * @param value defines the second matrix to compare
  2947. * @returns true is the current matrix and the given one values are strictly equal
  2948. */
  2949. equals(value: DeepImmutable<Matrix>): boolean;
  2950. /**
  2951. * Clone the current matrix
  2952. * @returns a new matrix from the current matrix
  2953. */
  2954. clone(): Matrix;
  2955. /**
  2956. * Returns the name of the current matrix class
  2957. * @returns the string "Matrix"
  2958. */
  2959. getClassName(): string;
  2960. /**
  2961. * Gets the hash code of the current matrix
  2962. * @returns the hash code
  2963. */
  2964. getHashCode(): number;
  2965. /**
  2966. * Decomposes the current Matrix into a translation, rotation and scaling components
  2967. * @param scale defines the scale vector3 given as a reference to update
  2968. * @param rotation defines the rotation quaternion given as a reference to update
  2969. * @param translation defines the translation vector3 given as a reference to update
  2970. * @returns true if operation was successful
  2971. */
  2972. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2973. /**
  2974. * Gets specific row of the matrix
  2975. * @param index defines the number of the row to get
  2976. * @returns the index-th row of the current matrix as a new Vector4
  2977. */
  2978. getRow(index: number): Nullable<Vector4>;
  2979. /**
  2980. * Sets the index-th row of the current matrix to the vector4 values
  2981. * @param index defines the number of the row to set
  2982. * @param row defines the target vector4
  2983. * @returns the updated current matrix
  2984. */
  2985. setRow(index: number, row: Vector4): Matrix;
  2986. /**
  2987. * Compute the transpose of the matrix
  2988. * @returns the new transposed matrix
  2989. */
  2990. transpose(): Matrix;
  2991. /**
  2992. * Compute the transpose of the matrix and store it in a given matrix
  2993. * @param result defines the target matrix
  2994. * @returns the current matrix
  2995. */
  2996. transposeToRef(result: Matrix): Matrix;
  2997. /**
  2998. * Sets the index-th row of the current matrix with the given 4 x float values
  2999. * @param index defines the row index
  3000. * @param x defines the x component to set
  3001. * @param y defines the y component to set
  3002. * @param z defines the z component to set
  3003. * @param w defines the w component to set
  3004. * @returns the updated current matrix
  3005. */
  3006. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3007. /**
  3008. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3009. * @param scale defines the scale factor
  3010. * @returns a new matrix
  3011. */
  3012. scale(scale: number): Matrix;
  3013. /**
  3014. * Scale the current matrix values by a factor to a given result matrix
  3015. * @param scale defines the scale factor
  3016. * @param result defines the matrix to store the result
  3017. * @returns the current matrix
  3018. */
  3019. scaleToRef(scale: number, result: Matrix): Matrix;
  3020. /**
  3021. * Scale the current matrix values by a factor and add the result to a given matrix
  3022. * @param scale defines the scale factor
  3023. * @param result defines the Matrix to store the result
  3024. * @returns the current matrix
  3025. */
  3026. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3027. /**
  3028. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3029. * @param ref matrix to store the result
  3030. */
  3031. toNormalMatrix(ref: Matrix): void;
  3032. /**
  3033. * Gets only rotation part of the current matrix
  3034. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3035. */
  3036. getRotationMatrix(): Matrix;
  3037. /**
  3038. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3039. * @param result defines the target matrix to store data to
  3040. * @returns the current matrix
  3041. */
  3042. getRotationMatrixToRef(result: Matrix): Matrix;
  3043. /**
  3044. * Toggles model matrix from being right handed to left handed in place and vice versa
  3045. */
  3046. toggleModelMatrixHandInPlace(): void;
  3047. /**
  3048. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3049. */
  3050. toggleProjectionMatrixHandInPlace(): void;
  3051. /**
  3052. * Creates a matrix from an array
  3053. * @param array defines the source array
  3054. * @param offset defines an offset in the source array
  3055. * @returns a new Matrix set from the starting index of the given array
  3056. */
  3057. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3058. /**
  3059. * Copy the content of an array into a given matrix
  3060. * @param array defines the source array
  3061. * @param offset defines an offset in the source array
  3062. * @param result defines the target matrix
  3063. */
  3064. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3065. /**
  3066. * Stores an array into a matrix after having multiplied each component by a given factor
  3067. * @param array defines the source array
  3068. * @param offset defines the offset in the source array
  3069. * @param scale defines the scaling factor
  3070. * @param result defines the target matrix
  3071. */
  3072. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3073. /**
  3074. * Gets an identity matrix that must not be updated
  3075. */
  3076. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3077. /**
  3078. * Stores a list of values (16) inside a given matrix
  3079. * @param initialM11 defines 1st value of 1st row
  3080. * @param initialM12 defines 2nd value of 1st row
  3081. * @param initialM13 defines 3rd value of 1st row
  3082. * @param initialM14 defines 4th value of 1st row
  3083. * @param initialM21 defines 1st value of 2nd row
  3084. * @param initialM22 defines 2nd value of 2nd row
  3085. * @param initialM23 defines 3rd value of 2nd row
  3086. * @param initialM24 defines 4th value of 2nd row
  3087. * @param initialM31 defines 1st value of 3rd row
  3088. * @param initialM32 defines 2nd value of 3rd row
  3089. * @param initialM33 defines 3rd value of 3rd row
  3090. * @param initialM34 defines 4th value of 3rd row
  3091. * @param initialM41 defines 1st value of 4th row
  3092. * @param initialM42 defines 2nd value of 4th row
  3093. * @param initialM43 defines 3rd value of 4th row
  3094. * @param initialM44 defines 4th value of 4th row
  3095. * @param result defines the target matrix
  3096. */
  3097. 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;
  3098. /**
  3099. * Creates new matrix from a list of values (16)
  3100. * @param initialM11 defines 1st value of 1st row
  3101. * @param initialM12 defines 2nd value of 1st row
  3102. * @param initialM13 defines 3rd value of 1st row
  3103. * @param initialM14 defines 4th value of 1st row
  3104. * @param initialM21 defines 1st value of 2nd row
  3105. * @param initialM22 defines 2nd value of 2nd row
  3106. * @param initialM23 defines 3rd value of 2nd row
  3107. * @param initialM24 defines 4th value of 2nd row
  3108. * @param initialM31 defines 1st value of 3rd row
  3109. * @param initialM32 defines 2nd value of 3rd row
  3110. * @param initialM33 defines 3rd value of 3rd row
  3111. * @param initialM34 defines 4th value of 3rd row
  3112. * @param initialM41 defines 1st value of 4th row
  3113. * @param initialM42 defines 2nd value of 4th row
  3114. * @param initialM43 defines 3rd value of 4th row
  3115. * @param initialM44 defines 4th value of 4th row
  3116. * @returns the new matrix
  3117. */
  3118. 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;
  3119. /**
  3120. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3121. * @param scale defines the scale vector3
  3122. * @param rotation defines the rotation quaternion
  3123. * @param translation defines the translation vector3
  3124. * @returns a new matrix
  3125. */
  3126. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3127. /**
  3128. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3129. * @param scale defines the scale vector3
  3130. * @param rotation defines the rotation quaternion
  3131. * @param translation defines the translation vector3
  3132. * @param result defines the target matrix
  3133. */
  3134. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3135. /**
  3136. * Creates a new identity matrix
  3137. * @returns a new identity matrix
  3138. */
  3139. static Identity(): Matrix;
  3140. /**
  3141. * Creates a new identity matrix and stores the result in a given matrix
  3142. * @param result defines the target matrix
  3143. */
  3144. static IdentityToRef(result: Matrix): void;
  3145. /**
  3146. * Creates a new zero matrix
  3147. * @returns a new zero matrix
  3148. */
  3149. static Zero(): Matrix;
  3150. /**
  3151. * Creates a new rotation matrix for "angle" radians around the X axis
  3152. * @param angle defines the angle (in radians) to use
  3153. * @return the new matrix
  3154. */
  3155. static RotationX(angle: number): Matrix;
  3156. /**
  3157. * Creates a new matrix as the invert of a given matrix
  3158. * @param source defines the source matrix
  3159. * @returns the new matrix
  3160. */
  3161. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3162. /**
  3163. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3164. * @param angle defines the angle (in radians) to use
  3165. * @param result defines the target matrix
  3166. */
  3167. static RotationXToRef(angle: number, result: Matrix): void;
  3168. /**
  3169. * Creates a new rotation matrix for "angle" radians around the Y axis
  3170. * @param angle defines the angle (in radians) to use
  3171. * @return the new matrix
  3172. */
  3173. static RotationY(angle: number): Matrix;
  3174. /**
  3175. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3176. * @param angle defines the angle (in radians) to use
  3177. * @param result defines the target matrix
  3178. */
  3179. static RotationYToRef(angle: number, result: Matrix): void;
  3180. /**
  3181. * Creates a new rotation matrix for "angle" radians around the Z axis
  3182. * @param angle defines the angle (in radians) to use
  3183. * @return the new matrix
  3184. */
  3185. static RotationZ(angle: number): Matrix;
  3186. /**
  3187. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3188. * @param angle defines the angle (in radians) to use
  3189. * @param result defines the target matrix
  3190. */
  3191. static RotationZToRef(angle: number, result: Matrix): void;
  3192. /**
  3193. * Creates a new rotation matrix for "angle" radians around the given axis
  3194. * @param axis defines the axis to use
  3195. * @param angle defines the angle (in radians) to use
  3196. * @return the new matrix
  3197. */
  3198. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3199. /**
  3200. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3201. * @param axis defines the axis to use
  3202. * @param angle defines the angle (in radians) to use
  3203. * @param result defines the target matrix
  3204. */
  3205. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3206. /**
  3207. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3208. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3209. * @param from defines the vector to align
  3210. * @param to defines the vector to align to
  3211. * @param result defines the target matrix
  3212. */
  3213. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3214. /**
  3215. * Creates a rotation matrix
  3216. * @param yaw defines the yaw angle in radians (Y axis)
  3217. * @param pitch defines the pitch angle in radians (X axis)
  3218. * @param roll defines the roll angle in radians (X axis)
  3219. * @returns the new rotation matrix
  3220. */
  3221. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3222. /**
  3223. * Creates a rotation matrix and stores it in a given matrix
  3224. * @param yaw defines the yaw angle in radians (Y axis)
  3225. * @param pitch defines the pitch angle in radians (X axis)
  3226. * @param roll defines the roll angle in radians (X axis)
  3227. * @param result defines the target matrix
  3228. */
  3229. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3230. /**
  3231. * Creates a scaling matrix
  3232. * @param x defines the scale factor on X axis
  3233. * @param y defines the scale factor on Y axis
  3234. * @param z defines the scale factor on Z axis
  3235. * @returns the new matrix
  3236. */
  3237. static Scaling(x: number, y: number, z: number): Matrix;
  3238. /**
  3239. * Creates a scaling matrix and stores it in a given matrix
  3240. * @param x defines the scale factor on X axis
  3241. * @param y defines the scale factor on Y axis
  3242. * @param z defines the scale factor on Z axis
  3243. * @param result defines the target matrix
  3244. */
  3245. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3246. /**
  3247. * Creates a translation matrix
  3248. * @param x defines the translation on X axis
  3249. * @param y defines the translation on Y axis
  3250. * @param z defines the translationon Z axis
  3251. * @returns the new matrix
  3252. */
  3253. static Translation(x: number, y: number, z: number): Matrix;
  3254. /**
  3255. * Creates a translation matrix and stores it in a given matrix
  3256. * @param x defines the translation on X axis
  3257. * @param y defines the translation on Y axis
  3258. * @param z defines the translationon Z axis
  3259. * @param result defines the target matrix
  3260. */
  3261. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3262. /**
  3263. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3264. * @param startValue defines the start value
  3265. * @param endValue defines the end value
  3266. * @param gradient defines the gradient factor
  3267. * @returns the new matrix
  3268. */
  3269. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3270. /**
  3271. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3272. * @param startValue defines the start value
  3273. * @param endValue defines the end value
  3274. * @param gradient defines the gradient factor
  3275. * @param result defines the Matrix object where to store data
  3276. */
  3277. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3278. /**
  3279. * Builds a new matrix whose values are computed by:
  3280. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3281. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3282. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3283. * @param startValue defines the first matrix
  3284. * @param endValue defines the second matrix
  3285. * @param gradient defines the gradient between the two matrices
  3286. * @returns the new matrix
  3287. */
  3288. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3289. /**
  3290. * Update a matrix to values which are computed by:
  3291. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3292. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3293. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3294. * @param startValue defines the first matrix
  3295. * @param endValue defines the second matrix
  3296. * @param gradient defines the gradient between the two matrices
  3297. * @param result defines the target matrix
  3298. */
  3299. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3300. /**
  3301. * 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"
  3302. * This function works in left handed mode
  3303. * @param eye defines the final position of the entity
  3304. * @param target defines where the entity should look at
  3305. * @param up defines the up vector for the entity
  3306. * @returns the new matrix
  3307. */
  3308. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3309. /**
  3310. * 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".
  3311. * This function works in left handed mode
  3312. * @param eye defines the final position of the entity
  3313. * @param target defines where the entity should look at
  3314. * @param up defines the up vector for the entity
  3315. * @param result defines the target matrix
  3316. */
  3317. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3318. /**
  3319. * 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"
  3320. * This function works in right handed mode
  3321. * @param eye defines the final position of the entity
  3322. * @param target defines where the entity should look at
  3323. * @param up defines the up vector for the entity
  3324. * @returns the new matrix
  3325. */
  3326. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3327. /**
  3328. * 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".
  3329. * This function works in right handed mode
  3330. * @param eye defines the final position of the entity
  3331. * @param target defines where the entity should look at
  3332. * @param up defines the up vector for the entity
  3333. * @param result defines the target matrix
  3334. */
  3335. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3336. /**
  3337. * Create a left-handed orthographic projection matrix
  3338. * @param width defines the viewport width
  3339. * @param height defines the viewport height
  3340. * @param znear defines the near clip plane
  3341. * @param zfar defines the far clip plane
  3342. * @returns a new matrix as a left-handed orthographic projection matrix
  3343. */
  3344. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3345. /**
  3346. * Store a left-handed orthographic projection to a given matrix
  3347. * @param width defines the viewport width
  3348. * @param height defines the viewport height
  3349. * @param znear defines the near clip plane
  3350. * @param zfar defines the far clip plane
  3351. * @param result defines the target matrix
  3352. */
  3353. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3354. /**
  3355. * Create a left-handed orthographic projection matrix
  3356. * @param left defines the viewport left coordinate
  3357. * @param right defines the viewport right coordinate
  3358. * @param bottom defines the viewport bottom coordinate
  3359. * @param top defines the viewport top coordinate
  3360. * @param znear defines the near clip plane
  3361. * @param zfar defines the far clip plane
  3362. * @returns a new matrix as a left-handed orthographic projection matrix
  3363. */
  3364. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3365. /**
  3366. * Stores a left-handed orthographic projection into a given matrix
  3367. * @param left defines the viewport left coordinate
  3368. * @param right defines the viewport right coordinate
  3369. * @param bottom defines the viewport bottom coordinate
  3370. * @param top defines the viewport top coordinate
  3371. * @param znear defines the near clip plane
  3372. * @param zfar defines the far clip plane
  3373. * @param result defines the target matrix
  3374. */
  3375. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3376. /**
  3377. * Creates a right-handed orthographic projection matrix
  3378. * @param left defines the viewport left coordinate
  3379. * @param right defines the viewport right coordinate
  3380. * @param bottom defines the viewport bottom coordinate
  3381. * @param top defines the viewport top coordinate
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @returns a new matrix as a right-handed orthographic projection matrix
  3385. */
  3386. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3387. /**
  3388. * Stores a right-handed orthographic projection into a given matrix
  3389. * @param left defines the viewport left coordinate
  3390. * @param right defines the viewport right coordinate
  3391. * @param bottom defines the viewport bottom coordinate
  3392. * @param top defines the viewport top coordinate
  3393. * @param znear defines the near clip plane
  3394. * @param zfar defines the far clip plane
  3395. * @param result defines the target matrix
  3396. */
  3397. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3398. /**
  3399. * Creates a left-handed perspective projection matrix
  3400. * @param width defines the viewport width
  3401. * @param height defines the viewport height
  3402. * @param znear defines the near clip plane
  3403. * @param zfar defines the far clip plane
  3404. * @returns a new matrix as a left-handed perspective projection matrix
  3405. */
  3406. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3407. /**
  3408. * Creates a left-handed perspective projection matrix
  3409. * @param fov defines the horizontal field of view
  3410. * @param aspect defines the aspect ratio
  3411. * @param znear defines the near clip plane
  3412. * @param zfar defines the far clip plane
  3413. * @returns a new matrix as a left-handed perspective projection matrix
  3414. */
  3415. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3416. /**
  3417. * Stores a left-handed perspective projection into a given matrix
  3418. * @param fov defines the horizontal field of view
  3419. * @param aspect defines the aspect ratio
  3420. * @param znear defines the near clip plane
  3421. * @param zfar defines the far clip plane
  3422. * @param result defines the target matrix
  3423. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3424. */
  3425. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3426. /**
  3427. * Creates a right-handed perspective projection matrix
  3428. * @param fov defines the horizontal field of view
  3429. * @param aspect defines the aspect ratio
  3430. * @param znear defines the near clip plane
  3431. * @param zfar defines the far clip plane
  3432. * @returns a new matrix as a right-handed perspective projection matrix
  3433. */
  3434. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3435. /**
  3436. * Stores a right-handed perspective projection into a given matrix
  3437. * @param fov defines the horizontal field of view
  3438. * @param aspect defines the aspect ratio
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3443. */
  3444. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3445. /**
  3446. * Stores a perspective projection for WebVR info a given matrix
  3447. * @param fov defines the field of view
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @param result defines the target matrix
  3451. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3452. */
  3453. static PerspectiveFovWebVRToRef(fov: {
  3454. upDegrees: number;
  3455. downDegrees: number;
  3456. leftDegrees: number;
  3457. rightDegrees: number;
  3458. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3459. /**
  3460. * Computes a complete transformation matrix
  3461. * @param viewport defines the viewport to use
  3462. * @param world defines the world matrix
  3463. * @param view defines the view matrix
  3464. * @param projection defines the projection matrix
  3465. * @param zmin defines the near clip plane
  3466. * @param zmax defines the far clip plane
  3467. * @returns the transformation matrix
  3468. */
  3469. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3470. /**
  3471. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3472. * @param matrix defines the matrix to use
  3473. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3474. */
  3475. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3476. /**
  3477. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3478. * @param matrix defines the matrix to use
  3479. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3480. */
  3481. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3482. /**
  3483. * Compute the transpose of a given matrix
  3484. * @param matrix defines the matrix to transpose
  3485. * @returns the new matrix
  3486. */
  3487. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3488. /**
  3489. * Compute the transpose of a matrix and store it in a target matrix
  3490. * @param matrix defines the matrix to transpose
  3491. * @param result defines the target matrix
  3492. */
  3493. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3494. /**
  3495. * Computes a reflection matrix from a plane
  3496. * @param plane defines the reflection plane
  3497. * @returns a new matrix
  3498. */
  3499. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3500. /**
  3501. * Computes a reflection matrix from a plane
  3502. * @param plane defines the reflection plane
  3503. * @param result defines the target matrix
  3504. */
  3505. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3506. /**
  3507. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3508. * @param xaxis defines the value of the 1st axis
  3509. * @param yaxis defines the value of the 2nd axis
  3510. * @param zaxis defines the value of the 3rd axis
  3511. * @param result defines the target matrix
  3512. */
  3513. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3514. /**
  3515. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3516. * @param quat defines the quaternion to use
  3517. * @param result defines the target matrix
  3518. */
  3519. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3520. }
  3521. /**
  3522. * @hidden
  3523. */
  3524. export class TmpVectors {
  3525. static Vector2: Vector2[];
  3526. static Vector3: Vector3[];
  3527. static Vector4: Vector4[];
  3528. static Quaternion: Quaternion[];
  3529. static Matrix: Matrix[];
  3530. }
  3531. }
  3532. declare module "babylonjs/Maths/math.color" {
  3533. import { DeepImmutable, FloatArray } from "babylonjs/types";
  3534. /**
  3535. * Class used to hold a RBG color
  3536. */
  3537. export class Color3 {
  3538. /**
  3539. * Defines the red component (between 0 and 1, default is 0)
  3540. */
  3541. r: number;
  3542. /**
  3543. * Defines the green component (between 0 and 1, default is 0)
  3544. */
  3545. g: number;
  3546. /**
  3547. * Defines the blue component (between 0 and 1, default is 0)
  3548. */
  3549. b: number;
  3550. /**
  3551. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3552. * @param r defines the red component (between 0 and 1, default is 0)
  3553. * @param g defines the green component (between 0 and 1, default is 0)
  3554. * @param b defines the blue component (between 0 and 1, default is 0)
  3555. */
  3556. constructor(
  3557. /**
  3558. * Defines the red component (between 0 and 1, default is 0)
  3559. */
  3560. r?: number,
  3561. /**
  3562. * Defines the green component (between 0 and 1, default is 0)
  3563. */
  3564. g?: number,
  3565. /**
  3566. * Defines the blue component (between 0 and 1, default is 0)
  3567. */
  3568. b?: number);
  3569. /**
  3570. * Creates a string with the Color3 current values
  3571. * @returns the string representation of the Color3 object
  3572. */
  3573. toString(): string;
  3574. /**
  3575. * Returns the string "Color3"
  3576. * @returns "Color3"
  3577. */
  3578. getClassName(): string;
  3579. /**
  3580. * Compute the Color3 hash code
  3581. * @returns an unique number that can be used to hash Color3 objects
  3582. */
  3583. getHashCode(): number;
  3584. /**
  3585. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3586. * @param array defines the array where to store the r,g,b components
  3587. * @param index defines an optional index in the target array to define where to start storing values
  3588. * @returns the current Color3 object
  3589. */
  3590. toArray(array: FloatArray, index?: number): Color3;
  3591. /**
  3592. * Returns a new Color4 object from the current Color3 and the given alpha
  3593. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3594. * @returns a new Color4 object
  3595. */
  3596. toColor4(alpha?: number): Color4;
  3597. /**
  3598. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3599. * @returns the new array
  3600. */
  3601. asArray(): number[];
  3602. /**
  3603. * Returns the luminance value
  3604. * @returns a float value
  3605. */
  3606. toLuminance(): number;
  3607. /**
  3608. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3609. * @param otherColor defines the second operand
  3610. * @returns the new Color3 object
  3611. */
  3612. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3613. /**
  3614. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3615. * @param otherColor defines the second operand
  3616. * @param result defines the Color3 object where to store the result
  3617. * @returns the current Color3
  3618. */
  3619. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3620. /**
  3621. * Determines equality between Color3 objects
  3622. * @param otherColor defines the second operand
  3623. * @returns true if the rgb values are equal to the given ones
  3624. */
  3625. equals(otherColor: DeepImmutable<Color3>): boolean;
  3626. /**
  3627. * Determines equality between the current Color3 object and a set of r,b,g values
  3628. * @param r defines the red component to check
  3629. * @param g defines the green component to check
  3630. * @param b defines the blue component to check
  3631. * @returns true if the rgb values are equal to the given ones
  3632. */
  3633. equalsFloats(r: number, g: number, b: number): boolean;
  3634. /**
  3635. * Multiplies in place each rgb value by scale
  3636. * @param scale defines the scaling factor
  3637. * @returns the updated Color3
  3638. */
  3639. scale(scale: number): Color3;
  3640. /**
  3641. * Multiplies the rgb values by scale and stores the result into "result"
  3642. * @param scale defines the scaling factor
  3643. * @param result defines the Color3 object where to store the result
  3644. * @returns the unmodified current Color3
  3645. */
  3646. scaleToRef(scale: number, result: Color3): Color3;
  3647. /**
  3648. * Scale the current Color3 values by a factor and add the result to a given Color3
  3649. * @param scale defines the scale factor
  3650. * @param result defines color to store the result into
  3651. * @returns the unmodified current Color3
  3652. */
  3653. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3654. /**
  3655. * Clamps the rgb values by the min and max values and stores the result into "result"
  3656. * @param min defines minimum clamping value (default is 0)
  3657. * @param max defines maximum clamping value (default is 1)
  3658. * @param result defines color to store the result into
  3659. * @returns the original Color3
  3660. */
  3661. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3662. /**
  3663. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3664. * @param otherColor defines the second operand
  3665. * @returns the new Color3
  3666. */
  3667. add(otherColor: DeepImmutable<Color3>): Color3;
  3668. /**
  3669. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3670. * @param otherColor defines the second operand
  3671. * @param result defines Color3 object to store the result into
  3672. * @returns the unmodified current Color3
  3673. */
  3674. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3675. /**
  3676. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3677. * @param otherColor defines the second operand
  3678. * @returns the new Color3
  3679. */
  3680. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3681. /**
  3682. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3683. * @param otherColor defines the second operand
  3684. * @param result defines Color3 object to store the result into
  3685. * @returns the unmodified current Color3
  3686. */
  3687. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3688. /**
  3689. * Copy the current object
  3690. * @returns a new Color3 copied the current one
  3691. */
  3692. clone(): Color3;
  3693. /**
  3694. * Copies the rgb values from the source in the current Color3
  3695. * @param source defines the source Color3 object
  3696. * @returns the updated Color3 object
  3697. */
  3698. copyFrom(source: DeepImmutable<Color3>): Color3;
  3699. /**
  3700. * Updates the Color3 rgb values from the given floats
  3701. * @param r defines the red component to read from
  3702. * @param g defines the green component to read from
  3703. * @param b defines the blue component to read from
  3704. * @returns the current Color3 object
  3705. */
  3706. copyFromFloats(r: number, g: number, b: number): Color3;
  3707. /**
  3708. * Updates the Color3 rgb values from the given floats
  3709. * @param r defines the red component to read from
  3710. * @param g defines the green component to read from
  3711. * @param b defines the blue component to read from
  3712. * @returns the current Color3 object
  3713. */
  3714. set(r: number, g: number, b: number): Color3;
  3715. /**
  3716. * Compute the Color3 hexadecimal code as a string
  3717. * @returns a string containing the hexadecimal representation of the Color3 object
  3718. */
  3719. toHexString(): string;
  3720. /**
  3721. * Computes a new Color3 converted from the current one to linear space
  3722. * @returns a new Color3 object
  3723. */
  3724. toLinearSpace(): Color3;
  3725. /**
  3726. * Converts current color in rgb space to HSV values
  3727. * @returns a new color3 representing the HSV values
  3728. */
  3729. toHSV(): Color3;
  3730. /**
  3731. * Converts current color in rgb space to HSV values
  3732. * @param result defines the Color3 where to store the HSV values
  3733. */
  3734. toHSVToRef(result: Color3): void;
  3735. /**
  3736. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3737. * @param convertedColor defines the Color3 object where to store the linear space version
  3738. * @returns the unmodified Color3
  3739. */
  3740. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3741. /**
  3742. * Computes a new Color3 converted from the current one to gamma space
  3743. * @returns a new Color3 object
  3744. */
  3745. toGammaSpace(): Color3;
  3746. /**
  3747. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3748. * @param convertedColor defines the Color3 object where to store the gamma space version
  3749. * @returns the unmodified Color3
  3750. */
  3751. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3752. private static _BlackReadOnly;
  3753. /**
  3754. * Convert Hue, saturation and value to a Color3 (RGB)
  3755. * @param hue defines the hue
  3756. * @param saturation defines the saturation
  3757. * @param value defines the value
  3758. * @param result defines the Color3 where to store the RGB values
  3759. */
  3760. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3761. /**
  3762. * Creates a new Color3 from the string containing valid hexadecimal values
  3763. * @param hex defines a string containing valid hexadecimal values
  3764. * @returns a new Color3 object
  3765. */
  3766. static FromHexString(hex: string): Color3;
  3767. /**
  3768. * Creates a new Color3 from the starting index of the given array
  3769. * @param array defines the source array
  3770. * @param offset defines an offset in the source array
  3771. * @returns a new Color3 object
  3772. */
  3773. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3774. /**
  3775. * Creates a new Color3 from integer values (< 256)
  3776. * @param r defines the red component to read from (value between 0 and 255)
  3777. * @param g defines the green component to read from (value between 0 and 255)
  3778. * @param b defines the blue component to read from (value between 0 and 255)
  3779. * @returns a new Color3 object
  3780. */
  3781. static FromInts(r: number, g: number, b: number): Color3;
  3782. /**
  3783. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3784. * @param start defines the start Color3 value
  3785. * @param end defines the end Color3 value
  3786. * @param amount defines the gradient value between start and end
  3787. * @returns a new Color3 object
  3788. */
  3789. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3790. /**
  3791. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3792. * @param left defines the start value
  3793. * @param right defines the end value
  3794. * @param amount defines the gradient factor
  3795. * @param result defines the Color3 object where to store the result
  3796. */
  3797. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3798. /**
  3799. * Returns a Color3 value containing a red color
  3800. * @returns a new Color3 object
  3801. */
  3802. static Red(): Color3;
  3803. /**
  3804. * Returns a Color3 value containing a green color
  3805. * @returns a new Color3 object
  3806. */
  3807. static Green(): Color3;
  3808. /**
  3809. * Returns a Color3 value containing a blue color
  3810. * @returns a new Color3 object
  3811. */
  3812. static Blue(): Color3;
  3813. /**
  3814. * Returns a Color3 value containing a black color
  3815. * @returns a new Color3 object
  3816. */
  3817. static Black(): Color3;
  3818. /**
  3819. * Gets a Color3 value containing a black color that must not be updated
  3820. */
  3821. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3822. /**
  3823. * Returns a Color3 value containing a white color
  3824. * @returns a new Color3 object
  3825. */
  3826. static White(): Color3;
  3827. /**
  3828. * Returns a Color3 value containing a purple color
  3829. * @returns a new Color3 object
  3830. */
  3831. static Purple(): Color3;
  3832. /**
  3833. * Returns a Color3 value containing a magenta color
  3834. * @returns a new Color3 object
  3835. */
  3836. static Magenta(): Color3;
  3837. /**
  3838. * Returns a Color3 value containing a yellow color
  3839. * @returns a new Color3 object
  3840. */
  3841. static Yellow(): Color3;
  3842. /**
  3843. * Returns a Color3 value containing a gray color
  3844. * @returns a new Color3 object
  3845. */
  3846. static Gray(): Color3;
  3847. /**
  3848. * Returns a Color3 value containing a teal color
  3849. * @returns a new Color3 object
  3850. */
  3851. static Teal(): Color3;
  3852. /**
  3853. * Returns a Color3 value containing a random color
  3854. * @returns a new Color3 object
  3855. */
  3856. static Random(): Color3;
  3857. }
  3858. /**
  3859. * Class used to hold a RBGA color
  3860. */
  3861. export class Color4 {
  3862. /**
  3863. * Defines the red component (between 0 and 1, default is 0)
  3864. */
  3865. r: number;
  3866. /**
  3867. * Defines the green component (between 0 and 1, default is 0)
  3868. */
  3869. g: number;
  3870. /**
  3871. * Defines the blue component (between 0 and 1, default is 0)
  3872. */
  3873. b: number;
  3874. /**
  3875. * Defines the alpha component (between 0 and 1, default is 1)
  3876. */
  3877. a: number;
  3878. /**
  3879. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3880. * @param r defines the red component (between 0 and 1, default is 0)
  3881. * @param g defines the green component (between 0 and 1, default is 0)
  3882. * @param b defines the blue component (between 0 and 1, default is 0)
  3883. * @param a defines the alpha component (between 0 and 1, default is 1)
  3884. */
  3885. constructor(
  3886. /**
  3887. * Defines the red component (between 0 and 1, default is 0)
  3888. */
  3889. r?: number,
  3890. /**
  3891. * Defines the green component (between 0 and 1, default is 0)
  3892. */
  3893. g?: number,
  3894. /**
  3895. * Defines the blue component (between 0 and 1, default is 0)
  3896. */
  3897. b?: number,
  3898. /**
  3899. * Defines the alpha component (between 0 and 1, default is 1)
  3900. */
  3901. a?: number);
  3902. /**
  3903. * Adds in place the given Color4 values to the current Color4 object
  3904. * @param right defines the second operand
  3905. * @returns the current updated Color4 object
  3906. */
  3907. addInPlace(right: DeepImmutable<Color4>): Color4;
  3908. /**
  3909. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3910. * @returns the new array
  3911. */
  3912. asArray(): number[];
  3913. /**
  3914. * Stores from the starting index in the given array the Color4 successive values
  3915. * @param array defines the array where to store the r,g,b components
  3916. * @param index defines an optional index in the target array to define where to start storing values
  3917. * @returns the current Color4 object
  3918. */
  3919. toArray(array: number[], index?: number): Color4;
  3920. /**
  3921. * Determines equality between Color4 objects
  3922. * @param otherColor defines the second operand
  3923. * @returns true if the rgba values are equal to the given ones
  3924. */
  3925. equals(otherColor: DeepImmutable<Color4>): boolean;
  3926. /**
  3927. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3928. * @param right defines the second operand
  3929. * @returns a new Color4 object
  3930. */
  3931. add(right: DeepImmutable<Color4>): Color4;
  3932. /**
  3933. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3934. * @param right defines the second operand
  3935. * @returns a new Color4 object
  3936. */
  3937. subtract(right: DeepImmutable<Color4>): Color4;
  3938. /**
  3939. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3940. * @param right defines the second operand
  3941. * @param result defines the Color4 object where to store the result
  3942. * @returns the current Color4 object
  3943. */
  3944. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3945. /**
  3946. * Creates a new Color4 with the current Color4 values multiplied by scale
  3947. * @param scale defines the scaling factor to apply
  3948. * @returns a new Color4 object
  3949. */
  3950. scale(scale: number): Color4;
  3951. /**
  3952. * Multiplies the current Color4 values by scale and stores the result in "result"
  3953. * @param scale defines the scaling factor to apply
  3954. * @param result defines the Color4 object where to store the result
  3955. * @returns the current unmodified Color4
  3956. */
  3957. scaleToRef(scale: number, result: Color4): Color4;
  3958. /**
  3959. * Scale the current Color4 values by a factor and add the result to a given Color4
  3960. * @param scale defines the scale factor
  3961. * @param result defines the Color4 object where to store the result
  3962. * @returns the unmodified current Color4
  3963. */
  3964. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3965. /**
  3966. * Clamps the rgb values by the min and max values and stores the result into "result"
  3967. * @param min defines minimum clamping value (default is 0)
  3968. * @param max defines maximum clamping value (default is 1)
  3969. * @param result defines color to store the result into.
  3970. * @returns the cuurent Color4
  3971. */
  3972. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3973. /**
  3974. * Multipy an Color4 value by another and return a new Color4 object
  3975. * @param color defines the Color4 value to multiply by
  3976. * @returns a new Color4 object
  3977. */
  3978. multiply(color: Color4): Color4;
  3979. /**
  3980. * Multipy a Color4 value by another and push the result in a reference value
  3981. * @param color defines the Color4 value to multiply by
  3982. * @param result defines the Color4 to fill the result in
  3983. * @returns the result Color4
  3984. */
  3985. multiplyToRef(color: Color4, result: Color4): Color4;
  3986. /**
  3987. * Creates a string with the Color4 current values
  3988. * @returns the string representation of the Color4 object
  3989. */
  3990. toString(): string;
  3991. /**
  3992. * Returns the string "Color4"
  3993. * @returns "Color4"
  3994. */
  3995. getClassName(): string;
  3996. /**
  3997. * Compute the Color4 hash code
  3998. * @returns an unique number that can be used to hash Color4 objects
  3999. */
  4000. getHashCode(): number;
  4001. /**
  4002. * Creates a new Color4 copied from the current one
  4003. * @returns a new Color4 object
  4004. */
  4005. clone(): Color4;
  4006. /**
  4007. * Copies the given Color4 values into the current one
  4008. * @param source defines the source Color4 object
  4009. * @returns the current updated Color4 object
  4010. */
  4011. copyFrom(source: Color4): Color4;
  4012. /**
  4013. * Copies the given float values into the current one
  4014. * @param r defines the red component to read from
  4015. * @param g defines the green component to read from
  4016. * @param b defines the blue component to read from
  4017. * @param a defines the alpha component to read from
  4018. * @returns the current updated Color4 object
  4019. */
  4020. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4021. /**
  4022. * Copies the given float values into the current one
  4023. * @param r defines the red component to read from
  4024. * @param g defines the green component to read from
  4025. * @param b defines the blue component to read from
  4026. * @param a defines the alpha component to read from
  4027. * @returns the current updated Color4 object
  4028. */
  4029. set(r: number, g: number, b: number, a: number): Color4;
  4030. /**
  4031. * Compute the Color4 hexadecimal code as a string
  4032. * @returns a string containing the hexadecimal representation of the Color4 object
  4033. */
  4034. toHexString(): string;
  4035. /**
  4036. * Computes a new Color4 converted from the current one to linear space
  4037. * @returns a new Color4 object
  4038. */
  4039. toLinearSpace(): Color4;
  4040. /**
  4041. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4042. * @param convertedColor defines the Color4 object where to store the linear space version
  4043. * @returns the unmodified Color4
  4044. */
  4045. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4046. /**
  4047. * Computes a new Color4 converted from the current one to gamma space
  4048. * @returns a new Color4 object
  4049. */
  4050. toGammaSpace(): Color4;
  4051. /**
  4052. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4053. * @param convertedColor defines the Color4 object where to store the gamma space version
  4054. * @returns the unmodified Color4
  4055. */
  4056. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4057. /**
  4058. * Creates a new Color4 from the string containing valid hexadecimal values
  4059. * @param hex defines a string containing valid hexadecimal values
  4060. * @returns a new Color4 object
  4061. */
  4062. static FromHexString(hex: string): Color4;
  4063. /**
  4064. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4065. * @param left defines the start value
  4066. * @param right defines the end value
  4067. * @param amount defines the gradient factor
  4068. * @returns a new Color4 object
  4069. */
  4070. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4071. /**
  4072. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4073. * @param left defines the start value
  4074. * @param right defines the end value
  4075. * @param amount defines the gradient factor
  4076. * @param result defines the Color4 object where to store data
  4077. */
  4078. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4079. /**
  4080. * Creates a new Color4 from a Color3 and an alpha value
  4081. * @param color3 defines the source Color3 to read from
  4082. * @param alpha defines the alpha component (1.0 by default)
  4083. * @returns a new Color4 object
  4084. */
  4085. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4086. /**
  4087. * Creates a new Color4 from the starting index element of the given array
  4088. * @param array defines the source array to read from
  4089. * @param offset defines the offset in the source array
  4090. * @returns a new Color4 object
  4091. */
  4092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4093. /**
  4094. * Creates a new Color3 from integer values (< 256)
  4095. * @param r defines the red component to read from (value between 0 and 255)
  4096. * @param g defines the green component to read from (value between 0 and 255)
  4097. * @param b defines the blue component to read from (value between 0 and 255)
  4098. * @param a defines the alpha component to read from (value between 0 and 255)
  4099. * @returns a new Color3 object
  4100. */
  4101. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4102. /**
  4103. * Check the content of a given array and convert it to an array containing RGBA data
  4104. * If the original array was already containing count * 4 values then it is returned directly
  4105. * @param colors defines the array to check
  4106. * @param count defines the number of RGBA data to expect
  4107. * @returns an array containing count * 4 values (RGBA)
  4108. */
  4109. static CheckColors4(colors: number[], count: number): number[];
  4110. }
  4111. /**
  4112. * @hidden
  4113. */
  4114. export class TmpColors {
  4115. static Color3: Color3[];
  4116. static Color4: Color4[];
  4117. }
  4118. }
  4119. declare module "babylonjs/Maths/sphericalPolynomial" {
  4120. import { Vector3 } from "babylonjs/Maths/math.vector";
  4121. import { Color3 } from "babylonjs/Maths/math.color";
  4122. /**
  4123. * Class representing spherical harmonics coefficients to the 3rd degree
  4124. */
  4125. export class SphericalHarmonics {
  4126. /**
  4127. * Defines whether or not the harmonics have been prescaled for rendering.
  4128. */
  4129. preScaled: boolean;
  4130. /**
  4131. * The l0,0 coefficients of the spherical harmonics
  4132. */
  4133. l00: Vector3;
  4134. /**
  4135. * The l1,-1 coefficients of the spherical harmonics
  4136. */
  4137. l1_1: Vector3;
  4138. /**
  4139. * The l1,0 coefficients of the spherical harmonics
  4140. */
  4141. l10: Vector3;
  4142. /**
  4143. * The l1,1 coefficients of the spherical harmonics
  4144. */
  4145. l11: Vector3;
  4146. /**
  4147. * The l2,-2 coefficients of the spherical harmonics
  4148. */
  4149. l2_2: Vector3;
  4150. /**
  4151. * The l2,-1 coefficients of the spherical harmonics
  4152. */
  4153. l2_1: Vector3;
  4154. /**
  4155. * The l2,0 coefficients of the spherical harmonics
  4156. */
  4157. l20: Vector3;
  4158. /**
  4159. * The l2,1 coefficients of the spherical harmonics
  4160. */
  4161. l21: Vector3;
  4162. /**
  4163. * The l2,2 coefficients of the spherical harmonics
  4164. */
  4165. l22: Vector3;
  4166. /**
  4167. * Adds a light to the spherical harmonics
  4168. * @param direction the direction of the light
  4169. * @param color the color of the light
  4170. * @param deltaSolidAngle the delta solid angle of the light
  4171. */
  4172. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4173. /**
  4174. * Scales the spherical harmonics by the given amount
  4175. * @param scale the amount to scale
  4176. */
  4177. scaleInPlace(scale: number): void;
  4178. /**
  4179. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4180. *
  4181. * ```
  4182. * E_lm = A_l * L_lm
  4183. * ```
  4184. *
  4185. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4186. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4187. * the scaling factors are given in equation 9.
  4188. */
  4189. convertIncidentRadianceToIrradiance(): void;
  4190. /**
  4191. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4192. *
  4193. * ```
  4194. * L = (1/pi) * E * rho
  4195. * ```
  4196. *
  4197. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4198. */
  4199. convertIrradianceToLambertianRadiance(): void;
  4200. /**
  4201. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4202. * required operations at run time.
  4203. *
  4204. * This is simply done by scaling back the SH with Ylm constants parameter.
  4205. * The trigonometric part being applied by the shader at run time.
  4206. */
  4207. preScaleForRendering(): void;
  4208. /**
  4209. * Constructs a spherical harmonics from an array.
  4210. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4211. * @returns the spherical harmonics
  4212. */
  4213. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4214. /**
  4215. * Gets the spherical harmonics from polynomial
  4216. * @param polynomial the spherical polynomial
  4217. * @returns the spherical harmonics
  4218. */
  4219. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4220. }
  4221. /**
  4222. * Class representing spherical polynomial coefficients to the 3rd degree
  4223. */
  4224. export class SphericalPolynomial {
  4225. private _harmonics;
  4226. /**
  4227. * The spherical harmonics used to create the polynomials.
  4228. */
  4229. readonly preScaledHarmonics: SphericalHarmonics;
  4230. /**
  4231. * The x coefficients of the spherical polynomial
  4232. */
  4233. x: Vector3;
  4234. /**
  4235. * The y coefficients of the spherical polynomial
  4236. */
  4237. y: Vector3;
  4238. /**
  4239. * The z coefficients of the spherical polynomial
  4240. */
  4241. z: Vector3;
  4242. /**
  4243. * The xx coefficients of the spherical polynomial
  4244. */
  4245. xx: Vector3;
  4246. /**
  4247. * The yy coefficients of the spherical polynomial
  4248. */
  4249. yy: Vector3;
  4250. /**
  4251. * The zz coefficients of the spherical polynomial
  4252. */
  4253. zz: Vector3;
  4254. /**
  4255. * The xy coefficients of the spherical polynomial
  4256. */
  4257. xy: Vector3;
  4258. /**
  4259. * The yz coefficients of the spherical polynomial
  4260. */
  4261. yz: Vector3;
  4262. /**
  4263. * The zx coefficients of the spherical polynomial
  4264. */
  4265. zx: Vector3;
  4266. /**
  4267. * Adds an ambient color to the spherical polynomial
  4268. * @param color the color to add
  4269. */
  4270. addAmbient(color: Color3): void;
  4271. /**
  4272. * Scales the spherical polynomial by the given amount
  4273. * @param scale the amount to scale
  4274. */
  4275. scaleInPlace(scale: number): void;
  4276. /**
  4277. * Gets the spherical polynomial from harmonics
  4278. * @param harmonics the spherical harmonics
  4279. * @returns the spherical polynomial
  4280. */
  4281. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4282. /**
  4283. * Constructs a spherical polynomial from an array.
  4284. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4285. * @returns the spherical polynomial
  4286. */
  4287. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4288. }
  4289. }
  4290. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  4291. /**
  4292. * Define options used to create a render target texture
  4293. */
  4294. export class RenderTargetCreationOptions {
  4295. /**
  4296. * Specifies is mipmaps must be generated
  4297. */
  4298. generateMipMaps?: boolean;
  4299. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4300. generateDepthBuffer?: boolean;
  4301. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4302. generateStencilBuffer?: boolean;
  4303. /** Defines texture type (int by default) */
  4304. type?: number;
  4305. /** Defines sampling mode (trilinear by default) */
  4306. samplingMode?: number;
  4307. /** Defines format (RGBA by default) */
  4308. format?: number;
  4309. }
  4310. }
  4311. declare module "babylonjs/Instrumentation/timeToken" {
  4312. import { Nullable } from "babylonjs/types";
  4313. /**
  4314. * @hidden
  4315. **/
  4316. export class _TimeToken {
  4317. _startTimeQuery: Nullable<WebGLQuery>;
  4318. _endTimeQuery: Nullable<WebGLQuery>;
  4319. _timeElapsedQuery: Nullable<WebGLQuery>;
  4320. _timeElapsedQueryEnded: boolean;
  4321. }
  4322. }
  4323. declare module "babylonjs/Engines/constants" {
  4324. /** Defines the cross module used constants to avoid circular dependncies */
  4325. export class Constants {
  4326. /** Defines that alpha blending is disabled */
  4327. static readonly ALPHA_DISABLE: number;
  4328. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4329. static readonly ALPHA_ADD: number;
  4330. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4331. static readonly ALPHA_COMBINE: number;
  4332. /** Defines that alpha blending to DEST - SRC * DEST */
  4333. static readonly ALPHA_SUBTRACT: number;
  4334. /** Defines that alpha blending to SRC * DEST */
  4335. static readonly ALPHA_MULTIPLY: number;
  4336. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4337. static readonly ALPHA_MAXIMIZED: number;
  4338. /** Defines that alpha blending to SRC + DEST */
  4339. static readonly ALPHA_ONEONE: number;
  4340. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4341. static readonly ALPHA_PREMULTIPLIED: number;
  4342. /**
  4343. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4344. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4345. */
  4346. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4347. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4348. static readonly ALPHA_INTERPOLATE: number;
  4349. /**
  4350. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4351. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4352. */
  4353. static readonly ALPHA_SCREENMODE: number;
  4354. /**
  4355. * Defines that alpha blending to SRC + DST
  4356. * Alpha will be set to SRC ALPHA + DST ALPHA
  4357. */
  4358. static readonly ALPHA_ONEONE_ONEONE: number;
  4359. /**
  4360. * Defines that alpha blending to SRC * DST ALPHA + DST
  4361. * Alpha will be set to 0
  4362. */
  4363. static readonly ALPHA_ALPHATOCOLOR: number;
  4364. /**
  4365. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4366. */
  4367. static readonly ALPHA_REVERSEONEMINUS: number;
  4368. /**
  4369. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4370. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4371. */
  4372. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4373. /**
  4374. * Defines that alpha blending to SRC + DST
  4375. * Alpha will be set to SRC ALPHA
  4376. */
  4377. static readonly ALPHA_ONEONE_ONEZERO: number;
  4378. /** Defines that alpha blending equation a SUM */
  4379. static readonly ALPHA_EQUATION_ADD: number;
  4380. /** Defines that alpha blending equation a SUBSTRACTION */
  4381. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4382. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4383. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4384. /** Defines that alpha blending equation a MAX operation */
  4385. static readonly ALPHA_EQUATION_MAX: number;
  4386. /** Defines that alpha blending equation a MIN operation */
  4387. static readonly ALPHA_EQUATION_MIN: number;
  4388. /**
  4389. * Defines that alpha blending equation a DARKEN operation:
  4390. * It takes the min of the src and sums the alpha channels.
  4391. */
  4392. static readonly ALPHA_EQUATION_DARKEN: number;
  4393. /** Defines that the ressource is not delayed*/
  4394. static readonly DELAYLOADSTATE_NONE: number;
  4395. /** Defines that the ressource was successfully delay loaded */
  4396. static readonly DELAYLOADSTATE_LOADED: number;
  4397. /** Defines that the ressource is currently delay loading */
  4398. static readonly DELAYLOADSTATE_LOADING: number;
  4399. /** Defines that the ressource is delayed and has not started loading */
  4400. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4401. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4402. static readonly NEVER: number;
  4403. /** 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 */
  4404. static readonly ALWAYS: number;
  4405. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4406. static readonly LESS: number;
  4407. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4408. static readonly EQUAL: number;
  4409. /** 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 */
  4410. static readonly LEQUAL: number;
  4411. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4412. static readonly GREATER: number;
  4413. /** 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 */
  4414. static readonly GEQUAL: number;
  4415. /** 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 */
  4416. static readonly NOTEQUAL: number;
  4417. /** Passed to stencilOperation to specify that stencil value must be kept */
  4418. static readonly KEEP: number;
  4419. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4420. static readonly REPLACE: number;
  4421. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4422. static readonly INCR: number;
  4423. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4424. static readonly DECR: number;
  4425. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4426. static readonly INVERT: number;
  4427. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4428. static readonly INCR_WRAP: number;
  4429. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4430. static readonly DECR_WRAP: number;
  4431. /** Texture is not repeating outside of 0..1 UVs */
  4432. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4433. /** Texture is repeating outside of 0..1 UVs */
  4434. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4435. /** Texture is repeating and mirrored */
  4436. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4437. /** ALPHA */
  4438. static readonly TEXTUREFORMAT_ALPHA: number;
  4439. /** LUMINANCE */
  4440. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4441. /** LUMINANCE_ALPHA */
  4442. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4443. /** RGB */
  4444. static readonly TEXTUREFORMAT_RGB: number;
  4445. /** RGBA */
  4446. static readonly TEXTUREFORMAT_RGBA: number;
  4447. /** RED */
  4448. static readonly TEXTUREFORMAT_RED: number;
  4449. /** RED (2nd reference) */
  4450. static readonly TEXTUREFORMAT_R: number;
  4451. /** RG */
  4452. static readonly TEXTUREFORMAT_RG: number;
  4453. /** RED_INTEGER */
  4454. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4455. /** RED_INTEGER (2nd reference) */
  4456. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4457. /** RG_INTEGER */
  4458. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4459. /** RGB_INTEGER */
  4460. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4461. /** RGBA_INTEGER */
  4462. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4463. /** UNSIGNED_BYTE */
  4464. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4465. /** UNSIGNED_BYTE (2nd reference) */
  4466. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4467. /** FLOAT */
  4468. static readonly TEXTURETYPE_FLOAT: number;
  4469. /** HALF_FLOAT */
  4470. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4471. /** BYTE */
  4472. static readonly TEXTURETYPE_BYTE: number;
  4473. /** SHORT */
  4474. static readonly TEXTURETYPE_SHORT: number;
  4475. /** UNSIGNED_SHORT */
  4476. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4477. /** INT */
  4478. static readonly TEXTURETYPE_INT: number;
  4479. /** UNSIGNED_INT */
  4480. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4481. /** UNSIGNED_SHORT_4_4_4_4 */
  4482. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4483. /** UNSIGNED_SHORT_5_5_5_1 */
  4484. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4485. /** UNSIGNED_SHORT_5_6_5 */
  4486. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4487. /** UNSIGNED_INT_2_10_10_10_REV */
  4488. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4489. /** UNSIGNED_INT_24_8 */
  4490. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4491. /** UNSIGNED_INT_10F_11F_11F_REV */
  4492. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4493. /** UNSIGNED_INT_5_9_9_9_REV */
  4494. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4495. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4496. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4497. /** nearest is mag = nearest and min = nearest and mip = linear */
  4498. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4499. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4500. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4501. /** Trilinear is mag = linear and min = linear and mip = linear */
  4502. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4503. /** nearest is mag = nearest and min = nearest and mip = linear */
  4504. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4505. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4506. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4507. /** Trilinear is mag = linear and min = linear and mip = linear */
  4508. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4509. /** mag = nearest and min = nearest and mip = nearest */
  4510. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4511. /** mag = nearest and min = linear and mip = nearest */
  4512. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4513. /** mag = nearest and min = linear and mip = linear */
  4514. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4515. /** mag = nearest and min = linear and mip = none */
  4516. static readonly TEXTURE_NEAREST_LINEAR: number;
  4517. /** mag = nearest and min = nearest and mip = none */
  4518. static readonly TEXTURE_NEAREST_NEAREST: number;
  4519. /** mag = linear and min = nearest and mip = nearest */
  4520. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4521. /** mag = linear and min = nearest and mip = linear */
  4522. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4523. /** mag = linear and min = linear and mip = none */
  4524. static readonly TEXTURE_LINEAR_LINEAR: number;
  4525. /** mag = linear and min = nearest and mip = none */
  4526. static readonly TEXTURE_LINEAR_NEAREST: number;
  4527. /** Explicit coordinates mode */
  4528. static readonly TEXTURE_EXPLICIT_MODE: number;
  4529. /** Spherical coordinates mode */
  4530. static readonly TEXTURE_SPHERICAL_MODE: number;
  4531. /** Planar coordinates mode */
  4532. static readonly TEXTURE_PLANAR_MODE: number;
  4533. /** Cubic coordinates mode */
  4534. static readonly TEXTURE_CUBIC_MODE: number;
  4535. /** Projection coordinates mode */
  4536. static readonly TEXTURE_PROJECTION_MODE: number;
  4537. /** Skybox coordinates mode */
  4538. static readonly TEXTURE_SKYBOX_MODE: number;
  4539. /** Inverse Cubic coordinates mode */
  4540. static readonly TEXTURE_INVCUBIC_MODE: number;
  4541. /** Equirectangular coordinates mode */
  4542. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4543. /** Equirectangular Fixed coordinates mode */
  4544. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4545. /** Equirectangular Fixed Mirrored coordinates mode */
  4546. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4547. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4548. static readonly SCALEMODE_FLOOR: number;
  4549. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4550. static readonly SCALEMODE_NEAREST: number;
  4551. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4552. static readonly SCALEMODE_CEILING: number;
  4553. /**
  4554. * The dirty texture flag value
  4555. */
  4556. static readonly MATERIAL_TextureDirtyFlag: number;
  4557. /**
  4558. * The dirty light flag value
  4559. */
  4560. static readonly MATERIAL_LightDirtyFlag: number;
  4561. /**
  4562. * The dirty fresnel flag value
  4563. */
  4564. static readonly MATERIAL_FresnelDirtyFlag: number;
  4565. /**
  4566. * The dirty attribute flag value
  4567. */
  4568. static readonly MATERIAL_AttributesDirtyFlag: number;
  4569. /**
  4570. * The dirty misc flag value
  4571. */
  4572. static readonly MATERIAL_MiscDirtyFlag: number;
  4573. /**
  4574. * The all dirty flag value
  4575. */
  4576. static readonly MATERIAL_AllDirtyFlag: number;
  4577. /**
  4578. * Returns the triangle fill mode
  4579. */
  4580. static readonly MATERIAL_TriangleFillMode: number;
  4581. /**
  4582. * Returns the wireframe mode
  4583. */
  4584. static readonly MATERIAL_WireFrameFillMode: number;
  4585. /**
  4586. * Returns the point fill mode
  4587. */
  4588. static readonly MATERIAL_PointFillMode: number;
  4589. /**
  4590. * Returns the point list draw mode
  4591. */
  4592. static readonly MATERIAL_PointListDrawMode: number;
  4593. /**
  4594. * Returns the line list draw mode
  4595. */
  4596. static readonly MATERIAL_LineListDrawMode: number;
  4597. /**
  4598. * Returns the line loop draw mode
  4599. */
  4600. static readonly MATERIAL_LineLoopDrawMode: number;
  4601. /**
  4602. * Returns the line strip draw mode
  4603. */
  4604. static readonly MATERIAL_LineStripDrawMode: number;
  4605. /**
  4606. * Returns the triangle strip draw mode
  4607. */
  4608. static readonly MATERIAL_TriangleStripDrawMode: number;
  4609. /**
  4610. * Returns the triangle fan draw mode
  4611. */
  4612. static readonly MATERIAL_TriangleFanDrawMode: number;
  4613. /**
  4614. * Stores the clock-wise side orientation
  4615. */
  4616. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4617. /**
  4618. * Stores the counter clock-wise side orientation
  4619. */
  4620. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4621. /**
  4622. * Nothing
  4623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4624. */
  4625. static readonly ACTION_NothingTrigger: number;
  4626. /**
  4627. * On pick
  4628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4629. */
  4630. static readonly ACTION_OnPickTrigger: number;
  4631. /**
  4632. * On left pick
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnLeftPickTrigger: number;
  4636. /**
  4637. * On right pick
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnRightPickTrigger: number;
  4641. /**
  4642. * On center pick
  4643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4644. */
  4645. static readonly ACTION_OnCenterPickTrigger: number;
  4646. /**
  4647. * On pick down
  4648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4649. */
  4650. static readonly ACTION_OnPickDownTrigger: number;
  4651. /**
  4652. * On double pick
  4653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4654. */
  4655. static readonly ACTION_OnDoublePickTrigger: number;
  4656. /**
  4657. * On pick up
  4658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4659. */
  4660. static readonly ACTION_OnPickUpTrigger: number;
  4661. /**
  4662. * On pick out.
  4663. * This trigger will only be raised if you also declared a OnPickDown
  4664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4665. */
  4666. static readonly ACTION_OnPickOutTrigger: number;
  4667. /**
  4668. * On long press
  4669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4670. */
  4671. static readonly ACTION_OnLongPressTrigger: number;
  4672. /**
  4673. * On pointer over
  4674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4675. */
  4676. static readonly ACTION_OnPointerOverTrigger: number;
  4677. /**
  4678. * On pointer out
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_OnPointerOutTrigger: number;
  4682. /**
  4683. * On every frame
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnEveryFrameTrigger: number;
  4687. /**
  4688. * On intersection enter
  4689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4690. */
  4691. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4692. /**
  4693. * On intersection exit
  4694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4695. */
  4696. static readonly ACTION_OnIntersectionExitTrigger: number;
  4697. /**
  4698. * On key down
  4699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4700. */
  4701. static readonly ACTION_OnKeyDownTrigger: number;
  4702. /**
  4703. * On key up
  4704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4705. */
  4706. static readonly ACTION_OnKeyUpTrigger: number;
  4707. /**
  4708. * Billboard mode will only apply to Y axis
  4709. */
  4710. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4711. /**
  4712. * Billboard mode will apply to all axes
  4713. */
  4714. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4715. /**
  4716. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4717. */
  4718. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4719. /**
  4720. * Gets or sets base Assets URL
  4721. */
  4722. static PARTICLES_BaseAssetsUrl: string;
  4723. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4724. * Test order :
  4725. * Is the bounding sphere outside the frustum ?
  4726. * If not, are the bounding box vertices outside the frustum ?
  4727. * It not, then the cullable object is in the frustum.
  4728. */
  4729. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4730. /** Culling strategy : Bounding Sphere Only.
  4731. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4732. * It's also less accurate than the standard because some not visible objects can still be selected.
  4733. * Test : is the bounding sphere outside the frustum ?
  4734. * If not, then the cullable object is in the frustum.
  4735. */
  4736. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4737. /** Culling strategy : Optimistic Inclusion.
  4738. * This in an inclusion test first, then the standard exclusion test.
  4739. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4740. * 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.
  4741. * Anyway, it's as accurate as the standard strategy.
  4742. * Test :
  4743. * Is the cullable object bounding sphere center in the frustum ?
  4744. * If not, apply the default culling strategy.
  4745. */
  4746. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4747. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4748. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4749. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4750. * 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.
  4751. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4752. * Test :
  4753. * Is the cullable object bounding sphere center in the frustum ?
  4754. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4755. */
  4756. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4757. /**
  4758. * No logging while loading
  4759. */
  4760. static readonly SCENELOADER_NO_LOGGING: number;
  4761. /**
  4762. * Minimal logging while loading
  4763. */
  4764. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4765. /**
  4766. * Summary logging while loading
  4767. */
  4768. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4769. /**
  4770. * Detailled logging while loading
  4771. */
  4772. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4773. }
  4774. }
  4775. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  4776. import { Nullable } from "babylonjs/types";
  4777. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  4778. /**
  4779. * This represents the required contract to create a new type of texture loader.
  4780. */
  4781. export interface IInternalTextureLoader {
  4782. /**
  4783. * Defines wether the loader supports cascade loading the different faces.
  4784. */
  4785. supportCascades: boolean;
  4786. /**
  4787. * This returns if the loader support the current file information.
  4788. * @param extension defines the file extension of the file being loaded
  4789. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4790. * @param fallback defines the fallback internal texture if any
  4791. * @param isBase64 defines whether the texture is encoded as a base64
  4792. * @param isBuffer defines whether the texture data are stored as a buffer
  4793. * @returns true if the loader can load the specified file
  4794. */
  4795. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4796. /**
  4797. * Transform the url before loading if required.
  4798. * @param rootUrl the url of the texture
  4799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4800. * @returns the transformed texture
  4801. */
  4802. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4803. /**
  4804. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4805. * @param rootUrl the url of the texture
  4806. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4807. * @returns the fallback texture
  4808. */
  4809. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4810. /**
  4811. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4812. * @param data contains the texture data
  4813. * @param texture defines the BabylonJS internal texture
  4814. * @param createPolynomials will be true if polynomials have been requested
  4815. * @param onLoad defines the callback to trigger once the texture is ready
  4816. * @param onError defines the callback to trigger in case of error
  4817. */
  4818. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4819. /**
  4820. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4821. * @param data contains the texture data
  4822. * @param texture defines the BabylonJS internal texture
  4823. * @param callback defines the method to call once ready to upload
  4824. */
  4825. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4826. }
  4827. }
  4828. declare module "babylonjs/Engines/IPipelineContext" {
  4829. /**
  4830. * Class used to store and describe the pipeline context associated with an effect
  4831. */
  4832. export interface IPipelineContext {
  4833. /**
  4834. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4835. */
  4836. isAsync: boolean;
  4837. /**
  4838. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4839. */
  4840. isReady: boolean;
  4841. /** @hidden */
  4842. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4843. }
  4844. }
  4845. declare module "babylonjs/Meshes/dataBuffer" {
  4846. /**
  4847. * Class used to store gfx data (like WebGLBuffer)
  4848. */
  4849. export class DataBuffer {
  4850. /**
  4851. * Gets or sets the number of objects referencing this buffer
  4852. */
  4853. references: number;
  4854. /** Gets or sets the size of the underlying buffer */
  4855. capacity: number;
  4856. /**
  4857. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4858. */
  4859. is32Bits: boolean;
  4860. /**
  4861. * Gets the underlying buffer
  4862. */
  4863. readonly underlyingResource: any;
  4864. }
  4865. }
  4866. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4867. /** @hidden */
  4868. export interface IShaderProcessor {
  4869. attributeProcessor?: (attribute: string) => string;
  4870. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4871. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4872. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4873. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4874. lineProcessor?: (line: string, isFragment: boolean) => string;
  4875. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4876. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4877. }
  4878. }
  4879. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4880. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4881. /** @hidden */
  4882. export interface ProcessingOptions {
  4883. defines: string[];
  4884. indexParameters: any;
  4885. isFragment: boolean;
  4886. shouldUseHighPrecisionShader: boolean;
  4887. supportsUniformBuffers: boolean;
  4888. shadersRepository: string;
  4889. includesShadersStore: {
  4890. [key: string]: string;
  4891. };
  4892. processor?: IShaderProcessor;
  4893. version: string;
  4894. platformName: string;
  4895. lookForClosingBracketForUniformBuffer?: boolean;
  4896. }
  4897. }
  4898. declare module "babylonjs/Misc/stringTools" {
  4899. /**
  4900. * Helper to manipulate strings
  4901. */
  4902. export class StringTools {
  4903. /**
  4904. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4905. * @param str Source string
  4906. * @param suffix Suffix to search for in the source string
  4907. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4908. */
  4909. static EndsWith(str: string, suffix: string): boolean;
  4910. /**
  4911. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4912. * @param str Source string
  4913. * @param suffix Suffix to search for in the source string
  4914. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4915. */
  4916. static StartsWith(str: string, suffix: string): boolean;
  4917. }
  4918. }
  4919. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4920. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4921. /** @hidden */
  4922. export class ShaderCodeNode {
  4923. line: string;
  4924. children: ShaderCodeNode[];
  4925. additionalDefineKey?: string;
  4926. additionalDefineValue?: string;
  4927. isValid(preprocessors: {
  4928. [key: string]: string;
  4929. }): boolean;
  4930. process(preprocessors: {
  4931. [key: string]: string;
  4932. }, options: ProcessingOptions): string;
  4933. }
  4934. }
  4935. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4936. /** @hidden */
  4937. export class ShaderCodeCursor {
  4938. private _lines;
  4939. lineIndex: number;
  4940. readonly currentLine: string;
  4941. readonly canRead: boolean;
  4942. lines: string[];
  4943. }
  4944. }
  4945. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4946. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4947. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4948. /** @hidden */
  4949. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4950. process(preprocessors: {
  4951. [key: string]: string;
  4952. }, options: ProcessingOptions): string;
  4953. }
  4954. }
  4955. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4956. /** @hidden */
  4957. export class ShaderDefineExpression {
  4958. isTrue(preprocessors: {
  4959. [key: string]: string;
  4960. }): boolean;
  4961. }
  4962. }
  4963. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4964. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4965. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4966. /** @hidden */
  4967. export class ShaderCodeTestNode extends ShaderCodeNode {
  4968. testExpression: ShaderDefineExpression;
  4969. isValid(preprocessors: {
  4970. [key: string]: string;
  4971. }): boolean;
  4972. }
  4973. }
  4974. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4975. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4976. /** @hidden */
  4977. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4978. define: string;
  4979. not: boolean;
  4980. constructor(define: string, not?: boolean);
  4981. isTrue(preprocessors: {
  4982. [key: string]: string;
  4983. }): boolean;
  4984. }
  4985. }
  4986. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4987. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4988. /** @hidden */
  4989. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4990. leftOperand: ShaderDefineExpression;
  4991. rightOperand: ShaderDefineExpression;
  4992. isTrue(preprocessors: {
  4993. [key: string]: string;
  4994. }): boolean;
  4995. }
  4996. }
  4997. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4998. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4999. /** @hidden */
  5000. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5001. leftOperand: ShaderDefineExpression;
  5002. rightOperand: ShaderDefineExpression;
  5003. isTrue(preprocessors: {
  5004. [key: string]: string;
  5005. }): boolean;
  5006. }
  5007. }
  5008. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5009. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5010. /** @hidden */
  5011. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5012. define: string;
  5013. operand: string;
  5014. testValue: string;
  5015. constructor(define: string, operand: string, testValue: string);
  5016. isTrue(preprocessors: {
  5017. [key: string]: string;
  5018. }): boolean;
  5019. }
  5020. }
  5021. declare module "babylonjs/Misc/loadFileError" {
  5022. import { WebRequest } from "babylonjs/Misc/webRequest";
  5023. /**
  5024. * @ignore
  5025. * Application error to support additional information when loading a file
  5026. */
  5027. export class LoadFileError extends Error {
  5028. /** defines the optional web request */
  5029. request?: WebRequest | undefined;
  5030. private static _setPrototypeOf;
  5031. /**
  5032. * Creates a new LoadFileError
  5033. * @param message defines the message of the error
  5034. * @param request defines the optional web request
  5035. */
  5036. constructor(message: string,
  5037. /** defines the optional web request */
  5038. request?: WebRequest | undefined);
  5039. }
  5040. }
  5041. declare module "babylonjs/Offline/IOfflineProvider" {
  5042. /**
  5043. * Class used to enable access to offline support
  5044. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5045. */
  5046. export interface IOfflineProvider {
  5047. /**
  5048. * Gets a boolean indicating if scene must be saved in the database
  5049. */
  5050. enableSceneOffline: boolean;
  5051. /**
  5052. * Gets a boolean indicating if textures must be saved in the database
  5053. */
  5054. enableTexturesOffline: boolean;
  5055. /**
  5056. * Open the offline support and make it available
  5057. * @param successCallback defines the callback to call on success
  5058. * @param errorCallback defines the callback to call on error
  5059. */
  5060. open(successCallback: () => void, errorCallback: () => void): void;
  5061. /**
  5062. * Loads an image from the offline support
  5063. * @param url defines the url to load from
  5064. * @param image defines the target DOM image
  5065. */
  5066. loadImage(url: string, image: HTMLImageElement): void;
  5067. /**
  5068. * Loads a file from offline support
  5069. * @param url defines the URL to load from
  5070. * @param sceneLoaded defines a callback to call on success
  5071. * @param progressCallBack defines a callback to call when progress changed
  5072. * @param errorCallback defines a callback to call on error
  5073. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5074. */
  5075. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5076. }
  5077. }
  5078. declare module "babylonjs/Misc/filesInputStore" {
  5079. /**
  5080. * Class used to help managing file picking and drag'n'drop
  5081. * File Storage
  5082. */
  5083. export class FilesInputStore {
  5084. /**
  5085. * List of files ready to be loaded
  5086. */
  5087. static FilesToLoad: {
  5088. [key: string]: File;
  5089. };
  5090. }
  5091. }
  5092. declare module "babylonjs/Misc/retryStrategy" {
  5093. import { WebRequest } from "babylonjs/Misc/webRequest";
  5094. /**
  5095. * Class used to define a retry strategy when error happens while loading assets
  5096. */
  5097. export class RetryStrategy {
  5098. /**
  5099. * Function used to defines an exponential back off strategy
  5100. * @param maxRetries defines the maximum number of retries (3 by default)
  5101. * @param baseInterval defines the interval between retries
  5102. * @returns the strategy function to use
  5103. */
  5104. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5105. }
  5106. }
  5107. declare module "babylonjs/Misc/fileTools" {
  5108. import { WebRequest } from "babylonjs/Misc/webRequest";
  5109. import { Nullable } from "babylonjs/types";
  5110. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  5111. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  5112. /**
  5113. * @hidden
  5114. */
  5115. export class FileTools {
  5116. /**
  5117. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5118. */
  5119. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5120. /**
  5121. * Gets or sets the base URL to use to load assets
  5122. */
  5123. static BaseUrl: string;
  5124. /**
  5125. * Default behaviour for cors in the application.
  5126. * It can be a string if the expected behavior is identical in the entire app.
  5127. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5128. */
  5129. static CorsBehavior: string | ((url: string | string[]) => string);
  5130. /**
  5131. * Gets or sets a function used to pre-process url before using them to load assets
  5132. */
  5133. static PreprocessUrl: (url: string) => string;
  5134. /**
  5135. * Removes unwanted characters from an url
  5136. * @param url defines the url to clean
  5137. * @returns the cleaned url
  5138. */
  5139. private static _CleanUrl;
  5140. /**
  5141. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5142. * @param url define the url we are trying
  5143. * @param element define the dom element where to configure the cors policy
  5144. */
  5145. static SetCorsBehavior(url: string | string[], element: {
  5146. crossOrigin: string | null;
  5147. }): void;
  5148. /**
  5149. * Loads an image as an HTMLImageElement.
  5150. * @param input url string, ArrayBuffer, or Blob to load
  5151. * @param onLoad callback called when the image successfully loads
  5152. * @param onError callback called when the image fails to load
  5153. * @param offlineProvider offline provider for caching
  5154. * @returns the HTMLImageElement of the loaded image
  5155. */
  5156. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5157. /**
  5158. * Loads a file
  5159. * @param fileToLoad defines the file to load
  5160. * @param callback defines the callback to call when data is loaded
  5161. * @param progressCallBack defines the callback to call during loading process
  5162. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5163. * @returns a file request object
  5164. */
  5165. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5166. /**
  5167. * Loads a file
  5168. * @param url url string, ArrayBuffer, or Blob to load
  5169. * @param onSuccess callback called when the file successfully loads
  5170. * @param onProgress callback called while file is loading (if the server supports this mode)
  5171. * @param offlineProvider defines the offline provider for caching
  5172. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5173. * @param onError callback called when the file fails to load
  5174. * @returns a file request object
  5175. */
  5176. 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;
  5177. /**
  5178. * Checks if the loaded document was accessed via `file:`-Protocol.
  5179. * @returns boolean
  5180. */
  5181. static IsFileURL(): boolean;
  5182. }
  5183. }
  5184. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5186. /** @hidden */
  5187. export class ShaderProcessor {
  5188. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5189. private static _ProcessPrecision;
  5190. private static _ExtractOperation;
  5191. private static _BuildSubExpression;
  5192. private static _BuildExpression;
  5193. private static _MoveCursorWithinIf;
  5194. private static _MoveCursor;
  5195. private static _EvaluatePreProcessors;
  5196. private static _PreparePreProcessors;
  5197. private static _ProcessShaderConversion;
  5198. private static _ProcessIncludes;
  5199. }
  5200. }
  5201. declare module "babylonjs/Materials/iEffectFallbacks" {
  5202. import { Effect } from "babylonjs/Materials/effect";
  5203. /**
  5204. * Interface used to define common properties for effect fallbacks
  5205. */
  5206. export interface IEffectFallbacks {
  5207. /**
  5208. * Removes the defines that should be removed when falling back.
  5209. * @param currentDefines defines the current define statements for the shader.
  5210. * @param effect defines the current effect we try to compile
  5211. * @returns The resulting defines with defines of the current rank removed.
  5212. */
  5213. reduce(currentDefines: string, effect: Effect): string;
  5214. /**
  5215. * Removes the fallback from the bound mesh.
  5216. */
  5217. unBindMesh(): void;
  5218. /**
  5219. * Checks to see if more fallbacks are still availible.
  5220. */
  5221. hasMoreFallbacks: boolean;
  5222. }
  5223. }
  5224. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5225. /**
  5226. * Class used to evalaute queries containing `and` and `or` operators
  5227. */
  5228. export class AndOrNotEvaluator {
  5229. /**
  5230. * Evaluate a query
  5231. * @param query defines the query to evaluate
  5232. * @param evaluateCallback defines the callback used to filter result
  5233. * @returns true if the query matches
  5234. */
  5235. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5236. private static _HandleParenthesisContent;
  5237. private static _SimplifyNegation;
  5238. }
  5239. }
  5240. declare module "babylonjs/Misc/tags" {
  5241. /**
  5242. * Class used to store custom tags
  5243. */
  5244. export class Tags {
  5245. /**
  5246. * Adds support for tags on the given object
  5247. * @param obj defines the object to use
  5248. */
  5249. static EnableFor(obj: any): void;
  5250. /**
  5251. * Removes tags support
  5252. * @param obj defines the object to use
  5253. */
  5254. static DisableFor(obj: any): void;
  5255. /**
  5256. * Gets a boolean indicating if the given object has tags
  5257. * @param obj defines the object to use
  5258. * @returns a boolean
  5259. */
  5260. static HasTags(obj: any): boolean;
  5261. /**
  5262. * Gets the tags available on a given object
  5263. * @param obj defines the object to use
  5264. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5265. * @returns the tags
  5266. */
  5267. static GetTags(obj: any, asString?: boolean): any;
  5268. /**
  5269. * Adds tags to an object
  5270. * @param obj defines the object to use
  5271. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5272. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5273. */
  5274. static AddTagsTo(obj: any, tagsString: string): void;
  5275. /**
  5276. * @hidden
  5277. */
  5278. static _AddTagTo(obj: any, tag: string): void;
  5279. /**
  5280. * Removes specific tags from a specific object
  5281. * @param obj defines the object to use
  5282. * @param tagsString defines the tags to remove
  5283. */
  5284. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5285. /**
  5286. * @hidden
  5287. */
  5288. static _RemoveTagFrom(obj: any, tag: string): void;
  5289. /**
  5290. * Defines if tags hosted on an object match a given query
  5291. * @param obj defines the object to use
  5292. * @param tagsQuery defines the tag query
  5293. * @returns a boolean
  5294. */
  5295. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5296. }
  5297. }
  5298. declare module "babylonjs/Maths/math.path" {
  5299. import { DeepImmutable, Nullable } from "babylonjs/types";
  5300. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5301. /**
  5302. * Defines potential orientation for back face culling
  5303. */
  5304. export enum Orientation {
  5305. /**
  5306. * Clockwise
  5307. */
  5308. CW = 0,
  5309. /** Counter clockwise */
  5310. CCW = 1
  5311. }
  5312. /** Class used to represent a Bezier curve */
  5313. export class BezierCurve {
  5314. /**
  5315. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5316. * @param t defines the time
  5317. * @param x1 defines the left coordinate on X axis
  5318. * @param y1 defines the left coordinate on Y axis
  5319. * @param x2 defines the right coordinate on X axis
  5320. * @param y2 defines the right coordinate on Y axis
  5321. * @returns the interpolated value
  5322. */
  5323. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5324. }
  5325. /**
  5326. * Defines angle representation
  5327. */
  5328. export class Angle {
  5329. private _radians;
  5330. /**
  5331. * Creates an Angle object of "radians" radians (float).
  5332. * @param radians the angle in radians
  5333. */
  5334. constructor(radians: number);
  5335. /**
  5336. * Get value in degrees
  5337. * @returns the Angle value in degrees (float)
  5338. */
  5339. degrees(): number;
  5340. /**
  5341. * Get value in radians
  5342. * @returns the Angle value in radians (float)
  5343. */
  5344. radians(): number;
  5345. /**
  5346. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5347. * @param a defines first vector
  5348. * @param b defines second vector
  5349. * @returns a new Angle
  5350. */
  5351. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5352. /**
  5353. * Gets a new Angle object from the given float in radians
  5354. * @param radians defines the angle value in radians
  5355. * @returns a new Angle
  5356. */
  5357. static FromRadians(radians: number): Angle;
  5358. /**
  5359. * Gets a new Angle object from the given float in degrees
  5360. * @param degrees defines the angle value in degrees
  5361. * @returns a new Angle
  5362. */
  5363. static FromDegrees(degrees: number): Angle;
  5364. }
  5365. /**
  5366. * This represents an arc in a 2d space.
  5367. */
  5368. export class Arc2 {
  5369. /** Defines the start point of the arc */
  5370. startPoint: Vector2;
  5371. /** Defines the mid point of the arc */
  5372. midPoint: Vector2;
  5373. /** Defines the end point of the arc */
  5374. endPoint: Vector2;
  5375. /**
  5376. * Defines the center point of the arc.
  5377. */
  5378. centerPoint: Vector2;
  5379. /**
  5380. * Defines the radius of the arc.
  5381. */
  5382. radius: number;
  5383. /**
  5384. * Defines the angle of the arc (from mid point to end point).
  5385. */
  5386. angle: Angle;
  5387. /**
  5388. * Defines the start angle of the arc (from start point to middle point).
  5389. */
  5390. startAngle: Angle;
  5391. /**
  5392. * Defines the orientation of the arc (clock wise/counter clock wise).
  5393. */
  5394. orientation: Orientation;
  5395. /**
  5396. * Creates an Arc object from the three given points : start, middle and end.
  5397. * @param startPoint Defines the start point of the arc
  5398. * @param midPoint Defines the midlle point of the arc
  5399. * @param endPoint Defines the end point of the arc
  5400. */
  5401. constructor(
  5402. /** Defines the start point of the arc */
  5403. startPoint: Vector2,
  5404. /** Defines the mid point of the arc */
  5405. midPoint: Vector2,
  5406. /** Defines the end point of the arc */
  5407. endPoint: Vector2);
  5408. }
  5409. /**
  5410. * Represents a 2D path made up of multiple 2D points
  5411. */
  5412. export class Path2 {
  5413. private _points;
  5414. private _length;
  5415. /**
  5416. * If the path start and end point are the same
  5417. */
  5418. closed: boolean;
  5419. /**
  5420. * Creates a Path2 object from the starting 2D coordinates x and y.
  5421. * @param x the starting points x value
  5422. * @param y the starting points y value
  5423. */
  5424. constructor(x: number, y: number);
  5425. /**
  5426. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5427. * @param x the added points x value
  5428. * @param y the added points y value
  5429. * @returns the updated Path2.
  5430. */
  5431. addLineTo(x: number, y: number): Path2;
  5432. /**
  5433. * 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.
  5434. * @param midX middle point x value
  5435. * @param midY middle point y value
  5436. * @param endX end point x value
  5437. * @param endY end point y value
  5438. * @param numberOfSegments (default: 36)
  5439. * @returns the updated Path2.
  5440. */
  5441. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5442. /**
  5443. * Closes the Path2.
  5444. * @returns the Path2.
  5445. */
  5446. close(): Path2;
  5447. /**
  5448. * Gets the sum of the distance between each sequential point in the path
  5449. * @returns the Path2 total length (float).
  5450. */
  5451. length(): number;
  5452. /**
  5453. * Gets the points which construct the path
  5454. * @returns the Path2 internal array of points.
  5455. */
  5456. getPoints(): Vector2[];
  5457. /**
  5458. * Retreives the point at the distance aways from the starting point
  5459. * @param normalizedLengthPosition the length along the path to retreive the point from
  5460. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5461. */
  5462. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5463. /**
  5464. * Creates a new path starting from an x and y position
  5465. * @param x starting x value
  5466. * @param y starting y value
  5467. * @returns a new Path2 starting at the coordinates (x, y).
  5468. */
  5469. static StartingAt(x: number, y: number): Path2;
  5470. }
  5471. /**
  5472. * Represents a 3D path made up of multiple 3D points
  5473. */
  5474. export class Path3D {
  5475. /**
  5476. * an array of Vector3, the curve axis of the Path3D
  5477. */
  5478. path: Vector3[];
  5479. private _curve;
  5480. private _distances;
  5481. private _tangents;
  5482. private _normals;
  5483. private _binormals;
  5484. private _raw;
  5485. /**
  5486. * new Path3D(path, normal, raw)
  5487. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5488. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5489. * @param path an array of Vector3, the curve axis of the Path3D
  5490. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5491. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5492. */
  5493. constructor(
  5494. /**
  5495. * an array of Vector3, the curve axis of the Path3D
  5496. */
  5497. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5498. /**
  5499. * Returns the Path3D array of successive Vector3 designing its curve.
  5500. * @returns the Path3D array of successive Vector3 designing its curve.
  5501. */
  5502. getCurve(): Vector3[];
  5503. /**
  5504. * Returns an array populated with tangent vectors on each Path3D curve point.
  5505. * @returns an array populated with tangent vectors on each Path3D curve point.
  5506. */
  5507. getTangents(): Vector3[];
  5508. /**
  5509. * Returns an array populated with normal vectors on each Path3D curve point.
  5510. * @returns an array populated with normal vectors on each Path3D curve point.
  5511. */
  5512. getNormals(): Vector3[];
  5513. /**
  5514. * Returns an array populated with binormal vectors on each Path3D curve point.
  5515. * @returns an array populated with binormal vectors on each Path3D curve point.
  5516. */
  5517. getBinormals(): Vector3[];
  5518. /**
  5519. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5520. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5521. */
  5522. getDistances(): number[];
  5523. /**
  5524. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5525. * @param path path which all values are copied into the curves points
  5526. * @param firstNormal which should be projected onto the curve
  5527. * @returns the same object updated.
  5528. */
  5529. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5530. private _compute;
  5531. private _getFirstNonNullVector;
  5532. private _getLastNonNullVector;
  5533. private _normalVector;
  5534. }
  5535. /**
  5536. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5537. * A Curve3 is designed from a series of successive Vector3.
  5538. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5539. */
  5540. export class Curve3 {
  5541. private _points;
  5542. private _length;
  5543. /**
  5544. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5545. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5546. * @param v1 (Vector3) the control point
  5547. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5548. * @param nbPoints (integer) the wanted number of points in the curve
  5549. * @returns the created Curve3
  5550. */
  5551. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5552. /**
  5553. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5554. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5555. * @param v1 (Vector3) the first control point
  5556. * @param v2 (Vector3) the second control point
  5557. * @param v3 (Vector3) the end point of the Cubic Bezier
  5558. * @param nbPoints (integer) the wanted number of points in the curve
  5559. * @returns the created Curve3
  5560. */
  5561. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5562. /**
  5563. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5564. * @param p1 (Vector3) the origin point of the Hermite Spline
  5565. * @param t1 (Vector3) the tangent vector at the origin point
  5566. * @param p2 (Vector3) the end point of the Hermite Spline
  5567. * @param t2 (Vector3) the tangent vector at the end point
  5568. * @param nbPoints (integer) the wanted number of points in the curve
  5569. * @returns the created Curve3
  5570. */
  5571. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5572. /**
  5573. * Returns a Curve3 object along a CatmullRom Spline curve :
  5574. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5575. * @param nbPoints (integer) the wanted number of points between each curve control points
  5576. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5577. * @returns the created Curve3
  5578. */
  5579. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5580. /**
  5581. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5582. * A Curve3 is designed from a series of successive Vector3.
  5583. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5584. * @param points points which make up the curve
  5585. */
  5586. constructor(points: Vector3[]);
  5587. /**
  5588. * @returns the Curve3 stored array of successive Vector3
  5589. */
  5590. getPoints(): Vector3[];
  5591. /**
  5592. * @returns the computed length (float) of the curve.
  5593. */
  5594. length(): number;
  5595. /**
  5596. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5597. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5598. * curveA and curveB keep unchanged.
  5599. * @param curve the curve to continue from this curve
  5600. * @returns the newly constructed curve
  5601. */
  5602. continue(curve: DeepImmutable<Curve3>): Curve3;
  5603. private _computeLength;
  5604. }
  5605. }
  5606. declare module "babylonjs/Animations/easing" {
  5607. /**
  5608. * This represents the main contract an easing function should follow.
  5609. * Easing functions are used throughout the animation system.
  5610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5611. */
  5612. export interface IEasingFunction {
  5613. /**
  5614. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5615. * of the easing function.
  5616. * The link below provides some of the most common examples of easing functions.
  5617. * @see https://easings.net/
  5618. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5619. * @returns the corresponding value on the curve defined by the easing function
  5620. */
  5621. ease(gradient: number): number;
  5622. }
  5623. /**
  5624. * Base class used for every default easing function.
  5625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5626. */
  5627. export class EasingFunction implements IEasingFunction {
  5628. /**
  5629. * Interpolation follows the mathematical formula associated with the easing function.
  5630. */
  5631. static readonly EASINGMODE_EASEIN: number;
  5632. /**
  5633. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5634. */
  5635. static readonly EASINGMODE_EASEOUT: number;
  5636. /**
  5637. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5638. */
  5639. static readonly EASINGMODE_EASEINOUT: number;
  5640. private _easingMode;
  5641. /**
  5642. * Sets the easing mode of the current function.
  5643. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5644. */
  5645. setEasingMode(easingMode: number): void;
  5646. /**
  5647. * Gets the current easing mode.
  5648. * @returns the easing mode
  5649. */
  5650. getEasingMode(): number;
  5651. /**
  5652. * @hidden
  5653. */
  5654. easeInCore(gradient: number): number;
  5655. /**
  5656. * Given an input gradient between 0 and 1, this returns the corresponding value
  5657. * of the easing function.
  5658. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5659. * @returns the corresponding value on the curve defined by the easing function
  5660. */
  5661. ease(gradient: number): number;
  5662. }
  5663. /**
  5664. * Easing function with a circle shape (see link below).
  5665. * @see https://easings.net/#easeInCirc
  5666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5667. */
  5668. export class CircleEase extends EasingFunction implements IEasingFunction {
  5669. /** @hidden */
  5670. easeInCore(gradient: number): number;
  5671. }
  5672. /**
  5673. * Easing function with a ease back shape (see link below).
  5674. * @see https://easings.net/#easeInBack
  5675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5676. */
  5677. export class BackEase extends EasingFunction implements IEasingFunction {
  5678. /** Defines the amplitude of the function */
  5679. amplitude: number;
  5680. /**
  5681. * Instantiates a back ease easing
  5682. * @see https://easings.net/#easeInBack
  5683. * @param amplitude Defines the amplitude of the function
  5684. */
  5685. constructor(
  5686. /** Defines the amplitude of the function */
  5687. amplitude?: number);
  5688. /** @hidden */
  5689. easeInCore(gradient: number): number;
  5690. }
  5691. /**
  5692. * Easing function with a bouncing shape (see link below).
  5693. * @see https://easings.net/#easeInBounce
  5694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5695. */
  5696. export class BounceEase extends EasingFunction implements IEasingFunction {
  5697. /** Defines the number of bounces */
  5698. bounces: number;
  5699. /** Defines the amplitude of the bounce */
  5700. bounciness: number;
  5701. /**
  5702. * Instantiates a bounce easing
  5703. * @see https://easings.net/#easeInBounce
  5704. * @param bounces Defines the number of bounces
  5705. * @param bounciness Defines the amplitude of the bounce
  5706. */
  5707. constructor(
  5708. /** Defines the number of bounces */
  5709. bounces?: number,
  5710. /** Defines the amplitude of the bounce */
  5711. bounciness?: number);
  5712. /** @hidden */
  5713. easeInCore(gradient: number): number;
  5714. }
  5715. /**
  5716. * Easing function with a power of 3 shape (see link below).
  5717. * @see https://easings.net/#easeInCubic
  5718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5719. */
  5720. export class CubicEase extends EasingFunction implements IEasingFunction {
  5721. /** @hidden */
  5722. easeInCore(gradient: number): number;
  5723. }
  5724. /**
  5725. * Easing function with an elastic shape (see link below).
  5726. * @see https://easings.net/#easeInElastic
  5727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5728. */
  5729. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5730. /** Defines the number of oscillations*/
  5731. oscillations: number;
  5732. /** Defines the amplitude of the oscillations*/
  5733. springiness: number;
  5734. /**
  5735. * Instantiates an elastic easing function
  5736. * @see https://easings.net/#easeInElastic
  5737. * @param oscillations Defines the number of oscillations
  5738. * @param springiness Defines the amplitude of the oscillations
  5739. */
  5740. constructor(
  5741. /** Defines the number of oscillations*/
  5742. oscillations?: number,
  5743. /** Defines the amplitude of the oscillations*/
  5744. springiness?: number);
  5745. /** @hidden */
  5746. easeInCore(gradient: number): number;
  5747. }
  5748. /**
  5749. * Easing function with an exponential shape (see link below).
  5750. * @see https://easings.net/#easeInExpo
  5751. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5752. */
  5753. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5754. /** Defines the exponent of the function */
  5755. exponent: number;
  5756. /**
  5757. * Instantiates an exponential easing function
  5758. * @see https://easings.net/#easeInExpo
  5759. * @param exponent Defines the exponent of the function
  5760. */
  5761. constructor(
  5762. /** Defines the exponent of the function */
  5763. exponent?: number);
  5764. /** @hidden */
  5765. easeInCore(gradient: number): number;
  5766. }
  5767. /**
  5768. * Easing function with a power shape (see link below).
  5769. * @see https://easings.net/#easeInQuad
  5770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5771. */
  5772. export class PowerEase extends EasingFunction implements IEasingFunction {
  5773. /** Defines the power of the function */
  5774. power: number;
  5775. /**
  5776. * Instantiates an power base easing function
  5777. * @see https://easings.net/#easeInQuad
  5778. * @param power Defines the power of the function
  5779. */
  5780. constructor(
  5781. /** Defines the power of the function */
  5782. power?: number);
  5783. /** @hidden */
  5784. easeInCore(gradient: number): number;
  5785. }
  5786. /**
  5787. * Easing function with a power of 2 shape (see link below).
  5788. * @see https://easings.net/#easeInQuad
  5789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5790. */
  5791. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5792. /** @hidden */
  5793. easeInCore(gradient: number): number;
  5794. }
  5795. /**
  5796. * Easing function with a power of 4 shape (see link below).
  5797. * @see https://easings.net/#easeInQuart
  5798. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5799. */
  5800. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5801. /** @hidden */
  5802. easeInCore(gradient: number): number;
  5803. }
  5804. /**
  5805. * Easing function with a power of 5 shape (see link below).
  5806. * @see https://easings.net/#easeInQuint
  5807. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5808. */
  5809. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5810. /** @hidden */
  5811. easeInCore(gradient: number): number;
  5812. }
  5813. /**
  5814. * Easing function with a sin shape (see link below).
  5815. * @see https://easings.net/#easeInSine
  5816. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5817. */
  5818. export class SineEase extends EasingFunction implements IEasingFunction {
  5819. /** @hidden */
  5820. easeInCore(gradient: number): number;
  5821. }
  5822. /**
  5823. * Easing function with a bezier shape (see link below).
  5824. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5825. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5826. */
  5827. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5828. /** Defines the x component of the start tangent in the bezier curve */
  5829. x1: number;
  5830. /** Defines the y component of the start tangent in the bezier curve */
  5831. y1: number;
  5832. /** Defines the x component of the end tangent in the bezier curve */
  5833. x2: number;
  5834. /** Defines the y component of the end tangent in the bezier curve */
  5835. y2: number;
  5836. /**
  5837. * Instantiates a bezier function
  5838. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5839. * @param x1 Defines the x component of the start tangent in the bezier curve
  5840. * @param y1 Defines the y component of the start tangent in the bezier curve
  5841. * @param x2 Defines the x component of the end tangent in the bezier curve
  5842. * @param y2 Defines the y component of the end tangent in the bezier curve
  5843. */
  5844. constructor(
  5845. /** Defines the x component of the start tangent in the bezier curve */
  5846. x1?: number,
  5847. /** Defines the y component of the start tangent in the bezier curve */
  5848. y1?: number,
  5849. /** Defines the x component of the end tangent in the bezier curve */
  5850. x2?: number,
  5851. /** Defines the y component of the end tangent in the bezier curve */
  5852. y2?: number);
  5853. /** @hidden */
  5854. easeInCore(gradient: number): number;
  5855. }
  5856. }
  5857. declare module "babylonjs/Animations/animationKey" {
  5858. /**
  5859. * Defines an interface which represents an animation key frame
  5860. */
  5861. export interface IAnimationKey {
  5862. /**
  5863. * Frame of the key frame
  5864. */
  5865. frame: number;
  5866. /**
  5867. * Value at the specifies key frame
  5868. */
  5869. value: any;
  5870. /**
  5871. * The input tangent for the cubic hermite spline
  5872. */
  5873. inTangent?: any;
  5874. /**
  5875. * The output tangent for the cubic hermite spline
  5876. */
  5877. outTangent?: any;
  5878. /**
  5879. * The animation interpolation type
  5880. */
  5881. interpolation?: AnimationKeyInterpolation;
  5882. }
  5883. /**
  5884. * Enum for the animation key frame interpolation type
  5885. */
  5886. export enum AnimationKeyInterpolation {
  5887. /**
  5888. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5889. */
  5890. STEP = 1
  5891. }
  5892. }
  5893. declare module "babylonjs/Animations/animationRange" {
  5894. /**
  5895. * Represents the range of an animation
  5896. */
  5897. export class AnimationRange {
  5898. /**The name of the animation range**/
  5899. name: string;
  5900. /**The starting frame of the animation */
  5901. from: number;
  5902. /**The ending frame of the animation*/
  5903. to: number;
  5904. /**
  5905. * Initializes the range of an animation
  5906. * @param name The name of the animation range
  5907. * @param from The starting frame of the animation
  5908. * @param to The ending frame of the animation
  5909. */
  5910. constructor(
  5911. /**The name of the animation range**/
  5912. name: string,
  5913. /**The starting frame of the animation */
  5914. from: number,
  5915. /**The ending frame of the animation*/
  5916. to: number);
  5917. /**
  5918. * Makes a copy of the animation range
  5919. * @returns A copy of the animation range
  5920. */
  5921. clone(): AnimationRange;
  5922. }
  5923. }
  5924. declare module "babylonjs/Animations/animationEvent" {
  5925. /**
  5926. * Composed of a frame, and an action function
  5927. */
  5928. export class AnimationEvent {
  5929. /** The frame for which the event is triggered **/
  5930. frame: number;
  5931. /** The event to perform when triggered **/
  5932. action: (currentFrame: number) => void;
  5933. /** Specifies if the event should be triggered only once**/
  5934. onlyOnce?: boolean | undefined;
  5935. /**
  5936. * Specifies if the animation event is done
  5937. */
  5938. isDone: boolean;
  5939. /**
  5940. * Initializes the animation event
  5941. * @param frame The frame for which the event is triggered
  5942. * @param action The event to perform when triggered
  5943. * @param onlyOnce Specifies if the event should be triggered only once
  5944. */
  5945. constructor(
  5946. /** The frame for which the event is triggered **/
  5947. frame: number,
  5948. /** The event to perform when triggered **/
  5949. action: (currentFrame: number) => void,
  5950. /** Specifies if the event should be triggered only once**/
  5951. onlyOnce?: boolean | undefined);
  5952. /** @hidden */
  5953. _clone(): AnimationEvent;
  5954. }
  5955. }
  5956. declare module "babylonjs/Behaviors/behavior" {
  5957. import { Nullable } from "babylonjs/types";
  5958. /**
  5959. * Interface used to define a behavior
  5960. */
  5961. export interface Behavior<T> {
  5962. /** gets or sets behavior's name */
  5963. name: string;
  5964. /**
  5965. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5966. */
  5967. init(): void;
  5968. /**
  5969. * Called when the behavior is attached to a target
  5970. * @param target defines the target where the behavior is attached to
  5971. */
  5972. attach(target: T): void;
  5973. /**
  5974. * Called when the behavior is detached from its target
  5975. */
  5976. detach(): void;
  5977. }
  5978. /**
  5979. * Interface implemented by classes supporting behaviors
  5980. */
  5981. export interface IBehaviorAware<T> {
  5982. /**
  5983. * Attach a behavior
  5984. * @param behavior defines the behavior to attach
  5985. * @returns the current host
  5986. */
  5987. addBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Remove a behavior from the current object
  5990. * @param behavior defines the behavior to detach
  5991. * @returns the current host
  5992. */
  5993. removeBehavior(behavior: Behavior<T>): T;
  5994. /**
  5995. * Gets a behavior using its name to search
  5996. * @param name defines the name to search
  5997. * @returns the behavior or null if not found
  5998. */
  5999. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6000. }
  6001. }
  6002. declare module "babylonjs/Misc/smartArray" {
  6003. /**
  6004. * Defines an array and its length.
  6005. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6006. */
  6007. export interface ISmartArrayLike<T> {
  6008. /**
  6009. * The data of the array.
  6010. */
  6011. data: Array<T>;
  6012. /**
  6013. * The active length of the array.
  6014. */
  6015. length: number;
  6016. }
  6017. /**
  6018. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6019. */
  6020. export class SmartArray<T> implements ISmartArrayLike<T> {
  6021. /**
  6022. * The full set of data from the array.
  6023. */
  6024. data: Array<T>;
  6025. /**
  6026. * The active length of the array.
  6027. */
  6028. length: number;
  6029. protected _id: number;
  6030. /**
  6031. * Instantiates a Smart Array.
  6032. * @param capacity defines the default capacity of the array.
  6033. */
  6034. constructor(capacity: number);
  6035. /**
  6036. * Pushes a value at the end of the active data.
  6037. * @param value defines the object to push in the array.
  6038. */
  6039. push(value: T): void;
  6040. /**
  6041. * Iterates over the active data and apply the lambda to them.
  6042. * @param func defines the action to apply on each value.
  6043. */
  6044. forEach(func: (content: T) => void): void;
  6045. /**
  6046. * Sorts the full sets of data.
  6047. * @param compareFn defines the comparison function to apply.
  6048. */
  6049. sort(compareFn: (a: T, b: T) => number): void;
  6050. /**
  6051. * Resets the active data to an empty array.
  6052. */
  6053. reset(): void;
  6054. /**
  6055. * Releases all the data from the array as well as the array.
  6056. */
  6057. dispose(): void;
  6058. /**
  6059. * Concats the active data with a given array.
  6060. * @param array defines the data to concatenate with.
  6061. */
  6062. concat(array: any): void;
  6063. /**
  6064. * Returns the position of a value in the active data.
  6065. * @param value defines the value to find the index for
  6066. * @returns the index if found in the active data otherwise -1
  6067. */
  6068. indexOf(value: T): number;
  6069. /**
  6070. * Returns whether an element is part of the active data.
  6071. * @param value defines the value to look for
  6072. * @returns true if found in the active data otherwise false
  6073. */
  6074. contains(value: T): boolean;
  6075. private static _GlobalId;
  6076. }
  6077. /**
  6078. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6079. * The data in this array can only be present once
  6080. */
  6081. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6082. private _duplicateId;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6086. * @param value defines the object to push in the array.
  6087. */
  6088. push(value: T): void;
  6089. /**
  6090. * Pushes a value at the end of the active data.
  6091. * If the data is already present, it won t be added again
  6092. * @param value defines the object to push in the array.
  6093. * @returns true if added false if it was already present
  6094. */
  6095. pushNoDuplicate(value: T): boolean;
  6096. /**
  6097. * Resets the active data to an empty array.
  6098. */
  6099. reset(): void;
  6100. /**
  6101. * Concats the active data with a given array.
  6102. * This ensures no dupplicate will be present in the result.
  6103. * @param array defines the data to concatenate with.
  6104. */
  6105. concatWithNoDuplicate(array: any): void;
  6106. }
  6107. }
  6108. declare module "babylonjs/Cameras/cameraInputsManager" {
  6109. import { Nullable } from "babylonjs/types";
  6110. import { Camera } from "babylonjs/Cameras/camera";
  6111. /**
  6112. * @ignore
  6113. * This is a list of all the different input types that are available in the application.
  6114. * Fo instance: ArcRotateCameraGamepadInput...
  6115. */
  6116. export var CameraInputTypes: {};
  6117. /**
  6118. * This is the contract to implement in order to create a new input class.
  6119. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6120. */
  6121. export interface ICameraInput<TCamera extends Camera> {
  6122. /**
  6123. * Defines the camera the input is attached to.
  6124. */
  6125. camera: Nullable<TCamera>;
  6126. /**
  6127. * Gets the class name of the current intput.
  6128. * @returns the class name
  6129. */
  6130. getClassName(): string;
  6131. /**
  6132. * Get the friendly name associated with the input class.
  6133. * @returns the input friendly name
  6134. */
  6135. getSimpleName(): string;
  6136. /**
  6137. * Attach the input controls to a specific dom element to get the input from.
  6138. * @param element Defines the element the controls should be listened from
  6139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6140. */
  6141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6142. /**
  6143. * Detach the current controls from the specified dom element.
  6144. * @param element Defines the element to stop listening the inputs from
  6145. */
  6146. detachControl(element: Nullable<HTMLElement>): void;
  6147. /**
  6148. * Update the current camera state depending on the inputs that have been used this frame.
  6149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6150. */
  6151. checkInputs?: () => void;
  6152. }
  6153. /**
  6154. * Represents a map of input types to input instance or input index to input instance.
  6155. */
  6156. export interface CameraInputsMap<TCamera extends Camera> {
  6157. /**
  6158. * Accessor to the input by input type.
  6159. */
  6160. [name: string]: ICameraInput<TCamera>;
  6161. /**
  6162. * Accessor to the input by input index.
  6163. */
  6164. [idx: number]: ICameraInput<TCamera>;
  6165. }
  6166. /**
  6167. * This represents the input manager used within a camera.
  6168. * It helps dealing with all the different kind of input attached to a camera.
  6169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6170. */
  6171. export class CameraInputsManager<TCamera extends Camera> {
  6172. /**
  6173. * Defines the list of inputs attahed to the camera.
  6174. */
  6175. attached: CameraInputsMap<TCamera>;
  6176. /**
  6177. * Defines the dom element the camera is collecting inputs from.
  6178. * This is null if the controls have not been attached.
  6179. */
  6180. attachedElement: Nullable<HTMLElement>;
  6181. /**
  6182. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6183. */
  6184. noPreventDefault: boolean;
  6185. /**
  6186. * Defined the camera the input manager belongs to.
  6187. */
  6188. camera: TCamera;
  6189. /**
  6190. * Update the current camera state depending on the inputs that have been used this frame.
  6191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6192. */
  6193. checkInputs: () => void;
  6194. /**
  6195. * Instantiate a new Camera Input Manager.
  6196. * @param camera Defines the camera the input manager blongs to
  6197. */
  6198. constructor(camera: TCamera);
  6199. /**
  6200. * Add an input method to a camera
  6201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6202. * @param input camera input method
  6203. */
  6204. add(input: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input method from a camera
  6207. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6208. * @param inputToRemove camera input method
  6209. */
  6210. remove(inputToRemove: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input type from a camera
  6213. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6214. * @param inputType the type of the input to remove
  6215. */
  6216. removeByType(inputType: string): void;
  6217. private _addCheckInputs;
  6218. /**
  6219. * Attach the input controls to the currently attached dom element to listen the events from.
  6220. * @param input Defines the input to attach
  6221. */
  6222. attachInput(input: ICameraInput<TCamera>): void;
  6223. /**
  6224. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6227. */
  6228. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6229. /**
  6230. * Detach the current manager inputs controls from a specific dom element.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6233. */
  6234. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6235. /**
  6236. * Rebuild the dynamic inputCheck function from the current list of
  6237. * defined inputs in the manager.
  6238. */
  6239. rebuildInputCheck(): void;
  6240. /**
  6241. * Remove all attached input methods from a camera
  6242. */
  6243. clear(): void;
  6244. /**
  6245. * Serialize the current input manager attached to a camera.
  6246. * This ensures than once parsed,
  6247. * the input associated to the camera will be identical to the current ones
  6248. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6249. */
  6250. serialize(serializedCamera: any): void;
  6251. /**
  6252. * Parses an input manager serialized JSON to restore the previous list of inputs
  6253. * and states associated to a camera.
  6254. * @param parsedCamera Defines the JSON to parse
  6255. */
  6256. parse(parsedCamera: any): void;
  6257. }
  6258. }
  6259. declare module "babylonjs/Meshes/buffer" {
  6260. import { Nullable, DataArray } from "babylonjs/types";
  6261. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6262. /**
  6263. * Class used to store data that will be store in GPU memory
  6264. */
  6265. export class Buffer {
  6266. private _engine;
  6267. private _buffer;
  6268. /** @hidden */
  6269. _data: Nullable<DataArray>;
  6270. private _updatable;
  6271. private _instanced;
  6272. /**
  6273. * Gets the byte stride.
  6274. */
  6275. readonly byteStride: number;
  6276. /**
  6277. * Constructor
  6278. * @param engine the engine
  6279. * @param data the data to use for this buffer
  6280. * @param updatable whether the data is updatable
  6281. * @param stride the stride (optional)
  6282. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6283. * @param instanced whether the buffer is instanced (optional)
  6284. * @param useBytes set to true if the stride in in bytes (optional)
  6285. */
  6286. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6287. /**
  6288. * Create a new VertexBuffer based on the current buffer
  6289. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6290. * @param offset defines offset in the buffer (0 by default)
  6291. * @param size defines the size in floats of attributes (position is 3 for instance)
  6292. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6293. * @param instanced defines if the vertex buffer contains indexed data
  6294. * @param useBytes defines if the offset and stride are in bytes
  6295. * @returns the new vertex buffer
  6296. */
  6297. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6298. /**
  6299. * Gets a boolean indicating if the Buffer is updatable?
  6300. * @returns true if the buffer is updatable
  6301. */
  6302. isUpdatable(): boolean;
  6303. /**
  6304. * Gets current buffer's data
  6305. * @returns a DataArray or null
  6306. */
  6307. getData(): Nullable<DataArray>;
  6308. /**
  6309. * Gets underlying native buffer
  6310. * @returns underlying native buffer
  6311. */
  6312. getBuffer(): Nullable<DataBuffer>;
  6313. /**
  6314. * Gets the stride in float32 units (i.e. byte stride / 4).
  6315. * May not be an integer if the byte stride is not divisible by 4.
  6316. * DEPRECATED. Use byteStride instead.
  6317. * @returns the stride in float32 units
  6318. */
  6319. getStrideSize(): number;
  6320. /**
  6321. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6322. * @param data defines the data to store
  6323. */
  6324. create(data?: Nullable<DataArray>): void;
  6325. /** @hidden */
  6326. _rebuild(): void;
  6327. /**
  6328. * Update current buffer data
  6329. * @param data defines the data to store
  6330. */
  6331. update(data: DataArray): void;
  6332. /**
  6333. * Updates the data directly.
  6334. * @param data the new data
  6335. * @param offset the new offset
  6336. * @param vertexCount the vertex count (optional)
  6337. * @param useBytes set to true if the offset is in bytes
  6338. */
  6339. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6340. /**
  6341. * Release all resources
  6342. */
  6343. dispose(): void;
  6344. }
  6345. /**
  6346. * Specialized buffer used to store vertex data
  6347. */
  6348. export class VertexBuffer {
  6349. /** @hidden */
  6350. _buffer: Buffer;
  6351. private _kind;
  6352. private _size;
  6353. private _ownsBuffer;
  6354. private _instanced;
  6355. private _instanceDivisor;
  6356. /**
  6357. * The byte type.
  6358. */
  6359. static readonly BYTE: number;
  6360. /**
  6361. * The unsigned byte type.
  6362. */
  6363. static readonly UNSIGNED_BYTE: number;
  6364. /**
  6365. * The short type.
  6366. */
  6367. static readonly SHORT: number;
  6368. /**
  6369. * The unsigned short type.
  6370. */
  6371. static readonly UNSIGNED_SHORT: number;
  6372. /**
  6373. * The integer type.
  6374. */
  6375. static readonly INT: number;
  6376. /**
  6377. * The unsigned integer type.
  6378. */
  6379. static readonly UNSIGNED_INT: number;
  6380. /**
  6381. * The float type.
  6382. */
  6383. static readonly FLOAT: number;
  6384. /**
  6385. * Gets or sets the instance divisor when in instanced mode
  6386. */
  6387. instanceDivisor: number;
  6388. /**
  6389. * Gets the byte stride.
  6390. */
  6391. readonly byteStride: number;
  6392. /**
  6393. * Gets the byte offset.
  6394. */
  6395. readonly byteOffset: number;
  6396. /**
  6397. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6398. */
  6399. readonly normalized: boolean;
  6400. /**
  6401. * Gets the data type of each component in the array.
  6402. */
  6403. readonly type: number;
  6404. /**
  6405. * Constructor
  6406. * @param engine the engine
  6407. * @param data the data to use for this vertex buffer
  6408. * @param kind the vertex buffer kind
  6409. * @param updatable whether the data is updatable
  6410. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6411. * @param stride the stride (optional)
  6412. * @param instanced whether the buffer is instanced (optional)
  6413. * @param offset the offset of the data (optional)
  6414. * @param size the number of components (optional)
  6415. * @param type the type of the component (optional)
  6416. * @param normalized whether the data contains normalized data (optional)
  6417. * @param useBytes set to true if stride and offset are in bytes (optional)
  6418. */
  6419. 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);
  6420. /** @hidden */
  6421. _rebuild(): void;
  6422. /**
  6423. * Returns the kind of the VertexBuffer (string)
  6424. * @returns a string
  6425. */
  6426. getKind(): string;
  6427. /**
  6428. * Gets a boolean indicating if the VertexBuffer is updatable?
  6429. * @returns true if the buffer is updatable
  6430. */
  6431. isUpdatable(): boolean;
  6432. /**
  6433. * Gets current buffer's data
  6434. * @returns a DataArray or null
  6435. */
  6436. getData(): Nullable<DataArray>;
  6437. /**
  6438. * Gets underlying native buffer
  6439. * @returns underlying native buffer
  6440. */
  6441. getBuffer(): Nullable<DataBuffer>;
  6442. /**
  6443. * Gets the stride in float32 units (i.e. byte stride / 4).
  6444. * May not be an integer if the byte stride is not divisible by 4.
  6445. * DEPRECATED. Use byteStride instead.
  6446. * @returns the stride in float32 units
  6447. */
  6448. getStrideSize(): number;
  6449. /**
  6450. * Returns the offset as a multiple of the type byte length.
  6451. * DEPRECATED. Use byteOffset instead.
  6452. * @returns the offset in bytes
  6453. */
  6454. getOffset(): number;
  6455. /**
  6456. * Returns the number of components per vertex attribute (integer)
  6457. * @returns the size in float
  6458. */
  6459. getSize(): number;
  6460. /**
  6461. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6462. * @returns true if this buffer is instanced
  6463. */
  6464. getIsInstanced(): boolean;
  6465. /**
  6466. * Returns the instancing divisor, zero for non-instanced (integer).
  6467. * @returns a number
  6468. */
  6469. getInstanceDivisor(): number;
  6470. /**
  6471. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6472. * @param data defines the data to store
  6473. */
  6474. create(data?: DataArray): void;
  6475. /**
  6476. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6477. * This function will create a new buffer if the current one is not updatable
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6483. * Returns the directly updated WebGLBuffer.
  6484. * @param data the new data
  6485. * @param offset the new offset
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6489. /**
  6490. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6491. */
  6492. dispose(): void;
  6493. /**
  6494. * Enumerates each value of this vertex buffer as numbers.
  6495. * @param count the number of values to enumerate
  6496. * @param callback the callback function called for each value
  6497. */
  6498. forEach(count: number, callback: (value: number, index: number) => void): void;
  6499. /**
  6500. * Positions
  6501. */
  6502. static readonly PositionKind: string;
  6503. /**
  6504. * Normals
  6505. */
  6506. static readonly NormalKind: string;
  6507. /**
  6508. * Tangents
  6509. */
  6510. static readonly TangentKind: string;
  6511. /**
  6512. * Texture coordinates
  6513. */
  6514. static readonly UVKind: string;
  6515. /**
  6516. * Texture coordinates 2
  6517. */
  6518. static readonly UV2Kind: string;
  6519. /**
  6520. * Texture coordinates 3
  6521. */
  6522. static readonly UV3Kind: string;
  6523. /**
  6524. * Texture coordinates 4
  6525. */
  6526. static readonly UV4Kind: string;
  6527. /**
  6528. * Texture coordinates 5
  6529. */
  6530. static readonly UV5Kind: string;
  6531. /**
  6532. * Texture coordinates 6
  6533. */
  6534. static readonly UV6Kind: string;
  6535. /**
  6536. * Colors
  6537. */
  6538. static readonly ColorKind: string;
  6539. /**
  6540. * Matrix indices (for bones)
  6541. */
  6542. static readonly MatricesIndicesKind: string;
  6543. /**
  6544. * Matrix weights (for bones)
  6545. */
  6546. static readonly MatricesWeightsKind: string;
  6547. /**
  6548. * Additional matrix indices (for bones)
  6549. */
  6550. static readonly MatricesIndicesExtraKind: string;
  6551. /**
  6552. * Additional matrix weights (for bones)
  6553. */
  6554. static readonly MatricesWeightsExtraKind: string;
  6555. /**
  6556. * Deduces the stride given a kind.
  6557. * @param kind The kind string to deduce
  6558. * @returns The deduced stride
  6559. */
  6560. static DeduceStride(kind: string): number;
  6561. /**
  6562. * Gets the byte length of the given type.
  6563. * @param type the type
  6564. * @returns the number of bytes
  6565. */
  6566. static GetTypeByteLength(type: number): number;
  6567. /**
  6568. * Enumerates each value of the given parameters as numbers.
  6569. * @param data the data to enumerate
  6570. * @param byteOffset the byte offset of the data
  6571. * @param byteStride the byte stride of the data
  6572. * @param componentCount the number of components per element
  6573. * @param componentType the type of the component
  6574. * @param count the number of values to enumerate
  6575. * @param normalized whether the data is normalized
  6576. * @param callback the callback function called for each value
  6577. */
  6578. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6579. private static _GetFloatValue;
  6580. }
  6581. }
  6582. declare module "babylonjs/Collisions/intersectionInfo" {
  6583. import { Nullable } from "babylonjs/types";
  6584. /**
  6585. * @hidden
  6586. */
  6587. export class IntersectionInfo {
  6588. bu: Nullable<number>;
  6589. bv: Nullable<number>;
  6590. distance: number;
  6591. faceId: number;
  6592. subMeshId: number;
  6593. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6594. }
  6595. }
  6596. declare module "babylonjs/Maths/math.plane" {
  6597. import { DeepImmutable } from "babylonjs/types";
  6598. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6599. /**
  6600. * Represens a plane by the equation ax + by + cz + d = 0
  6601. */
  6602. export class Plane {
  6603. private static _TmpMatrix;
  6604. /**
  6605. * Normal of the plane (a,b,c)
  6606. */
  6607. normal: Vector3;
  6608. /**
  6609. * d component of the plane
  6610. */
  6611. d: number;
  6612. /**
  6613. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6614. * @param a a component of the plane
  6615. * @param b b component of the plane
  6616. * @param c c component of the plane
  6617. * @param d d component of the plane
  6618. */
  6619. constructor(a: number, b: number, c: number, d: number);
  6620. /**
  6621. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6622. */
  6623. asArray(): number[];
  6624. /**
  6625. * @returns a new plane copied from the current Plane.
  6626. */
  6627. clone(): Plane;
  6628. /**
  6629. * @returns the string "Plane".
  6630. */
  6631. getClassName(): string;
  6632. /**
  6633. * @returns the Plane hash code.
  6634. */
  6635. getHashCode(): number;
  6636. /**
  6637. * Normalize the current Plane in place.
  6638. * @returns the updated Plane.
  6639. */
  6640. normalize(): Plane;
  6641. /**
  6642. * Applies a transformation the plane and returns the result
  6643. * @param transformation the transformation matrix to be applied to the plane
  6644. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6645. */
  6646. transform(transformation: DeepImmutable<Matrix>): Plane;
  6647. /**
  6648. * Calcualtte the dot product between the point and the plane normal
  6649. * @param point point to calculate the dot product with
  6650. * @returns the dot product (float) of the point coordinates and the plane normal.
  6651. */
  6652. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6653. /**
  6654. * Updates the current Plane from the plane defined by the three given points.
  6655. * @param point1 one of the points used to contruct the plane
  6656. * @param point2 one of the points used to contruct the plane
  6657. * @param point3 one of the points used to contruct the plane
  6658. * @returns the updated Plane.
  6659. */
  6660. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6661. /**
  6662. * Checks if the plane is facing a given direction
  6663. * @param direction the direction to check if the plane is facing
  6664. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6665. * @returns True is the vector "direction" is the same side than the plane normal.
  6666. */
  6667. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6668. /**
  6669. * Calculates the distance to a point
  6670. * @param point point to calculate distance to
  6671. * @returns the signed distance (float) from the given point to the Plane.
  6672. */
  6673. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6674. /**
  6675. * Creates a plane from an array
  6676. * @param array the array to create a plane from
  6677. * @returns a new Plane from the given array.
  6678. */
  6679. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6680. /**
  6681. * Creates a plane from three points
  6682. * @param point1 point used to create the plane
  6683. * @param point2 point used to create the plane
  6684. * @param point3 point used to create the plane
  6685. * @returns a new Plane defined by the three given points.
  6686. */
  6687. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6688. /**
  6689. * Creates a plane from an origin point and a normal
  6690. * @param origin origin of the plane to be constructed
  6691. * @param normal normal of the plane to be constructed
  6692. * @returns a new Plane the normal vector to this plane at the given origin point.
  6693. * Note : the vector "normal" is updated because normalized.
  6694. */
  6695. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6696. /**
  6697. * Calculates the distance from a plane and a point
  6698. * @param origin origin of the plane to be constructed
  6699. * @param normal normal of the plane to be constructed
  6700. * @param point point to calculate distance to
  6701. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6702. */
  6703. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6704. }
  6705. }
  6706. declare module "babylonjs/Culling/boundingSphere" {
  6707. import { DeepImmutable } from "babylonjs/types";
  6708. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6709. import { Plane } from "babylonjs/Maths/math.plane";
  6710. /**
  6711. * Class used to store bounding sphere information
  6712. */
  6713. export class BoundingSphere {
  6714. /**
  6715. * Gets the center of the bounding sphere in local space
  6716. */
  6717. readonly center: Vector3;
  6718. /**
  6719. * Radius of the bounding sphere in local space
  6720. */
  6721. radius: number;
  6722. /**
  6723. * Gets the center of the bounding sphere in world space
  6724. */
  6725. readonly centerWorld: Vector3;
  6726. /**
  6727. * Radius of the bounding sphere in world space
  6728. */
  6729. radiusWorld: number;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * Creates a new bounding sphere
  6742. * @param min defines the minimum vector (in local space)
  6743. * @param max defines the maximum vector (in local space)
  6744. * @param worldMatrix defines the new world matrix
  6745. */
  6746. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6747. /**
  6748. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6749. * @param min defines the new minimum vector (in local space)
  6750. * @param max defines the new maximum vector (in local space)
  6751. * @param worldMatrix defines the new world matrix
  6752. */
  6753. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6754. /**
  6755. * Scale the current bounding sphere by applying a scale factor
  6756. * @param factor defines the scale factor to apply
  6757. * @returns the current bounding box
  6758. */
  6759. scale(factor: number): BoundingSphere;
  6760. /**
  6761. * Gets the world matrix of the bounding box
  6762. * @returns a matrix
  6763. */
  6764. getWorldMatrix(): DeepImmutable<Matrix>;
  6765. /** @hidden */
  6766. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6767. /**
  6768. * Tests if the bounding sphere is intersecting the frustum planes
  6769. * @param frustumPlanes defines the frustum planes to test
  6770. * @returns true if there is an intersection
  6771. */
  6772. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6773. /**
  6774. * Tests if the bounding sphere center is in between the frustum planes.
  6775. * Used for optimistic fast inclusion.
  6776. * @param frustumPlanes defines the frustum planes to test
  6777. * @returns true if the sphere center is in between the frustum planes
  6778. */
  6779. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6780. /**
  6781. * Tests if a point is inside the bounding sphere
  6782. * @param point defines the point to test
  6783. * @returns true if the point is inside the bounding sphere
  6784. */
  6785. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6786. /**
  6787. * Checks if two sphere intersct
  6788. * @param sphere0 sphere 0
  6789. * @param sphere1 sphere 1
  6790. * @returns true if the speres intersect
  6791. */
  6792. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6793. }
  6794. }
  6795. declare module "babylonjs/Culling/boundingBox" {
  6796. import { DeepImmutable } from "babylonjs/types";
  6797. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6798. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6799. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6800. import { Plane } from "babylonjs/Maths/math.plane";
  6801. /**
  6802. * Class used to store bounding box information
  6803. */
  6804. export class BoundingBox implements ICullable {
  6805. /**
  6806. * Gets the 8 vectors representing the bounding box in local space
  6807. */
  6808. readonly vectors: Vector3[];
  6809. /**
  6810. * Gets the center of the bounding box in local space
  6811. */
  6812. readonly center: Vector3;
  6813. /**
  6814. * Gets the center of the bounding box in world space
  6815. */
  6816. readonly centerWorld: Vector3;
  6817. /**
  6818. * Gets the extend size in local space
  6819. */
  6820. readonly extendSize: Vector3;
  6821. /**
  6822. * Gets the extend size in world space
  6823. */
  6824. readonly extendSizeWorld: Vector3;
  6825. /**
  6826. * Gets the OBB (object bounding box) directions
  6827. */
  6828. readonly directions: Vector3[];
  6829. /**
  6830. * Gets the 8 vectors representing the bounding box in world space
  6831. */
  6832. readonly vectorsWorld: Vector3[];
  6833. /**
  6834. * Gets the minimum vector in world space
  6835. */
  6836. readonly minimumWorld: Vector3;
  6837. /**
  6838. * Gets the maximum vector in world space
  6839. */
  6840. readonly maximumWorld: Vector3;
  6841. /**
  6842. * Gets the minimum vector in local space
  6843. */
  6844. readonly minimum: Vector3;
  6845. /**
  6846. * Gets the maximum vector in local space
  6847. */
  6848. readonly maximum: Vector3;
  6849. private _worldMatrix;
  6850. private static readonly TmpVector3;
  6851. /**
  6852. * @hidden
  6853. */
  6854. _tag: number;
  6855. /**
  6856. * Creates a new bounding box
  6857. * @param min defines the minimum vector (in local space)
  6858. * @param max defines the maximum vector (in local space)
  6859. * @param worldMatrix defines the new world matrix
  6860. */
  6861. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6862. /**
  6863. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6864. * @param min defines the new minimum vector (in local space)
  6865. * @param max defines the new maximum vector (in local space)
  6866. * @param worldMatrix defines the new world matrix
  6867. */
  6868. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6869. /**
  6870. * Scale the current bounding box by applying a scale factor
  6871. * @param factor defines the scale factor to apply
  6872. * @returns the current bounding box
  6873. */
  6874. scale(factor: number): BoundingBox;
  6875. /**
  6876. * Gets the world matrix of the bounding box
  6877. * @returns a matrix
  6878. */
  6879. getWorldMatrix(): DeepImmutable<Matrix>;
  6880. /** @hidden */
  6881. _update(world: DeepImmutable<Matrix>): void;
  6882. /**
  6883. * Tests if the bounding box is intersecting the frustum planes
  6884. * @param frustumPlanes defines the frustum planes to test
  6885. * @returns true if there is an intersection
  6886. */
  6887. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6888. /**
  6889. * Tests if the bounding box is entirely inside the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an inclusion
  6892. */
  6893. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if a point is inside the bounding box
  6896. * @param point defines the point to test
  6897. * @returns true if the point is inside the bounding box
  6898. */
  6899. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6900. /**
  6901. * Tests if the bounding box intersects with a bounding sphere
  6902. * @param sphere defines the sphere to test
  6903. * @returns true if there is an intersection
  6904. */
  6905. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6906. /**
  6907. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6908. * @param min defines the min vector to use
  6909. * @param max defines the max vector to use
  6910. * @returns true if there is an intersection
  6911. */
  6912. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6913. /**
  6914. * Tests if two bounding boxes are intersections
  6915. * @param box0 defines the first box to test
  6916. * @param box1 defines the second box to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6920. /**
  6921. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6922. * @param minPoint defines the minimum vector of the bounding box
  6923. * @param maxPoint defines the maximum vector of the bounding box
  6924. * @param sphereCenter defines the sphere center
  6925. * @param sphereRadius defines the sphere radius
  6926. * @returns true if there is an intersection
  6927. */
  6928. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6929. /**
  6930. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6931. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @return true if there is an inclusion
  6934. */
  6935. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6938. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6939. * @param frustumPlanes defines the frustum planes to test
  6940. * @return true if there is an intersection
  6941. */
  6942. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6943. }
  6944. }
  6945. declare module "babylonjs/Collisions/collider" {
  6946. import { Nullable, IndicesArray } from "babylonjs/types";
  6947. import { Vector3 } from "babylonjs/Maths/math.vector";
  6948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6949. import { Plane } from "babylonjs/Maths/math.plane";
  6950. /** @hidden */
  6951. export class Collider {
  6952. /** Define if a collision was found */
  6953. collisionFound: boolean;
  6954. /**
  6955. * Define last intersection point in local space
  6956. */
  6957. intersectionPoint: Vector3;
  6958. /**
  6959. * Define last collided mesh
  6960. */
  6961. collidedMesh: Nullable<AbstractMesh>;
  6962. private _collisionPoint;
  6963. private _planeIntersectionPoint;
  6964. private _tempVector;
  6965. private _tempVector2;
  6966. private _tempVector3;
  6967. private _tempVector4;
  6968. private _edge;
  6969. private _baseToVertex;
  6970. private _destinationPoint;
  6971. private _slidePlaneNormal;
  6972. private _displacementVector;
  6973. /** @hidden */
  6974. _radius: Vector3;
  6975. /** @hidden */
  6976. _retry: number;
  6977. private _velocity;
  6978. private _basePoint;
  6979. private _epsilon;
  6980. /** @hidden */
  6981. _velocityWorldLength: number;
  6982. /** @hidden */
  6983. _basePointWorld: Vector3;
  6984. private _velocityWorld;
  6985. private _normalizedVelocity;
  6986. /** @hidden */
  6987. _initialVelocity: Vector3;
  6988. /** @hidden */
  6989. _initialPosition: Vector3;
  6990. private _nearestDistance;
  6991. private _collisionMask;
  6992. collisionMask: number;
  6993. /**
  6994. * Gets the plane normal used to compute the sliding response (in local space)
  6995. */
  6996. readonly slidePlaneNormal: Vector3;
  6997. /** @hidden */
  6998. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6999. /** @hidden */
  7000. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7001. /** @hidden */
  7002. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7003. /** @hidden */
  7004. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7007. /** @hidden */
  7008. _getResponse(pos: Vector3, vel: Vector3): void;
  7009. }
  7010. }
  7011. declare module "babylonjs/Culling/boundingInfo" {
  7012. import { DeepImmutable } from "babylonjs/types";
  7013. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7014. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7015. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7016. import { Plane } from "babylonjs/Maths/math.plane";
  7017. import { Collider } from "babylonjs/Collisions/collider";
  7018. /**
  7019. * Interface for cullable objects
  7020. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7021. */
  7022. export interface ICullable {
  7023. /**
  7024. * Checks if the object or part of the object is in the frustum
  7025. * @param frustumPlanes Camera near/planes
  7026. * @returns true if the object is in frustum otherwise false
  7027. */
  7028. isInFrustum(frustumPlanes: Plane[]): boolean;
  7029. /**
  7030. * Checks if a cullable object (mesh...) is in the camera frustum
  7031. * Unlike isInFrustum this cheks the full bounding box
  7032. * @param frustumPlanes Camera near/planes
  7033. * @returns true if the object is in frustum otherwise false
  7034. */
  7035. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7036. }
  7037. /**
  7038. * Info for a bounding data of a mesh
  7039. */
  7040. export class BoundingInfo implements ICullable {
  7041. /**
  7042. * Bounding box for the mesh
  7043. */
  7044. readonly boundingBox: BoundingBox;
  7045. /**
  7046. * Bounding sphere for the mesh
  7047. */
  7048. readonly boundingSphere: BoundingSphere;
  7049. private _isLocked;
  7050. private static readonly TmpVector3;
  7051. /**
  7052. * Constructs bounding info
  7053. * @param minimum min vector of the bounding box/sphere
  7054. * @param maximum max vector of the bounding box/sphere
  7055. * @param worldMatrix defines the new world matrix
  7056. */
  7057. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7058. /**
  7059. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7060. * @param min defines the new minimum vector (in local space)
  7061. * @param max defines the new maximum vector (in local space)
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7065. /**
  7066. * min vector of the bounding box/sphere
  7067. */
  7068. readonly minimum: Vector3;
  7069. /**
  7070. * max vector of the bounding box/sphere
  7071. */
  7072. readonly maximum: Vector3;
  7073. /**
  7074. * If the info is locked and won't be updated to avoid perf overhead
  7075. */
  7076. isLocked: boolean;
  7077. /**
  7078. * Updates the bounding sphere and box
  7079. * @param world world matrix to be used to update
  7080. */
  7081. update(world: DeepImmutable<Matrix>): void;
  7082. /**
  7083. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7084. * @param center New center of the bounding info
  7085. * @param extend New extend of the bounding info
  7086. * @returns the current bounding info
  7087. */
  7088. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7089. /**
  7090. * Scale the current bounding info by applying a scale factor
  7091. * @param factor defines the scale factor to apply
  7092. * @returns the current bounding info
  7093. */
  7094. scale(factor: number): BoundingInfo;
  7095. /**
  7096. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7097. * @param frustumPlanes defines the frustum to test
  7098. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7099. * @returns true if the bounding info is in the frustum planes
  7100. */
  7101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7102. /**
  7103. * Gets the world distance between the min and max points of the bounding box
  7104. */
  7105. readonly diagonalLength: number;
  7106. /**
  7107. * Checks if a cullable object (mesh...) is in the camera frustum
  7108. * Unlike isInFrustum this cheks the full bounding box
  7109. * @param frustumPlanes Camera near/planes
  7110. * @returns true if the object is in frustum otherwise false
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /** @hidden */
  7114. _checkCollision(collider: Collider): boolean;
  7115. /**
  7116. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7117. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7118. * @param point the point to check intersection with
  7119. * @returns if the point intersects
  7120. */
  7121. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7122. /**
  7123. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param boundingInfo the bounding info to check intersection with
  7126. * @param precise if the intersection should be done using OBB
  7127. * @returns if the bounding info intersects
  7128. */
  7129. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7130. }
  7131. }
  7132. declare module "babylonjs/Maths/math.functions" {
  7133. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7134. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7135. /**
  7136. * Extracts minimum and maximum values from a list of indexed positions
  7137. * @param positions defines the positions to use
  7138. * @param indices defines the indices to the positions
  7139. * @param indexStart defines the start index
  7140. * @param indexCount defines the end index
  7141. * @param bias defines bias value to add to the result
  7142. * @return minimum and maximum values
  7143. */
  7144. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7145. minimum: Vector3;
  7146. maximum: Vector3;
  7147. };
  7148. /**
  7149. * Extracts minimum and maximum values from a list of positions
  7150. * @param positions defines the positions to use
  7151. * @param start defines the start index in the positions array
  7152. * @param count defines the number of positions to handle
  7153. * @param bias defines bias value to add to the result
  7154. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7155. * @return minimum and maximum values
  7156. */
  7157. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7158. minimum: Vector3;
  7159. maximum: Vector3;
  7160. };
  7161. }
  7162. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7163. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7164. /** @hidden */
  7165. export class WebGLDataBuffer extends DataBuffer {
  7166. private _buffer;
  7167. constructor(resource: WebGLBuffer);
  7168. readonly underlyingResource: any;
  7169. }
  7170. }
  7171. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7172. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7173. import { Nullable } from "babylonjs/types";
  7174. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7175. /** @hidden */
  7176. export class WebGLPipelineContext implements IPipelineContext {
  7177. engine: ThinEngine;
  7178. program: Nullable<WebGLProgram>;
  7179. context?: WebGLRenderingContext;
  7180. vertexShader?: WebGLShader;
  7181. fragmentShader?: WebGLShader;
  7182. isParallelCompiled: boolean;
  7183. onCompiled?: () => void;
  7184. transformFeedback?: WebGLTransformFeedback | null;
  7185. readonly isAsync: boolean;
  7186. readonly isReady: boolean;
  7187. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7188. }
  7189. }
  7190. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7191. import { FloatArray, Nullable } from "babylonjs/types";
  7192. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7193. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7194. module "babylonjs/Engines/thinEngine" {
  7195. interface ThinEngine {
  7196. /**
  7197. * Create an uniform buffer
  7198. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7199. * @param elements defines the content of the uniform buffer
  7200. * @returns the webGL uniform buffer
  7201. */
  7202. createUniformBuffer(elements: FloatArray): DataBuffer;
  7203. /**
  7204. * Create a dynamic uniform buffer
  7205. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7206. * @param elements defines the content of the uniform buffer
  7207. * @returns the webGL uniform buffer
  7208. */
  7209. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7210. /**
  7211. * Update an existing uniform buffer
  7212. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7213. * @param uniformBuffer defines the target uniform buffer
  7214. * @param elements defines the content to update
  7215. * @param offset defines the offset in the uniform buffer where update should start
  7216. * @param count defines the size of the data to update
  7217. */
  7218. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7219. /**
  7220. * Bind an uniform buffer to the current webGL context
  7221. * @param buffer defines the buffer to bind
  7222. */
  7223. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7224. /**
  7225. * Bind a buffer to the current webGL context at a given location
  7226. * @param buffer defines the buffer to bind
  7227. * @param location defines the index where to bind the buffer
  7228. */
  7229. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7230. /**
  7231. * Bind a specific block at a given index in a specific shader program
  7232. * @param pipelineContext defines the pipeline context to use
  7233. * @param blockName defines the block name
  7234. * @param index defines the index where to bind the block
  7235. */
  7236. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7237. }
  7238. }
  7239. }
  7240. declare module "babylonjs/Materials/uniformBuffer" {
  7241. import { Nullable, FloatArray } from "babylonjs/types";
  7242. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7243. import { Engine } from "babylonjs/Engines/engine";
  7244. import { Effect } from "babylonjs/Materials/effect";
  7245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7246. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7247. import { Color3 } from "babylonjs/Maths/math.color";
  7248. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7249. /**
  7250. * Uniform buffer objects.
  7251. *
  7252. * Handles blocks of uniform on the GPU.
  7253. *
  7254. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7255. *
  7256. * For more information, please refer to :
  7257. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7258. */
  7259. export class UniformBuffer {
  7260. private _engine;
  7261. private _buffer;
  7262. private _data;
  7263. private _bufferData;
  7264. private _dynamic?;
  7265. private _uniformLocations;
  7266. private _uniformSizes;
  7267. private _uniformLocationPointer;
  7268. private _needSync;
  7269. private _noUBO;
  7270. private _currentEffect;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. }
  7692. }
  7693. }
  7694. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7695. import { Nullable } from "babylonjs/types";
  7696. import { Scene } from "babylonjs/scene";
  7697. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7698. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7699. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7700. /**
  7701. * Class for creating a cube texture
  7702. */
  7703. export class CubeTexture extends BaseTexture {
  7704. private _delayedOnLoad;
  7705. /**
  7706. * The url of the texture
  7707. */
  7708. url: string;
  7709. /**
  7710. * Gets or sets the center of the bounding box associated with the cube texture.
  7711. * It must define where the camera used to render the texture was set
  7712. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7713. */
  7714. boundingBoxPosition: Vector3;
  7715. private _boundingBoxSize;
  7716. /**
  7717. * Gets or sets the size of the bounding box associated with the cube texture
  7718. * When defined, the cubemap will switch to local mode
  7719. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7720. * @example https://www.babylonjs-playground.com/#RNASML
  7721. */
  7722. /**
  7723. * Returns the bounding box size
  7724. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7725. */
  7726. boundingBoxSize: Vector3;
  7727. protected _rotationY: number;
  7728. /**
  7729. * Sets texture matrix rotation angle around Y axis in radians.
  7730. */
  7731. /**
  7732. * Gets texture matrix rotation angle around Y axis radians.
  7733. */
  7734. rotationY: number;
  7735. /**
  7736. * Are mip maps generated for this texture or not.
  7737. */
  7738. readonly noMipmap: boolean;
  7739. private _noMipmap;
  7740. private _files;
  7741. protected _forcedExtension: Nullable<string>;
  7742. private _extensions;
  7743. private _textureMatrix;
  7744. private _format;
  7745. private _createPolynomials;
  7746. /** @hidden */
  7747. _prefiltered: boolean;
  7748. /**
  7749. * Creates a cube texture from an array of image urls
  7750. * @param files defines an array of image urls
  7751. * @param scene defines the hosting scene
  7752. * @param noMipmap specifies if mip maps are not used
  7753. * @returns a cube texture
  7754. */
  7755. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7756. /**
  7757. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7758. * @param url defines the url of the prefiltered texture
  7759. * @param scene defines the scene the texture is attached to
  7760. * @param forcedExtension defines the extension of the file if different from the url
  7761. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7762. * @return the prefiltered texture
  7763. */
  7764. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7765. /**
  7766. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7767. * as prefiltered data.
  7768. * @param rootUrl defines the url of the texture or the root name of the six images
  7769. * @param scene defines the scene the texture is attached to
  7770. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7771. * @param noMipmap defines if mipmaps should be created or not
  7772. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7773. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7774. * @param onError defines a callback triggered in case of error during load
  7775. * @param format defines the internal format to use for the texture once loaded
  7776. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7777. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7778. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7779. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7780. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7781. * @return the cube texture
  7782. */
  7783. 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);
  7784. /**
  7785. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7786. */
  7787. readonly isPrefiltered: boolean;
  7788. /**
  7789. * Get the current class name of the texture useful for serialization or dynamic coding.
  7790. * @returns "CubeTexture"
  7791. */
  7792. getClassName(): string;
  7793. /**
  7794. * Update the url (and optional buffer) of this texture if url was null during construction.
  7795. * @param url the url of the texture
  7796. * @param forcedExtension defines the extension to use
  7797. * @param onLoad callback called when the texture is loaded (defaults to null)
  7798. */
  7799. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7800. /**
  7801. * Delays loading of the cube texture
  7802. * @param forcedExtension defines the extension to use
  7803. */
  7804. delayLoad(forcedExtension?: string): void;
  7805. /**
  7806. * Returns the reflection texture matrix
  7807. * @returns the reflection texture matrix
  7808. */
  7809. getReflectionTextureMatrix(): Matrix;
  7810. /**
  7811. * Sets the reflection texture matrix
  7812. * @param value Reflection texture matrix
  7813. */
  7814. setReflectionTextureMatrix(value: Matrix): void;
  7815. /**
  7816. * Parses text to create a cube texture
  7817. * @param parsedTexture define the serialized text to read from
  7818. * @param scene defines the hosting scene
  7819. * @param rootUrl defines the root url of the cube texture
  7820. * @returns a cube texture
  7821. */
  7822. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7823. /**
  7824. * Makes a clone, or deep copy, of the cube texture
  7825. * @returns a new cube texture
  7826. */
  7827. clone(): CubeTexture;
  7828. }
  7829. }
  7830. declare module "babylonjs/Materials/materialDefines" {
  7831. /**
  7832. * Manages the defines for the Material
  7833. */
  7834. export class MaterialDefines {
  7835. /** @hidden */
  7836. protected _keys: string[];
  7837. private _isDirty;
  7838. /** @hidden */
  7839. _renderId: number;
  7840. /** @hidden */
  7841. _areLightsDirty: boolean;
  7842. /** @hidden */
  7843. _areLightsDisposed: boolean;
  7844. /** @hidden */
  7845. _areAttributesDirty: boolean;
  7846. /** @hidden */
  7847. _areTexturesDirty: boolean;
  7848. /** @hidden */
  7849. _areFresnelDirty: boolean;
  7850. /** @hidden */
  7851. _areMiscDirty: boolean;
  7852. /** @hidden */
  7853. _areImageProcessingDirty: boolean;
  7854. /** @hidden */
  7855. _normals: boolean;
  7856. /** @hidden */
  7857. _uvs: boolean;
  7858. /** @hidden */
  7859. _needNormals: boolean;
  7860. /** @hidden */
  7861. _needUVs: boolean;
  7862. [id: string]: any;
  7863. /**
  7864. * Specifies if the material needs to be re-calculated
  7865. */
  7866. readonly isDirty: boolean;
  7867. /**
  7868. * Marks the material to indicate that it has been re-calculated
  7869. */
  7870. markAsProcessed(): void;
  7871. /**
  7872. * Marks the material to indicate that it needs to be re-calculated
  7873. */
  7874. markAsUnprocessed(): void;
  7875. /**
  7876. * Marks the material to indicate all of its defines need to be re-calculated
  7877. */
  7878. markAllAsDirty(): void;
  7879. /**
  7880. * Marks the material to indicate that image processing needs to be re-calculated
  7881. */
  7882. markAsImageProcessingDirty(): void;
  7883. /**
  7884. * Marks the material to indicate the lights need to be re-calculated
  7885. * @param disposed Defines whether the light is dirty due to dispose or not
  7886. */
  7887. markAsLightDirty(disposed?: boolean): void;
  7888. /**
  7889. * Marks the attribute state as changed
  7890. */
  7891. markAsAttributesDirty(): void;
  7892. /**
  7893. * Marks the texture state as changed
  7894. */
  7895. markAsTexturesDirty(): void;
  7896. /**
  7897. * Marks the fresnel state as changed
  7898. */
  7899. markAsFresnelDirty(): void;
  7900. /**
  7901. * Marks the misc state as changed
  7902. */
  7903. markAsMiscDirty(): void;
  7904. /**
  7905. * Rebuilds the material defines
  7906. */
  7907. rebuild(): void;
  7908. /**
  7909. * Specifies if two material defines are equal
  7910. * @param other - A material define instance to compare to
  7911. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7912. */
  7913. isEqual(other: MaterialDefines): boolean;
  7914. /**
  7915. * Clones this instance's defines to another instance
  7916. * @param other - material defines to clone values to
  7917. */
  7918. cloneTo(other: MaterialDefines): void;
  7919. /**
  7920. * Resets the material define values
  7921. */
  7922. reset(): void;
  7923. /**
  7924. * Converts the material define values to a string
  7925. * @returns - String of material define information
  7926. */
  7927. toString(): string;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/colorCurves" {
  7931. import { Effect } from "babylonjs/Materials/effect";
  7932. /**
  7933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7935. * 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;
  7936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7937. */
  7938. export class ColorCurves {
  7939. private _dirty;
  7940. private _tempColor;
  7941. private _globalCurve;
  7942. private _highlightsCurve;
  7943. private _midtonesCurve;
  7944. private _shadowsCurve;
  7945. private _positiveCurve;
  7946. private _negativeCurve;
  7947. private _globalHue;
  7948. private _globalDensity;
  7949. private _globalSaturation;
  7950. private _globalExposure;
  7951. /**
  7952. * Gets the global Hue value.
  7953. * 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).
  7954. */
  7955. /**
  7956. * Sets the global Hue value.
  7957. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7958. */
  7959. globalHue: number;
  7960. /**
  7961. * Gets the global Density value.
  7962. * 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.
  7963. * Values less than zero provide a filter of opposite hue.
  7964. */
  7965. /**
  7966. * Sets the global Density value.
  7967. * 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.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. globalDensity: number;
  7971. /**
  7972. * Gets the global Saturation value.
  7973. * 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.
  7974. */
  7975. /**
  7976. * Sets the global Saturation value.
  7977. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7978. */
  7979. globalSaturation: number;
  7980. /**
  7981. * Gets the global Exposure value.
  7982. * 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.
  7983. */
  7984. /**
  7985. * Sets the global Exposure value.
  7986. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7987. */
  7988. globalExposure: number;
  7989. private _highlightsHue;
  7990. private _highlightsDensity;
  7991. private _highlightsSaturation;
  7992. private _highlightsExposure;
  7993. /**
  7994. * Gets the highlights Hue value.
  7995. * 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).
  7996. */
  7997. /**
  7998. * Sets the highlights Hue value.
  7999. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8000. */
  8001. highlightsHue: number;
  8002. /**
  8003. * Gets the highlights Density value.
  8004. * 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.
  8005. * Values less than zero provide a filter of opposite hue.
  8006. */
  8007. /**
  8008. * Sets the highlights Density value.
  8009. * 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.
  8010. * Values less than zero provide a filter of opposite hue.
  8011. */
  8012. highlightsDensity: number;
  8013. /**
  8014. * Gets the highlights Saturation value.
  8015. * 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.
  8016. */
  8017. /**
  8018. * Sets the highlights Saturation value.
  8019. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8020. */
  8021. highlightsSaturation: number;
  8022. /**
  8023. * Gets the highlights Exposure value.
  8024. * 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.
  8025. */
  8026. /**
  8027. * Sets the highlights Exposure value.
  8028. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8029. */
  8030. highlightsExposure: number;
  8031. private _midtonesHue;
  8032. private _midtonesDensity;
  8033. private _midtonesSaturation;
  8034. private _midtonesExposure;
  8035. /**
  8036. * Gets the midtones Hue value.
  8037. * 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).
  8038. */
  8039. /**
  8040. * Sets the midtones Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. midtonesHue: number;
  8044. /**
  8045. * Gets the midtones Density value.
  8046. * 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.
  8047. * Values less than zero provide a filter of opposite hue.
  8048. */
  8049. /**
  8050. * Sets the midtones Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. midtonesDensity: number;
  8055. /**
  8056. * Gets the midtones Saturation value.
  8057. * 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.
  8058. */
  8059. /**
  8060. * Sets the midtones Saturation value.
  8061. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8062. */
  8063. midtonesSaturation: number;
  8064. /**
  8065. * Gets the midtones Exposure value.
  8066. * 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.
  8067. */
  8068. /**
  8069. * Sets the midtones Exposure value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8071. */
  8072. midtonesExposure: number;
  8073. private _shadowsHue;
  8074. private _shadowsDensity;
  8075. private _shadowsSaturation;
  8076. private _shadowsExposure;
  8077. /**
  8078. * Gets the shadows Hue value.
  8079. * 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).
  8080. */
  8081. /**
  8082. * Sets the shadows Hue value.
  8083. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8084. */
  8085. shadowsHue: number;
  8086. /**
  8087. * Gets the shadows Density value.
  8088. * 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.
  8089. * Values less than zero provide a filter of opposite hue.
  8090. */
  8091. /**
  8092. * Sets the shadows Density value.
  8093. * 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.
  8094. * Values less than zero provide a filter of opposite hue.
  8095. */
  8096. shadowsDensity: number;
  8097. /**
  8098. * Gets the shadows Saturation value.
  8099. * 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.
  8100. */
  8101. /**
  8102. * Sets the shadows Saturation value.
  8103. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8104. */
  8105. shadowsSaturation: number;
  8106. /**
  8107. * Gets the shadows Exposure value.
  8108. * 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.
  8109. */
  8110. /**
  8111. * Sets the shadows Exposure value.
  8112. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8113. */
  8114. shadowsExposure: number;
  8115. /**
  8116. * Returns the class name
  8117. * @returns The class name
  8118. */
  8119. getClassName(): string;
  8120. /**
  8121. * Binds the color curves to the shader.
  8122. * @param colorCurves The color curve to bind
  8123. * @param effect The effect to bind to
  8124. * @param positiveUniform The positive uniform shader parameter
  8125. * @param neutralUniform The neutral uniform shader parameter
  8126. * @param negativeUniform The negative uniform shader parameter
  8127. */
  8128. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8129. /**
  8130. * Prepare the list of uniforms associated with the ColorCurves effects.
  8131. * @param uniformsList The list of uniforms used in the effect
  8132. */
  8133. static PrepareUniforms(uniformsList: string[]): void;
  8134. /**
  8135. * Returns color grading data based on a hue, density, saturation and exposure value.
  8136. * @param filterHue The hue of the color filter.
  8137. * @param filterDensity The density of the color filter.
  8138. * @param saturation The saturation.
  8139. * @param exposure The exposure.
  8140. * @param result The result data container.
  8141. */
  8142. private getColorGradingDataToRef;
  8143. /**
  8144. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8145. * @param value The input slider value in range [-100,100].
  8146. * @returns Adjusted value.
  8147. */
  8148. private static applyColorGradingSliderNonlinear;
  8149. /**
  8150. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8151. * @param hue The hue (H) input.
  8152. * @param saturation The saturation (S) input.
  8153. * @param brightness The brightness (B) input.
  8154. * @result An RGBA color represented as Vector4.
  8155. */
  8156. private static fromHSBToRef;
  8157. /**
  8158. * Returns a value clamped between min and max
  8159. * @param value The value to clamp
  8160. * @param min The minimum of value
  8161. * @param max The maximum of value
  8162. * @returns The clamped value.
  8163. */
  8164. private static clamp;
  8165. /**
  8166. * Clones the current color curve instance.
  8167. * @return The cloned curves
  8168. */
  8169. clone(): ColorCurves;
  8170. /**
  8171. * Serializes the current color curve instance to a json representation.
  8172. * @return a JSON representation
  8173. */
  8174. serialize(): any;
  8175. /**
  8176. * Parses the color curve from a json representation.
  8177. * @param source the JSON source to parse
  8178. * @return The parsed curves
  8179. */
  8180. static Parse(source: any): ColorCurves;
  8181. }
  8182. }
  8183. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8184. import { Observable } from "babylonjs/Misc/observable";
  8185. import { Nullable } from "babylonjs/types";
  8186. import { Color4 } from "babylonjs/Maths/math.color";
  8187. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8188. import { Effect } from "babylonjs/Materials/effect";
  8189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8190. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8191. /**
  8192. * Interface to follow in your material defines to integrate easily the
  8193. * Image proccessing functions.
  8194. * @hidden
  8195. */
  8196. export interface IImageProcessingConfigurationDefines {
  8197. IMAGEPROCESSING: boolean;
  8198. VIGNETTE: boolean;
  8199. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8200. VIGNETTEBLENDMODEOPAQUE: boolean;
  8201. TONEMAPPING: boolean;
  8202. TONEMAPPING_ACES: boolean;
  8203. CONTRAST: boolean;
  8204. EXPOSURE: boolean;
  8205. COLORCURVES: boolean;
  8206. COLORGRADING: boolean;
  8207. COLORGRADING3D: boolean;
  8208. SAMPLER3DGREENDEPTH: boolean;
  8209. SAMPLER3DBGRMAP: boolean;
  8210. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8211. }
  8212. /**
  8213. * @hidden
  8214. */
  8215. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8216. IMAGEPROCESSING: boolean;
  8217. VIGNETTE: boolean;
  8218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8219. VIGNETTEBLENDMODEOPAQUE: boolean;
  8220. TONEMAPPING: boolean;
  8221. TONEMAPPING_ACES: boolean;
  8222. CONTRAST: boolean;
  8223. COLORCURVES: boolean;
  8224. COLORGRADING: boolean;
  8225. COLORGRADING3D: boolean;
  8226. SAMPLER3DGREENDEPTH: boolean;
  8227. SAMPLER3DBGRMAP: boolean;
  8228. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8229. EXPOSURE: boolean;
  8230. constructor();
  8231. }
  8232. /**
  8233. * This groups together the common properties used for image processing either in direct forward pass
  8234. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8235. * or not.
  8236. */
  8237. export class ImageProcessingConfiguration {
  8238. /**
  8239. * Default tone mapping applied in BabylonJS.
  8240. */
  8241. static readonly TONEMAPPING_STANDARD: number;
  8242. /**
  8243. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8244. * to other engines rendering to increase portability.
  8245. */
  8246. static readonly TONEMAPPING_ACES: number;
  8247. /**
  8248. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8249. */
  8250. colorCurves: Nullable<ColorCurves>;
  8251. private _colorCurvesEnabled;
  8252. /**
  8253. * Gets wether the color curves effect is enabled.
  8254. */
  8255. /**
  8256. * Sets wether the color curves effect is enabled.
  8257. */
  8258. colorCurvesEnabled: boolean;
  8259. private _colorGradingTexture;
  8260. /**
  8261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8262. */
  8263. /**
  8264. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8265. */
  8266. colorGradingTexture: Nullable<BaseTexture>;
  8267. private _colorGradingEnabled;
  8268. /**
  8269. * Gets wether the color grading effect is enabled.
  8270. */
  8271. /**
  8272. * Sets wether the color grading effect is enabled.
  8273. */
  8274. colorGradingEnabled: boolean;
  8275. private _colorGradingWithGreenDepth;
  8276. /**
  8277. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8278. */
  8279. /**
  8280. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8281. */
  8282. colorGradingWithGreenDepth: boolean;
  8283. private _colorGradingBGR;
  8284. /**
  8285. * Gets wether the color grading texture contains BGR values.
  8286. */
  8287. /**
  8288. * Sets wether the color grading texture contains BGR values.
  8289. */
  8290. colorGradingBGR: boolean;
  8291. /** @hidden */
  8292. _exposure: number;
  8293. /**
  8294. * Gets the Exposure used in the effect.
  8295. */
  8296. /**
  8297. * Sets the Exposure used in the effect.
  8298. */
  8299. exposure: number;
  8300. private _toneMappingEnabled;
  8301. /**
  8302. * Gets wether the tone mapping effect is enabled.
  8303. */
  8304. /**
  8305. * Sets wether the tone mapping effect is enabled.
  8306. */
  8307. toneMappingEnabled: boolean;
  8308. private _toneMappingType;
  8309. /**
  8310. * Gets the type of tone mapping effect.
  8311. */
  8312. /**
  8313. * Sets the type of tone mapping effect used in BabylonJS.
  8314. */
  8315. toneMappingType: number;
  8316. protected _contrast: number;
  8317. /**
  8318. * Gets the contrast used in the effect.
  8319. */
  8320. /**
  8321. * Sets the contrast used in the effect.
  8322. */
  8323. contrast: number;
  8324. /**
  8325. * Vignette stretch size.
  8326. */
  8327. vignetteStretch: number;
  8328. /**
  8329. * Vignette centre X Offset.
  8330. */
  8331. vignetteCentreX: number;
  8332. /**
  8333. * Vignette centre Y Offset.
  8334. */
  8335. vignetteCentreY: number;
  8336. /**
  8337. * Vignette weight or intensity of the vignette effect.
  8338. */
  8339. vignetteWeight: number;
  8340. /**
  8341. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8342. * if vignetteEnabled is set to true.
  8343. */
  8344. vignetteColor: Color4;
  8345. /**
  8346. * Camera field of view used by the Vignette effect.
  8347. */
  8348. vignetteCameraFov: number;
  8349. private _vignetteBlendMode;
  8350. /**
  8351. * Gets the vignette blend mode allowing different kind of effect.
  8352. */
  8353. /**
  8354. * Sets the vignette blend mode allowing different kind of effect.
  8355. */
  8356. vignetteBlendMode: number;
  8357. private _vignetteEnabled;
  8358. /**
  8359. * Gets wether the vignette effect is enabled.
  8360. */
  8361. /**
  8362. * Sets wether the vignette effect is enabled.
  8363. */
  8364. vignetteEnabled: boolean;
  8365. private _applyByPostProcess;
  8366. /**
  8367. * Gets wether the image processing is applied through a post process or not.
  8368. */
  8369. /**
  8370. * Sets wether the image processing is applied through a post process or not.
  8371. */
  8372. applyByPostProcess: boolean;
  8373. private _isEnabled;
  8374. /**
  8375. * Gets wether the image processing is enabled or not.
  8376. */
  8377. /**
  8378. * Sets wether the image processing is enabled or not.
  8379. */
  8380. isEnabled: boolean;
  8381. /**
  8382. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8383. */
  8384. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8385. /**
  8386. * Method called each time the image processing information changes requires to recompile the effect.
  8387. */
  8388. protected _updateParameters(): void;
  8389. /**
  8390. * Gets the current class name.
  8391. * @return "ImageProcessingConfiguration"
  8392. */
  8393. getClassName(): string;
  8394. /**
  8395. * Prepare the list of uniforms associated with the Image Processing effects.
  8396. * @param uniforms The list of uniforms used in the effect
  8397. * @param defines the list of defines currently in use
  8398. */
  8399. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8400. /**
  8401. * Prepare the list of samplers associated with the Image Processing effects.
  8402. * @param samplersList The list of uniforms used in the effect
  8403. * @param defines the list of defines currently in use
  8404. */
  8405. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8406. /**
  8407. * Prepare the list of defines associated to the shader.
  8408. * @param defines the list of defines to complete
  8409. * @param forPostProcess Define if we are currently in post process mode or not
  8410. */
  8411. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8412. /**
  8413. * Returns true if all the image processing information are ready.
  8414. * @returns True if ready, otherwise, false
  8415. */
  8416. isReady(): boolean;
  8417. /**
  8418. * Binds the image processing to the shader.
  8419. * @param effect The effect to bind to
  8420. * @param aspectRatio Define the current aspect ratio of the effect
  8421. */
  8422. bind(effect: Effect, aspectRatio?: number): void;
  8423. /**
  8424. * Clones the current image processing instance.
  8425. * @return The cloned image processing
  8426. */
  8427. clone(): ImageProcessingConfiguration;
  8428. /**
  8429. * Serializes the current image processing instance to a json representation.
  8430. * @return a JSON representation
  8431. */
  8432. serialize(): any;
  8433. /**
  8434. * Parses the image processing from a json representation.
  8435. * @param source the JSON source to parse
  8436. * @return The parsed image processing
  8437. */
  8438. static Parse(source: any): ImageProcessingConfiguration;
  8439. private static _VIGNETTEMODE_MULTIPLY;
  8440. private static _VIGNETTEMODE_OPAQUE;
  8441. /**
  8442. * Used to apply the vignette as a mix with the pixel color.
  8443. */
  8444. static readonly VIGNETTEMODE_MULTIPLY: number;
  8445. /**
  8446. * Used to apply the vignette as a replacement of the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_OPAQUE: number;
  8449. }
  8450. }
  8451. declare module "babylonjs/Shaders/postprocess.vertex" {
  8452. /** @hidden */
  8453. export var postprocessVertexShader: {
  8454. name: string;
  8455. shader: string;
  8456. };
  8457. }
  8458. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8459. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8460. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8461. module "babylonjs/Engines/thinEngine" {
  8462. interface ThinEngine {
  8463. /**
  8464. * Creates a new render target texture
  8465. * @param size defines the size of the texture
  8466. * @param options defines the options used to create the texture
  8467. * @returns a new render target texture stored in an InternalTexture
  8468. */
  8469. createRenderTargetTexture(size: number | {
  8470. width: number;
  8471. height: number;
  8472. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8473. }
  8474. }
  8475. }
  8476. declare module "babylonjs/Maths/math.axis" {
  8477. import { Vector3 } from "babylonjs/Maths/math.vector";
  8478. /** Defines supported spaces */
  8479. export enum Space {
  8480. /** Local (object) space */
  8481. LOCAL = 0,
  8482. /** World space */
  8483. WORLD = 1,
  8484. /** Bone space */
  8485. BONE = 2
  8486. }
  8487. /** Defines the 3 main axes */
  8488. export class Axis {
  8489. /** X axis */
  8490. static X: Vector3;
  8491. /** Y axis */
  8492. static Y: Vector3;
  8493. /** Z axis */
  8494. static Z: Vector3;
  8495. }
  8496. }
  8497. declare module "babylonjs/Cameras/targetCamera" {
  8498. import { Nullable } from "babylonjs/types";
  8499. import { Camera } from "babylonjs/Cameras/camera";
  8500. import { Scene } from "babylonjs/scene";
  8501. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8502. /**
  8503. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8504. * This is the base of the follow, arc rotate cameras and Free camera
  8505. * @see http://doc.babylonjs.com/features/cameras
  8506. */
  8507. export class TargetCamera extends Camera {
  8508. private static _RigCamTransformMatrix;
  8509. private static _TargetTransformMatrix;
  8510. private static _TargetFocalPoint;
  8511. /**
  8512. * Define the current direction the camera is moving to
  8513. */
  8514. cameraDirection: Vector3;
  8515. /**
  8516. * Define the current rotation the camera is rotating to
  8517. */
  8518. cameraRotation: Vector2;
  8519. /**
  8520. * When set, the up vector of the camera will be updated by the rotation of the camera
  8521. */
  8522. updateUpVectorFromRotation: boolean;
  8523. private _tmpQuaternion;
  8524. /**
  8525. * Define the current rotation of the camera
  8526. */
  8527. rotation: Vector3;
  8528. /**
  8529. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8530. */
  8531. rotationQuaternion: Quaternion;
  8532. /**
  8533. * Define the current speed of the camera
  8534. */
  8535. speed: number;
  8536. /**
  8537. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8538. * around all axis.
  8539. */
  8540. noRotationConstraint: boolean;
  8541. /**
  8542. * Define the current target of the camera as an object or a position.
  8543. */
  8544. lockedTarget: any;
  8545. /** @hidden */
  8546. _currentTarget: Vector3;
  8547. /** @hidden */
  8548. _initialFocalDistance: number;
  8549. /** @hidden */
  8550. _viewMatrix: Matrix;
  8551. /** @hidden */
  8552. _camMatrix: Matrix;
  8553. /** @hidden */
  8554. _cameraTransformMatrix: Matrix;
  8555. /** @hidden */
  8556. _cameraRotationMatrix: Matrix;
  8557. /** @hidden */
  8558. _referencePoint: Vector3;
  8559. /** @hidden */
  8560. _transformedReferencePoint: Vector3;
  8561. protected _globalCurrentTarget: Vector3;
  8562. protected _globalCurrentUpVector: Vector3;
  8563. /** @hidden */
  8564. _reset: () => void;
  8565. private _defaultUp;
  8566. /**
  8567. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8568. * This is the base of the follow, arc rotate cameras and Free camera
  8569. * @see http://doc.babylonjs.com/features/cameras
  8570. * @param name Defines the name of the camera in the scene
  8571. * @param position Defines the start position of the camera in the scene
  8572. * @param scene Defines the scene the camera belongs to
  8573. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8574. */
  8575. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8576. /**
  8577. * Gets the position in front of the camera at a given distance.
  8578. * @param distance The distance from the camera we want the position to be
  8579. * @returns the position
  8580. */
  8581. getFrontPosition(distance: number): Vector3;
  8582. /** @hidden */
  8583. _getLockedTargetPosition(): Nullable<Vector3>;
  8584. private _storedPosition;
  8585. private _storedRotation;
  8586. private _storedRotationQuaternion;
  8587. /**
  8588. * Store current camera state of the camera (fov, position, rotation, etc..)
  8589. * @returns the camera
  8590. */
  8591. storeState(): Camera;
  8592. /**
  8593. * Restored camera state. You must call storeState() first
  8594. * @returns whether it was successful or not
  8595. * @hidden
  8596. */
  8597. _restoreStateValues(): boolean;
  8598. /** @hidden */
  8599. _initCache(): void;
  8600. /** @hidden */
  8601. _updateCache(ignoreParentClass?: boolean): void;
  8602. /** @hidden */
  8603. _isSynchronizedViewMatrix(): boolean;
  8604. /** @hidden */
  8605. _computeLocalCameraSpeed(): number;
  8606. /**
  8607. * Defines the target the camera should look at.
  8608. * @param target Defines the new target as a Vector or a mesh
  8609. */
  8610. setTarget(target: Vector3): void;
  8611. /**
  8612. * Return the current target position of the camera. This value is expressed in local space.
  8613. * @returns the target position
  8614. */
  8615. getTarget(): Vector3;
  8616. /** @hidden */
  8617. _decideIfNeedsToMove(): boolean;
  8618. /** @hidden */
  8619. _updatePosition(): void;
  8620. /** @hidden */
  8621. _checkInputs(): void;
  8622. protected _updateCameraRotationMatrix(): void;
  8623. /**
  8624. * 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)
  8625. * @returns the current camera
  8626. */
  8627. private _rotateUpVectorWithCameraRotationMatrix;
  8628. private _cachedRotationZ;
  8629. private _cachedQuaternionRotationZ;
  8630. /** @hidden */
  8631. _getViewMatrix(): Matrix;
  8632. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8633. /**
  8634. * @hidden
  8635. */
  8636. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8637. /**
  8638. * @hidden
  8639. */
  8640. _updateRigCameras(): void;
  8641. private _getRigCamPositionAndTarget;
  8642. /**
  8643. * Gets the current object class name.
  8644. * @return the class name
  8645. */
  8646. getClassName(): string;
  8647. }
  8648. }
  8649. declare module "babylonjs/Events/keyboardEvents" {
  8650. /**
  8651. * Gather the list of keyboard event types as constants.
  8652. */
  8653. export class KeyboardEventTypes {
  8654. /**
  8655. * The keydown event is fired when a key becomes active (pressed).
  8656. */
  8657. static readonly KEYDOWN: number;
  8658. /**
  8659. * The keyup event is fired when a key has been released.
  8660. */
  8661. static readonly KEYUP: number;
  8662. }
  8663. /**
  8664. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8665. */
  8666. export class KeyboardInfo {
  8667. /**
  8668. * Defines the type of event (KeyboardEventTypes)
  8669. */
  8670. type: number;
  8671. /**
  8672. * Defines the related dom event
  8673. */
  8674. event: KeyboardEvent;
  8675. /**
  8676. * Instantiates a new keyboard info.
  8677. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8678. * @param type Defines the type of event (KeyboardEventTypes)
  8679. * @param event Defines the related dom event
  8680. */
  8681. constructor(
  8682. /**
  8683. * Defines the type of event (KeyboardEventTypes)
  8684. */
  8685. type: number,
  8686. /**
  8687. * Defines the related dom event
  8688. */
  8689. event: KeyboardEvent);
  8690. }
  8691. /**
  8692. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8693. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8694. */
  8695. export class KeyboardInfoPre extends KeyboardInfo {
  8696. /**
  8697. * Defines the type of event (KeyboardEventTypes)
  8698. */
  8699. type: number;
  8700. /**
  8701. * Defines the related dom event
  8702. */
  8703. event: KeyboardEvent;
  8704. /**
  8705. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8706. */
  8707. skipOnPointerObservable: boolean;
  8708. /**
  8709. * Instantiates a new keyboard pre info.
  8710. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8711. * @param type Defines the type of event (KeyboardEventTypes)
  8712. * @param event Defines the related dom event
  8713. */
  8714. constructor(
  8715. /**
  8716. * Defines the type of event (KeyboardEventTypes)
  8717. */
  8718. type: number,
  8719. /**
  8720. * Defines the related dom event
  8721. */
  8722. event: KeyboardEvent);
  8723. }
  8724. }
  8725. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8726. import { Nullable } from "babylonjs/types";
  8727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8728. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8729. /**
  8730. * Manage the keyboard inputs to control the movement of a free camera.
  8731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8732. */
  8733. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8734. /**
  8735. * Defines the camera the input is attached to.
  8736. */
  8737. camera: FreeCamera;
  8738. /**
  8739. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8740. */
  8741. keysUp: number[];
  8742. /**
  8743. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8744. */
  8745. keysDown: number[];
  8746. /**
  8747. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8748. */
  8749. keysLeft: number[];
  8750. /**
  8751. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8752. */
  8753. keysRight: number[];
  8754. private _keys;
  8755. private _onCanvasBlurObserver;
  8756. private _onKeyboardObserver;
  8757. private _engine;
  8758. private _scene;
  8759. /**
  8760. * Attach the input controls to a specific dom element to get the input from.
  8761. * @param element Defines the element the controls should be listened from
  8762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8763. */
  8764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8765. /**
  8766. * Detach the current controls from the specified dom element.
  8767. * @param element Defines the element to stop listening the inputs from
  8768. */
  8769. detachControl(element: Nullable<HTMLElement>): void;
  8770. /**
  8771. * Update the current camera state depending on the inputs that have been used this frame.
  8772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8773. */
  8774. checkInputs(): void;
  8775. /**
  8776. * Gets the class name of the current intput.
  8777. * @returns the class name
  8778. */
  8779. getClassName(): string;
  8780. /** @hidden */
  8781. _onLostFocus(): void;
  8782. /**
  8783. * Get the friendly name associated with the input class.
  8784. * @returns the input friendly name
  8785. */
  8786. getSimpleName(): string;
  8787. }
  8788. }
  8789. declare module "babylonjs/Lights/shadowLight" {
  8790. import { Camera } from "babylonjs/Cameras/camera";
  8791. import { Scene } from "babylonjs/scene";
  8792. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8794. import { Light } from "babylonjs/Lights/light";
  8795. /**
  8796. * Interface describing all the common properties and methods a shadow light needs to implement.
  8797. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8798. * as well as binding the different shadow properties to the effects.
  8799. */
  8800. export interface IShadowLight extends Light {
  8801. /**
  8802. * The light id in the scene (used in scene.findLighById for instance)
  8803. */
  8804. id: string;
  8805. /**
  8806. * The position the shdow will be casted from.
  8807. */
  8808. position: Vector3;
  8809. /**
  8810. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8811. */
  8812. direction: Vector3;
  8813. /**
  8814. * The transformed position. Position of the light in world space taking parenting in account.
  8815. */
  8816. transformedPosition: Vector3;
  8817. /**
  8818. * The transformed direction. Direction of the light in world space taking parenting in account.
  8819. */
  8820. transformedDirection: Vector3;
  8821. /**
  8822. * The friendly name of the light in the scene.
  8823. */
  8824. name: string;
  8825. /**
  8826. * Defines the shadow projection clipping minimum z value.
  8827. */
  8828. shadowMinZ: number;
  8829. /**
  8830. * Defines the shadow projection clipping maximum z value.
  8831. */
  8832. shadowMaxZ: number;
  8833. /**
  8834. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8835. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8836. */
  8837. computeTransformedInformation(): boolean;
  8838. /**
  8839. * Gets the scene the light belongs to.
  8840. * @returns The scene
  8841. */
  8842. getScene(): Scene;
  8843. /**
  8844. * Callback defining a custom Projection Matrix Builder.
  8845. * This can be used to override the default projection matrix computation.
  8846. */
  8847. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8848. /**
  8849. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8850. * @param matrix The materix to updated with the projection information
  8851. * @param viewMatrix The transform matrix of the light
  8852. * @param renderList The list of mesh to render in the map
  8853. * @returns The current light
  8854. */
  8855. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8856. /**
  8857. * Gets the current depth scale used in ESM.
  8858. * @returns The scale
  8859. */
  8860. getDepthScale(): number;
  8861. /**
  8862. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8863. * @returns true if a cube texture needs to be use
  8864. */
  8865. needCube(): boolean;
  8866. /**
  8867. * Detects if the projection matrix requires to be recomputed this frame.
  8868. * @returns true if it requires to be recomputed otherwise, false.
  8869. */
  8870. needProjectionMatrixCompute(): boolean;
  8871. /**
  8872. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8873. */
  8874. forceProjectionMatrixCompute(): void;
  8875. /**
  8876. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8877. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8878. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8879. */
  8880. getShadowDirection(faceIndex?: number): Vector3;
  8881. /**
  8882. * Gets the minZ used for shadow according to both the scene and the light.
  8883. * @param activeCamera The camera we are returning the min for
  8884. * @returns the depth min z
  8885. */
  8886. getDepthMinZ(activeCamera: Camera): number;
  8887. /**
  8888. * Gets the maxZ used for shadow according to both the scene and the light.
  8889. * @param activeCamera The camera we are returning the max for
  8890. * @returns the depth max z
  8891. */
  8892. getDepthMaxZ(activeCamera: Camera): number;
  8893. }
  8894. /**
  8895. * Base implementation IShadowLight
  8896. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8897. */
  8898. export abstract class ShadowLight extends Light implements IShadowLight {
  8899. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8900. protected _position: Vector3;
  8901. protected _setPosition(value: Vector3): void;
  8902. /**
  8903. * Sets the position the shadow will be casted from. Also use as the light position for both
  8904. * point and spot lights.
  8905. */
  8906. /**
  8907. * Sets the position the shadow will be casted from. Also use as the light position for both
  8908. * point and spot lights.
  8909. */
  8910. position: Vector3;
  8911. protected _direction: Vector3;
  8912. protected _setDirection(value: Vector3): void;
  8913. /**
  8914. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8915. * Also use as the light direction on spot and directional lights.
  8916. */
  8917. /**
  8918. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8919. * Also use as the light direction on spot and directional lights.
  8920. */
  8921. direction: Vector3;
  8922. private _shadowMinZ;
  8923. /**
  8924. * Gets the shadow projection clipping minimum z value.
  8925. */
  8926. /**
  8927. * Sets the shadow projection clipping minimum z value.
  8928. */
  8929. shadowMinZ: number;
  8930. private _shadowMaxZ;
  8931. /**
  8932. * Sets the shadow projection clipping maximum z value.
  8933. */
  8934. /**
  8935. * Gets the shadow projection clipping maximum z value.
  8936. */
  8937. shadowMaxZ: number;
  8938. /**
  8939. * Callback defining a custom Projection Matrix Builder.
  8940. * This can be used to override the default projection matrix computation.
  8941. */
  8942. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8943. /**
  8944. * The transformed position. Position of the light in world space taking parenting in account.
  8945. */
  8946. transformedPosition: Vector3;
  8947. /**
  8948. * The transformed direction. Direction of the light in world space taking parenting in account.
  8949. */
  8950. transformedDirection: Vector3;
  8951. private _needProjectionMatrixCompute;
  8952. /**
  8953. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8954. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8955. */
  8956. computeTransformedInformation(): boolean;
  8957. /**
  8958. * Return the depth scale used for the shadow map.
  8959. * @returns the depth scale.
  8960. */
  8961. getDepthScale(): number;
  8962. /**
  8963. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8964. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8965. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8966. */
  8967. getShadowDirection(faceIndex?: number): Vector3;
  8968. /**
  8969. * Returns the ShadowLight absolute position in the World.
  8970. * @returns the position vector in world space
  8971. */
  8972. getAbsolutePosition(): Vector3;
  8973. /**
  8974. * Sets the ShadowLight direction toward the passed target.
  8975. * @param target The point to target in local space
  8976. * @returns the updated ShadowLight direction
  8977. */
  8978. setDirectionToTarget(target: Vector3): Vector3;
  8979. /**
  8980. * Returns the light rotation in euler definition.
  8981. * @returns the x y z rotation in local space.
  8982. */
  8983. getRotation(): Vector3;
  8984. /**
  8985. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8986. * @returns true if a cube texture needs to be use
  8987. */
  8988. needCube(): boolean;
  8989. /**
  8990. * Detects if the projection matrix requires to be recomputed this frame.
  8991. * @returns true if it requires to be recomputed otherwise, false.
  8992. */
  8993. needProjectionMatrixCompute(): boolean;
  8994. /**
  8995. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8996. */
  8997. forceProjectionMatrixCompute(): void;
  8998. /** @hidden */
  8999. _initCache(): void;
  9000. /** @hidden */
  9001. _isSynchronized(): boolean;
  9002. /**
  9003. * Computes the world matrix of the node
  9004. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9005. * @returns the world matrix
  9006. */
  9007. computeWorldMatrix(force?: boolean): Matrix;
  9008. /**
  9009. * Gets the minZ used for shadow according to both the scene and the light.
  9010. * @param activeCamera The camera we are returning the min for
  9011. * @returns the depth min z
  9012. */
  9013. getDepthMinZ(activeCamera: Camera): number;
  9014. /**
  9015. * Gets the maxZ used for shadow according to both the scene and the light.
  9016. * @param activeCamera The camera we are returning the max for
  9017. * @returns the depth max z
  9018. */
  9019. getDepthMaxZ(activeCamera: Camera): number;
  9020. /**
  9021. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9022. * @param matrix The materix to updated with the projection information
  9023. * @param viewMatrix The transform matrix of the light
  9024. * @param renderList The list of mesh to render in the map
  9025. * @returns The current light
  9026. */
  9027. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9028. }
  9029. }
  9030. declare module "babylonjs/Materials/effectFallbacks" {
  9031. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9032. import { Effect } from "babylonjs/Materials/effect";
  9033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9034. /**
  9035. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9036. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9037. */
  9038. export class EffectFallbacks implements IEffectFallbacks {
  9039. private _defines;
  9040. private _currentRank;
  9041. private _maxRank;
  9042. private _mesh;
  9043. /**
  9044. * Removes the fallback from the bound mesh.
  9045. */
  9046. unBindMesh(): void;
  9047. /**
  9048. * Adds a fallback on the specified property.
  9049. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9050. * @param define The name of the define in the shader
  9051. */
  9052. addFallback(rank: number, define: string): void;
  9053. /**
  9054. * Sets the mesh to use CPU skinning when needing to fallback.
  9055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9056. * @param mesh The mesh to use the fallbacks.
  9057. */
  9058. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9059. /**
  9060. * Checks to see if more fallbacks are still availible.
  9061. */
  9062. readonly hasMoreFallbacks: boolean;
  9063. /**
  9064. * Removes the defines that should be removed when falling back.
  9065. * @param currentDefines defines the current define statements for the shader.
  9066. * @param effect defines the current effect we try to compile
  9067. * @returns The resulting defines with defines of the current rank removed.
  9068. */
  9069. reduce(currentDefines: string, effect: Effect): string;
  9070. }
  9071. }
  9072. declare module "babylonjs/Materials/materialHelper" {
  9073. import { Nullable } from "babylonjs/types";
  9074. import { Scene } from "babylonjs/scene";
  9075. import { Engine } from "babylonjs/Engines/engine";
  9076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9077. import { Light } from "babylonjs/Lights/light";
  9078. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9079. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  9080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9081. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9082. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9083. /**
  9084. * "Static Class" containing the most commonly used helper while dealing with material for
  9085. * rendering purpose.
  9086. *
  9087. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9088. *
  9089. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9090. */
  9091. export class MaterialHelper {
  9092. /**
  9093. * Bind the current view position to an effect.
  9094. * @param effect The effect to be bound
  9095. * @param scene The scene the eyes position is used from
  9096. */
  9097. static BindEyePosition(effect: Effect, scene: Scene): void;
  9098. /**
  9099. * Helps preparing the defines values about the UVs in used in the effect.
  9100. * UVs are shared as much as we can accross channels in the shaders.
  9101. * @param texture The texture we are preparing the UVs for
  9102. * @param defines The defines to update
  9103. * @param key The channel key "diffuse", "specular"... used in the shader
  9104. */
  9105. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9106. /**
  9107. * Binds a texture matrix value to its corrsponding uniform
  9108. * @param texture The texture to bind the matrix for
  9109. * @param uniformBuffer The uniform buffer receivin the data
  9110. * @param key The channel key "diffuse", "specular"... used in the shader
  9111. */
  9112. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9113. /**
  9114. * Gets the current status of the fog (should it be enabled?)
  9115. * @param mesh defines the mesh to evaluate for fog support
  9116. * @param scene defines the hosting scene
  9117. * @returns true if fog must be enabled
  9118. */
  9119. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9120. /**
  9121. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9122. * @param mesh defines the current mesh
  9123. * @param scene defines the current scene
  9124. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9125. * @param pointsCloud defines if point cloud rendering has to be turned on
  9126. * @param fogEnabled defines if fog has to be turned on
  9127. * @param alphaTest defines if alpha testing has to be turned on
  9128. * @param defines defines the current list of defines
  9129. */
  9130. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9131. /**
  9132. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9133. * @param scene defines the current scene
  9134. * @param engine defines the current engine
  9135. * @param defines specifies the list of active defines
  9136. * @param useInstances defines if instances have to be turned on
  9137. * @param useClipPlane defines if clip plane have to be turned on
  9138. */
  9139. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9140. /**
  9141. * Prepares the defines for bones
  9142. * @param mesh The mesh containing the geometry data we will draw
  9143. * @param defines The defines to update
  9144. */
  9145. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9146. /**
  9147. * Prepares the defines for morph targets
  9148. * @param mesh The mesh containing the geometry data we will draw
  9149. * @param defines The defines to update
  9150. */
  9151. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9152. /**
  9153. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9154. * @param mesh The mesh containing the geometry data we will draw
  9155. * @param defines The defines to update
  9156. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9157. * @param useBones Precise whether bones should be used or not (override mesh info)
  9158. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9159. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9160. * @returns false if defines are considered not dirty and have not been checked
  9161. */
  9162. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9163. /**
  9164. * Prepares the defines related to multiview
  9165. * @param scene The scene we are intending to draw
  9166. * @param defines The defines to update
  9167. */
  9168. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9169. /**
  9170. * Prepares the defines related to the light information passed in parameter
  9171. * @param scene The scene we are intending to draw
  9172. * @param mesh The mesh the effect is compiling for
  9173. * @param light The light the effect is compiling for
  9174. * @param lightIndex The index of the light
  9175. * @param defines The defines to update
  9176. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9177. * @param state Defines the current state regarding what is needed (normals, etc...)
  9178. */
  9179. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9180. needNormals: boolean;
  9181. needRebuild: boolean;
  9182. shadowEnabled: boolean;
  9183. specularEnabled: boolean;
  9184. lightmapMode: boolean;
  9185. }): void;
  9186. /**
  9187. * Prepares the defines related to the light information passed in parameter
  9188. * @param scene The scene we are intending to draw
  9189. * @param mesh The mesh the effect is compiling for
  9190. * @param defines The defines to update
  9191. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9192. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9193. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9194. * @returns true if normals will be required for the rest of the effect
  9195. */
  9196. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9197. /**
  9198. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9199. * @param lightIndex defines the light index
  9200. * @param uniformsList The uniform list
  9201. * @param samplersList The sampler list
  9202. * @param projectedLightTexture defines if projected texture must be used
  9203. * @param uniformBuffersList defines an optional list of uniform buffers
  9204. */
  9205. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9206. /**
  9207. * Prepares the uniforms and samplers list to be used in the effect
  9208. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9209. * @param samplersList The sampler list
  9210. * @param defines The defines helping in the list generation
  9211. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9212. */
  9213. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9214. /**
  9215. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9216. * @param defines The defines to update while falling back
  9217. * @param fallbacks The authorized effect fallbacks
  9218. * @param maxSimultaneousLights The maximum number of lights allowed
  9219. * @param rank the current rank of the Effect
  9220. * @returns The newly affected rank
  9221. */
  9222. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9223. private static _TmpMorphInfluencers;
  9224. /**
  9225. * Prepares the list of attributes required for morph targets according to the effect defines.
  9226. * @param attribs The current list of supported attribs
  9227. * @param mesh The mesh to prepare the morph targets attributes for
  9228. * @param influencers The number of influencers
  9229. */
  9230. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9231. /**
  9232. * Prepares the list of attributes required for morph targets according to the effect defines.
  9233. * @param attribs The current list of supported attribs
  9234. * @param mesh The mesh to prepare the morph targets attributes for
  9235. * @param defines The current Defines of the effect
  9236. */
  9237. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9238. /**
  9239. * Prepares the list of attributes required for bones according to the effect defines.
  9240. * @param attribs The current list of supported attribs
  9241. * @param mesh The mesh to prepare the bones attributes for
  9242. * @param defines The current Defines of the effect
  9243. * @param fallbacks The current efffect fallback strategy
  9244. */
  9245. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9246. /**
  9247. * Check and prepare the list of attributes required for instances according to the effect defines.
  9248. * @param attribs The current list of supported attribs
  9249. * @param defines The current MaterialDefines of the effect
  9250. */
  9251. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9252. /**
  9253. * Add the list of attributes required for instances to the attribs array.
  9254. * @param attribs The current list of supported attribs
  9255. */
  9256. static PushAttributesForInstances(attribs: string[]): void;
  9257. /**
  9258. * Binds the light shadow information to the effect for the given mesh.
  9259. * @param light The light containing the generator
  9260. * @param scene The scene the lights belongs to
  9261. * @param mesh The mesh we are binding the information to render
  9262. * @param lightIndex The light index in the effect used to render the mesh
  9263. * @param effect The effect we are binding the data to
  9264. */
  9265. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9266. /**
  9267. * Binds the light information to the effect.
  9268. * @param light The light containing the generator
  9269. * @param effect The effect we are binding the data to
  9270. * @param lightIndex The light index in the effect used to render
  9271. */
  9272. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9273. /**
  9274. * Binds the lights information from the scene to the effect for the given mesh.
  9275. * @param light Light to bind
  9276. * @param lightIndex Light index
  9277. * @param scene The scene where the light belongs to
  9278. * @param mesh The mesh we are binding the information to render
  9279. * @param effect The effect we are binding the data to
  9280. * @param useSpecular Defines if specular is supported
  9281. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9282. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9283. */
  9284. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param scene The scene the lights belongs to
  9288. * @param mesh The mesh we are binding the information to render
  9289. * @param effect The effect we are binding the data to
  9290. * @param defines The generated defines for the effect
  9291. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. private static _tempFogColor;
  9297. /**
  9298. * Binds the fog information from the scene to the effect for the given mesh.
  9299. * @param scene The scene the lights belongs to
  9300. * @param mesh The mesh we are binding the information to render
  9301. * @param effect The effect we are binding the data to
  9302. * @param linearSpace Defines if the fog effect is applied in linear space
  9303. */
  9304. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9305. /**
  9306. * Binds the bones information from the mesh to the effect.
  9307. * @param mesh The mesh we are binding the information to render
  9308. * @param effect The effect we are binding the data to
  9309. */
  9310. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9311. /**
  9312. * Binds the morph targets information from the mesh to the effect.
  9313. * @param abstractMesh The mesh we are binding the information to render
  9314. * @param effect The effect we are binding the data to
  9315. */
  9316. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9317. /**
  9318. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9319. * @param defines The generated defines used in the effect
  9320. * @param effect The effect we are binding the data to
  9321. * @param scene The scene we are willing to render with logarithmic scale for
  9322. */
  9323. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9324. /**
  9325. * Binds the clip plane information from the scene to the effect.
  9326. * @param scene The scene the clip plane information are extracted from
  9327. * @param effect The effect we are binding the data to
  9328. */
  9329. static BindClipPlane(effect: Effect, scene: Scene): void;
  9330. }
  9331. }
  9332. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9333. /** @hidden */
  9334. export var packingFunctions: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9340. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9341. /** @hidden */
  9342. export var shadowMapPixelShader: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9348. /** @hidden */
  9349. export var bonesDeclaration: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9355. /** @hidden */
  9356. export var morphTargetsVertexGlobalDeclaration: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9362. /** @hidden */
  9363. export var morphTargetsVertexDeclaration: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9369. /** @hidden */
  9370. export var instancesDeclaration: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9376. /** @hidden */
  9377. export var helperFunctions: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9383. /** @hidden */
  9384. export var morphTargetsVertex: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9390. /** @hidden */
  9391. export var instancesVertex: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9397. /** @hidden */
  9398. export var bonesVertex: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9404. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9405. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9406. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9407. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9408. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9410. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9411. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9412. /** @hidden */
  9413. export var shadowMapVertexShader: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9419. /** @hidden */
  9420. export var depthBoxBlurPixelShader: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9426. import { Nullable } from "babylonjs/types";
  9427. import { Scene } from "babylonjs/scene";
  9428. import { Matrix } from "babylonjs/Maths/math.vector";
  9429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9431. import { Mesh } from "babylonjs/Meshes/mesh";
  9432. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9433. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9434. import { Effect } from "babylonjs/Materials/effect";
  9435. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9436. import "babylonjs/Shaders/shadowMap.fragment";
  9437. import "babylonjs/Shaders/shadowMap.vertex";
  9438. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9439. import { Observable } from "babylonjs/Misc/observable";
  9440. /**
  9441. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9442. */
  9443. export interface ICustomShaderOptions {
  9444. /**
  9445. * Gets or sets the custom shader name to use
  9446. */
  9447. shaderName: string;
  9448. /**
  9449. * The list of attribute names used in the shader
  9450. */
  9451. attributes?: string[];
  9452. /**
  9453. * The list of unifrom names used in the shader
  9454. */
  9455. uniforms?: string[];
  9456. /**
  9457. * The list of sampler names used in the shader
  9458. */
  9459. samplers?: string[];
  9460. /**
  9461. * The list of defines used in the shader
  9462. */
  9463. defines?: string[];
  9464. }
  9465. /**
  9466. * Interface to implement to create a shadow generator compatible with BJS.
  9467. */
  9468. export interface IShadowGenerator {
  9469. /**
  9470. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9471. * @returns The render target texture if present otherwise, null
  9472. */
  9473. getShadowMap(): Nullable<RenderTargetTexture>;
  9474. /**
  9475. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9476. * @returns The render target texture if the shadow map is present otherwise, null
  9477. */
  9478. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9479. /**
  9480. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9481. * @param subMesh The submesh we want to render in the shadow map
  9482. * @param useInstances Defines wether will draw in the map using instances
  9483. * @returns true if ready otherwise, false
  9484. */
  9485. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9486. /**
  9487. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9488. * @param defines Defines of the material we want to update
  9489. * @param lightIndex Index of the light in the enabled light list of the material
  9490. */
  9491. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9492. /**
  9493. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9494. * defined in the generator but impacting the effect).
  9495. * It implies the unifroms available on the materials are the standard BJS ones.
  9496. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9497. * @param effect The effect we are binfing the information for
  9498. */
  9499. bindShadowLight(lightIndex: string, effect: Effect): void;
  9500. /**
  9501. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9502. * (eq to shadow prjection matrix * light transform matrix)
  9503. * @returns The transform matrix used to create the shadow map
  9504. */
  9505. getTransformMatrix(): Matrix;
  9506. /**
  9507. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9508. * Cube and 2D textures for instance.
  9509. */
  9510. recreateShadowMap(): void;
  9511. /**
  9512. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9513. * @param onCompiled Callback triggered at the and of the effects compilation
  9514. * @param options Sets of optional options forcing the compilation with different modes
  9515. */
  9516. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9517. useInstances: boolean;
  9518. }>): void;
  9519. /**
  9520. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9521. * @param options Sets of optional options forcing the compilation with different modes
  9522. * @returns A promise that resolves when the compilation completes
  9523. */
  9524. forceCompilationAsync(options?: Partial<{
  9525. useInstances: boolean;
  9526. }>): Promise<void>;
  9527. /**
  9528. * Serializes the shadow generator setup to a json object.
  9529. * @returns The serialized JSON object
  9530. */
  9531. serialize(): any;
  9532. /**
  9533. * Disposes the Shadow map and related Textures and effects.
  9534. */
  9535. dispose(): void;
  9536. }
  9537. /**
  9538. * Default implementation IShadowGenerator.
  9539. * This is the main object responsible of generating shadows in the framework.
  9540. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9541. */
  9542. export class ShadowGenerator implements IShadowGenerator {
  9543. /**
  9544. * Shadow generator mode None: no filtering applied.
  9545. */
  9546. static readonly FILTER_NONE: number;
  9547. /**
  9548. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9549. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9550. */
  9551. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9552. /**
  9553. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9554. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9555. */
  9556. static readonly FILTER_POISSONSAMPLING: number;
  9557. /**
  9558. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9559. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9560. */
  9561. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9562. /**
  9563. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9564. * edge artifacts on steep falloff.
  9565. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9566. */
  9567. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9570. * edge artifacts on steep falloff.
  9571. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9572. */
  9573. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9574. /**
  9575. * Shadow generator mode PCF: Percentage Closer Filtering
  9576. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9577. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9578. */
  9579. static readonly FILTER_PCF: number;
  9580. /**
  9581. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9582. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9583. * Contact Hardening
  9584. */
  9585. static readonly FILTER_PCSS: number;
  9586. /**
  9587. * Reserved for PCF and PCSS
  9588. * Highest Quality.
  9589. *
  9590. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9591. *
  9592. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9593. */
  9594. static readonly QUALITY_HIGH: number;
  9595. /**
  9596. * Reserved for PCF and PCSS
  9597. * Good tradeoff for quality/perf cross devices
  9598. *
  9599. * Execute PCF on a 3*3 kernel.
  9600. *
  9601. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9602. */
  9603. static readonly QUALITY_MEDIUM: number;
  9604. /**
  9605. * Reserved for PCF and PCSS
  9606. * The lowest quality but the fastest.
  9607. *
  9608. * Execute PCF on a 1*1 kernel.
  9609. *
  9610. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9611. */
  9612. static readonly QUALITY_LOW: number;
  9613. /** Gets or sets the custom shader name to use */
  9614. customShaderOptions: ICustomShaderOptions;
  9615. /**
  9616. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9617. */
  9618. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9619. /**
  9620. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9621. */
  9622. onAfterShadowMapRenderObservable: Observable<Effect>;
  9623. /**
  9624. * Observable triggered before a mesh is rendered in the shadow map.
  9625. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9626. */
  9627. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9628. /**
  9629. * Observable triggered after a mesh is rendered in the shadow map.
  9630. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9631. */
  9632. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9633. private _bias;
  9634. /**
  9635. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9636. */
  9637. /**
  9638. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9639. */
  9640. bias: number;
  9641. private _normalBias;
  9642. /**
  9643. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9644. */
  9645. /**
  9646. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9647. */
  9648. normalBias: number;
  9649. private _blurBoxOffset;
  9650. /**
  9651. * Gets the blur box offset: offset applied during the blur pass.
  9652. * Only useful if useKernelBlur = false
  9653. */
  9654. /**
  9655. * Sets the blur box offset: offset applied during the blur pass.
  9656. * Only useful if useKernelBlur = false
  9657. */
  9658. blurBoxOffset: number;
  9659. private _blurScale;
  9660. /**
  9661. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9662. * 2 means half of the size.
  9663. */
  9664. /**
  9665. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9666. * 2 means half of the size.
  9667. */
  9668. blurScale: number;
  9669. private _blurKernel;
  9670. /**
  9671. * Gets the blur kernel: kernel size of the blur pass.
  9672. * Only useful if useKernelBlur = true
  9673. */
  9674. /**
  9675. * Sets the blur kernel: kernel size of the blur pass.
  9676. * Only useful if useKernelBlur = true
  9677. */
  9678. blurKernel: number;
  9679. private _useKernelBlur;
  9680. /**
  9681. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9682. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9683. */
  9684. /**
  9685. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9686. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9687. */
  9688. useKernelBlur: boolean;
  9689. private _depthScale;
  9690. /**
  9691. * Gets the depth scale used in ESM mode.
  9692. */
  9693. /**
  9694. * Sets the depth scale used in ESM mode.
  9695. * This can override the scale stored on the light.
  9696. */
  9697. depthScale: number;
  9698. private _filter;
  9699. /**
  9700. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9701. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9702. */
  9703. /**
  9704. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9705. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9706. */
  9707. filter: number;
  9708. /**
  9709. * Gets if the current filter is set to Poisson Sampling.
  9710. */
  9711. /**
  9712. * Sets the current filter to Poisson Sampling.
  9713. */
  9714. usePoissonSampling: boolean;
  9715. /**
  9716. * Gets if the current filter is set to ESM.
  9717. */
  9718. /**
  9719. * Sets the current filter is to ESM.
  9720. */
  9721. useExponentialShadowMap: boolean;
  9722. /**
  9723. * Gets if the current filter is set to filtered ESM.
  9724. */
  9725. /**
  9726. * Gets if the current filter is set to filtered ESM.
  9727. */
  9728. useBlurExponentialShadowMap: boolean;
  9729. /**
  9730. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9731. * exponential to prevent steep falloff artifacts).
  9732. */
  9733. /**
  9734. * Sets the current filter to "close ESM" (using the inverse of the
  9735. * exponential to prevent steep falloff artifacts).
  9736. */
  9737. useCloseExponentialShadowMap: boolean;
  9738. /**
  9739. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9740. * exponential to prevent steep falloff artifacts).
  9741. */
  9742. /**
  9743. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9744. * exponential to prevent steep falloff artifacts).
  9745. */
  9746. useBlurCloseExponentialShadowMap: boolean;
  9747. /**
  9748. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9749. */
  9750. /**
  9751. * Sets the current filter to "PCF" (percentage closer filtering).
  9752. */
  9753. usePercentageCloserFiltering: boolean;
  9754. private _filteringQuality;
  9755. /**
  9756. * Gets the PCF or PCSS Quality.
  9757. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9758. */
  9759. /**
  9760. * Sets the PCF or PCSS Quality.
  9761. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9762. */
  9763. filteringQuality: number;
  9764. /**
  9765. * Gets if the current filter is set to "PCSS" (contact hardening).
  9766. */
  9767. /**
  9768. * Sets the current filter to "PCSS" (contact hardening).
  9769. */
  9770. useContactHardeningShadow: boolean;
  9771. private _contactHardeningLightSizeUVRatio;
  9772. /**
  9773. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9774. * Using a ratio helps keeping shape stability independently of the map size.
  9775. *
  9776. * It does not account for the light projection as it was having too much
  9777. * instability during the light setup or during light position changes.
  9778. *
  9779. * Only valid if useContactHardeningShadow is true.
  9780. */
  9781. /**
  9782. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9783. * Using a ratio helps keeping shape stability independently of the map size.
  9784. *
  9785. * It does not account for the light projection as it was having too much
  9786. * instability during the light setup or during light position changes.
  9787. *
  9788. * Only valid if useContactHardeningShadow is true.
  9789. */
  9790. contactHardeningLightSizeUVRatio: number;
  9791. private _darkness;
  9792. /** Gets or sets the actual darkness of a shadow */
  9793. darkness: number;
  9794. /**
  9795. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9796. * 0 means strongest and 1 would means no shadow.
  9797. * @returns the darkness.
  9798. */
  9799. getDarkness(): number;
  9800. /**
  9801. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9802. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9803. * @returns the shadow generator allowing fluent coding.
  9804. */
  9805. setDarkness(darkness: number): ShadowGenerator;
  9806. private _transparencyShadow;
  9807. /** Gets or sets the ability to have transparent shadow */
  9808. transparencyShadow: boolean;
  9809. /**
  9810. * Sets the ability to have transparent shadow (boolean).
  9811. * @param transparent True if transparent else False
  9812. * @returns the shadow generator allowing fluent coding
  9813. */
  9814. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9815. private _shadowMap;
  9816. private _shadowMap2;
  9817. /**
  9818. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9819. * @returns The render target texture if present otherwise, null
  9820. */
  9821. getShadowMap(): Nullable<RenderTargetTexture>;
  9822. /**
  9823. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9824. * @returns The render target texture if the shadow map is present otherwise, null
  9825. */
  9826. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9827. /**
  9828. * Gets the class name of that object
  9829. * @returns "ShadowGenerator"
  9830. */
  9831. getClassName(): string;
  9832. /**
  9833. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9834. * @param mesh Mesh to add
  9835. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9836. * @returns the Shadow Generator itself
  9837. */
  9838. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9839. /**
  9840. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9841. * @param mesh Mesh to remove
  9842. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9843. * @returns the Shadow Generator itself
  9844. */
  9845. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9846. /**
  9847. * Controls the extent to which the shadows fade out at the edge of the frustum
  9848. * Used only by directionals and spots
  9849. */
  9850. frustumEdgeFalloff: number;
  9851. private _light;
  9852. /**
  9853. * Returns the associated light object.
  9854. * @returns the light generating the shadow
  9855. */
  9856. getLight(): IShadowLight;
  9857. /**
  9858. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9859. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9860. * It might on the other hand introduce peter panning.
  9861. */
  9862. forceBackFacesOnly: boolean;
  9863. private _scene;
  9864. private _lightDirection;
  9865. private _effect;
  9866. private _viewMatrix;
  9867. private _projectionMatrix;
  9868. private _transformMatrix;
  9869. private _cachedPosition;
  9870. private _cachedDirection;
  9871. private _cachedDefines;
  9872. private _currentRenderID;
  9873. private _boxBlurPostprocess;
  9874. private _kernelBlurXPostprocess;
  9875. private _kernelBlurYPostprocess;
  9876. private _blurPostProcesses;
  9877. private _mapSize;
  9878. private _currentFaceIndex;
  9879. private _currentFaceIndexCache;
  9880. private _textureType;
  9881. private _defaultTextureMatrix;
  9882. private _storedUniqueId;
  9883. /** @hidden */
  9884. static _SceneComponentInitialization: (scene: Scene) => void;
  9885. /**
  9886. * Creates a ShadowGenerator object.
  9887. * A ShadowGenerator is the required tool to use the shadows.
  9888. * Each light casting shadows needs to use its own ShadowGenerator.
  9889. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9890. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9891. * @param light The light object generating the shadows.
  9892. * @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.
  9893. */
  9894. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9895. private _initializeGenerator;
  9896. private _initializeShadowMap;
  9897. private _initializeBlurRTTAndPostProcesses;
  9898. private _renderForShadowMap;
  9899. private _renderSubMeshForShadowMap;
  9900. private _applyFilterValues;
  9901. /**
  9902. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9903. * @param onCompiled Callback triggered at the and of the effects compilation
  9904. * @param options Sets of optional options forcing the compilation with different modes
  9905. */
  9906. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9907. useInstances: boolean;
  9908. }>): void;
  9909. /**
  9910. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9911. * @param options Sets of optional options forcing the compilation with different modes
  9912. * @returns A promise that resolves when the compilation completes
  9913. */
  9914. forceCompilationAsync(options?: Partial<{
  9915. useInstances: boolean;
  9916. }>): Promise<void>;
  9917. /**
  9918. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9919. * @param subMesh The submesh we want to render in the shadow map
  9920. * @param useInstances Defines wether will draw in the map using instances
  9921. * @returns true if ready otherwise, false
  9922. */
  9923. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9924. /**
  9925. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9926. * @param defines Defines of the material we want to update
  9927. * @param lightIndex Index of the light in the enabled light list of the material
  9928. */
  9929. prepareDefines(defines: any, lightIndex: number): void;
  9930. /**
  9931. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9932. * defined in the generator but impacting the effect).
  9933. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9934. * @param effect The effect we are binfing the information for
  9935. */
  9936. bindShadowLight(lightIndex: string, effect: Effect): void;
  9937. /**
  9938. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9939. * (eq to shadow prjection matrix * light transform matrix)
  9940. * @returns The transform matrix used to create the shadow map
  9941. */
  9942. getTransformMatrix(): Matrix;
  9943. /**
  9944. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9945. * Cube and 2D textures for instance.
  9946. */
  9947. recreateShadowMap(): void;
  9948. private _disposeBlurPostProcesses;
  9949. private _disposeRTTandPostProcesses;
  9950. /**
  9951. * Disposes the ShadowGenerator.
  9952. * Returns nothing.
  9953. */
  9954. dispose(): void;
  9955. /**
  9956. * Serializes the shadow generator setup to a json object.
  9957. * @returns The serialized JSON object
  9958. */
  9959. serialize(): any;
  9960. /**
  9961. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9962. * @param parsedShadowGenerator The JSON object to parse
  9963. * @param scene The scene to create the shadow map for
  9964. * @returns The parsed shadow generator
  9965. */
  9966. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9967. }
  9968. }
  9969. declare module "babylonjs/Lights/light" {
  9970. import { Nullable } from "babylonjs/types";
  9971. import { Scene } from "babylonjs/scene";
  9972. import { Vector3 } from "babylonjs/Maths/math.vector";
  9973. import { Color3 } from "babylonjs/Maths/math.color";
  9974. import { Node } from "babylonjs/node";
  9975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9976. import { Effect } from "babylonjs/Materials/effect";
  9977. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9978. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9979. /**
  9980. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9981. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9982. * 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.
  9983. */
  9984. export abstract class Light extends Node {
  9985. /**
  9986. * Falloff Default: light is falling off following the material specification:
  9987. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9988. */
  9989. static readonly FALLOFF_DEFAULT: number;
  9990. /**
  9991. * Falloff Physical: light is falling off following the inverse squared distance law.
  9992. */
  9993. static readonly FALLOFF_PHYSICAL: number;
  9994. /**
  9995. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9996. * to enhance interoperability with other engines.
  9997. */
  9998. static readonly FALLOFF_GLTF: number;
  9999. /**
  10000. * Falloff Standard: light is falling off like in the standard material
  10001. * to enhance interoperability with other materials.
  10002. */
  10003. static readonly FALLOFF_STANDARD: number;
  10004. /**
  10005. * If every light affecting the material is in this lightmapMode,
  10006. * material.lightmapTexture adds or multiplies
  10007. * (depends on material.useLightmapAsShadowmap)
  10008. * after every other light calculations.
  10009. */
  10010. static readonly LIGHTMAP_DEFAULT: number;
  10011. /**
  10012. * material.lightmapTexture as only diffuse lighting from this light
  10013. * adds only specular lighting from this light
  10014. * adds dynamic shadows
  10015. */
  10016. static readonly LIGHTMAP_SPECULAR: number;
  10017. /**
  10018. * material.lightmapTexture as only lighting
  10019. * no light calculation from this light
  10020. * only adds dynamic shadows from this light
  10021. */
  10022. static readonly LIGHTMAP_SHADOWSONLY: number;
  10023. /**
  10024. * Each light type uses the default quantity according to its type:
  10025. * point/spot lights use luminous intensity
  10026. * directional lights use illuminance
  10027. */
  10028. static readonly INTENSITYMODE_AUTOMATIC: number;
  10029. /**
  10030. * lumen (lm)
  10031. */
  10032. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10033. /**
  10034. * candela (lm/sr)
  10035. */
  10036. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10037. /**
  10038. * lux (lm/m^2)
  10039. */
  10040. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10041. /**
  10042. * nit (cd/m^2)
  10043. */
  10044. static readonly INTENSITYMODE_LUMINANCE: number;
  10045. /**
  10046. * Light type const id of the point light.
  10047. */
  10048. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10049. /**
  10050. * Light type const id of the directional light.
  10051. */
  10052. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10053. /**
  10054. * Light type const id of the spot light.
  10055. */
  10056. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10057. /**
  10058. * Light type const id of the hemispheric light.
  10059. */
  10060. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10061. /**
  10062. * Diffuse gives the basic color to an object.
  10063. */
  10064. diffuse: Color3;
  10065. /**
  10066. * Specular produces a highlight color on an object.
  10067. * Note: This is note affecting PBR materials.
  10068. */
  10069. specular: Color3;
  10070. /**
  10071. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10072. * falling off base on range or angle.
  10073. * This can be set to any values in Light.FALLOFF_x.
  10074. *
  10075. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10076. * other types of materials.
  10077. */
  10078. falloffType: number;
  10079. /**
  10080. * Strength of the light.
  10081. * Note: By default it is define in the framework own unit.
  10082. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10083. */
  10084. intensity: number;
  10085. private _range;
  10086. protected _inverseSquaredRange: number;
  10087. /**
  10088. * Defines how far from the source the light is impacting in scene units.
  10089. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10090. */
  10091. /**
  10092. * Defines how far from the source the light is impacting in scene units.
  10093. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10094. */
  10095. range: number;
  10096. /**
  10097. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10098. * of light.
  10099. */
  10100. private _photometricScale;
  10101. private _intensityMode;
  10102. /**
  10103. * Gets the photometric scale used to interpret the intensity.
  10104. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10105. */
  10106. /**
  10107. * Sets the photometric scale used to interpret the intensity.
  10108. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10109. */
  10110. intensityMode: number;
  10111. private _radius;
  10112. /**
  10113. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10114. */
  10115. /**
  10116. * sets the light radius used by PBR Materials to simulate soft area lights.
  10117. */
  10118. radius: number;
  10119. private _renderPriority;
  10120. /**
  10121. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10122. * exceeding the number allowed of the materials.
  10123. */
  10124. renderPriority: number;
  10125. private _shadowEnabled;
  10126. /**
  10127. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10128. * the current shadow generator.
  10129. */
  10130. /**
  10131. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10132. * the current shadow generator.
  10133. */
  10134. shadowEnabled: boolean;
  10135. private _includedOnlyMeshes;
  10136. /**
  10137. * Gets the only meshes impacted by this light.
  10138. */
  10139. /**
  10140. * Sets the only meshes impacted by this light.
  10141. */
  10142. includedOnlyMeshes: AbstractMesh[];
  10143. private _excludedMeshes;
  10144. /**
  10145. * Gets the meshes not impacted by this light.
  10146. */
  10147. /**
  10148. * Sets the meshes not impacted by this light.
  10149. */
  10150. excludedMeshes: AbstractMesh[];
  10151. private _excludeWithLayerMask;
  10152. /**
  10153. * Gets the layer id use to find what meshes are not impacted by the light.
  10154. * Inactive if 0
  10155. */
  10156. /**
  10157. * Sets the layer id use to find what meshes are not impacted by the light.
  10158. * Inactive if 0
  10159. */
  10160. excludeWithLayerMask: number;
  10161. private _includeOnlyWithLayerMask;
  10162. /**
  10163. * Gets the layer id use to find what meshes are impacted by the light.
  10164. * Inactive if 0
  10165. */
  10166. /**
  10167. * Sets the layer id use to find what meshes are impacted by the light.
  10168. * Inactive if 0
  10169. */
  10170. includeOnlyWithLayerMask: number;
  10171. private _lightmapMode;
  10172. /**
  10173. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10174. */
  10175. /**
  10176. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10177. */
  10178. lightmapMode: number;
  10179. /**
  10180. * Shadow generator associted to the light.
  10181. * @hidden Internal use only.
  10182. */
  10183. _shadowGenerator: Nullable<IShadowGenerator>;
  10184. /**
  10185. * @hidden Internal use only.
  10186. */
  10187. _excludedMeshesIds: string[];
  10188. /**
  10189. * @hidden Internal use only.
  10190. */
  10191. _includedOnlyMeshesIds: string[];
  10192. /**
  10193. * The current light unifom buffer.
  10194. * @hidden Internal use only.
  10195. */
  10196. _uniformBuffer: UniformBuffer;
  10197. /**
  10198. * Creates a Light object in the scene.
  10199. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10200. * @param name The firendly name of the light
  10201. * @param scene The scene the light belongs too
  10202. */
  10203. constructor(name: string, scene: Scene);
  10204. protected abstract _buildUniformLayout(): void;
  10205. /**
  10206. * Sets the passed Effect "effect" with the Light information.
  10207. * @param effect The effect to update
  10208. * @param lightIndex The index of the light in the effect to update
  10209. * @returns The light
  10210. */
  10211. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10212. /**
  10213. * Sets the passed Effect "effect" with the Light information.
  10214. * @param effect The effect to update
  10215. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10216. * @returns The light
  10217. */
  10218. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10219. /**
  10220. * Returns the string "Light".
  10221. * @returns the class name
  10222. */
  10223. getClassName(): string;
  10224. /** @hidden */
  10225. readonly _isLight: boolean;
  10226. /**
  10227. * Converts the light information to a readable string for debug purpose.
  10228. * @param fullDetails Supports for multiple levels of logging within scene loading
  10229. * @returns the human readable light info
  10230. */
  10231. toString(fullDetails?: boolean): string;
  10232. /** @hidden */
  10233. protected _syncParentEnabledState(): void;
  10234. /**
  10235. * Set the enabled state of this node.
  10236. * @param value - the new enabled state
  10237. */
  10238. setEnabled(value: boolean): void;
  10239. /**
  10240. * Returns the Light associated shadow generator if any.
  10241. * @return the associated shadow generator.
  10242. */
  10243. getShadowGenerator(): Nullable<IShadowGenerator>;
  10244. /**
  10245. * Returns a Vector3, the absolute light position in the World.
  10246. * @returns the world space position of the light
  10247. */
  10248. getAbsolutePosition(): Vector3;
  10249. /**
  10250. * Specifies if the light will affect the passed mesh.
  10251. * @param mesh The mesh to test against the light
  10252. * @return true the mesh is affected otherwise, false.
  10253. */
  10254. canAffectMesh(mesh: AbstractMesh): boolean;
  10255. /**
  10256. * Sort function to order lights for rendering.
  10257. * @param a First Light object to compare to second.
  10258. * @param b Second Light object to compare first.
  10259. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10260. */
  10261. static CompareLightsPriority(a: Light, b: Light): number;
  10262. /**
  10263. * Releases resources associated with this node.
  10264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10266. */
  10267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10268. /**
  10269. * Returns the light type ID (integer).
  10270. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10271. */
  10272. getTypeID(): number;
  10273. /**
  10274. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10275. * @returns the scaled intensity in intensity mode unit
  10276. */
  10277. getScaledIntensity(): number;
  10278. /**
  10279. * Returns a new Light object, named "name", from the current one.
  10280. * @param name The name of the cloned light
  10281. * @returns the new created light
  10282. */
  10283. clone(name: string): Nullable<Light>;
  10284. /**
  10285. * Serializes the current light into a Serialization object.
  10286. * @returns the serialized object.
  10287. */
  10288. serialize(): any;
  10289. /**
  10290. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10291. * This new light is named "name" and added to the passed scene.
  10292. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10293. * @param name The friendly name of the light
  10294. * @param scene The scene the new light will belong to
  10295. * @returns the constructor function
  10296. */
  10297. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10298. /**
  10299. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10300. * @param parsedLight The JSON representation of the light
  10301. * @param scene The scene to create the parsed light in
  10302. * @returns the created light after parsing
  10303. */
  10304. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10305. private _hookArrayForExcluded;
  10306. private _hookArrayForIncludedOnly;
  10307. private _resyncMeshes;
  10308. /**
  10309. * Forces the meshes to update their light related information in their rendering used effects
  10310. * @hidden Internal Use Only
  10311. */
  10312. _markMeshesAsLightDirty(): void;
  10313. /**
  10314. * Recomputes the cached photometric scale if needed.
  10315. */
  10316. private _computePhotometricScale;
  10317. /**
  10318. * Returns the Photometric Scale according to the light type and intensity mode.
  10319. */
  10320. private _getPhotometricScale;
  10321. /**
  10322. * Reorder the light in the scene according to their defined priority.
  10323. * @hidden Internal Use Only
  10324. */
  10325. _reorderLightsInScene(): void;
  10326. /**
  10327. * Prepares the list of defines specific to the light type.
  10328. * @param defines the list of defines
  10329. * @param lightIndex defines the index of the light for the effect
  10330. */
  10331. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10332. }
  10333. }
  10334. declare module "babylonjs/Actions/action" {
  10335. import { Observable } from "babylonjs/Misc/observable";
  10336. import { Condition } from "babylonjs/Actions/condition";
  10337. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10338. import { ActionManager } from "babylonjs/Actions/actionManager";
  10339. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10340. /**
  10341. * Interface used to define Action
  10342. */
  10343. export interface IAction {
  10344. /**
  10345. * Trigger for the action
  10346. */
  10347. trigger: number;
  10348. /** Options of the trigger */
  10349. triggerOptions: any;
  10350. /**
  10351. * Gets the trigger parameters
  10352. * @returns the trigger parameters
  10353. */
  10354. getTriggerParameter(): any;
  10355. /**
  10356. * Internal only - executes current action event
  10357. * @hidden
  10358. */
  10359. _executeCurrent(evt?: ActionEvent): void;
  10360. /**
  10361. * Serialize placeholder for child classes
  10362. * @param parent of child
  10363. * @returns the serialized object
  10364. */
  10365. serialize(parent: any): any;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. _prepare(): void;
  10371. /**
  10372. * Internal only - manager for action
  10373. * @hidden
  10374. */
  10375. _actionManager: AbstractActionManager;
  10376. /**
  10377. * Adds action to chain of actions, may be a DoNothingAction
  10378. * @param action defines the next action to execute
  10379. * @returns The action passed in
  10380. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10381. */
  10382. then(action: IAction): IAction;
  10383. }
  10384. /**
  10385. * The action to be carried out following a trigger
  10386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10387. */
  10388. export class Action implements IAction {
  10389. /** the trigger, with or without parameters, for the action */
  10390. triggerOptions: any;
  10391. /**
  10392. * Trigger for the action
  10393. */
  10394. trigger: number;
  10395. /**
  10396. * Internal only - manager for action
  10397. * @hidden
  10398. */
  10399. _actionManager: ActionManager;
  10400. private _nextActiveAction;
  10401. private _child;
  10402. private _condition?;
  10403. private _triggerParameter;
  10404. /**
  10405. * An event triggered prior to action being executed.
  10406. */
  10407. onBeforeExecuteObservable: Observable<Action>;
  10408. /**
  10409. * Creates a new Action
  10410. * @param triggerOptions the trigger, with or without parameters, for the action
  10411. * @param condition an optional determinant of action
  10412. */
  10413. constructor(
  10414. /** the trigger, with or without parameters, for the action */
  10415. triggerOptions: any, condition?: Condition);
  10416. /**
  10417. * Internal only
  10418. * @hidden
  10419. */
  10420. _prepare(): void;
  10421. /**
  10422. * Gets the trigger parameters
  10423. * @returns the trigger parameters
  10424. */
  10425. getTriggerParameter(): any;
  10426. /**
  10427. * Internal only - executes current action event
  10428. * @hidden
  10429. */
  10430. _executeCurrent(evt?: ActionEvent): void;
  10431. /**
  10432. * Execute placeholder for child classes
  10433. * @param evt optional action event
  10434. */
  10435. execute(evt?: ActionEvent): void;
  10436. /**
  10437. * Skips to next active action
  10438. */
  10439. skipToNextActiveAction(): void;
  10440. /**
  10441. * Adds action to chain of actions, may be a DoNothingAction
  10442. * @param action defines the next action to execute
  10443. * @returns The action passed in
  10444. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10445. */
  10446. then(action: Action): Action;
  10447. /**
  10448. * Internal only
  10449. * @hidden
  10450. */
  10451. _getProperty(propertyPath: string): string;
  10452. /**
  10453. * Internal only
  10454. * @hidden
  10455. */
  10456. _getEffectiveTarget(target: any, propertyPath: string): any;
  10457. /**
  10458. * Serialize placeholder for child classes
  10459. * @param parent of child
  10460. * @returns the serialized object
  10461. */
  10462. serialize(parent: any): any;
  10463. /**
  10464. * Internal only called by serialize
  10465. * @hidden
  10466. */
  10467. protected _serialize(serializedAction: any, parent?: any): any;
  10468. /**
  10469. * Internal only
  10470. * @hidden
  10471. */
  10472. static _SerializeValueAsString: (value: any) => string;
  10473. /**
  10474. * Internal only
  10475. * @hidden
  10476. */
  10477. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10478. name: string;
  10479. targetType: string;
  10480. value: string;
  10481. };
  10482. }
  10483. }
  10484. declare module "babylonjs/Actions/condition" {
  10485. import { ActionManager } from "babylonjs/Actions/actionManager";
  10486. /**
  10487. * A Condition applied to an Action
  10488. */
  10489. export class Condition {
  10490. /**
  10491. * Internal only - manager for action
  10492. * @hidden
  10493. */
  10494. _actionManager: ActionManager;
  10495. /**
  10496. * Internal only
  10497. * @hidden
  10498. */
  10499. _evaluationId: number;
  10500. /**
  10501. * Internal only
  10502. * @hidden
  10503. */
  10504. _currentResult: boolean;
  10505. /**
  10506. * Creates a new Condition
  10507. * @param actionManager the manager of the action the condition is applied to
  10508. */
  10509. constructor(actionManager: ActionManager);
  10510. /**
  10511. * Check if the current condition is valid
  10512. * @returns a boolean
  10513. */
  10514. isValid(): boolean;
  10515. /**
  10516. * Internal only
  10517. * @hidden
  10518. */
  10519. _getProperty(propertyPath: string): string;
  10520. /**
  10521. * Internal only
  10522. * @hidden
  10523. */
  10524. _getEffectiveTarget(target: any, propertyPath: string): any;
  10525. /**
  10526. * Serialize placeholder for child classes
  10527. * @returns the serialized object
  10528. */
  10529. serialize(): any;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. protected _serialize(serializedCondition: any): any;
  10535. }
  10536. /**
  10537. * Defines specific conditional operators as extensions of Condition
  10538. */
  10539. export class ValueCondition extends Condition {
  10540. /** path to specify the property of the target the conditional operator uses */
  10541. propertyPath: string;
  10542. /** the value compared by the conditional operator against the current value of the property */
  10543. value: any;
  10544. /** the conditional operator, default ValueCondition.IsEqual */
  10545. operator: number;
  10546. /**
  10547. * Internal only
  10548. * @hidden
  10549. */
  10550. private static _IsEqual;
  10551. /**
  10552. * Internal only
  10553. * @hidden
  10554. */
  10555. private static _IsDifferent;
  10556. /**
  10557. * Internal only
  10558. * @hidden
  10559. */
  10560. private static _IsGreater;
  10561. /**
  10562. * Internal only
  10563. * @hidden
  10564. */
  10565. private static _IsLesser;
  10566. /**
  10567. * returns the number for IsEqual
  10568. */
  10569. static readonly IsEqual: number;
  10570. /**
  10571. * Returns the number for IsDifferent
  10572. */
  10573. static readonly IsDifferent: number;
  10574. /**
  10575. * Returns the number for IsGreater
  10576. */
  10577. static readonly IsGreater: number;
  10578. /**
  10579. * Returns the number for IsLesser
  10580. */
  10581. static readonly IsLesser: number;
  10582. /**
  10583. * Internal only The action manager for the condition
  10584. * @hidden
  10585. */
  10586. _actionManager: ActionManager;
  10587. /**
  10588. * Internal only
  10589. * @hidden
  10590. */
  10591. private _target;
  10592. /**
  10593. * Internal only
  10594. * @hidden
  10595. */
  10596. private _effectiveTarget;
  10597. /**
  10598. * Internal only
  10599. * @hidden
  10600. */
  10601. private _property;
  10602. /**
  10603. * Creates a new ValueCondition
  10604. * @param actionManager manager for the action the condition applies to
  10605. * @param target for the action
  10606. * @param propertyPath path to specify the property of the target the conditional operator uses
  10607. * @param value the value compared by the conditional operator against the current value of the property
  10608. * @param operator the conditional operator, default ValueCondition.IsEqual
  10609. */
  10610. constructor(actionManager: ActionManager, target: any,
  10611. /** path to specify the property of the target the conditional operator uses */
  10612. propertyPath: string,
  10613. /** the value compared by the conditional operator against the current value of the property */
  10614. value: any,
  10615. /** the conditional operator, default ValueCondition.IsEqual */
  10616. operator?: number);
  10617. /**
  10618. * Compares the given value with the property value for the specified conditional operator
  10619. * @returns the result of the comparison
  10620. */
  10621. isValid(): boolean;
  10622. /**
  10623. * Serialize the ValueCondition into a JSON compatible object
  10624. * @returns serialization object
  10625. */
  10626. serialize(): any;
  10627. /**
  10628. * Gets the name of the conditional operator for the ValueCondition
  10629. * @param operator the conditional operator
  10630. * @returns the name
  10631. */
  10632. static GetOperatorName(operator: number): string;
  10633. }
  10634. /**
  10635. * Defines a predicate condition as an extension of Condition
  10636. */
  10637. export class PredicateCondition extends Condition {
  10638. /** defines the predicate function used to validate the condition */
  10639. predicate: () => boolean;
  10640. /**
  10641. * Internal only - manager for action
  10642. * @hidden
  10643. */
  10644. _actionManager: ActionManager;
  10645. /**
  10646. * Creates a new PredicateCondition
  10647. * @param actionManager manager for the action the condition applies to
  10648. * @param predicate defines the predicate function used to validate the condition
  10649. */
  10650. constructor(actionManager: ActionManager,
  10651. /** defines the predicate function used to validate the condition */
  10652. predicate: () => boolean);
  10653. /**
  10654. * @returns the validity of the predicate condition
  10655. */
  10656. isValid(): boolean;
  10657. }
  10658. /**
  10659. * Defines a state condition as an extension of Condition
  10660. */
  10661. export class StateCondition extends Condition {
  10662. /** Value to compare with target state */
  10663. value: string;
  10664. /**
  10665. * Internal only - manager for action
  10666. * @hidden
  10667. */
  10668. _actionManager: ActionManager;
  10669. /**
  10670. * Internal only
  10671. * @hidden
  10672. */
  10673. private _target;
  10674. /**
  10675. * Creates a new StateCondition
  10676. * @param actionManager manager for the action the condition applies to
  10677. * @param target of the condition
  10678. * @param value to compare with target state
  10679. */
  10680. constructor(actionManager: ActionManager, target: any,
  10681. /** Value to compare with target state */
  10682. value: string);
  10683. /**
  10684. * Gets a boolean indicating if the current condition is met
  10685. * @returns the validity of the state
  10686. */
  10687. isValid(): boolean;
  10688. /**
  10689. * Serialize the StateCondition into a JSON compatible object
  10690. * @returns serialization object
  10691. */
  10692. serialize(): any;
  10693. }
  10694. }
  10695. declare module "babylonjs/Actions/directActions" {
  10696. import { Action } from "babylonjs/Actions/action";
  10697. import { Condition } from "babylonjs/Actions/condition";
  10698. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10699. /**
  10700. * This defines an action responsible to toggle a boolean once triggered.
  10701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10702. */
  10703. export class SwitchBooleanAction extends Action {
  10704. /**
  10705. * The path to the boolean property in the target object
  10706. */
  10707. propertyPath: string;
  10708. private _target;
  10709. private _effectiveTarget;
  10710. private _property;
  10711. /**
  10712. * Instantiate the action
  10713. * @param triggerOptions defines the trigger options
  10714. * @param target defines the object containing the boolean
  10715. * @param propertyPath defines the path to the boolean property in the target object
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action toggle the boolean value.
  10723. */
  10724. execute(): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to set a the state field of the target
  10734. * to a desired value once triggered.
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10736. */
  10737. export class SetStateAction extends Action {
  10738. /**
  10739. * The value to store in the state field.
  10740. */
  10741. value: string;
  10742. private _target;
  10743. /**
  10744. * Instantiate the action
  10745. * @param triggerOptions defines the trigger options
  10746. * @param target defines the object containing the state property
  10747. * @param value defines the value to store in the state field
  10748. * @param condition defines the trigger related conditions
  10749. */
  10750. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10751. /**
  10752. * Execute the action and store the value on the target state property.
  10753. */
  10754. execute(): void;
  10755. /**
  10756. * Serializes the actions and its related information.
  10757. * @param parent defines the object to serialize in
  10758. * @returns the serialized object
  10759. */
  10760. serialize(parent: any): any;
  10761. }
  10762. /**
  10763. * This defines an action responsible to set a property of the target
  10764. * to a desired value once triggered.
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10766. */
  10767. export class SetValueAction extends Action {
  10768. /**
  10769. * The path of the property to set in the target.
  10770. */
  10771. propertyPath: string;
  10772. /**
  10773. * The value to set in the property
  10774. */
  10775. value: any;
  10776. private _target;
  10777. private _effectiveTarget;
  10778. private _property;
  10779. /**
  10780. * Instantiate the action
  10781. * @param triggerOptions defines the trigger options
  10782. * @param target defines the object containing the property
  10783. * @param propertyPath defines the path of the property to set in the target
  10784. * @param value defines the value to set in the property
  10785. * @param condition defines the trigger related conditions
  10786. */
  10787. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10788. /** @hidden */
  10789. _prepare(): void;
  10790. /**
  10791. * Execute the action and set the targetted property to the desired value.
  10792. */
  10793. execute(): void;
  10794. /**
  10795. * Serializes the actions and its related information.
  10796. * @param parent defines the object to serialize in
  10797. * @returns the serialized object
  10798. */
  10799. serialize(parent: any): any;
  10800. }
  10801. /**
  10802. * This defines an action responsible to increment the target value
  10803. * to a desired value once triggered.
  10804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10805. */
  10806. export class IncrementValueAction extends Action {
  10807. /**
  10808. * The path of the property to increment in the target.
  10809. */
  10810. propertyPath: string;
  10811. /**
  10812. * The value we should increment the property by.
  10813. */
  10814. value: any;
  10815. private _target;
  10816. private _effectiveTarget;
  10817. private _property;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the object containing the property
  10822. * @param propertyPath defines the path of the property to increment in the target
  10823. * @param value defines the value value we should increment the property by
  10824. * @param condition defines the trigger related conditions
  10825. */
  10826. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10827. /** @hidden */
  10828. _prepare(): void;
  10829. /**
  10830. * Execute the action and increment the target of the value amount.
  10831. */
  10832. execute(): void;
  10833. /**
  10834. * Serializes the actions and its related information.
  10835. * @param parent defines the object to serialize in
  10836. * @returns the serialized object
  10837. */
  10838. serialize(parent: any): any;
  10839. }
  10840. /**
  10841. * This defines an action responsible to start an animation once triggered.
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10843. */
  10844. export class PlayAnimationAction extends Action {
  10845. /**
  10846. * Where the animation should start (animation frame)
  10847. */
  10848. from: number;
  10849. /**
  10850. * Where the animation should stop (animation frame)
  10851. */
  10852. to: number;
  10853. /**
  10854. * Define if the animation should loop or stop after the first play.
  10855. */
  10856. loop?: boolean;
  10857. private _target;
  10858. /**
  10859. * Instantiate the action
  10860. * @param triggerOptions defines the trigger options
  10861. * @param target defines the target animation or animation name
  10862. * @param from defines from where the animation should start (animation frame)
  10863. * @param end defines where the animation should stop (animation frame)
  10864. * @param loop defines if the animation should loop or stop after the first play
  10865. * @param condition defines the trigger related conditions
  10866. */
  10867. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10868. /** @hidden */
  10869. _prepare(): void;
  10870. /**
  10871. * Execute the action and play the animation.
  10872. */
  10873. execute(): void;
  10874. /**
  10875. * Serializes the actions and its related information.
  10876. * @param parent defines the object to serialize in
  10877. * @returns the serialized object
  10878. */
  10879. serialize(parent: any): any;
  10880. }
  10881. /**
  10882. * This defines an action responsible to stop an animation once triggered.
  10883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10884. */
  10885. export class StopAnimationAction extends Action {
  10886. private _target;
  10887. /**
  10888. * Instantiate the action
  10889. * @param triggerOptions defines the trigger options
  10890. * @param target defines the target animation or animation name
  10891. * @param condition defines the trigger related conditions
  10892. */
  10893. constructor(triggerOptions: any, target: any, condition?: Condition);
  10894. /** @hidden */
  10895. _prepare(): void;
  10896. /**
  10897. * Execute the action and stop the animation.
  10898. */
  10899. execute(): void;
  10900. /**
  10901. * Serializes the actions and its related information.
  10902. * @param parent defines the object to serialize in
  10903. * @returns the serialized object
  10904. */
  10905. serialize(parent: any): any;
  10906. }
  10907. /**
  10908. * This defines an action responsible that does nothing once triggered.
  10909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10910. */
  10911. export class DoNothingAction extends Action {
  10912. /**
  10913. * Instantiate the action
  10914. * @param triggerOptions defines the trigger options
  10915. * @param condition defines the trigger related conditions
  10916. */
  10917. constructor(triggerOptions?: any, condition?: Condition);
  10918. /**
  10919. * Execute the action and do nothing.
  10920. */
  10921. execute(): void;
  10922. /**
  10923. * Serializes the actions and its related information.
  10924. * @param parent defines the object to serialize in
  10925. * @returns the serialized object
  10926. */
  10927. serialize(parent: any): any;
  10928. }
  10929. /**
  10930. * This defines an action responsible to trigger several actions once triggered.
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10932. */
  10933. export class CombineAction extends Action {
  10934. /**
  10935. * The list of aggregated animations to run.
  10936. */
  10937. children: Action[];
  10938. /**
  10939. * Instantiate the action
  10940. * @param triggerOptions defines the trigger options
  10941. * @param children defines the list of aggregated animations to run
  10942. * @param condition defines the trigger related conditions
  10943. */
  10944. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10945. /** @hidden */
  10946. _prepare(): void;
  10947. /**
  10948. * Execute the action and executes all the aggregated actions.
  10949. */
  10950. execute(evt: ActionEvent): void;
  10951. /**
  10952. * Serializes the actions and its related information.
  10953. * @param parent defines the object to serialize in
  10954. * @returns the serialized object
  10955. */
  10956. serialize(parent: any): any;
  10957. }
  10958. /**
  10959. * This defines an action responsible to run code (external event) once triggered.
  10960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10961. */
  10962. export class ExecuteCodeAction extends Action {
  10963. /**
  10964. * The callback function to run.
  10965. */
  10966. func: (evt: ActionEvent) => void;
  10967. /**
  10968. * Instantiate the action
  10969. * @param triggerOptions defines the trigger options
  10970. * @param func defines the callback function to run
  10971. * @param condition defines the trigger related conditions
  10972. */
  10973. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10974. /**
  10975. * Execute the action and run the attached code.
  10976. */
  10977. execute(evt: ActionEvent): void;
  10978. }
  10979. /**
  10980. * This defines an action responsible to set the parent property of the target once triggered.
  10981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10982. */
  10983. export class SetParentAction extends Action {
  10984. private _parent;
  10985. private _target;
  10986. /**
  10987. * Instantiate the action
  10988. * @param triggerOptions defines the trigger options
  10989. * @param target defines the target containing the parent property
  10990. * @param parent defines from where the animation should start (animation frame)
  10991. * @param condition defines the trigger related conditions
  10992. */
  10993. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10994. /** @hidden */
  10995. _prepare(): void;
  10996. /**
  10997. * Execute the action and set the parent property.
  10998. */
  10999. execute(): void;
  11000. /**
  11001. * Serializes the actions and its related information.
  11002. * @param parent defines the object to serialize in
  11003. * @returns the serialized object
  11004. */
  11005. serialize(parent: any): any;
  11006. }
  11007. }
  11008. declare module "babylonjs/Actions/actionManager" {
  11009. import { Nullable } from "babylonjs/types";
  11010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11011. import { Scene } from "babylonjs/scene";
  11012. import { IAction } from "babylonjs/Actions/action";
  11013. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11014. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11015. /**
  11016. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11017. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11019. */
  11020. export class ActionManager extends AbstractActionManager {
  11021. /**
  11022. * Nothing
  11023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11024. */
  11025. static readonly NothingTrigger: number;
  11026. /**
  11027. * On pick
  11028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11029. */
  11030. static readonly OnPickTrigger: number;
  11031. /**
  11032. * On left pick
  11033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11034. */
  11035. static readonly OnLeftPickTrigger: number;
  11036. /**
  11037. * On right pick
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11039. */
  11040. static readonly OnRightPickTrigger: number;
  11041. /**
  11042. * On center pick
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11044. */
  11045. static readonly OnCenterPickTrigger: number;
  11046. /**
  11047. * On pick down
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11049. */
  11050. static readonly OnPickDownTrigger: number;
  11051. /**
  11052. * On double pick
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly OnDoublePickTrigger: number;
  11056. /**
  11057. * On pick up
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnPickUpTrigger: number;
  11061. /**
  11062. * On pick out.
  11063. * This trigger will only be raised if you also declared a OnPickDown
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11065. */
  11066. static readonly OnPickOutTrigger: number;
  11067. /**
  11068. * On long press
  11069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11070. */
  11071. static readonly OnLongPressTrigger: number;
  11072. /**
  11073. * On pointer over
  11074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11075. */
  11076. static readonly OnPointerOverTrigger: number;
  11077. /**
  11078. * On pointer out
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11080. */
  11081. static readonly OnPointerOutTrigger: number;
  11082. /**
  11083. * On every frame
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11085. */
  11086. static readonly OnEveryFrameTrigger: number;
  11087. /**
  11088. * On intersection enter
  11089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11090. */
  11091. static readonly OnIntersectionEnterTrigger: number;
  11092. /**
  11093. * On intersection exit
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnIntersectionExitTrigger: number;
  11097. /**
  11098. * On key down
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnKeyDownTrigger: number;
  11102. /**
  11103. * On key up
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnKeyUpTrigger: number;
  11107. private _scene;
  11108. /**
  11109. * Creates a new action manager
  11110. * @param scene defines the hosting scene
  11111. */
  11112. constructor(scene: Scene);
  11113. /**
  11114. * Releases all associated resources
  11115. */
  11116. dispose(): void;
  11117. /**
  11118. * Gets hosting scene
  11119. * @returns the hosting scene
  11120. */
  11121. getScene(): Scene;
  11122. /**
  11123. * Does this action manager handles actions of any of the given triggers
  11124. * @param triggers defines the triggers to be tested
  11125. * @return a boolean indicating whether one (or more) of the triggers is handled
  11126. */
  11127. hasSpecificTriggers(triggers: number[]): boolean;
  11128. /**
  11129. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11130. * speed.
  11131. * @param triggerA defines the trigger to be tested
  11132. * @param triggerB defines the trigger to be tested
  11133. * @return a boolean indicating whether one (or more) of the triggers is handled
  11134. */
  11135. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11136. /**
  11137. * Does this action manager handles actions of a given trigger
  11138. * @param trigger defines the trigger to be tested
  11139. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11140. * @return whether the trigger is handled
  11141. */
  11142. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11143. /**
  11144. * Does this action manager has pointer triggers
  11145. */
  11146. readonly hasPointerTriggers: boolean;
  11147. /**
  11148. * Does this action manager has pick triggers
  11149. */
  11150. readonly hasPickTriggers: boolean;
  11151. /**
  11152. * Registers an action to this action manager
  11153. * @param action defines the action to be registered
  11154. * @return the action amended (prepared) after registration
  11155. */
  11156. registerAction(action: IAction): Nullable<IAction>;
  11157. /**
  11158. * Unregisters an action to this action manager
  11159. * @param action defines the action to be unregistered
  11160. * @return a boolean indicating whether the action has been unregistered
  11161. */
  11162. unregisterAction(action: IAction): Boolean;
  11163. /**
  11164. * Process a specific trigger
  11165. * @param trigger defines the trigger to process
  11166. * @param evt defines the event details to be processed
  11167. */
  11168. processTrigger(trigger: number, evt?: IActionEvent): void;
  11169. /** @hidden */
  11170. _getEffectiveTarget(target: any, propertyPath: string): any;
  11171. /** @hidden */
  11172. _getProperty(propertyPath: string): string;
  11173. /**
  11174. * Serialize this manager to a JSON object
  11175. * @param name defines the property name to store this manager
  11176. * @returns a JSON representation of this manager
  11177. */
  11178. serialize(name: string): any;
  11179. /**
  11180. * Creates a new ActionManager from a JSON data
  11181. * @param parsedActions defines the JSON data to read from
  11182. * @param object defines the hosting mesh
  11183. * @param scene defines the hosting scene
  11184. */
  11185. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11186. /**
  11187. * Get a trigger name by index
  11188. * @param trigger defines the trigger index
  11189. * @returns a trigger name
  11190. */
  11191. static GetTriggerName(trigger: number): string;
  11192. }
  11193. }
  11194. declare module "babylonjs/Culling/ray" {
  11195. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11196. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11198. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11199. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11200. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11201. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11202. import { Plane } from "babylonjs/Maths/math.plane";
  11203. /**
  11204. * Class representing a ray with position and direction
  11205. */
  11206. export class Ray {
  11207. /** origin point */
  11208. origin: Vector3;
  11209. /** direction */
  11210. direction: Vector3;
  11211. /** length of the ray */
  11212. length: number;
  11213. private static readonly TmpVector3;
  11214. private _tmpRay;
  11215. /**
  11216. * Creates a new ray
  11217. * @param origin origin point
  11218. * @param direction direction
  11219. * @param length length of the ray
  11220. */
  11221. constructor(
  11222. /** origin point */
  11223. origin: Vector3,
  11224. /** direction */
  11225. direction: Vector3,
  11226. /** length of the ray */
  11227. length?: number);
  11228. /**
  11229. * Checks if the ray intersects a box
  11230. * @param minimum bound of the box
  11231. * @param maximum bound of the box
  11232. * @param intersectionTreshold extra extend to be added to the box in all direction
  11233. * @returns if the box was hit
  11234. */
  11235. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11236. /**
  11237. * Checks if the ray intersects a box
  11238. * @param box the bounding box to check
  11239. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11240. * @returns if the box was hit
  11241. */
  11242. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * If the ray hits a sphere
  11245. * @param sphere the bounding sphere to check
  11246. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11247. * @returns true if it hits the sphere
  11248. */
  11249. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11250. /**
  11251. * If the ray hits a triange
  11252. * @param vertex0 triangle vertex
  11253. * @param vertex1 triangle vertex
  11254. * @param vertex2 triangle vertex
  11255. * @returns intersection information if hit
  11256. */
  11257. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11258. /**
  11259. * Checks if ray intersects a plane
  11260. * @param plane the plane to check
  11261. * @returns the distance away it was hit
  11262. */
  11263. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11264. /**
  11265. * Calculate the intercept of a ray on a given axis
  11266. * @param axis to check 'x' | 'y' | 'z'
  11267. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11268. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11269. */
  11270. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param mesh the mesh to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @returns picking info of the intersecton
  11276. */
  11277. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11278. /**
  11279. * Checks if ray intersects a mesh
  11280. * @param meshes the meshes to check
  11281. * @param fastCheck if only the bounding box should checked
  11282. * @param results array to store result in
  11283. * @returns Array of picking infos
  11284. */
  11285. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11286. private _comparePickingInfo;
  11287. private static smallnum;
  11288. private static rayl;
  11289. /**
  11290. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11291. * @param sega the first point of the segment to test the intersection against
  11292. * @param segb the second point of the segment to test the intersection against
  11293. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11294. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11295. */
  11296. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11297. /**
  11298. * Update the ray from viewport position
  11299. * @param x position
  11300. * @param y y position
  11301. * @param viewportWidth viewport width
  11302. * @param viewportHeight viewport height
  11303. * @param world world matrix
  11304. * @param view view matrix
  11305. * @param projection projection matrix
  11306. * @returns this ray updated
  11307. */
  11308. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11309. /**
  11310. * Creates a ray with origin and direction of 0,0,0
  11311. * @returns the new ray
  11312. */
  11313. static Zero(): Ray;
  11314. /**
  11315. * Creates a new ray from screen space and viewport
  11316. * @param x position
  11317. * @param y y position
  11318. * @param viewportWidth viewport width
  11319. * @param viewportHeight viewport height
  11320. * @param world world matrix
  11321. * @param view view matrix
  11322. * @param projection projection matrix
  11323. * @returns new ray
  11324. */
  11325. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11326. /**
  11327. * 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
  11328. * transformed to the given world matrix.
  11329. * @param origin The origin point
  11330. * @param end The end point
  11331. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11332. * @returns the new ray
  11333. */
  11334. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @returns the resulting new ray
  11340. */
  11341. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11342. /**
  11343. * Transforms a ray by a matrix
  11344. * @param ray ray to transform
  11345. * @param matrix matrix to apply
  11346. * @param result ray to store result in
  11347. */
  11348. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11349. /**
  11350. * Unproject a ray from screen space to object space
  11351. * @param sourceX defines the screen space x coordinate to use
  11352. * @param sourceY defines the screen space y coordinate to use
  11353. * @param viewportWidth defines the current width of the viewport
  11354. * @param viewportHeight defines the current height of the viewport
  11355. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11356. * @param view defines the view matrix to use
  11357. * @param projection defines the projection matrix to use
  11358. */
  11359. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11360. }
  11361. /**
  11362. * Type used to define predicate used to select faces when a mesh intersection is detected
  11363. */
  11364. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11365. module "babylonjs/scene" {
  11366. interface Scene {
  11367. /** @hidden */
  11368. _tempPickingRay: Nullable<Ray>;
  11369. /** @hidden */
  11370. _cachedRayForTransform: Ray;
  11371. /** @hidden */
  11372. _pickWithRayInverseMatrix: Matrix;
  11373. /** @hidden */
  11374. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11375. /** @hidden */
  11376. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11377. }
  11378. }
  11379. }
  11380. declare module "babylonjs/sceneComponent" {
  11381. import { Scene } from "babylonjs/scene";
  11382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11384. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11385. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11386. import { Nullable } from "babylonjs/types";
  11387. import { Camera } from "babylonjs/Cameras/camera";
  11388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11389. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11390. import { AbstractScene } from "babylonjs/abstractScene";
  11391. /**
  11392. * Groups all the scene component constants in one place to ease maintenance.
  11393. * @hidden
  11394. */
  11395. export class SceneComponentConstants {
  11396. static readonly NAME_EFFECTLAYER: string;
  11397. static readonly NAME_LAYER: string;
  11398. static readonly NAME_LENSFLARESYSTEM: string;
  11399. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11400. static readonly NAME_PARTICLESYSTEM: string;
  11401. static readonly NAME_GAMEPAD: string;
  11402. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11403. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11404. static readonly NAME_DEPTHRENDERER: string;
  11405. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11406. static readonly NAME_SPRITE: string;
  11407. static readonly NAME_OUTLINERENDERER: string;
  11408. static readonly NAME_PROCEDURALTEXTURE: string;
  11409. static readonly NAME_SHADOWGENERATOR: string;
  11410. static readonly NAME_OCTREE: string;
  11411. static readonly NAME_PHYSICSENGINE: string;
  11412. static readonly NAME_AUDIO: string;
  11413. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11414. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11415. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11416. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11417. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11418. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11419. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11420. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11421. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11422. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11423. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11424. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11425. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11426. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11427. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11428. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11429. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11430. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11431. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11432. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11433. static readonly STEP_AFTERRENDER_AUDIO: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11436. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11437. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11438. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11439. static readonly STEP_POINTERMOVE_SPRITE: number;
  11440. static readonly STEP_POINTERDOWN_SPRITE: number;
  11441. static readonly STEP_POINTERUP_SPRITE: number;
  11442. }
  11443. /**
  11444. * This represents a scene component.
  11445. *
  11446. * This is used to decouple the dependency the scene is having on the different workloads like
  11447. * layers, post processes...
  11448. */
  11449. export interface ISceneComponent {
  11450. /**
  11451. * The name of the component. Each component must have a unique name.
  11452. */
  11453. name: string;
  11454. /**
  11455. * The scene the component belongs to.
  11456. */
  11457. scene: Scene;
  11458. /**
  11459. * Register the component to one instance of a scene.
  11460. */
  11461. register(): void;
  11462. /**
  11463. * Rebuilds the elements related to this component in case of
  11464. * context lost for instance.
  11465. */
  11466. rebuild(): void;
  11467. /**
  11468. * Disposes the component and the associated ressources.
  11469. */
  11470. dispose(): void;
  11471. }
  11472. /**
  11473. * This represents a SERIALIZABLE scene component.
  11474. *
  11475. * This extends Scene Component to add Serialization methods on top.
  11476. */
  11477. export interface ISceneSerializableComponent extends ISceneComponent {
  11478. /**
  11479. * Adds all the elements from the container to the scene
  11480. * @param container the container holding the elements
  11481. */
  11482. addFromContainer(container: AbstractScene): void;
  11483. /**
  11484. * Removes all the elements in the container from the scene
  11485. * @param container contains the elements to remove
  11486. * @param dispose if the removed element should be disposed (default: false)
  11487. */
  11488. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11489. /**
  11490. * Serializes the component data to the specified json object
  11491. * @param serializationObject The object to serialize to
  11492. */
  11493. serialize(serializationObject: any): void;
  11494. }
  11495. /**
  11496. * Strong typing of a Mesh related stage step action
  11497. */
  11498. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11499. /**
  11500. * Strong typing of a Evaluate Sub Mesh related stage step action
  11501. */
  11502. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11503. /**
  11504. * Strong typing of a Active Mesh related stage step action
  11505. */
  11506. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11507. /**
  11508. * Strong typing of a Camera related stage step action
  11509. */
  11510. export type CameraStageAction = (camera: Camera) => void;
  11511. /**
  11512. * Strong typing of a Camera Frame buffer related stage step action
  11513. */
  11514. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11515. /**
  11516. * Strong typing of a Render Target related stage step action
  11517. */
  11518. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11519. /**
  11520. * Strong typing of a RenderingGroup related stage step action
  11521. */
  11522. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11523. /**
  11524. * Strong typing of a Mesh Render related stage step action
  11525. */
  11526. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11527. /**
  11528. * Strong typing of a simple stage step action
  11529. */
  11530. export type SimpleStageAction = () => void;
  11531. /**
  11532. * Strong typing of a render target action.
  11533. */
  11534. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11535. /**
  11536. * Strong typing of a pointer move action.
  11537. */
  11538. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11539. /**
  11540. * Strong typing of a pointer up/down action.
  11541. */
  11542. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11543. /**
  11544. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11545. * @hidden
  11546. */
  11547. export class Stage<T extends Function> extends Array<{
  11548. index: number;
  11549. component: ISceneComponent;
  11550. action: T;
  11551. }> {
  11552. /**
  11553. * Hide ctor from the rest of the world.
  11554. * @param items The items to add.
  11555. */
  11556. private constructor();
  11557. /**
  11558. * Creates a new Stage.
  11559. * @returns A new instance of a Stage
  11560. */
  11561. static Create<T extends Function>(): Stage<T>;
  11562. /**
  11563. * Registers a step in an ordered way in the targeted stage.
  11564. * @param index Defines the position to register the step in
  11565. * @param component Defines the component attached to the step
  11566. * @param action Defines the action to launch during the step
  11567. */
  11568. registerStep(index: number, component: ISceneComponent, action: T): void;
  11569. /**
  11570. * Clears all the steps from the stage.
  11571. */
  11572. clear(): void;
  11573. }
  11574. }
  11575. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11576. import { Nullable } from "babylonjs/types";
  11577. import { Observable } from "babylonjs/Misc/observable";
  11578. import { Scene } from "babylonjs/scene";
  11579. import { Sprite } from "babylonjs/Sprites/sprite";
  11580. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11581. import { Ray } from "babylonjs/Culling/ray";
  11582. import { Camera } from "babylonjs/Cameras/camera";
  11583. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11584. import { ISceneComponent } from "babylonjs/sceneComponent";
  11585. module "babylonjs/scene" {
  11586. interface Scene {
  11587. /** @hidden */
  11588. _pointerOverSprite: Nullable<Sprite>;
  11589. /** @hidden */
  11590. _pickedDownSprite: Nullable<Sprite>;
  11591. /** @hidden */
  11592. _tempSpritePickingRay: Nullable<Ray>;
  11593. /**
  11594. * All of the sprite managers added to this scene
  11595. * @see http://doc.babylonjs.com/babylon101/sprites
  11596. */
  11597. spriteManagers: Array<ISpriteManager>;
  11598. /**
  11599. * An event triggered when sprites rendering is about to start
  11600. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11601. */
  11602. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11603. /**
  11604. * An event triggered when sprites rendering is done
  11605. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11606. */
  11607. onAfterSpritesRenderingObservable: Observable<Scene>;
  11608. /** @hidden */
  11609. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11610. /** Launch a ray to try to pick a sprite in the scene
  11611. * @param x position on screen
  11612. * @param y position on screen
  11613. * @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
  11614. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11615. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11616. * @returns a PickingInfo
  11617. */
  11618. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11619. /** Use the given ray to pick a sprite in the scene
  11620. * @param ray The ray (in world space) to use to pick meshes
  11621. * @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
  11622. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11623. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11624. * @returns a PickingInfo
  11625. */
  11626. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11627. /** @hidden */
  11628. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11629. /** Launch a ray to try to pick sprites in the scene
  11630. * @param x position on screen
  11631. * @param y position on screen
  11632. * @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
  11633. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11634. * @returns a PickingInfo array
  11635. */
  11636. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11637. /** Use the given ray to pick sprites in the scene
  11638. * @param ray The ray (in world space) to use to pick meshes
  11639. * @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
  11640. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11641. * @returns a PickingInfo array
  11642. */
  11643. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11644. /**
  11645. * Force the sprite under the pointer
  11646. * @param sprite defines the sprite to use
  11647. */
  11648. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11649. /**
  11650. * Gets the sprite under the pointer
  11651. * @returns a Sprite or null if no sprite is under the pointer
  11652. */
  11653. getPointerOverSprite(): Nullable<Sprite>;
  11654. }
  11655. }
  11656. /**
  11657. * Defines the sprite scene component responsible to manage sprites
  11658. * in a given scene.
  11659. */
  11660. export class SpriteSceneComponent implements ISceneComponent {
  11661. /**
  11662. * The component name helpfull to identify the component in the list of scene components.
  11663. */
  11664. readonly name: string;
  11665. /**
  11666. * The scene the component belongs to.
  11667. */
  11668. scene: Scene;
  11669. /** @hidden */
  11670. private _spritePredicate;
  11671. /**
  11672. * Creates a new instance of the component for the given scene
  11673. * @param scene Defines the scene to register the component in
  11674. */
  11675. constructor(scene: Scene);
  11676. /**
  11677. * Registers the component in a given scene
  11678. */
  11679. register(): void;
  11680. /**
  11681. * Rebuilds the elements related to this component in case of
  11682. * context lost for instance.
  11683. */
  11684. rebuild(): void;
  11685. /**
  11686. * Disposes the component and the associated ressources.
  11687. */
  11688. dispose(): void;
  11689. private _pickSpriteButKeepRay;
  11690. private _pointerMove;
  11691. private _pointerDown;
  11692. private _pointerUp;
  11693. }
  11694. }
  11695. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11696. /** @hidden */
  11697. export var fogFragmentDeclaration: {
  11698. name: string;
  11699. shader: string;
  11700. };
  11701. }
  11702. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11703. /** @hidden */
  11704. export var fogFragment: {
  11705. name: string;
  11706. shader: string;
  11707. };
  11708. }
  11709. declare module "babylonjs/Shaders/sprites.fragment" {
  11710. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11711. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11712. /** @hidden */
  11713. export var spritesPixelShader: {
  11714. name: string;
  11715. shader: string;
  11716. };
  11717. }
  11718. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11719. /** @hidden */
  11720. export var fogVertexDeclaration: {
  11721. name: string;
  11722. shader: string;
  11723. };
  11724. }
  11725. declare module "babylonjs/Shaders/sprites.vertex" {
  11726. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11727. /** @hidden */
  11728. export var spritesVertexShader: {
  11729. name: string;
  11730. shader: string;
  11731. };
  11732. }
  11733. declare module "babylonjs/Sprites/spriteManager" {
  11734. import { IDisposable, Scene } from "babylonjs/scene";
  11735. import { Nullable } from "babylonjs/types";
  11736. import { Observable } from "babylonjs/Misc/observable";
  11737. import { Sprite } from "babylonjs/Sprites/sprite";
  11738. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11739. import { Camera } from "babylonjs/Cameras/camera";
  11740. import { Texture } from "babylonjs/Materials/Textures/texture";
  11741. import "babylonjs/Shaders/sprites.fragment";
  11742. import "babylonjs/Shaders/sprites.vertex";
  11743. import { Ray } from "babylonjs/Culling/ray";
  11744. /**
  11745. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11746. */
  11747. export interface ISpriteManager extends IDisposable {
  11748. /**
  11749. * Restricts the camera to viewing objects with the same layerMask.
  11750. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11751. */
  11752. layerMask: number;
  11753. /**
  11754. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11755. */
  11756. isPickable: boolean;
  11757. /**
  11758. * Specifies the rendering group id for this mesh (0 by default)
  11759. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11760. */
  11761. renderingGroupId: number;
  11762. /**
  11763. * Defines the list of sprites managed by the manager.
  11764. */
  11765. sprites: Array<Sprite>;
  11766. /**
  11767. * Tests the intersection of a sprite with a specific ray.
  11768. * @param ray The ray we are sending to test the collision
  11769. * @param camera The camera space we are sending rays in
  11770. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11771. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11772. * @returns picking info or null.
  11773. */
  11774. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11775. /**
  11776. * Intersects the sprites with a ray
  11777. * @param ray defines the ray to intersect with
  11778. * @param camera defines the current active camera
  11779. * @param predicate defines a predicate used to select candidate sprites
  11780. * @returns null if no hit or a PickingInfo array
  11781. */
  11782. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11783. /**
  11784. * Renders the list of sprites on screen.
  11785. */
  11786. render(): void;
  11787. }
  11788. /**
  11789. * Class used to manage multiple sprites on the same spritesheet
  11790. * @see http://doc.babylonjs.com/babylon101/sprites
  11791. */
  11792. export class SpriteManager implements ISpriteManager {
  11793. /** defines the manager's name */
  11794. name: string;
  11795. /** Gets the list of sprites */
  11796. sprites: Sprite[];
  11797. /** Gets or sets the rendering group id (0 by default) */
  11798. renderingGroupId: number;
  11799. /** Gets or sets camera layer mask */
  11800. layerMask: number;
  11801. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11802. fogEnabled: boolean;
  11803. /** Gets or sets a boolean indicating if the sprites are pickable */
  11804. isPickable: boolean;
  11805. /** Defines the default width of a cell in the spritesheet */
  11806. cellWidth: number;
  11807. /** Defines the default height of a cell in the spritesheet */
  11808. cellHeight: number;
  11809. /** Associative array from JSON sprite data file */
  11810. private _cellData;
  11811. /** Array of sprite names from JSON sprite data file */
  11812. private _spriteMap;
  11813. /** True when packed cell data from JSON file is ready*/
  11814. private _packedAndReady;
  11815. /**
  11816. * An event triggered when the manager is disposed.
  11817. */
  11818. onDisposeObservable: Observable<SpriteManager>;
  11819. private _onDisposeObserver;
  11820. /**
  11821. * Callback called when the manager is disposed
  11822. */
  11823. onDispose: () => void;
  11824. private _capacity;
  11825. private _fromPacked;
  11826. private _spriteTexture;
  11827. private _epsilon;
  11828. private _scene;
  11829. private _vertexData;
  11830. private _buffer;
  11831. private _vertexBuffers;
  11832. private _indexBuffer;
  11833. private _effectBase;
  11834. private _effectFog;
  11835. /**
  11836. * Gets or sets the spritesheet texture
  11837. */
  11838. texture: Texture;
  11839. /**
  11840. * Creates a new sprite manager
  11841. * @param name defines the manager's name
  11842. * @param imgUrl defines the sprite sheet url
  11843. * @param capacity defines the maximum allowed number of sprites
  11844. * @param cellSize defines the size of a sprite cell
  11845. * @param scene defines the hosting scene
  11846. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11847. * @param samplingMode defines the smapling mode to use with spritesheet
  11848. * @param fromPacked set to false; do not alter
  11849. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11850. */
  11851. constructor(
  11852. /** defines the manager's name */
  11853. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11854. private _makePacked;
  11855. private _appendSpriteVertex;
  11856. /**
  11857. * Intersects the sprites with a ray
  11858. * @param ray defines the ray to intersect with
  11859. * @param camera defines the current active camera
  11860. * @param predicate defines a predicate used to select candidate sprites
  11861. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11862. * @returns null if no hit or a PickingInfo
  11863. */
  11864. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11865. /**
  11866. * Intersects the sprites with a ray
  11867. * @param ray defines the ray to intersect with
  11868. * @param camera defines the current active camera
  11869. * @param predicate defines a predicate used to select candidate sprites
  11870. * @returns null if no hit or a PickingInfo array
  11871. */
  11872. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11873. /**
  11874. * Render all child sprites
  11875. */
  11876. render(): void;
  11877. /**
  11878. * Release associated resources
  11879. */
  11880. dispose(): void;
  11881. }
  11882. }
  11883. declare module "babylonjs/Sprites/sprite" {
  11884. import { Vector3 } from "babylonjs/Maths/math.vector";
  11885. import { Nullable } from "babylonjs/types";
  11886. import { ActionManager } from "babylonjs/Actions/actionManager";
  11887. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11888. import { Color4 } from "babylonjs/Maths/math.color";
  11889. /**
  11890. * Class used to represent a sprite
  11891. * @see http://doc.babylonjs.com/babylon101/sprites
  11892. */
  11893. export class Sprite {
  11894. /** defines the name */
  11895. name: string;
  11896. /** Gets or sets the current world position */
  11897. position: Vector3;
  11898. /** Gets or sets the main color */
  11899. color: Color4;
  11900. /** Gets or sets the width */
  11901. width: number;
  11902. /** Gets or sets the height */
  11903. height: number;
  11904. /** Gets or sets rotation angle */
  11905. angle: number;
  11906. /** Gets or sets the cell index in the sprite sheet */
  11907. cellIndex: number;
  11908. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11909. cellRef: string;
  11910. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11911. invertU: number;
  11912. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11913. invertV: number;
  11914. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11915. disposeWhenFinishedAnimating: boolean;
  11916. /** Gets the list of attached animations */
  11917. animations: Animation[];
  11918. /** Gets or sets a boolean indicating if the sprite can be picked */
  11919. isPickable: boolean;
  11920. /**
  11921. * Gets or sets the associated action manager
  11922. */
  11923. actionManager: Nullable<ActionManager>;
  11924. private _animationStarted;
  11925. private _loopAnimation;
  11926. private _fromIndex;
  11927. private _toIndex;
  11928. private _delay;
  11929. private _direction;
  11930. private _manager;
  11931. private _time;
  11932. private _onAnimationEnd;
  11933. /**
  11934. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11935. */
  11936. isVisible: boolean;
  11937. /**
  11938. * Gets or sets the sprite size
  11939. */
  11940. size: number;
  11941. /**
  11942. * Creates a new Sprite
  11943. * @param name defines the name
  11944. * @param manager defines the manager
  11945. */
  11946. constructor(
  11947. /** defines the name */
  11948. name: string, manager: ISpriteManager);
  11949. /**
  11950. * Starts an animation
  11951. * @param from defines the initial key
  11952. * @param to defines the end key
  11953. * @param loop defines if the animation must loop
  11954. * @param delay defines the start delay (in ms)
  11955. * @param onAnimationEnd defines a callback to call when animation ends
  11956. */
  11957. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11958. /** Stops current animation (if any) */
  11959. stopAnimation(): void;
  11960. /** @hidden */
  11961. _animate(deltaTime: number): void;
  11962. /** Release associated resources */
  11963. dispose(): void;
  11964. }
  11965. }
  11966. declare module "babylonjs/Collisions/pickingInfo" {
  11967. import { Nullable } from "babylonjs/types";
  11968. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11970. import { Sprite } from "babylonjs/Sprites/sprite";
  11971. import { Ray } from "babylonjs/Culling/ray";
  11972. /**
  11973. * Information about the result of picking within a scene
  11974. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11975. */
  11976. export class PickingInfo {
  11977. /** @hidden */
  11978. _pickingUnavailable: boolean;
  11979. /**
  11980. * If the pick collided with an object
  11981. */
  11982. hit: boolean;
  11983. /**
  11984. * Distance away where the pick collided
  11985. */
  11986. distance: number;
  11987. /**
  11988. * The location of pick collision
  11989. */
  11990. pickedPoint: Nullable<Vector3>;
  11991. /**
  11992. * The mesh corresponding the the pick collision
  11993. */
  11994. pickedMesh: Nullable<AbstractMesh>;
  11995. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11996. bu: number;
  11997. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11998. bv: number;
  11999. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12000. faceId: number;
  12001. /** Id of the the submesh that was picked */
  12002. subMeshId: number;
  12003. /** If a sprite was picked, this will be the sprite the pick collided with */
  12004. pickedSprite: Nullable<Sprite>;
  12005. /**
  12006. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12007. */
  12008. originMesh: Nullable<AbstractMesh>;
  12009. /**
  12010. * The ray that was used to perform the picking.
  12011. */
  12012. ray: Nullable<Ray>;
  12013. /**
  12014. * Gets the normal correspodning to the face the pick collided with
  12015. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12016. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12017. * @returns The normal correspodning to the face the pick collided with
  12018. */
  12019. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12020. /**
  12021. * Gets the texture coordinates of where the pick occured
  12022. * @returns the vector containing the coordnates of the texture
  12023. */
  12024. getTextureCoordinates(): Nullable<Vector2>;
  12025. }
  12026. }
  12027. declare module "babylonjs/Events/pointerEvents" {
  12028. import { Nullable } from "babylonjs/types";
  12029. import { Vector2 } from "babylonjs/Maths/math.vector";
  12030. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12031. import { Ray } from "babylonjs/Culling/ray";
  12032. /**
  12033. * Gather the list of pointer event types as constants.
  12034. */
  12035. export class PointerEventTypes {
  12036. /**
  12037. * 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.
  12038. */
  12039. static readonly POINTERDOWN: number;
  12040. /**
  12041. * The pointerup event is fired when a pointer is no longer active.
  12042. */
  12043. static readonly POINTERUP: number;
  12044. /**
  12045. * The pointermove event is fired when a pointer changes coordinates.
  12046. */
  12047. static readonly POINTERMOVE: number;
  12048. /**
  12049. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12050. */
  12051. static readonly POINTERWHEEL: number;
  12052. /**
  12053. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12054. */
  12055. static readonly POINTERPICK: number;
  12056. /**
  12057. * The pointertap event is fired when a the object has been touched and released without drag.
  12058. */
  12059. static readonly POINTERTAP: number;
  12060. /**
  12061. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12062. */
  12063. static readonly POINTERDOUBLETAP: number;
  12064. }
  12065. /**
  12066. * Base class of pointer info types.
  12067. */
  12068. export class PointerInfoBase {
  12069. /**
  12070. * Defines the type of event (PointerEventTypes)
  12071. */
  12072. type: number;
  12073. /**
  12074. * Defines the related dom event
  12075. */
  12076. event: PointerEvent | MouseWheelEvent;
  12077. /**
  12078. * Instantiates the base class of pointers info.
  12079. * @param type Defines the type of event (PointerEventTypes)
  12080. * @param event Defines the related dom event
  12081. */
  12082. constructor(
  12083. /**
  12084. * Defines the type of event (PointerEventTypes)
  12085. */
  12086. type: number,
  12087. /**
  12088. * Defines the related dom event
  12089. */
  12090. event: PointerEvent | MouseWheelEvent);
  12091. }
  12092. /**
  12093. * This class is used to store pointer related info for the onPrePointerObservable event.
  12094. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12095. */
  12096. export class PointerInfoPre extends PointerInfoBase {
  12097. /**
  12098. * Ray from a pointer if availible (eg. 6dof controller)
  12099. */
  12100. ray: Nullable<Ray>;
  12101. /**
  12102. * Defines the local position of the pointer on the canvas.
  12103. */
  12104. localPosition: Vector2;
  12105. /**
  12106. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12107. */
  12108. skipOnPointerObservable: boolean;
  12109. /**
  12110. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12111. * @param type Defines the type of event (PointerEventTypes)
  12112. * @param event Defines the related dom event
  12113. * @param localX Defines the local x coordinates of the pointer when the event occured
  12114. * @param localY Defines the local y coordinates of the pointer when the event occured
  12115. */
  12116. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12117. }
  12118. /**
  12119. * This type contains all the data related to a pointer event in Babylon.js.
  12120. * 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.
  12121. */
  12122. export class PointerInfo extends PointerInfoBase {
  12123. /**
  12124. * Defines the picking info associated to the info (if any)\
  12125. */
  12126. pickInfo: Nullable<PickingInfo>;
  12127. /**
  12128. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12129. * @param type Defines the type of event (PointerEventTypes)
  12130. * @param event Defines the related dom event
  12131. * @param pickInfo Defines the picking info associated to the info (if any)\
  12132. */
  12133. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12134. /**
  12135. * Defines the picking info associated to the info (if any)\
  12136. */
  12137. pickInfo: Nullable<PickingInfo>);
  12138. }
  12139. /**
  12140. * Data relating to a touch event on the screen.
  12141. */
  12142. export interface PointerTouch {
  12143. /**
  12144. * X coordinate of touch.
  12145. */
  12146. x: number;
  12147. /**
  12148. * Y coordinate of touch.
  12149. */
  12150. y: number;
  12151. /**
  12152. * Id of touch. Unique for each finger.
  12153. */
  12154. pointerId: number;
  12155. /**
  12156. * Event type passed from DOM.
  12157. */
  12158. type: any;
  12159. }
  12160. }
  12161. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12162. import { Observable } from "babylonjs/Misc/observable";
  12163. import { Nullable } from "babylonjs/types";
  12164. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12165. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12166. /**
  12167. * Manage the mouse inputs to control the movement of a free camera.
  12168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12169. */
  12170. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12171. /**
  12172. * Define if touch is enabled in the mouse input
  12173. */
  12174. touchEnabled: boolean;
  12175. /**
  12176. * Defines the camera the input is attached to.
  12177. */
  12178. camera: FreeCamera;
  12179. /**
  12180. * Defines the buttons associated with the input to handle camera move.
  12181. */
  12182. buttons: number[];
  12183. /**
  12184. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12185. */
  12186. angularSensibility: number;
  12187. private _pointerInput;
  12188. private _onMouseMove;
  12189. private _observer;
  12190. private previousPosition;
  12191. /**
  12192. * Observable for when a pointer move event occurs containing the move offset
  12193. */
  12194. onPointerMovedObservable: Observable<{
  12195. offsetX: number;
  12196. offsetY: number;
  12197. }>;
  12198. /**
  12199. * @hidden
  12200. * If the camera should be rotated automatically based on pointer movement
  12201. */
  12202. _allowCameraRotation: boolean;
  12203. /**
  12204. * Manage the mouse inputs to control the movement of a free camera.
  12205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12206. * @param touchEnabled Defines if touch is enabled or not
  12207. */
  12208. constructor(
  12209. /**
  12210. * Define if touch is enabled in the mouse input
  12211. */
  12212. touchEnabled?: boolean);
  12213. /**
  12214. * Attach the input controls to a specific dom element to get the input from.
  12215. * @param element Defines the element the controls should be listened from
  12216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12217. */
  12218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12219. /**
  12220. * Called on JS contextmenu event.
  12221. * Override this method to provide functionality.
  12222. */
  12223. protected onContextMenu(evt: PointerEvent): void;
  12224. /**
  12225. * Detach the current controls from the specified dom element.
  12226. * @param element Defines the element to stop listening the inputs from
  12227. */
  12228. detachControl(element: Nullable<HTMLElement>): void;
  12229. /**
  12230. * Gets the class name of the current intput.
  12231. * @returns the class name
  12232. */
  12233. getClassName(): string;
  12234. /**
  12235. * Get the friendly name associated with the input class.
  12236. * @returns the input friendly name
  12237. */
  12238. getSimpleName(): string;
  12239. }
  12240. }
  12241. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12242. import { Nullable } from "babylonjs/types";
  12243. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12244. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12245. /**
  12246. * Manage the touch inputs to control the movement of a free camera.
  12247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12248. */
  12249. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12250. /**
  12251. * Defines the camera the input is attached to.
  12252. */
  12253. camera: FreeCamera;
  12254. /**
  12255. * Defines the touch sensibility for rotation.
  12256. * The higher the faster.
  12257. */
  12258. touchAngularSensibility: number;
  12259. /**
  12260. * Defines the touch sensibility for move.
  12261. * The higher the faster.
  12262. */
  12263. touchMoveSensibility: number;
  12264. private _offsetX;
  12265. private _offsetY;
  12266. private _pointerPressed;
  12267. private _pointerInput;
  12268. private _observer;
  12269. private _onLostFocus;
  12270. /**
  12271. * Attach the input controls to a specific dom element to get the input from.
  12272. * @param element Defines the element the controls should be listened from
  12273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12274. */
  12275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12276. /**
  12277. * Detach the current controls from the specified dom element.
  12278. * @param element Defines the element to stop listening the inputs from
  12279. */
  12280. detachControl(element: Nullable<HTMLElement>): void;
  12281. /**
  12282. * Update the current camera state depending on the inputs that have been used this frame.
  12283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12284. */
  12285. checkInputs(): void;
  12286. /**
  12287. * Gets the class name of the current intput.
  12288. * @returns the class name
  12289. */
  12290. getClassName(): string;
  12291. /**
  12292. * Get the friendly name associated with the input class.
  12293. * @returns the input friendly name
  12294. */
  12295. getSimpleName(): string;
  12296. }
  12297. }
  12298. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12299. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12300. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12301. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12302. import { Nullable } from "babylonjs/types";
  12303. /**
  12304. * Default Inputs manager for the FreeCamera.
  12305. * It groups all the default supported inputs for ease of use.
  12306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12307. */
  12308. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12309. /**
  12310. * @hidden
  12311. */
  12312. _mouseInput: Nullable<FreeCameraMouseInput>;
  12313. /**
  12314. * Instantiates a new FreeCameraInputsManager.
  12315. * @param camera Defines the camera the inputs belong to
  12316. */
  12317. constructor(camera: FreeCamera);
  12318. /**
  12319. * Add keyboard input support to the input manager.
  12320. * @returns the current input manager
  12321. */
  12322. addKeyboard(): FreeCameraInputsManager;
  12323. /**
  12324. * Add mouse input support to the input manager.
  12325. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12326. * @returns the current input manager
  12327. */
  12328. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12329. /**
  12330. * Removes the mouse input support from the manager
  12331. * @returns the current input manager
  12332. */
  12333. removeMouse(): FreeCameraInputsManager;
  12334. /**
  12335. * Add touch input support to the input manager.
  12336. * @returns the current input manager
  12337. */
  12338. addTouch(): FreeCameraInputsManager;
  12339. /**
  12340. * Remove all attached input methods from a camera
  12341. */
  12342. clear(): void;
  12343. }
  12344. }
  12345. declare module "babylonjs/Cameras/freeCamera" {
  12346. import { Vector3 } from "babylonjs/Maths/math.vector";
  12347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12348. import { Scene } from "babylonjs/scene";
  12349. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12350. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12351. /**
  12352. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12353. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12354. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12355. */
  12356. export class FreeCamera extends TargetCamera {
  12357. /**
  12358. * Define the collision ellipsoid of the camera.
  12359. * This is helpful to simulate a camera body like the player body around the camera
  12360. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12361. */
  12362. ellipsoid: Vector3;
  12363. /**
  12364. * Define an offset for the position of the ellipsoid around the camera.
  12365. * This can be helpful to determine the center of the body near the gravity center of the body
  12366. * instead of its head.
  12367. */
  12368. ellipsoidOffset: Vector3;
  12369. /**
  12370. * Enable or disable collisions of the camera with the rest of the scene objects.
  12371. */
  12372. checkCollisions: boolean;
  12373. /**
  12374. * Enable or disable gravity on the camera.
  12375. */
  12376. applyGravity: boolean;
  12377. /**
  12378. * Define the input manager associated to the camera.
  12379. */
  12380. inputs: FreeCameraInputsManager;
  12381. /**
  12382. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12383. * Higher values reduce sensitivity.
  12384. */
  12385. /**
  12386. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12387. * Higher values reduce sensitivity.
  12388. */
  12389. angularSensibility: number;
  12390. /**
  12391. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12392. */
  12393. keysUp: number[];
  12394. /**
  12395. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12396. */
  12397. keysDown: number[];
  12398. /**
  12399. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12400. */
  12401. keysLeft: number[];
  12402. /**
  12403. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12404. */
  12405. keysRight: number[];
  12406. /**
  12407. * Event raised when the camera collide with a mesh in the scene.
  12408. */
  12409. onCollide: (collidedMesh: AbstractMesh) => void;
  12410. private _collider;
  12411. private _needMoveForGravity;
  12412. private _oldPosition;
  12413. private _diffPosition;
  12414. private _newPosition;
  12415. /** @hidden */
  12416. _localDirection: Vector3;
  12417. /** @hidden */
  12418. _transformedDirection: Vector3;
  12419. /**
  12420. * Instantiates a Free Camera.
  12421. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12422. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12423. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12424. * @param name Define the name of the camera in the scene
  12425. * @param position Define the start position of the camera in the scene
  12426. * @param scene Define the scene the camera belongs to
  12427. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12428. */
  12429. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12430. /**
  12431. * Attached controls to the current camera.
  12432. * @param element Defines the element the controls should be listened from
  12433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12434. */
  12435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12436. /**
  12437. * Detach the current controls from the camera.
  12438. * The camera will stop reacting to inputs.
  12439. * @param element Defines the element to stop listening the inputs from
  12440. */
  12441. detachControl(element: HTMLElement): void;
  12442. private _collisionMask;
  12443. /**
  12444. * Define a collision mask to limit the list of object the camera can collide with
  12445. */
  12446. collisionMask: number;
  12447. /** @hidden */
  12448. _collideWithWorld(displacement: Vector3): void;
  12449. private _onCollisionPositionChange;
  12450. /** @hidden */
  12451. _checkInputs(): void;
  12452. /** @hidden */
  12453. _decideIfNeedsToMove(): boolean;
  12454. /** @hidden */
  12455. _updatePosition(): void;
  12456. /**
  12457. * Destroy the camera and release the current resources hold by it.
  12458. */
  12459. dispose(): void;
  12460. /**
  12461. * Gets the current object class name.
  12462. * @return the class name
  12463. */
  12464. getClassName(): string;
  12465. }
  12466. }
  12467. declare module "babylonjs/Gamepads/gamepad" {
  12468. import { Observable } from "babylonjs/Misc/observable";
  12469. /**
  12470. * Represents a gamepad control stick position
  12471. */
  12472. export class StickValues {
  12473. /**
  12474. * The x component of the control stick
  12475. */
  12476. x: number;
  12477. /**
  12478. * The y component of the control stick
  12479. */
  12480. y: number;
  12481. /**
  12482. * Initializes the gamepad x and y control stick values
  12483. * @param x The x component of the gamepad control stick value
  12484. * @param y The y component of the gamepad control stick value
  12485. */
  12486. constructor(
  12487. /**
  12488. * The x component of the control stick
  12489. */
  12490. x: number,
  12491. /**
  12492. * The y component of the control stick
  12493. */
  12494. y: number);
  12495. }
  12496. /**
  12497. * An interface which manages callbacks for gamepad button changes
  12498. */
  12499. export interface GamepadButtonChanges {
  12500. /**
  12501. * Called when a gamepad has been changed
  12502. */
  12503. changed: boolean;
  12504. /**
  12505. * Called when a gamepad press event has been triggered
  12506. */
  12507. pressChanged: boolean;
  12508. /**
  12509. * Called when a touch event has been triggered
  12510. */
  12511. touchChanged: boolean;
  12512. /**
  12513. * Called when a value has changed
  12514. */
  12515. valueChanged: boolean;
  12516. }
  12517. /**
  12518. * Represents a gamepad
  12519. */
  12520. export class Gamepad {
  12521. /**
  12522. * The id of the gamepad
  12523. */
  12524. id: string;
  12525. /**
  12526. * The index of the gamepad
  12527. */
  12528. index: number;
  12529. /**
  12530. * The browser gamepad
  12531. */
  12532. browserGamepad: any;
  12533. /**
  12534. * Specifies what type of gamepad this represents
  12535. */
  12536. type: number;
  12537. private _leftStick;
  12538. private _rightStick;
  12539. /** @hidden */
  12540. _isConnected: boolean;
  12541. private _leftStickAxisX;
  12542. private _leftStickAxisY;
  12543. private _rightStickAxisX;
  12544. private _rightStickAxisY;
  12545. /**
  12546. * Triggered when the left control stick has been changed
  12547. */
  12548. private _onleftstickchanged;
  12549. /**
  12550. * Triggered when the right control stick has been changed
  12551. */
  12552. private _onrightstickchanged;
  12553. /**
  12554. * Represents a gamepad controller
  12555. */
  12556. static GAMEPAD: number;
  12557. /**
  12558. * Represents a generic controller
  12559. */
  12560. static GENERIC: number;
  12561. /**
  12562. * Represents an XBox controller
  12563. */
  12564. static XBOX: number;
  12565. /**
  12566. * Represents a pose-enabled controller
  12567. */
  12568. static POSE_ENABLED: number;
  12569. /**
  12570. * Represents an Dual Shock controller
  12571. */
  12572. static DUALSHOCK: number;
  12573. /**
  12574. * Specifies whether the left control stick should be Y-inverted
  12575. */
  12576. protected _invertLeftStickY: boolean;
  12577. /**
  12578. * Specifies if the gamepad has been connected
  12579. */
  12580. readonly isConnected: boolean;
  12581. /**
  12582. * Initializes the gamepad
  12583. * @param id The id of the gamepad
  12584. * @param index The index of the gamepad
  12585. * @param browserGamepad The browser gamepad
  12586. * @param leftStickX The x component of the left joystick
  12587. * @param leftStickY The y component of the left joystick
  12588. * @param rightStickX The x component of the right joystick
  12589. * @param rightStickY The y component of the right joystick
  12590. */
  12591. constructor(
  12592. /**
  12593. * The id of the gamepad
  12594. */
  12595. id: string,
  12596. /**
  12597. * The index of the gamepad
  12598. */
  12599. index: number,
  12600. /**
  12601. * The browser gamepad
  12602. */
  12603. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12604. /**
  12605. * Callback triggered when the left joystick has changed
  12606. * @param callback
  12607. */
  12608. onleftstickchanged(callback: (values: StickValues) => void): void;
  12609. /**
  12610. * Callback triggered when the right joystick has changed
  12611. * @param callback
  12612. */
  12613. onrightstickchanged(callback: (values: StickValues) => void): void;
  12614. /**
  12615. * Gets the left joystick
  12616. */
  12617. /**
  12618. * Sets the left joystick values
  12619. */
  12620. leftStick: StickValues;
  12621. /**
  12622. * Gets the right joystick
  12623. */
  12624. /**
  12625. * Sets the right joystick value
  12626. */
  12627. rightStick: StickValues;
  12628. /**
  12629. * Updates the gamepad joystick positions
  12630. */
  12631. update(): void;
  12632. /**
  12633. * Disposes the gamepad
  12634. */
  12635. dispose(): void;
  12636. }
  12637. /**
  12638. * Represents a generic gamepad
  12639. */
  12640. export class GenericPad extends Gamepad {
  12641. private _buttons;
  12642. private _onbuttondown;
  12643. private _onbuttonup;
  12644. /**
  12645. * Observable triggered when a button has been pressed
  12646. */
  12647. onButtonDownObservable: Observable<number>;
  12648. /**
  12649. * Observable triggered when a button has been released
  12650. */
  12651. onButtonUpObservable: Observable<number>;
  12652. /**
  12653. * Callback triggered when a button has been pressed
  12654. * @param callback Called when a button has been pressed
  12655. */
  12656. onbuttondown(callback: (buttonPressed: number) => void): void;
  12657. /**
  12658. * Callback triggered when a button has been released
  12659. * @param callback Called when a button has been released
  12660. */
  12661. onbuttonup(callback: (buttonReleased: number) => void): void;
  12662. /**
  12663. * Initializes the generic gamepad
  12664. * @param id The id of the generic gamepad
  12665. * @param index The index of the generic gamepad
  12666. * @param browserGamepad The browser gamepad
  12667. */
  12668. constructor(id: string, index: number, browserGamepad: any);
  12669. private _setButtonValue;
  12670. /**
  12671. * Updates the generic gamepad
  12672. */
  12673. update(): void;
  12674. /**
  12675. * Disposes the generic gamepad
  12676. */
  12677. dispose(): void;
  12678. }
  12679. }
  12680. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12681. import { Nullable } from "babylonjs/types";
  12682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12683. import { Scene } from "babylonjs/scene";
  12684. module "babylonjs/Engines/engine" {
  12685. interface Engine {
  12686. /**
  12687. * Creates a raw texture
  12688. * @param data defines the data to store in the texture
  12689. * @param width defines the width of the texture
  12690. * @param height defines the height of the texture
  12691. * @param format defines the format of the data
  12692. * @param generateMipMaps defines if the engine should generate the mip levels
  12693. * @param invertY defines if data must be stored with Y axis inverted
  12694. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12695. * @param compression defines the compression used (null by default)
  12696. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12697. * @returns the raw texture inside an InternalTexture
  12698. */
  12699. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12700. /**
  12701. * Update a raw texture
  12702. * @param texture defines the texture to update
  12703. * @param data defines the data to store in the texture
  12704. * @param format defines the format of the data
  12705. * @param invertY defines if data must be stored with Y axis inverted
  12706. */
  12707. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12708. /**
  12709. * Update a raw texture
  12710. * @param texture defines the texture to update
  12711. * @param data defines the data to store in the texture
  12712. * @param format defines the format of the data
  12713. * @param invertY defines if data must be stored with Y axis inverted
  12714. * @param compression defines the compression used (null by default)
  12715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12716. */
  12717. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12718. /**
  12719. * Creates a new raw cube texture
  12720. * @param data defines the array of data to use to create each face
  12721. * @param size defines the size of the textures
  12722. * @param format defines the format of the data
  12723. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12724. * @param generateMipMaps defines if the engine should generate the mip levels
  12725. * @param invertY defines if data must be stored with Y axis inverted
  12726. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12727. * @param compression defines the compression used (null by default)
  12728. * @returns the cube texture as an InternalTexture
  12729. */
  12730. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12731. /**
  12732. * Update a raw cube texture
  12733. * @param texture defines the texture to udpdate
  12734. * @param data defines the data to store
  12735. * @param format defines the data format
  12736. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12737. * @param invertY defines if data must be stored with Y axis inverted
  12738. */
  12739. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12740. /**
  12741. * Update a raw cube texture
  12742. * @param texture defines the texture to udpdate
  12743. * @param data defines the data to store
  12744. * @param format defines the data format
  12745. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12746. * @param invertY defines if data must be stored with Y axis inverted
  12747. * @param compression defines the compression used (null by default)
  12748. */
  12749. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12750. /**
  12751. * Update a raw cube texture
  12752. * @param texture defines the texture to udpdate
  12753. * @param data defines the data to store
  12754. * @param format defines the data format
  12755. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12756. * @param invertY defines if data must be stored with Y axis inverted
  12757. * @param compression defines the compression used (null by default)
  12758. * @param level defines which level of the texture to update
  12759. */
  12760. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12761. /**
  12762. * Creates a new raw cube texture from a specified url
  12763. * @param url defines the url where the data is located
  12764. * @param scene defines the current scene
  12765. * @param size defines the size of the textures
  12766. * @param format defines the format of the data
  12767. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12768. * @param noMipmap defines if the engine should avoid generating the mip levels
  12769. * @param callback defines a callback used to extract texture data from loaded data
  12770. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12771. * @param onLoad defines a callback called when texture is loaded
  12772. * @param onError defines a callback called if there is an error
  12773. * @returns the cube texture as an InternalTexture
  12774. */
  12775. 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;
  12776. /**
  12777. * Creates a new raw cube texture from a specified url
  12778. * @param url defines the url where the data is located
  12779. * @param scene defines the current scene
  12780. * @param size defines the size of the textures
  12781. * @param format defines the format of the data
  12782. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12783. * @param noMipmap defines if the engine should avoid generating the mip levels
  12784. * @param callback defines a callback used to extract texture data from loaded data
  12785. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12786. * @param onLoad defines a callback called when texture is loaded
  12787. * @param onError defines a callback called if there is an error
  12788. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12789. * @param invertY defines if data must be stored with Y axis inverted
  12790. * @returns the cube texture as an InternalTexture
  12791. */
  12792. 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;
  12793. /**
  12794. * Creates a new raw 3D texture
  12795. * @param data defines the data used to create the texture
  12796. * @param width defines the width of the texture
  12797. * @param height defines the height of the texture
  12798. * @param depth defines the depth of the texture
  12799. * @param format defines the format of the texture
  12800. * @param generateMipMaps defines if the engine must generate mip levels
  12801. * @param invertY defines if data must be stored with Y axis inverted
  12802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12803. * @param compression defines the compressed used (can be null)
  12804. * @param textureType defines the compressed used (can be null)
  12805. * @returns a new raw 3D texture (stored in an InternalTexture)
  12806. */
  12807. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12808. /**
  12809. * Update a raw 3D texture
  12810. * @param texture defines the texture to update
  12811. * @param data defines the data to store
  12812. * @param format defines the data format
  12813. * @param invertY defines if data must be stored with Y axis inverted
  12814. */
  12815. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12816. /**
  12817. * Update a raw 3D texture
  12818. * @param texture defines the texture to update
  12819. * @param data defines the data to store
  12820. * @param format defines the data format
  12821. * @param invertY defines if data must be stored with Y axis inverted
  12822. * @param compression defines the used compression (can be null)
  12823. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12824. */
  12825. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12826. }
  12827. }
  12828. }
  12829. declare module "babylonjs/Materials/Textures/rawTexture" {
  12830. import { Scene } from "babylonjs/scene";
  12831. import { Texture } from "babylonjs/Materials/Textures/texture";
  12832. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12833. /**
  12834. * Raw texture can help creating a texture directly from an array of data.
  12835. * This can be super useful if you either get the data from an uncompressed source or
  12836. * if you wish to create your texture pixel by pixel.
  12837. */
  12838. export class RawTexture extends Texture {
  12839. /**
  12840. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12841. */
  12842. format: number;
  12843. private _engine;
  12844. /**
  12845. * Instantiates a new RawTexture.
  12846. * Raw texture can help creating a texture directly from an array of data.
  12847. * This can be super useful if you either get the data from an uncompressed source or
  12848. * if you wish to create your texture pixel by pixel.
  12849. * @param data define the array of data to use to create the texture
  12850. * @param width define the width of the texture
  12851. * @param height define the height of the texture
  12852. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12853. * @param scene define the scene the texture belongs to
  12854. * @param generateMipMaps define whether mip maps should be generated or not
  12855. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12856. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12857. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12858. */
  12859. constructor(data: ArrayBufferView, width: number, height: number,
  12860. /**
  12861. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12862. */
  12863. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12864. /**
  12865. * Updates the texture underlying data.
  12866. * @param data Define the new data of the texture
  12867. */
  12868. update(data: ArrayBufferView): void;
  12869. /**
  12870. * Creates a luminance texture from some data.
  12871. * @param data Define the texture data
  12872. * @param width Define the width of the texture
  12873. * @param height Define the height of the texture
  12874. * @param scene Define the scene the texture belongs to
  12875. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12876. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12877. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12878. * @returns the luminance texture
  12879. */
  12880. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12881. /**
  12882. * Creates a luminance alpha texture from some data.
  12883. * @param data Define the texture data
  12884. * @param width Define the width of the texture
  12885. * @param height Define the height of the texture
  12886. * @param scene Define the scene the texture belongs to
  12887. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12888. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12889. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12890. * @returns the luminance alpha texture
  12891. */
  12892. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12893. /**
  12894. * Creates an alpha texture from some data.
  12895. * @param data Define the texture data
  12896. * @param width Define the width of the texture
  12897. * @param height Define the height of the texture
  12898. * @param scene Define the scene the texture belongs to
  12899. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12900. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12901. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12902. * @returns the alpha texture
  12903. */
  12904. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12905. /**
  12906. * Creates a RGB texture from some data.
  12907. * @param data Define the texture data
  12908. * @param width Define the width of the texture
  12909. * @param height Define the height of the texture
  12910. * @param scene Define the scene the texture belongs to
  12911. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12912. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12913. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12914. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12915. * @returns the RGB alpha texture
  12916. */
  12917. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12918. /**
  12919. * Creates a RGBA texture from some data.
  12920. * @param data Define the texture data
  12921. * @param width Define the width of the texture
  12922. * @param height Define the height of the texture
  12923. * @param scene Define the scene the texture belongs to
  12924. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12925. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12926. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12927. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12928. * @returns the RGBA texture
  12929. */
  12930. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12931. /**
  12932. * Creates a R texture from some data.
  12933. * @param data Define the texture data
  12934. * @param width Define the width of the texture
  12935. * @param height Define the height of the texture
  12936. * @param scene Define the scene the texture belongs to
  12937. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12938. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12939. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12940. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12941. * @returns the R texture
  12942. */
  12943. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12944. }
  12945. }
  12946. declare module "babylonjs/Maths/math.size" {
  12947. /**
  12948. * Interface for the size containing width and height
  12949. */
  12950. export interface ISize {
  12951. /**
  12952. * Width
  12953. */
  12954. width: number;
  12955. /**
  12956. * Heighht
  12957. */
  12958. height: number;
  12959. }
  12960. /**
  12961. * Size containing widht and height
  12962. */
  12963. export class Size implements ISize {
  12964. /**
  12965. * Width
  12966. */
  12967. width: number;
  12968. /**
  12969. * Height
  12970. */
  12971. height: number;
  12972. /**
  12973. * Creates a Size object from the given width and height (floats).
  12974. * @param width width of the new size
  12975. * @param height height of the new size
  12976. */
  12977. constructor(width: number, height: number);
  12978. /**
  12979. * Returns a string with the Size width and height
  12980. * @returns a string with the Size width and height
  12981. */
  12982. toString(): string;
  12983. /**
  12984. * "Size"
  12985. * @returns the string "Size"
  12986. */
  12987. getClassName(): string;
  12988. /**
  12989. * Returns the Size hash code.
  12990. * @returns a hash code for a unique width and height
  12991. */
  12992. getHashCode(): number;
  12993. /**
  12994. * Updates the current size from the given one.
  12995. * @param src the given size
  12996. */
  12997. copyFrom(src: Size): void;
  12998. /**
  12999. * Updates in place the current Size from the given floats.
  13000. * @param width width of the new size
  13001. * @param height height of the new size
  13002. * @returns the updated Size.
  13003. */
  13004. copyFromFloats(width: number, height: number): Size;
  13005. /**
  13006. * Updates in place the current Size from the given floats.
  13007. * @param width width to set
  13008. * @param height height to set
  13009. * @returns the updated Size.
  13010. */
  13011. set(width: number, height: number): Size;
  13012. /**
  13013. * Multiplies the width and height by numbers
  13014. * @param w factor to multiple the width by
  13015. * @param h factor to multiple the height by
  13016. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13017. */
  13018. multiplyByFloats(w: number, h: number): Size;
  13019. /**
  13020. * Clones the size
  13021. * @returns a new Size copied from the given one.
  13022. */
  13023. clone(): Size;
  13024. /**
  13025. * True if the current Size and the given one width and height are strictly equal.
  13026. * @param other the other size to compare against
  13027. * @returns True if the current Size and the given one width and height are strictly equal.
  13028. */
  13029. equals(other: Size): boolean;
  13030. /**
  13031. * The surface of the Size : width * height (float).
  13032. */
  13033. readonly surface: number;
  13034. /**
  13035. * Create a new size of zero
  13036. * @returns a new Size set to (0.0, 0.0)
  13037. */
  13038. static Zero(): Size;
  13039. /**
  13040. * Sums the width and height of two sizes
  13041. * @param otherSize size to add to this size
  13042. * @returns a new Size set as the addition result of the current Size and the given one.
  13043. */
  13044. add(otherSize: Size): Size;
  13045. /**
  13046. * Subtracts the width and height of two
  13047. * @param otherSize size to subtract to this size
  13048. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13049. */
  13050. subtract(otherSize: Size): Size;
  13051. /**
  13052. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13053. * @param start starting size to lerp between
  13054. * @param end end size to lerp between
  13055. * @param amount amount to lerp between the start and end values
  13056. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13057. */
  13058. static Lerp(start: Size, end: Size, amount: number): Size;
  13059. }
  13060. }
  13061. declare module "babylonjs/Animations/runtimeAnimation" {
  13062. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13063. import { Animatable } from "babylonjs/Animations/animatable";
  13064. import { Scene } from "babylonjs/scene";
  13065. /**
  13066. * Defines a runtime animation
  13067. */
  13068. export class RuntimeAnimation {
  13069. private _events;
  13070. /**
  13071. * The current frame of the runtime animation
  13072. */
  13073. private _currentFrame;
  13074. /**
  13075. * The animation used by the runtime animation
  13076. */
  13077. private _animation;
  13078. /**
  13079. * The target of the runtime animation
  13080. */
  13081. private _target;
  13082. /**
  13083. * The initiating animatable
  13084. */
  13085. private _host;
  13086. /**
  13087. * The original value of the runtime animation
  13088. */
  13089. private _originalValue;
  13090. /**
  13091. * The original blend value of the runtime animation
  13092. */
  13093. private _originalBlendValue;
  13094. /**
  13095. * The offsets cache of the runtime animation
  13096. */
  13097. private _offsetsCache;
  13098. /**
  13099. * The high limits cache of the runtime animation
  13100. */
  13101. private _highLimitsCache;
  13102. /**
  13103. * Specifies if the runtime animation has been stopped
  13104. */
  13105. private _stopped;
  13106. /**
  13107. * The blending factor of the runtime animation
  13108. */
  13109. private _blendingFactor;
  13110. /**
  13111. * The BabylonJS scene
  13112. */
  13113. private _scene;
  13114. /**
  13115. * The current value of the runtime animation
  13116. */
  13117. private _currentValue;
  13118. /** @hidden */
  13119. _animationState: _IAnimationState;
  13120. /**
  13121. * The active target of the runtime animation
  13122. */
  13123. private _activeTargets;
  13124. private _currentActiveTarget;
  13125. private _directTarget;
  13126. /**
  13127. * The target path of the runtime animation
  13128. */
  13129. private _targetPath;
  13130. /**
  13131. * The weight of the runtime animation
  13132. */
  13133. private _weight;
  13134. /**
  13135. * The ratio offset of the runtime animation
  13136. */
  13137. private _ratioOffset;
  13138. /**
  13139. * The previous delay of the runtime animation
  13140. */
  13141. private _previousDelay;
  13142. /**
  13143. * The previous ratio of the runtime animation
  13144. */
  13145. private _previousRatio;
  13146. private _enableBlending;
  13147. private _keys;
  13148. private _minFrame;
  13149. private _maxFrame;
  13150. private _minValue;
  13151. private _maxValue;
  13152. private _targetIsArray;
  13153. /**
  13154. * Gets the current frame of the runtime animation
  13155. */
  13156. readonly currentFrame: number;
  13157. /**
  13158. * Gets the weight of the runtime animation
  13159. */
  13160. readonly weight: number;
  13161. /**
  13162. * Gets the current value of the runtime animation
  13163. */
  13164. readonly currentValue: any;
  13165. /**
  13166. * Gets the target path of the runtime animation
  13167. */
  13168. readonly targetPath: string;
  13169. /**
  13170. * Gets the actual target of the runtime animation
  13171. */
  13172. readonly target: any;
  13173. /** @hidden */
  13174. _onLoop: () => void;
  13175. /**
  13176. * Create a new RuntimeAnimation object
  13177. * @param target defines the target of the animation
  13178. * @param animation defines the source animation object
  13179. * @param scene defines the hosting scene
  13180. * @param host defines the initiating Animatable
  13181. */
  13182. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13183. private _preparePath;
  13184. /**
  13185. * Gets the animation from the runtime animation
  13186. */
  13187. readonly animation: Animation;
  13188. /**
  13189. * Resets the runtime animation to the beginning
  13190. * @param restoreOriginal defines whether to restore the target property to the original value
  13191. */
  13192. reset(restoreOriginal?: boolean): void;
  13193. /**
  13194. * Specifies if the runtime animation is stopped
  13195. * @returns Boolean specifying if the runtime animation is stopped
  13196. */
  13197. isStopped(): boolean;
  13198. /**
  13199. * Disposes of the runtime animation
  13200. */
  13201. dispose(): void;
  13202. /**
  13203. * Apply the interpolated value to the target
  13204. * @param currentValue defines the value computed by the animation
  13205. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13206. */
  13207. setValue(currentValue: any, weight: number): void;
  13208. private _getOriginalValues;
  13209. private _setValue;
  13210. /**
  13211. * Gets the loop pmode of the runtime animation
  13212. * @returns Loop Mode
  13213. */
  13214. private _getCorrectLoopMode;
  13215. /**
  13216. * Move the current animation to a given frame
  13217. * @param frame defines the frame to move to
  13218. */
  13219. goToFrame(frame: number): void;
  13220. /**
  13221. * @hidden Internal use only
  13222. */
  13223. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13224. /**
  13225. * Execute the current animation
  13226. * @param delay defines the delay to add to the current frame
  13227. * @param from defines the lower bound of the animation range
  13228. * @param to defines the upper bound of the animation range
  13229. * @param loop defines if the current animation must loop
  13230. * @param speedRatio defines the current speed ratio
  13231. * @param weight defines the weight of the animation (default is -1 so no weight)
  13232. * @param onLoop optional callback called when animation loops
  13233. * @returns a boolean indicating if the animation is running
  13234. */
  13235. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13236. }
  13237. }
  13238. declare module "babylonjs/Animations/animatable" {
  13239. import { Animation } from "babylonjs/Animations/animation";
  13240. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13241. import { Nullable } from "babylonjs/types";
  13242. import { Observable } from "babylonjs/Misc/observable";
  13243. import { Scene } from "babylonjs/scene";
  13244. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13245. import { Node } from "babylonjs/node";
  13246. /**
  13247. * Class used to store an actual running animation
  13248. */
  13249. export class Animatable {
  13250. /** defines the target object */
  13251. target: any;
  13252. /** defines the starting frame number (default is 0) */
  13253. fromFrame: number;
  13254. /** defines the ending frame number (default is 100) */
  13255. toFrame: number;
  13256. /** defines if the animation must loop (default is false) */
  13257. loopAnimation: boolean;
  13258. /** defines a callback to call when animation ends if it is not looping */
  13259. onAnimationEnd?: (() => void) | null | undefined;
  13260. /** defines a callback to call when animation loops */
  13261. onAnimationLoop?: (() => void) | null | undefined;
  13262. private _localDelayOffset;
  13263. private _pausedDelay;
  13264. private _runtimeAnimations;
  13265. private _paused;
  13266. private _scene;
  13267. private _speedRatio;
  13268. private _weight;
  13269. private _syncRoot;
  13270. /**
  13271. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13272. * This will only apply for non looping animation (default is true)
  13273. */
  13274. disposeOnEnd: boolean;
  13275. /**
  13276. * Gets a boolean indicating if the animation has started
  13277. */
  13278. animationStarted: boolean;
  13279. /**
  13280. * Observer raised when the animation ends
  13281. */
  13282. onAnimationEndObservable: Observable<Animatable>;
  13283. /**
  13284. * Observer raised when the animation loops
  13285. */
  13286. onAnimationLoopObservable: Observable<Animatable>;
  13287. /**
  13288. * Gets the root Animatable used to synchronize and normalize animations
  13289. */
  13290. readonly syncRoot: Nullable<Animatable>;
  13291. /**
  13292. * Gets the current frame of the first RuntimeAnimation
  13293. * Used to synchronize Animatables
  13294. */
  13295. readonly masterFrame: number;
  13296. /**
  13297. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13298. */
  13299. weight: number;
  13300. /**
  13301. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13302. */
  13303. speedRatio: number;
  13304. /**
  13305. * Creates a new Animatable
  13306. * @param scene defines the hosting scene
  13307. * @param target defines the target object
  13308. * @param fromFrame defines the starting frame number (default is 0)
  13309. * @param toFrame defines the ending frame number (default is 100)
  13310. * @param loopAnimation defines if the animation must loop (default is false)
  13311. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13312. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13313. * @param animations defines a group of animation to add to the new Animatable
  13314. * @param onAnimationLoop defines a callback to call when animation loops
  13315. */
  13316. constructor(scene: Scene,
  13317. /** defines the target object */
  13318. target: any,
  13319. /** defines the starting frame number (default is 0) */
  13320. fromFrame?: number,
  13321. /** defines the ending frame number (default is 100) */
  13322. toFrame?: number,
  13323. /** defines if the animation must loop (default is false) */
  13324. loopAnimation?: boolean, speedRatio?: number,
  13325. /** defines a callback to call when animation ends if it is not looping */
  13326. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13327. /** defines a callback to call when animation loops */
  13328. onAnimationLoop?: (() => void) | null | undefined);
  13329. /**
  13330. * Synchronize and normalize current Animatable with a source Animatable
  13331. * This is useful when using animation weights and when animations are not of the same length
  13332. * @param root defines the root Animatable to synchronize with
  13333. * @returns the current Animatable
  13334. */
  13335. syncWith(root: Animatable): Animatable;
  13336. /**
  13337. * Gets the list of runtime animations
  13338. * @returns an array of RuntimeAnimation
  13339. */
  13340. getAnimations(): RuntimeAnimation[];
  13341. /**
  13342. * Adds more animations to the current animatable
  13343. * @param target defines the target of the animations
  13344. * @param animations defines the new animations to add
  13345. */
  13346. appendAnimations(target: any, animations: Animation[]): void;
  13347. /**
  13348. * Gets the source animation for a specific property
  13349. * @param property defines the propertyu to look for
  13350. * @returns null or the source animation for the given property
  13351. */
  13352. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13353. /**
  13354. * Gets the runtime animation for a specific property
  13355. * @param property defines the propertyu to look for
  13356. * @returns null or the runtime animation for the given property
  13357. */
  13358. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13359. /**
  13360. * Resets the animatable to its original state
  13361. */
  13362. reset(): void;
  13363. /**
  13364. * Allows the animatable to blend with current running animations
  13365. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13366. * @param blendingSpeed defines the blending speed to use
  13367. */
  13368. enableBlending(blendingSpeed: number): void;
  13369. /**
  13370. * Disable animation blending
  13371. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13372. */
  13373. disableBlending(): void;
  13374. /**
  13375. * Jump directly to a given frame
  13376. * @param frame defines the frame to jump to
  13377. */
  13378. goToFrame(frame: number): void;
  13379. /**
  13380. * Pause the animation
  13381. */
  13382. pause(): void;
  13383. /**
  13384. * Restart the animation
  13385. */
  13386. restart(): void;
  13387. private _raiseOnAnimationEnd;
  13388. /**
  13389. * Stop and delete the current animation
  13390. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13391. * @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)
  13392. */
  13393. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13394. /**
  13395. * Wait asynchronously for the animation to end
  13396. * @returns a promise which will be fullfilled when the animation ends
  13397. */
  13398. waitAsync(): Promise<Animatable>;
  13399. /** @hidden */
  13400. _animate(delay: number): boolean;
  13401. }
  13402. module "babylonjs/scene" {
  13403. interface Scene {
  13404. /** @hidden */
  13405. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13406. /** @hidden */
  13407. _processLateAnimationBindingsForMatrices(holder: {
  13408. totalWeight: number;
  13409. animations: RuntimeAnimation[];
  13410. originalValue: Matrix;
  13411. }): any;
  13412. /** @hidden */
  13413. _processLateAnimationBindingsForQuaternions(holder: {
  13414. totalWeight: number;
  13415. animations: RuntimeAnimation[];
  13416. originalValue: Quaternion;
  13417. }, refQuaternion: Quaternion): Quaternion;
  13418. /** @hidden */
  13419. _processLateAnimationBindings(): void;
  13420. /**
  13421. * Will start the animation sequence of a given target
  13422. * @param target defines the target
  13423. * @param from defines from which frame should animation start
  13424. * @param to defines until which frame should animation run.
  13425. * @param weight defines the weight to apply to the animation (1.0 by default)
  13426. * @param loop defines if the animation loops
  13427. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13428. * @param onAnimationEnd defines the function to be executed when the animation ends
  13429. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13430. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13431. * @param onAnimationLoop defines the callback to call when an animation loops
  13432. * @returns the animatable object created for this animation
  13433. */
  13434. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13435. /**
  13436. * Will start the animation sequence of a given target
  13437. * @param target defines the target
  13438. * @param from defines from which frame should animation start
  13439. * @param to defines until which frame should animation run.
  13440. * @param loop defines if the animation loops
  13441. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13442. * @param onAnimationEnd defines the function to be executed when the animation ends
  13443. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13444. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13445. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13446. * @param onAnimationLoop defines the callback to call when an animation loops
  13447. * @returns the animatable object created for this animation
  13448. */
  13449. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13450. /**
  13451. * Will start the animation sequence of a given target and its hierarchy
  13452. * @param target defines the target
  13453. * @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.
  13454. * @param from defines from which frame should animation start
  13455. * @param to defines until which frame should animation run.
  13456. * @param loop defines if the animation loops
  13457. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13458. * @param onAnimationEnd defines the function to be executed when the animation ends
  13459. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13460. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13461. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13462. * @param onAnimationLoop defines the callback to call when an animation loops
  13463. * @returns the list of created animatables
  13464. */
  13465. 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[];
  13466. /**
  13467. * Begin a new animation on a given node
  13468. * @param target defines the target where the animation will take place
  13469. * @param animations defines the list of animations to start
  13470. * @param from defines the initial value
  13471. * @param to defines the final value
  13472. * @param loop defines if you want animation to loop (off by default)
  13473. * @param speedRatio defines the speed ratio to apply to all animations
  13474. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13475. * @param onAnimationLoop defines the callback to call when an animation loops
  13476. * @returns the list of created animatables
  13477. */
  13478. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13479. /**
  13480. * Begin a new animation on a given node and its hierarchy
  13481. * @param target defines the root node where the animation will take place
  13482. * @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.
  13483. * @param animations defines the list of animations to start
  13484. * @param from defines the initial value
  13485. * @param to defines the final value
  13486. * @param loop defines if you want animation to loop (off by default)
  13487. * @param speedRatio defines the speed ratio to apply to all animations
  13488. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13489. * @param onAnimationLoop defines the callback to call when an animation loops
  13490. * @returns the list of animatables created for all nodes
  13491. */
  13492. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13493. /**
  13494. * Gets the animatable associated with a specific target
  13495. * @param target defines the target of the animatable
  13496. * @returns the required animatable if found
  13497. */
  13498. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13499. /**
  13500. * Gets all animatables associated with a given target
  13501. * @param target defines the target to look animatables for
  13502. * @returns an array of Animatables
  13503. */
  13504. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13505. /**
  13506. * Stops and removes all animations that have been applied to the scene
  13507. */
  13508. stopAllAnimations(): void;
  13509. /**
  13510. * Gets the current delta time used by animation engine
  13511. */
  13512. deltaTime: number;
  13513. }
  13514. }
  13515. module "babylonjs/Bones/bone" {
  13516. interface Bone {
  13517. /**
  13518. * Copy an animation range from another bone
  13519. * @param source defines the source bone
  13520. * @param rangeName defines the range name to copy
  13521. * @param frameOffset defines the frame offset
  13522. * @param rescaleAsRequired defines if rescaling must be applied if required
  13523. * @param skelDimensionsRatio defines the scaling ratio
  13524. * @returns true if operation was successful
  13525. */
  13526. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13527. }
  13528. }
  13529. }
  13530. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13531. /**
  13532. * Class used to override all child animations of a given target
  13533. */
  13534. export class AnimationPropertiesOverride {
  13535. /**
  13536. * Gets or sets a value indicating if animation blending must be used
  13537. */
  13538. enableBlending: boolean;
  13539. /**
  13540. * Gets or sets the blending speed to use when enableBlending is true
  13541. */
  13542. blendingSpeed: number;
  13543. /**
  13544. * Gets or sets the default loop mode to use
  13545. */
  13546. loopMode: number;
  13547. }
  13548. }
  13549. declare module "babylonjs/Bones/skeleton" {
  13550. import { Bone } from "babylonjs/Bones/bone";
  13551. import { Observable } from "babylonjs/Misc/observable";
  13552. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13553. import { Scene } from "babylonjs/scene";
  13554. import { Nullable } from "babylonjs/types";
  13555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13556. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13557. import { Animatable } from "babylonjs/Animations/animatable";
  13558. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13559. import { Animation } from "babylonjs/Animations/animation";
  13560. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13561. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13562. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13563. /**
  13564. * Class used to handle skinning animations
  13565. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13566. */
  13567. export class Skeleton implements IAnimatable {
  13568. /** defines the skeleton name */
  13569. name: string;
  13570. /** defines the skeleton Id */
  13571. id: string;
  13572. /**
  13573. * Defines the list of child bones
  13574. */
  13575. bones: Bone[];
  13576. /**
  13577. * Defines an estimate of the dimension of the skeleton at rest
  13578. */
  13579. dimensionsAtRest: Vector3;
  13580. /**
  13581. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13582. */
  13583. needInitialSkinMatrix: boolean;
  13584. /**
  13585. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13586. */
  13587. overrideMesh: Nullable<AbstractMesh>;
  13588. /**
  13589. * Gets the list of animations attached to this skeleton
  13590. */
  13591. animations: Array<Animation>;
  13592. private _scene;
  13593. private _isDirty;
  13594. private _transformMatrices;
  13595. private _transformMatrixTexture;
  13596. private _meshesWithPoseMatrix;
  13597. private _animatables;
  13598. private _identity;
  13599. private _synchronizedWithMesh;
  13600. private _ranges;
  13601. private _lastAbsoluteTransformsUpdateId;
  13602. private _canUseTextureForBones;
  13603. private _uniqueId;
  13604. /** @hidden */
  13605. _numBonesWithLinkedTransformNode: number;
  13606. /** @hidden */
  13607. _hasWaitingData: Nullable<boolean>;
  13608. /**
  13609. * Specifies if the skeleton should be serialized
  13610. */
  13611. doNotSerialize: boolean;
  13612. private _useTextureToStoreBoneMatrices;
  13613. /**
  13614. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13615. * Please note that this option is not available if the hardware does not support it
  13616. */
  13617. useTextureToStoreBoneMatrices: boolean;
  13618. private _animationPropertiesOverride;
  13619. /**
  13620. * Gets or sets the animation properties override
  13621. */
  13622. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13623. /**
  13624. * List of inspectable custom properties (used by the Inspector)
  13625. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13626. */
  13627. inspectableCustomProperties: IInspectable[];
  13628. /**
  13629. * An observable triggered before computing the skeleton's matrices
  13630. */
  13631. onBeforeComputeObservable: Observable<Skeleton>;
  13632. /**
  13633. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13634. */
  13635. readonly isUsingTextureForMatrices: boolean;
  13636. /**
  13637. * Gets the unique ID of this skeleton
  13638. */
  13639. readonly uniqueId: number;
  13640. /**
  13641. * Creates a new skeleton
  13642. * @param name defines the skeleton name
  13643. * @param id defines the skeleton Id
  13644. * @param scene defines the hosting scene
  13645. */
  13646. constructor(
  13647. /** defines the skeleton name */
  13648. name: string,
  13649. /** defines the skeleton Id */
  13650. id: string, scene: Scene);
  13651. /**
  13652. * Gets the current object class name.
  13653. * @return the class name
  13654. */
  13655. getClassName(): string;
  13656. /**
  13657. * Returns an array containing the root bones
  13658. * @returns an array containing the root bones
  13659. */
  13660. getChildren(): Array<Bone>;
  13661. /**
  13662. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13663. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13664. * @returns a Float32Array containing matrices data
  13665. */
  13666. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13667. /**
  13668. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13669. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13670. * @returns a raw texture containing the data
  13671. */
  13672. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13673. /**
  13674. * Gets the current hosting scene
  13675. * @returns a scene object
  13676. */
  13677. getScene(): Scene;
  13678. /**
  13679. * Gets a string representing the current skeleton data
  13680. * @param fullDetails defines a boolean indicating if we want a verbose version
  13681. * @returns a string representing the current skeleton data
  13682. */
  13683. toString(fullDetails?: boolean): string;
  13684. /**
  13685. * Get bone's index searching by name
  13686. * @param name defines bone's name to search for
  13687. * @return the indice of the bone. Returns -1 if not found
  13688. */
  13689. getBoneIndexByName(name: string): number;
  13690. /**
  13691. * Creater a new animation range
  13692. * @param name defines the name of the range
  13693. * @param from defines the start key
  13694. * @param to defines the end key
  13695. */
  13696. createAnimationRange(name: string, from: number, to: number): void;
  13697. /**
  13698. * Delete a specific animation range
  13699. * @param name defines the name of the range
  13700. * @param deleteFrames defines if frames must be removed as well
  13701. */
  13702. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13703. /**
  13704. * Gets a specific animation range
  13705. * @param name defines the name of the range to look for
  13706. * @returns the requested animation range or null if not found
  13707. */
  13708. getAnimationRange(name: string): Nullable<AnimationRange>;
  13709. /**
  13710. * Gets the list of all animation ranges defined on this skeleton
  13711. * @returns an array
  13712. */
  13713. getAnimationRanges(): Nullable<AnimationRange>[];
  13714. /**
  13715. * Copy animation range from a source skeleton.
  13716. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13717. * @param source defines the source skeleton
  13718. * @param name defines the name of the range to copy
  13719. * @param rescaleAsRequired defines if rescaling must be applied if required
  13720. * @returns true if operation was successful
  13721. */
  13722. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13723. /**
  13724. * Forces the skeleton to go to rest pose
  13725. */
  13726. returnToRest(): void;
  13727. private _getHighestAnimationFrame;
  13728. /**
  13729. * Begin a specific animation range
  13730. * @param name defines the name of the range to start
  13731. * @param loop defines if looping must be turned on (false by default)
  13732. * @param speedRatio defines the speed ratio to apply (1 by default)
  13733. * @param onAnimationEnd defines a callback which will be called when animation will end
  13734. * @returns a new animatable
  13735. */
  13736. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13737. /** @hidden */
  13738. _markAsDirty(): void;
  13739. /** @hidden */
  13740. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13741. /** @hidden */
  13742. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13743. private _computeTransformMatrices;
  13744. /**
  13745. * Build all resources required to render a skeleton
  13746. */
  13747. prepare(): void;
  13748. /**
  13749. * Gets the list of animatables currently running for this skeleton
  13750. * @returns an array of animatables
  13751. */
  13752. getAnimatables(): IAnimatable[];
  13753. /**
  13754. * Clone the current skeleton
  13755. * @param name defines the name of the new skeleton
  13756. * @param id defines the id of the new skeleton
  13757. * @returns the new skeleton
  13758. */
  13759. clone(name: string, id: string): Skeleton;
  13760. /**
  13761. * Enable animation blending for this skeleton
  13762. * @param blendingSpeed defines the blending speed to apply
  13763. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13764. */
  13765. enableBlending(blendingSpeed?: number): void;
  13766. /**
  13767. * Releases all resources associated with the current skeleton
  13768. */
  13769. dispose(): void;
  13770. /**
  13771. * Serialize the skeleton in a JSON object
  13772. * @returns a JSON object
  13773. */
  13774. serialize(): any;
  13775. /**
  13776. * Creates a new skeleton from serialized data
  13777. * @param parsedSkeleton defines the serialized data
  13778. * @param scene defines the hosting scene
  13779. * @returns a new skeleton
  13780. */
  13781. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13782. /**
  13783. * Compute all node absolute transforms
  13784. * @param forceUpdate defines if computation must be done even if cache is up to date
  13785. */
  13786. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13787. /**
  13788. * Gets the root pose matrix
  13789. * @returns a matrix
  13790. */
  13791. getPoseMatrix(): Nullable<Matrix>;
  13792. /**
  13793. * Sorts bones per internal index
  13794. */
  13795. sortBones(): void;
  13796. private _sortBones;
  13797. }
  13798. }
  13799. declare module "babylonjs/Bones/bone" {
  13800. import { Skeleton } from "babylonjs/Bones/skeleton";
  13801. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13802. import { Nullable } from "babylonjs/types";
  13803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13804. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13805. import { Node } from "babylonjs/node";
  13806. import { Space } from "babylonjs/Maths/math.axis";
  13807. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13808. /**
  13809. * Class used to store bone information
  13810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13811. */
  13812. export class Bone extends Node {
  13813. /**
  13814. * defines the bone name
  13815. */
  13816. name: string;
  13817. private static _tmpVecs;
  13818. private static _tmpQuat;
  13819. private static _tmpMats;
  13820. /**
  13821. * Gets the list of child bones
  13822. */
  13823. children: Bone[];
  13824. /** Gets the animations associated with this bone */
  13825. animations: import("babylonjs/Animations/animation").Animation[];
  13826. /**
  13827. * Gets or sets bone length
  13828. */
  13829. length: number;
  13830. /**
  13831. * @hidden Internal only
  13832. * Set this value to map this bone to a different index in the transform matrices
  13833. * Set this value to -1 to exclude the bone from the transform matrices
  13834. */
  13835. _index: Nullable<number>;
  13836. private _skeleton;
  13837. private _localMatrix;
  13838. private _restPose;
  13839. private _baseMatrix;
  13840. private _absoluteTransform;
  13841. private _invertedAbsoluteTransform;
  13842. private _parent;
  13843. private _scalingDeterminant;
  13844. private _worldTransform;
  13845. private _localScaling;
  13846. private _localRotation;
  13847. private _localPosition;
  13848. private _needToDecompose;
  13849. private _needToCompose;
  13850. /** @hidden */
  13851. _linkedTransformNode: Nullable<TransformNode>;
  13852. /** @hidden */
  13853. _waitingTransformNodeId: Nullable<string>;
  13854. /** @hidden */
  13855. /** @hidden */
  13856. _matrix: Matrix;
  13857. /**
  13858. * Create a new bone
  13859. * @param name defines the bone name
  13860. * @param skeleton defines the parent skeleton
  13861. * @param parentBone defines the parent (can be null if the bone is the root)
  13862. * @param localMatrix defines the local matrix
  13863. * @param restPose defines the rest pose matrix
  13864. * @param baseMatrix defines the base matrix
  13865. * @param index defines index of the bone in the hiearchy
  13866. */
  13867. constructor(
  13868. /**
  13869. * defines the bone name
  13870. */
  13871. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13872. /**
  13873. * Gets the current object class name.
  13874. * @return the class name
  13875. */
  13876. getClassName(): string;
  13877. /**
  13878. * Gets the parent skeleton
  13879. * @returns a skeleton
  13880. */
  13881. getSkeleton(): Skeleton;
  13882. /**
  13883. * Gets parent bone
  13884. * @returns a bone or null if the bone is the root of the bone hierarchy
  13885. */
  13886. getParent(): Nullable<Bone>;
  13887. /**
  13888. * Returns an array containing the root bones
  13889. * @returns an array containing the root bones
  13890. */
  13891. getChildren(): Array<Bone>;
  13892. /**
  13893. * Sets the parent bone
  13894. * @param parent defines the parent (can be null if the bone is the root)
  13895. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13896. */
  13897. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13898. /**
  13899. * Gets the local matrix
  13900. * @returns a matrix
  13901. */
  13902. getLocalMatrix(): Matrix;
  13903. /**
  13904. * Gets the base matrix (initial matrix which remains unchanged)
  13905. * @returns a matrix
  13906. */
  13907. getBaseMatrix(): Matrix;
  13908. /**
  13909. * Gets the rest pose matrix
  13910. * @returns a matrix
  13911. */
  13912. getRestPose(): Matrix;
  13913. /**
  13914. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13915. */
  13916. getWorldMatrix(): Matrix;
  13917. /**
  13918. * Sets the local matrix to rest pose matrix
  13919. */
  13920. returnToRest(): void;
  13921. /**
  13922. * Gets the inverse of the absolute transform matrix.
  13923. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13924. * @returns a matrix
  13925. */
  13926. getInvertedAbsoluteTransform(): Matrix;
  13927. /**
  13928. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13929. * @returns a matrix
  13930. */
  13931. getAbsoluteTransform(): Matrix;
  13932. /**
  13933. * Links with the given transform node.
  13934. * The local matrix of this bone is copied from the transform node every frame.
  13935. * @param transformNode defines the transform node to link to
  13936. */
  13937. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13938. /**
  13939. * Gets the node used to drive the bone's transformation
  13940. * @returns a transform node or null
  13941. */
  13942. getTransformNode(): Nullable<TransformNode>;
  13943. /** Gets or sets current position (in local space) */
  13944. position: Vector3;
  13945. /** Gets or sets current rotation (in local space) */
  13946. rotation: Vector3;
  13947. /** Gets or sets current rotation quaternion (in local space) */
  13948. rotationQuaternion: Quaternion;
  13949. /** Gets or sets current scaling (in local space) */
  13950. scaling: Vector3;
  13951. /**
  13952. * Gets the animation properties override
  13953. */
  13954. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13955. private _decompose;
  13956. private _compose;
  13957. /**
  13958. * Update the base and local matrices
  13959. * @param matrix defines the new base or local matrix
  13960. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13961. * @param updateLocalMatrix defines if the local matrix should be updated
  13962. */
  13963. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13964. /** @hidden */
  13965. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13966. /**
  13967. * Flag the bone as dirty (Forcing it to update everything)
  13968. */
  13969. markAsDirty(): void;
  13970. /** @hidden */
  13971. _markAsDirtyAndCompose(): void;
  13972. private _markAsDirtyAndDecompose;
  13973. /**
  13974. * Translate the bone in local or world space
  13975. * @param vec The amount to translate the bone
  13976. * @param space The space that the translation is in
  13977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13978. */
  13979. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13980. /**
  13981. * Set the postion of the bone in local or world space
  13982. * @param position The position to set the bone
  13983. * @param space The space that the position is in
  13984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13985. */
  13986. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13987. /**
  13988. * Set the absolute position of the bone (world space)
  13989. * @param position The position to set the bone
  13990. * @param mesh The mesh that this bone is attached to
  13991. */
  13992. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13993. /**
  13994. * Scale the bone on the x, y and z axes (in local space)
  13995. * @param x The amount to scale the bone on the x axis
  13996. * @param y The amount to scale the bone on the y axis
  13997. * @param z The amount to scale the bone on the z axis
  13998. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13999. */
  14000. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14001. /**
  14002. * Set the bone scaling in local space
  14003. * @param scale defines the scaling vector
  14004. */
  14005. setScale(scale: Vector3): void;
  14006. /**
  14007. * Gets the current scaling in local space
  14008. * @returns the current scaling vector
  14009. */
  14010. getScale(): Vector3;
  14011. /**
  14012. * Gets the current scaling in local space and stores it in a target vector
  14013. * @param result defines the target vector
  14014. */
  14015. getScaleToRef(result: Vector3): void;
  14016. /**
  14017. * Set the yaw, pitch, and roll of the bone in local or world space
  14018. * @param yaw The rotation of the bone on the y axis
  14019. * @param pitch The rotation of the bone on the x axis
  14020. * @param roll The rotation of the bone on the z axis
  14021. * @param space The space that the axes of rotation are in
  14022. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14023. */
  14024. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14025. /**
  14026. * Add a rotation to the bone on an axis in local or world space
  14027. * @param axis The axis to rotate the bone on
  14028. * @param amount The amount to rotate the bone
  14029. * @param space The space that the axis is in
  14030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14031. */
  14032. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14033. /**
  14034. * Set the rotation of the bone to a particular axis angle in local or world space
  14035. * @param axis The axis to rotate the bone on
  14036. * @param angle The angle that the bone should be rotated to
  14037. * @param space The space that the axis is in
  14038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14039. */
  14040. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14041. /**
  14042. * Set the euler rotation of the bone in local of world space
  14043. * @param rotation The euler rotation that the bone should be set to
  14044. * @param space The space that the rotation is in
  14045. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14046. */
  14047. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14048. /**
  14049. * Set the quaternion rotation of the bone in local of world space
  14050. * @param quat The quaternion rotation that the bone should be set to
  14051. * @param space The space that the rotation is in
  14052. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14053. */
  14054. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14055. /**
  14056. * Set the rotation matrix of the bone in local of world space
  14057. * @param rotMat The rotation matrix that the bone should be set to
  14058. * @param space The space that the rotation is in
  14059. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14060. */
  14061. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14062. private _rotateWithMatrix;
  14063. private _getNegativeRotationToRef;
  14064. /**
  14065. * Get the position of the bone in local or world space
  14066. * @param space The space that the returned position is in
  14067. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14068. * @returns The position of the bone
  14069. */
  14070. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14071. /**
  14072. * Copy the position of the bone to a vector3 in local or world space
  14073. * @param space The space that the returned position is in
  14074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14075. * @param result The vector3 to copy the position to
  14076. */
  14077. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14078. /**
  14079. * Get the absolute position of the bone (world space)
  14080. * @param mesh The mesh that this bone is attached to
  14081. * @returns The absolute position of the bone
  14082. */
  14083. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14084. /**
  14085. * Copy the absolute position of the bone (world space) to the result param
  14086. * @param mesh The mesh that this bone is attached to
  14087. * @param result The vector3 to copy the absolute position to
  14088. */
  14089. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14090. /**
  14091. * Compute the absolute transforms of this bone and its children
  14092. */
  14093. computeAbsoluteTransforms(): void;
  14094. /**
  14095. * Get the world direction from an axis that is in the local space of the bone
  14096. * @param localAxis The local direction that is used to compute the world direction
  14097. * @param mesh The mesh that this bone is attached to
  14098. * @returns The world direction
  14099. */
  14100. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14101. /**
  14102. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14103. * @param localAxis The local direction that is used to compute the world direction
  14104. * @param mesh The mesh that this bone is attached to
  14105. * @param result The vector3 that the world direction will be copied to
  14106. */
  14107. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14108. /**
  14109. * Get the euler rotation of the bone in local or world space
  14110. * @param space The space that the rotation should be in
  14111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14112. * @returns The euler rotation
  14113. */
  14114. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14115. /**
  14116. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14117. * @param space The space that the rotation should be in
  14118. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14119. * @param result The vector3 that the rotation should be copied to
  14120. */
  14121. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14122. /**
  14123. * Get the quaternion rotation of the bone in either local or world space
  14124. * @param space The space that the rotation should be in
  14125. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14126. * @returns The quaternion rotation
  14127. */
  14128. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14129. /**
  14130. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14131. * @param space The space that the rotation should be in
  14132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14133. * @param result The quaternion that the rotation should be copied to
  14134. */
  14135. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14136. /**
  14137. * Get the rotation matrix of the bone in local or world space
  14138. * @param space The space that the rotation should be in
  14139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14140. * @returns The rotation matrix
  14141. */
  14142. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14143. /**
  14144. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14145. * @param space The space that the rotation should be in
  14146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14147. * @param result The quaternion that the rotation should be copied to
  14148. */
  14149. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14150. /**
  14151. * Get the world position of a point that is in the local space of the bone
  14152. * @param position The local position
  14153. * @param mesh The mesh that this bone is attached to
  14154. * @returns The world position
  14155. */
  14156. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14157. /**
  14158. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14159. * @param position The local position
  14160. * @param mesh The mesh that this bone is attached to
  14161. * @param result The vector3 that the world position should be copied to
  14162. */
  14163. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14164. /**
  14165. * Get the local position of a point that is in world space
  14166. * @param position The world position
  14167. * @param mesh The mesh that this bone is attached to
  14168. * @returns The local position
  14169. */
  14170. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14171. /**
  14172. * Get the local position of a point that is in world space and copy it to the result param
  14173. * @param position The world position
  14174. * @param mesh The mesh that this bone is attached to
  14175. * @param result The vector3 that the local position should be copied to
  14176. */
  14177. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14178. }
  14179. }
  14180. declare module "babylonjs/Meshes/transformNode" {
  14181. import { DeepImmutable } from "babylonjs/types";
  14182. import { Observable } from "babylonjs/Misc/observable";
  14183. import { Nullable } from "babylonjs/types";
  14184. import { Camera } from "babylonjs/Cameras/camera";
  14185. import { Scene } from "babylonjs/scene";
  14186. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14187. import { Node } from "babylonjs/node";
  14188. import { Bone } from "babylonjs/Bones/bone";
  14189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14190. import { Space } from "babylonjs/Maths/math.axis";
  14191. /**
  14192. * 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.
  14193. * @see https://doc.babylonjs.com/how_to/transformnode
  14194. */
  14195. export class TransformNode extends Node {
  14196. /**
  14197. * Object will not rotate to face the camera
  14198. */
  14199. static BILLBOARDMODE_NONE: number;
  14200. /**
  14201. * Object will rotate to face the camera but only on the x axis
  14202. */
  14203. static BILLBOARDMODE_X: number;
  14204. /**
  14205. * Object will rotate to face the camera but only on the y axis
  14206. */
  14207. static BILLBOARDMODE_Y: number;
  14208. /**
  14209. * Object will rotate to face the camera but only on the z axis
  14210. */
  14211. static BILLBOARDMODE_Z: number;
  14212. /**
  14213. * Object will rotate to face the camera
  14214. */
  14215. static BILLBOARDMODE_ALL: number;
  14216. /**
  14217. * Object will rotate to face the camera's position instead of orientation
  14218. */
  14219. static BILLBOARDMODE_USE_POSITION: number;
  14220. private _forward;
  14221. private _forwardInverted;
  14222. private _up;
  14223. private _right;
  14224. private _rightInverted;
  14225. private _position;
  14226. private _rotation;
  14227. private _rotationQuaternion;
  14228. protected _scaling: Vector3;
  14229. protected _isDirty: boolean;
  14230. private _transformToBoneReferal;
  14231. private _isAbsoluteSynced;
  14232. private _billboardMode;
  14233. /**
  14234. * Gets or sets the billboard mode. Default is 0.
  14235. *
  14236. * | Value | Type | Description |
  14237. * | --- | --- | --- |
  14238. * | 0 | BILLBOARDMODE_NONE | |
  14239. * | 1 | BILLBOARDMODE_X | |
  14240. * | 2 | BILLBOARDMODE_Y | |
  14241. * | 4 | BILLBOARDMODE_Z | |
  14242. * | 7 | BILLBOARDMODE_ALL | |
  14243. *
  14244. */
  14245. billboardMode: number;
  14246. private _preserveParentRotationForBillboard;
  14247. /**
  14248. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14249. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14250. */
  14251. preserveParentRotationForBillboard: boolean;
  14252. /**
  14253. * 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
  14254. */
  14255. scalingDeterminant: number;
  14256. private _infiniteDistance;
  14257. /**
  14258. * Gets or sets the distance of the object to max, often used by skybox
  14259. */
  14260. infiniteDistance: boolean;
  14261. /**
  14262. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14263. * By default the system will update normals to compensate
  14264. */
  14265. ignoreNonUniformScaling: boolean;
  14266. /**
  14267. * 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
  14268. */
  14269. reIntegrateRotationIntoRotationQuaternion: boolean;
  14270. /** @hidden */
  14271. _poseMatrix: Nullable<Matrix>;
  14272. /** @hidden */
  14273. _localMatrix: Matrix;
  14274. private _usePivotMatrix;
  14275. private _absolutePosition;
  14276. private _absoluteScaling;
  14277. private _absoluteRotationQuaternion;
  14278. private _pivotMatrix;
  14279. private _pivotMatrixInverse;
  14280. protected _postMultiplyPivotMatrix: boolean;
  14281. protected _isWorldMatrixFrozen: boolean;
  14282. /** @hidden */
  14283. _indexInSceneTransformNodesArray: number;
  14284. /**
  14285. * An event triggered after the world matrix is updated
  14286. */
  14287. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14288. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14289. /**
  14290. * Gets a string identifying the name of the class
  14291. * @returns "TransformNode" string
  14292. */
  14293. getClassName(): string;
  14294. /**
  14295. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14296. */
  14297. position: Vector3;
  14298. /**
  14299. * 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)).
  14300. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14301. */
  14302. rotation: Vector3;
  14303. /**
  14304. * 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)).
  14305. */
  14306. scaling: Vector3;
  14307. /**
  14308. * 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).
  14309. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14310. */
  14311. rotationQuaternion: Nullable<Quaternion>;
  14312. /**
  14313. * The forward direction of that transform in world space.
  14314. */
  14315. readonly forward: Vector3;
  14316. /**
  14317. * The up direction of that transform in world space.
  14318. */
  14319. readonly up: Vector3;
  14320. /**
  14321. * The right direction of that transform in world space.
  14322. */
  14323. readonly right: Vector3;
  14324. /**
  14325. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14326. * @param matrix the matrix to copy the pose from
  14327. * @returns this TransformNode.
  14328. */
  14329. updatePoseMatrix(matrix: Matrix): TransformNode;
  14330. /**
  14331. * Returns the mesh Pose matrix.
  14332. * @returns the pose matrix
  14333. */
  14334. getPoseMatrix(): Matrix;
  14335. /** @hidden */
  14336. _isSynchronized(): boolean;
  14337. /** @hidden */
  14338. _initCache(): void;
  14339. /**
  14340. * Flag the transform node as dirty (Forcing it to update everything)
  14341. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14342. * @returns this transform node
  14343. */
  14344. markAsDirty(property: string): TransformNode;
  14345. /**
  14346. * Returns the current mesh absolute position.
  14347. * Returns a Vector3.
  14348. */
  14349. readonly absolutePosition: Vector3;
  14350. /**
  14351. * Returns the current mesh absolute scaling.
  14352. * Returns a Vector3.
  14353. */
  14354. readonly absoluteScaling: Vector3;
  14355. /**
  14356. * Returns the current mesh absolute rotation.
  14357. * Returns a Quaternion.
  14358. */
  14359. readonly absoluteRotationQuaternion: Quaternion;
  14360. /**
  14361. * Sets a new matrix to apply before all other transformation
  14362. * @param matrix defines the transform matrix
  14363. * @returns the current TransformNode
  14364. */
  14365. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14366. /**
  14367. * Sets a new pivot matrix to the current node
  14368. * @param matrix defines the new pivot matrix to use
  14369. * @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
  14370. * @returns the current TransformNode
  14371. */
  14372. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14373. /**
  14374. * Returns the mesh pivot matrix.
  14375. * Default : Identity.
  14376. * @returns the matrix
  14377. */
  14378. getPivotMatrix(): Matrix;
  14379. /**
  14380. * Instantiate (when possible) or clone that node with its hierarchy
  14381. * @param newParent defines the new parent to use for the instance (or clone)
  14382. * @returns an instance (or a clone) of the current node with its hiearchy
  14383. */
  14384. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14385. /**
  14386. * Prevents the World matrix to be computed any longer
  14387. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14388. * @returns the TransformNode.
  14389. */
  14390. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14391. /**
  14392. * Allows back the World matrix computation.
  14393. * @returns the TransformNode.
  14394. */
  14395. unfreezeWorldMatrix(): this;
  14396. /**
  14397. * True if the World matrix has been frozen.
  14398. */
  14399. readonly isWorldMatrixFrozen: boolean;
  14400. /**
  14401. * Retuns the mesh absolute position in the World.
  14402. * @returns a Vector3.
  14403. */
  14404. getAbsolutePosition(): Vector3;
  14405. /**
  14406. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14407. * @param absolutePosition the absolute position to set
  14408. * @returns the TransformNode.
  14409. */
  14410. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14411. /**
  14412. * Sets the mesh position in its local space.
  14413. * @param vector3 the position to set in localspace
  14414. * @returns the TransformNode.
  14415. */
  14416. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14417. /**
  14418. * Returns the mesh position in the local space from the current World matrix values.
  14419. * @returns a new Vector3.
  14420. */
  14421. getPositionExpressedInLocalSpace(): Vector3;
  14422. /**
  14423. * Translates the mesh along the passed Vector3 in its local space.
  14424. * @param vector3 the distance to translate in localspace
  14425. * @returns the TransformNode.
  14426. */
  14427. locallyTranslate(vector3: Vector3): TransformNode;
  14428. private static _lookAtVectorCache;
  14429. /**
  14430. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14431. * @param targetPoint the position (must be in same space as current mesh) to look at
  14432. * @param yawCor optional yaw (y-axis) correction in radians
  14433. * @param pitchCor optional pitch (x-axis) correction in radians
  14434. * @param rollCor optional roll (z-axis) correction in radians
  14435. * @param space the choosen space of the target
  14436. * @returns the TransformNode.
  14437. */
  14438. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14439. /**
  14440. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14441. * This Vector3 is expressed in the World space.
  14442. * @param localAxis axis to rotate
  14443. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14444. */
  14445. getDirection(localAxis: Vector3): Vector3;
  14446. /**
  14447. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14448. * localAxis is expressed in the mesh local space.
  14449. * result is computed in the Wordl space from the mesh World matrix.
  14450. * @param localAxis axis to rotate
  14451. * @param result the resulting transformnode
  14452. * @returns this TransformNode.
  14453. */
  14454. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14455. /**
  14456. * Sets this transform node rotation to the given local axis.
  14457. * @param localAxis the axis in local space
  14458. * @param yawCor optional yaw (y-axis) correction in radians
  14459. * @param pitchCor optional pitch (x-axis) correction in radians
  14460. * @param rollCor optional roll (z-axis) correction in radians
  14461. * @returns this TransformNode
  14462. */
  14463. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14464. /**
  14465. * Sets a new pivot point to the current node
  14466. * @param point defines the new pivot point to use
  14467. * @param space defines if the point is in world or local space (local by default)
  14468. * @returns the current TransformNode
  14469. */
  14470. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14471. /**
  14472. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14473. * @returns the pivot point
  14474. */
  14475. getPivotPoint(): Vector3;
  14476. /**
  14477. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14478. * @param result the vector3 to store the result
  14479. * @returns this TransformNode.
  14480. */
  14481. getPivotPointToRef(result: Vector3): TransformNode;
  14482. /**
  14483. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14484. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14485. */
  14486. getAbsolutePivotPoint(): Vector3;
  14487. /**
  14488. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14489. * @param result vector3 to store the result
  14490. * @returns this TransformNode.
  14491. */
  14492. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14493. /**
  14494. * Defines the passed node as the parent of the current node.
  14495. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14496. * @see https://doc.babylonjs.com/how_to/parenting
  14497. * @param node the node ot set as the parent
  14498. * @returns this TransformNode.
  14499. */
  14500. setParent(node: Nullable<Node>): TransformNode;
  14501. private _nonUniformScaling;
  14502. /**
  14503. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14504. */
  14505. readonly nonUniformScaling: boolean;
  14506. /** @hidden */
  14507. _updateNonUniformScalingState(value: boolean): boolean;
  14508. /**
  14509. * Attach the current TransformNode to another TransformNode associated with a bone
  14510. * @param bone Bone affecting the TransformNode
  14511. * @param affectedTransformNode TransformNode associated with the bone
  14512. * @returns this object
  14513. */
  14514. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14515. /**
  14516. * Detach the transform node if its associated with a bone
  14517. * @returns this object
  14518. */
  14519. detachFromBone(): TransformNode;
  14520. private static _rotationAxisCache;
  14521. /**
  14522. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14523. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14524. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14525. * The passed axis is also normalized.
  14526. * @param axis the axis to rotate around
  14527. * @param amount the amount to rotate in radians
  14528. * @param space Space to rotate in (Default: local)
  14529. * @returns the TransformNode.
  14530. */
  14531. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14532. /**
  14533. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14534. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14535. * The passed axis is also normalized. .
  14536. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14537. * @param point the point to rotate around
  14538. * @param axis the axis to rotate around
  14539. * @param amount the amount to rotate in radians
  14540. * @returns the TransformNode
  14541. */
  14542. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14543. /**
  14544. * Translates the mesh along the axis vector for the passed distance in the given space.
  14545. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14546. * @param axis the axis to translate in
  14547. * @param distance the distance to translate
  14548. * @param space Space to rotate in (Default: local)
  14549. * @returns the TransformNode.
  14550. */
  14551. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14552. /**
  14553. * Adds a rotation step to the mesh current rotation.
  14554. * x, y, z are Euler angles expressed in radians.
  14555. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14556. * This means this rotation is made in the mesh local space only.
  14557. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14558. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14559. * ```javascript
  14560. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14561. * ```
  14562. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14563. * 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.
  14564. * @param x Rotation to add
  14565. * @param y Rotation to add
  14566. * @param z Rotation to add
  14567. * @returns the TransformNode.
  14568. */
  14569. addRotation(x: number, y: number, z: number): TransformNode;
  14570. /**
  14571. * @hidden
  14572. */
  14573. protected _getEffectiveParent(): Nullable<Node>;
  14574. /**
  14575. * Computes the world matrix of the node
  14576. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14577. * @returns the world matrix
  14578. */
  14579. computeWorldMatrix(force?: boolean): Matrix;
  14580. protected _afterComputeWorldMatrix(): void;
  14581. /**
  14582. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14583. * @param func callback function to add
  14584. *
  14585. * @returns the TransformNode.
  14586. */
  14587. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14588. /**
  14589. * Removes a registered callback function.
  14590. * @param func callback function to remove
  14591. * @returns the TransformNode.
  14592. */
  14593. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14594. /**
  14595. * Gets the position of the current mesh in camera space
  14596. * @param camera defines the camera to use
  14597. * @returns a position
  14598. */
  14599. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14600. /**
  14601. * Returns the distance from the mesh to the active camera
  14602. * @param camera defines the camera to use
  14603. * @returns the distance
  14604. */
  14605. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14606. /**
  14607. * Clone the current transform node
  14608. * @param name Name of the new clone
  14609. * @param newParent New parent for the clone
  14610. * @param doNotCloneChildren Do not clone children hierarchy
  14611. * @returns the new transform node
  14612. */
  14613. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14614. /**
  14615. * Serializes the objects information.
  14616. * @param currentSerializationObject defines the object to serialize in
  14617. * @returns the serialized object
  14618. */
  14619. serialize(currentSerializationObject?: any): any;
  14620. /**
  14621. * Returns a new TransformNode object parsed from the source provided.
  14622. * @param parsedTransformNode is the source.
  14623. * @param scene the scne the object belongs to
  14624. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14625. * @returns a new TransformNode object parsed from the source provided.
  14626. */
  14627. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14628. /**
  14629. * Get all child-transformNodes of this node
  14630. * @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
  14631. * @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
  14632. * @returns an array of TransformNode
  14633. */
  14634. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14635. /**
  14636. * Releases resources associated with this transform node.
  14637. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14638. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14639. */
  14640. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14641. /**
  14642. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14643. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14644. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14645. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14646. * @returns the current mesh
  14647. */
  14648. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14649. private _syncAbsoluteScalingAndRotation;
  14650. }
  14651. }
  14652. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14653. import { Observable } from "babylonjs/Misc/observable";
  14654. import { Nullable } from "babylonjs/types";
  14655. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14656. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14658. import { Ray } from "babylonjs/Culling/ray";
  14659. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14660. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14661. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14662. /**
  14663. * Defines the types of pose enabled controllers that are supported
  14664. */
  14665. export enum PoseEnabledControllerType {
  14666. /**
  14667. * HTC Vive
  14668. */
  14669. VIVE = 0,
  14670. /**
  14671. * Oculus Rift
  14672. */
  14673. OCULUS = 1,
  14674. /**
  14675. * Windows mixed reality
  14676. */
  14677. WINDOWS = 2,
  14678. /**
  14679. * Samsung gear VR
  14680. */
  14681. GEAR_VR = 3,
  14682. /**
  14683. * Google Daydream
  14684. */
  14685. DAYDREAM = 4,
  14686. /**
  14687. * Generic
  14688. */
  14689. GENERIC = 5
  14690. }
  14691. /**
  14692. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14693. */
  14694. export interface MutableGamepadButton {
  14695. /**
  14696. * Value of the button/trigger
  14697. */
  14698. value: number;
  14699. /**
  14700. * If the button/trigger is currently touched
  14701. */
  14702. touched: boolean;
  14703. /**
  14704. * If the button/trigger is currently pressed
  14705. */
  14706. pressed: boolean;
  14707. }
  14708. /**
  14709. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14710. * @hidden
  14711. */
  14712. export interface ExtendedGamepadButton extends GamepadButton {
  14713. /**
  14714. * If the button/trigger is currently pressed
  14715. */
  14716. readonly pressed: boolean;
  14717. /**
  14718. * If the button/trigger is currently touched
  14719. */
  14720. readonly touched: boolean;
  14721. /**
  14722. * Value of the button/trigger
  14723. */
  14724. readonly value: number;
  14725. }
  14726. /** @hidden */
  14727. export interface _GamePadFactory {
  14728. /**
  14729. * Returns wether or not the current gamepad can be created for this type of controller.
  14730. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14731. * @returns true if it can be created, otherwise false
  14732. */
  14733. canCreate(gamepadInfo: any): boolean;
  14734. /**
  14735. * Creates a new instance of the Gamepad.
  14736. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14737. * @returns the new gamepad instance
  14738. */
  14739. create(gamepadInfo: any): Gamepad;
  14740. }
  14741. /**
  14742. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14743. */
  14744. export class PoseEnabledControllerHelper {
  14745. /** @hidden */
  14746. static _ControllerFactories: _GamePadFactory[];
  14747. /** @hidden */
  14748. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14749. /**
  14750. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14751. * @param vrGamepad the gamepad to initialized
  14752. * @returns a vr controller of the type the gamepad identified as
  14753. */
  14754. static InitiateController(vrGamepad: any): Gamepad;
  14755. }
  14756. /**
  14757. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14758. */
  14759. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14760. /**
  14761. * If the controller is used in a webXR session
  14762. */
  14763. isXR: boolean;
  14764. private _deviceRoomPosition;
  14765. private _deviceRoomRotationQuaternion;
  14766. /**
  14767. * The device position in babylon space
  14768. */
  14769. devicePosition: Vector3;
  14770. /**
  14771. * The device rotation in babylon space
  14772. */
  14773. deviceRotationQuaternion: Quaternion;
  14774. /**
  14775. * The scale factor of the device in babylon space
  14776. */
  14777. deviceScaleFactor: number;
  14778. /**
  14779. * (Likely devicePosition should be used instead) The device position in its room space
  14780. */
  14781. position: Vector3;
  14782. /**
  14783. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14784. */
  14785. rotationQuaternion: Quaternion;
  14786. /**
  14787. * The type of controller (Eg. Windows mixed reality)
  14788. */
  14789. controllerType: PoseEnabledControllerType;
  14790. protected _calculatedPosition: Vector3;
  14791. private _calculatedRotation;
  14792. /**
  14793. * The raw pose from the device
  14794. */
  14795. rawPose: DevicePose;
  14796. private _trackPosition;
  14797. private _maxRotationDistFromHeadset;
  14798. private _draggedRoomRotation;
  14799. /**
  14800. * @hidden
  14801. */
  14802. _disableTrackPosition(fixedPosition: Vector3): void;
  14803. /**
  14804. * Internal, the mesh attached to the controller
  14805. * @hidden
  14806. */
  14807. _mesh: Nullable<AbstractMesh>;
  14808. private _poseControlledCamera;
  14809. private _leftHandSystemQuaternion;
  14810. /**
  14811. * Internal, matrix used to convert room space to babylon space
  14812. * @hidden
  14813. */
  14814. _deviceToWorld: Matrix;
  14815. /**
  14816. * Node to be used when casting a ray from the controller
  14817. * @hidden
  14818. */
  14819. _pointingPoseNode: Nullable<TransformNode>;
  14820. /**
  14821. * Name of the child mesh that can be used to cast a ray from the controller
  14822. */
  14823. static readonly POINTING_POSE: string;
  14824. /**
  14825. * Creates a new PoseEnabledController from a gamepad
  14826. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14827. */
  14828. constructor(browserGamepad: any);
  14829. private _workingMatrix;
  14830. /**
  14831. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14832. */
  14833. update(): void;
  14834. /**
  14835. * Updates only the pose device and mesh without doing any button event checking
  14836. */
  14837. protected _updatePoseAndMesh(): void;
  14838. /**
  14839. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14840. * @param poseData raw pose fromthe device
  14841. */
  14842. updateFromDevice(poseData: DevicePose): void;
  14843. /**
  14844. * @hidden
  14845. */
  14846. _meshAttachedObservable: Observable<AbstractMesh>;
  14847. /**
  14848. * Attaches a mesh to the controller
  14849. * @param mesh the mesh to be attached
  14850. */
  14851. attachToMesh(mesh: AbstractMesh): void;
  14852. /**
  14853. * Attaches the controllers mesh to a camera
  14854. * @param camera the camera the mesh should be attached to
  14855. */
  14856. attachToPoseControlledCamera(camera: TargetCamera): void;
  14857. /**
  14858. * Disposes of the controller
  14859. */
  14860. dispose(): void;
  14861. /**
  14862. * The mesh that is attached to the controller
  14863. */
  14864. readonly mesh: Nullable<AbstractMesh>;
  14865. /**
  14866. * Gets the ray of the controller in the direction the controller is pointing
  14867. * @param length the length the resulting ray should be
  14868. * @returns a ray in the direction the controller is pointing
  14869. */
  14870. getForwardRay(length?: number): Ray;
  14871. }
  14872. }
  14873. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14874. import { Observable } from "babylonjs/Misc/observable";
  14875. import { Scene } from "babylonjs/scene";
  14876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14877. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14878. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14879. import { Nullable } from "babylonjs/types";
  14880. /**
  14881. * Defines the WebVRController object that represents controllers tracked in 3D space
  14882. */
  14883. export abstract class WebVRController extends PoseEnabledController {
  14884. /**
  14885. * Internal, the default controller model for the controller
  14886. */
  14887. protected _defaultModel: Nullable<AbstractMesh>;
  14888. /**
  14889. * Fired when the trigger state has changed
  14890. */
  14891. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14892. /**
  14893. * Fired when the main button state has changed
  14894. */
  14895. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14896. /**
  14897. * Fired when the secondary button state has changed
  14898. */
  14899. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14900. /**
  14901. * Fired when the pad state has changed
  14902. */
  14903. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14904. /**
  14905. * Fired when controllers stick values have changed
  14906. */
  14907. onPadValuesChangedObservable: Observable<StickValues>;
  14908. /**
  14909. * Array of button availible on the controller
  14910. */
  14911. protected _buttons: Array<MutableGamepadButton>;
  14912. private _onButtonStateChange;
  14913. /**
  14914. * Fired when a controller button's state has changed
  14915. * @param callback the callback containing the button that was modified
  14916. */
  14917. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14918. /**
  14919. * X and Y axis corresponding to the controllers joystick
  14920. */
  14921. pad: StickValues;
  14922. /**
  14923. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14924. */
  14925. hand: string;
  14926. /**
  14927. * The default controller model for the controller
  14928. */
  14929. readonly defaultModel: Nullable<AbstractMesh>;
  14930. /**
  14931. * Creates a new WebVRController from a gamepad
  14932. * @param vrGamepad the gamepad that the WebVRController should be created from
  14933. */
  14934. constructor(vrGamepad: any);
  14935. /**
  14936. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14937. */
  14938. update(): void;
  14939. /**
  14940. * Function to be called when a button is modified
  14941. */
  14942. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14943. /**
  14944. * Loads a mesh and attaches it to the controller
  14945. * @param scene the scene the mesh should be added to
  14946. * @param meshLoaded callback for when the mesh has been loaded
  14947. */
  14948. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14949. private _setButtonValue;
  14950. private _changes;
  14951. private _checkChanges;
  14952. /**
  14953. * Disposes of th webVRCOntroller
  14954. */
  14955. dispose(): void;
  14956. }
  14957. }
  14958. declare module "babylonjs/Lights/hemisphericLight" {
  14959. import { Nullable } from "babylonjs/types";
  14960. import { Scene } from "babylonjs/scene";
  14961. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14962. import { Color3 } from "babylonjs/Maths/math.color";
  14963. import { Effect } from "babylonjs/Materials/effect";
  14964. import { Light } from "babylonjs/Lights/light";
  14965. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14966. /**
  14967. * The HemisphericLight simulates the ambient environment light,
  14968. * so the passed direction is the light reflection direction, not the incoming direction.
  14969. */
  14970. export class HemisphericLight extends Light {
  14971. /**
  14972. * The groundColor is the light in the opposite direction to the one specified during creation.
  14973. * 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.
  14974. */
  14975. groundColor: Color3;
  14976. /**
  14977. * The light reflection direction, not the incoming direction.
  14978. */
  14979. direction: Vector3;
  14980. /**
  14981. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14982. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14983. * The HemisphericLight can't cast shadows.
  14984. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14985. * @param name The friendly name of the light
  14986. * @param direction The direction of the light reflection
  14987. * @param scene The scene the light belongs to
  14988. */
  14989. constructor(name: string, direction: Vector3, scene: Scene);
  14990. protected _buildUniformLayout(): void;
  14991. /**
  14992. * Returns the string "HemisphericLight".
  14993. * @return The class name
  14994. */
  14995. getClassName(): string;
  14996. /**
  14997. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14998. * Returns the updated direction.
  14999. * @param target The target the direction should point to
  15000. * @return The computed direction
  15001. */
  15002. setDirectionToTarget(target: Vector3): Vector3;
  15003. /**
  15004. * Returns the shadow generator associated to the light.
  15005. * @returns Always null for hemispheric lights because it does not support shadows.
  15006. */
  15007. getShadowGenerator(): Nullable<IShadowGenerator>;
  15008. /**
  15009. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15010. * @param effect The effect to update
  15011. * @param lightIndex The index of the light in the effect to update
  15012. * @returns The hemispheric light
  15013. */
  15014. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15015. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15016. /**
  15017. * Computes the world matrix of the node
  15018. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15019. * @param useWasUpdatedFlag defines a reserved property
  15020. * @returns the world matrix
  15021. */
  15022. computeWorldMatrix(): Matrix;
  15023. /**
  15024. * Returns the integer 3.
  15025. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15026. */
  15027. getTypeID(): number;
  15028. /**
  15029. * Prepares the list of defines specific to the light type.
  15030. * @param defines the list of defines
  15031. * @param lightIndex defines the index of the light for the effect
  15032. */
  15033. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15034. }
  15035. }
  15036. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15037. /** @hidden */
  15038. export var vrMultiviewToSingleviewPixelShader: {
  15039. name: string;
  15040. shader: string;
  15041. };
  15042. }
  15043. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15045. import { Scene } from "babylonjs/scene";
  15046. /**
  15047. * Renders to multiple views with a single draw call
  15048. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15049. */
  15050. export class MultiviewRenderTarget extends RenderTargetTexture {
  15051. /**
  15052. * Creates a multiview render target
  15053. * @param scene scene used with the render target
  15054. * @param size the size of the render target (used for each view)
  15055. */
  15056. constructor(scene: Scene, size?: number | {
  15057. width: number;
  15058. height: number;
  15059. } | {
  15060. ratio: number;
  15061. });
  15062. /**
  15063. * @hidden
  15064. * @param faceIndex the face index, if its a cube texture
  15065. */
  15066. _bindFrameBuffer(faceIndex?: number): void;
  15067. /**
  15068. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15069. * @returns the view count
  15070. */
  15071. getViewCount(): number;
  15072. }
  15073. }
  15074. declare module "babylonjs/Maths/math.frustum" {
  15075. import { Matrix } from "babylonjs/Maths/math.vector";
  15076. import { DeepImmutable } from "babylonjs/types";
  15077. import { Plane } from "babylonjs/Maths/math.plane";
  15078. /**
  15079. * Represents a camera frustum
  15080. */
  15081. export class Frustum {
  15082. /**
  15083. * Gets the planes representing the frustum
  15084. * @param transform matrix to be applied to the returned planes
  15085. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15086. */
  15087. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15088. /**
  15089. * Gets the near frustum plane transformed by the transform matrix
  15090. * @param transform transformation matrix to be applied to the resulting frustum plane
  15091. * @param frustumPlane the resuling frustum plane
  15092. */
  15093. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15094. /**
  15095. * Gets the far frustum plane transformed by the transform matrix
  15096. * @param transform transformation matrix to be applied to the resulting frustum plane
  15097. * @param frustumPlane the resuling frustum plane
  15098. */
  15099. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15100. /**
  15101. * Gets the left frustum plane transformed by the transform matrix
  15102. * @param transform transformation matrix to be applied to the resulting frustum plane
  15103. * @param frustumPlane the resuling frustum plane
  15104. */
  15105. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15106. /**
  15107. * Gets the right frustum plane transformed by the transform matrix
  15108. * @param transform transformation matrix to be applied to the resulting frustum plane
  15109. * @param frustumPlane the resuling frustum plane
  15110. */
  15111. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15112. /**
  15113. * Gets the top frustum plane transformed by the transform matrix
  15114. * @param transform transformation matrix to be applied to the resulting frustum plane
  15115. * @param frustumPlane the resuling frustum plane
  15116. */
  15117. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15118. /**
  15119. * Gets the bottom frustum plane transformed by the transform matrix
  15120. * @param transform transformation matrix to be applied to the resulting frustum plane
  15121. * @param frustumPlane the resuling frustum plane
  15122. */
  15123. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15124. /**
  15125. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15126. * @param transform transformation matrix to be applied to the resulting frustum planes
  15127. * @param frustumPlanes the resuling frustum planes
  15128. */
  15129. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15130. }
  15131. }
  15132. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15133. import { Camera } from "babylonjs/Cameras/camera";
  15134. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15135. import { Nullable } from "babylonjs/types";
  15136. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15137. import { Matrix } from "babylonjs/Maths/math.vector";
  15138. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15139. module "babylonjs/Engines/engine" {
  15140. interface Engine {
  15141. /**
  15142. * Creates a new multiview render target
  15143. * @param width defines the width of the texture
  15144. * @param height defines the height of the texture
  15145. * @returns the created multiview texture
  15146. */
  15147. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15148. /**
  15149. * Binds a multiview framebuffer to be drawn to
  15150. * @param multiviewTexture texture to bind
  15151. */
  15152. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15153. }
  15154. }
  15155. module "babylonjs/Cameras/camera" {
  15156. interface Camera {
  15157. /**
  15158. * @hidden
  15159. * 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)
  15160. */
  15161. _useMultiviewToSingleView: boolean;
  15162. /**
  15163. * @hidden
  15164. * 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)
  15165. */
  15166. _multiviewTexture: Nullable<RenderTargetTexture>;
  15167. /**
  15168. * @hidden
  15169. * ensures the multiview texture of the camera exists and has the specified width/height
  15170. * @param width height to set on the multiview texture
  15171. * @param height width to set on the multiview texture
  15172. */
  15173. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15174. }
  15175. }
  15176. module "babylonjs/scene" {
  15177. interface Scene {
  15178. /** @hidden */
  15179. _transformMatrixR: Matrix;
  15180. /** @hidden */
  15181. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15182. /** @hidden */
  15183. _createMultiviewUbo(): void;
  15184. /** @hidden */
  15185. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15186. /** @hidden */
  15187. _renderMultiviewToSingleView(camera: Camera): void;
  15188. }
  15189. }
  15190. }
  15191. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15192. import { Camera } from "babylonjs/Cameras/camera";
  15193. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15194. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15195. import "babylonjs/Engines/Extensions/engine.multiview";
  15196. /**
  15197. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15198. * This will not be used for webXR as it supports displaying texture arrays directly
  15199. */
  15200. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15201. /**
  15202. * Initializes a VRMultiviewToSingleview
  15203. * @param name name of the post process
  15204. * @param camera camera to be applied to
  15205. * @param scaleFactor scaling factor to the size of the output texture
  15206. */
  15207. constructor(name: string, camera: Camera, scaleFactor: number);
  15208. }
  15209. }
  15210. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15211. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15212. import { Nullable } from "babylonjs/types";
  15213. import { Size } from "babylonjs/Maths/math.size";
  15214. import { Observable } from "babylonjs/Misc/observable";
  15215. module "babylonjs/Engines/engine" {
  15216. interface Engine {
  15217. /** @hidden */
  15218. _vrDisplay: any;
  15219. /** @hidden */
  15220. _vrSupported: boolean;
  15221. /** @hidden */
  15222. _oldSize: Size;
  15223. /** @hidden */
  15224. _oldHardwareScaleFactor: number;
  15225. /** @hidden */
  15226. _vrExclusivePointerMode: boolean;
  15227. /** @hidden */
  15228. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15229. /** @hidden */
  15230. _onVRDisplayPointerRestricted: () => void;
  15231. /** @hidden */
  15232. _onVRDisplayPointerUnrestricted: () => void;
  15233. /** @hidden */
  15234. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15235. /** @hidden */
  15236. _onVrDisplayDisconnect: Nullable<() => void>;
  15237. /** @hidden */
  15238. _onVrDisplayPresentChange: Nullable<() => void>;
  15239. /**
  15240. * Observable signaled when VR display mode changes
  15241. */
  15242. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15243. /**
  15244. * Observable signaled when VR request present is complete
  15245. */
  15246. onVRRequestPresentComplete: Observable<boolean>;
  15247. /**
  15248. * Observable signaled when VR request present starts
  15249. */
  15250. onVRRequestPresentStart: Observable<Engine>;
  15251. /**
  15252. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15253. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15254. */
  15255. isInVRExclusivePointerMode: boolean;
  15256. /**
  15257. * Gets a boolean indicating if a webVR device was detected
  15258. * @returns true if a webVR device was detected
  15259. */
  15260. isVRDevicePresent(): boolean;
  15261. /**
  15262. * Gets the current webVR device
  15263. * @returns the current webVR device (or null)
  15264. */
  15265. getVRDevice(): any;
  15266. /**
  15267. * Initializes a webVR display and starts listening to display change events
  15268. * The onVRDisplayChangedObservable will be notified upon these changes
  15269. * @returns A promise containing a VRDisplay and if vr is supported
  15270. */
  15271. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15272. /** @hidden */
  15273. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15274. /**
  15275. * Call this function to switch to webVR mode
  15276. * Will do nothing if webVR is not supported or if there is no webVR device
  15277. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15278. */
  15279. enableVR(): void;
  15280. /** @hidden */
  15281. _onVRFullScreenTriggered(): void;
  15282. }
  15283. }
  15284. }
  15285. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15286. import { Nullable } from "babylonjs/types";
  15287. import { Observable } from "babylonjs/Misc/observable";
  15288. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15289. import { Scene } from "babylonjs/scene";
  15290. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15291. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15292. import { Node } from "babylonjs/node";
  15293. import { Ray } from "babylonjs/Culling/ray";
  15294. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15295. import "babylonjs/Engines/Extensions/engine.webVR";
  15296. /**
  15297. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15298. * IMPORTANT!! The data is right-hand data.
  15299. * @export
  15300. * @interface DevicePose
  15301. */
  15302. export interface DevicePose {
  15303. /**
  15304. * The position of the device, values in array are [x,y,z].
  15305. */
  15306. readonly position: Nullable<Float32Array>;
  15307. /**
  15308. * The linearVelocity of the device, values in array are [x,y,z].
  15309. */
  15310. readonly linearVelocity: Nullable<Float32Array>;
  15311. /**
  15312. * The linearAcceleration of the device, values in array are [x,y,z].
  15313. */
  15314. readonly linearAcceleration: Nullable<Float32Array>;
  15315. /**
  15316. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15317. */
  15318. readonly orientation: Nullable<Float32Array>;
  15319. /**
  15320. * The angularVelocity of the device, values in array are [x,y,z].
  15321. */
  15322. readonly angularVelocity: Nullable<Float32Array>;
  15323. /**
  15324. * The angularAcceleration of the device, values in array are [x,y,z].
  15325. */
  15326. readonly angularAcceleration: Nullable<Float32Array>;
  15327. }
  15328. /**
  15329. * Interface representing a pose controlled object in Babylon.
  15330. * A pose controlled object has both regular pose values as well as pose values
  15331. * from an external device such as a VR head mounted display
  15332. */
  15333. export interface PoseControlled {
  15334. /**
  15335. * The position of the object in babylon space.
  15336. */
  15337. position: Vector3;
  15338. /**
  15339. * The rotation quaternion of the object in babylon space.
  15340. */
  15341. rotationQuaternion: Quaternion;
  15342. /**
  15343. * The position of the device in babylon space.
  15344. */
  15345. devicePosition?: Vector3;
  15346. /**
  15347. * The rotation quaternion of the device in babylon space.
  15348. */
  15349. deviceRotationQuaternion: Quaternion;
  15350. /**
  15351. * The raw pose coming from the device.
  15352. */
  15353. rawPose: Nullable<DevicePose>;
  15354. /**
  15355. * The scale of the device to be used when translating from device space to babylon space.
  15356. */
  15357. deviceScaleFactor: number;
  15358. /**
  15359. * Updates the poseControlled values based on the input device pose.
  15360. * @param poseData the pose data to update the object with
  15361. */
  15362. updateFromDevice(poseData: DevicePose): void;
  15363. }
  15364. /**
  15365. * Set of options to customize the webVRCamera
  15366. */
  15367. export interface WebVROptions {
  15368. /**
  15369. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15370. */
  15371. trackPosition?: boolean;
  15372. /**
  15373. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15374. */
  15375. positionScale?: number;
  15376. /**
  15377. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15378. */
  15379. displayName?: string;
  15380. /**
  15381. * Should the native controller meshes be initialized. (default: true)
  15382. */
  15383. controllerMeshes?: boolean;
  15384. /**
  15385. * Creating a default HemiLight only on controllers. (default: true)
  15386. */
  15387. defaultLightingOnControllers?: boolean;
  15388. /**
  15389. * If you don't want to use the default VR button of the helper. (default: false)
  15390. */
  15391. useCustomVRButton?: boolean;
  15392. /**
  15393. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15394. */
  15395. customVRButton?: HTMLButtonElement;
  15396. /**
  15397. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15398. */
  15399. rayLength?: number;
  15400. /**
  15401. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15402. */
  15403. defaultHeight?: number;
  15404. /**
  15405. * If multiview should be used if availible (default: false)
  15406. */
  15407. useMultiview?: boolean;
  15408. }
  15409. /**
  15410. * This represents a WebVR camera.
  15411. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15412. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15413. */
  15414. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15415. private webVROptions;
  15416. /**
  15417. * @hidden
  15418. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15419. */
  15420. _vrDevice: any;
  15421. /**
  15422. * The rawPose of the vrDevice.
  15423. */
  15424. rawPose: Nullable<DevicePose>;
  15425. private _onVREnabled;
  15426. private _specsVersion;
  15427. private _attached;
  15428. private _frameData;
  15429. protected _descendants: Array<Node>;
  15430. private _deviceRoomPosition;
  15431. /** @hidden */
  15432. _deviceRoomRotationQuaternion: Quaternion;
  15433. private _standingMatrix;
  15434. /**
  15435. * Represents device position in babylon space.
  15436. */
  15437. devicePosition: Vector3;
  15438. /**
  15439. * Represents device rotation in babylon space.
  15440. */
  15441. deviceRotationQuaternion: Quaternion;
  15442. /**
  15443. * The scale of the device to be used when translating from device space to babylon space.
  15444. */
  15445. deviceScaleFactor: number;
  15446. private _deviceToWorld;
  15447. private _worldToDevice;
  15448. /**
  15449. * References to the webVR controllers for the vrDevice.
  15450. */
  15451. controllers: Array<WebVRController>;
  15452. /**
  15453. * Emits an event when a controller is attached.
  15454. */
  15455. onControllersAttachedObservable: Observable<WebVRController[]>;
  15456. /**
  15457. * Emits an event when a controller's mesh has been loaded;
  15458. */
  15459. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15460. /**
  15461. * Emits an event when the HMD's pose has been updated.
  15462. */
  15463. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15464. private _poseSet;
  15465. /**
  15466. * If the rig cameras be used as parent instead of this camera.
  15467. */
  15468. rigParenting: boolean;
  15469. private _lightOnControllers;
  15470. private _defaultHeight?;
  15471. /**
  15472. * Instantiates a WebVRFreeCamera.
  15473. * @param name The name of the WebVRFreeCamera
  15474. * @param position The starting anchor position for the camera
  15475. * @param scene The scene the camera belongs to
  15476. * @param webVROptions a set of customizable options for the webVRCamera
  15477. */
  15478. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15479. /**
  15480. * Gets the device distance from the ground in meters.
  15481. * @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.
  15482. */
  15483. deviceDistanceToRoomGround(): number;
  15484. /**
  15485. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15486. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15487. */
  15488. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15489. /**
  15490. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15491. * @returns A promise with a boolean set to if the standing matrix is supported.
  15492. */
  15493. useStandingMatrixAsync(): Promise<boolean>;
  15494. /**
  15495. * Disposes the camera
  15496. */
  15497. dispose(): void;
  15498. /**
  15499. * Gets a vrController by name.
  15500. * @param name The name of the controller to retreive
  15501. * @returns the controller matching the name specified or null if not found
  15502. */
  15503. getControllerByName(name: string): Nullable<WebVRController>;
  15504. private _leftController;
  15505. /**
  15506. * The controller corresponding to the users left hand.
  15507. */
  15508. readonly leftController: Nullable<WebVRController>;
  15509. private _rightController;
  15510. /**
  15511. * The controller corresponding to the users right hand.
  15512. */
  15513. readonly rightController: Nullable<WebVRController>;
  15514. /**
  15515. * Casts a ray forward from the vrCamera's gaze.
  15516. * @param length Length of the ray (default: 100)
  15517. * @returns the ray corresponding to the gaze
  15518. */
  15519. getForwardRay(length?: number): Ray;
  15520. /**
  15521. * @hidden
  15522. * Updates the camera based on device's frame data
  15523. */
  15524. _checkInputs(): void;
  15525. /**
  15526. * Updates the poseControlled values based on the input device pose.
  15527. * @param poseData Pose coming from the device
  15528. */
  15529. updateFromDevice(poseData: DevicePose): void;
  15530. private _htmlElementAttached;
  15531. private _detachIfAttached;
  15532. /**
  15533. * WebVR's attach control will start broadcasting frames to the device.
  15534. * Note that in certain browsers (chrome for example) this function must be called
  15535. * within a user-interaction callback. Example:
  15536. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15537. *
  15538. * @param element html element to attach the vrDevice to
  15539. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15540. */
  15541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15542. /**
  15543. * Detaches the camera from the html element and disables VR
  15544. *
  15545. * @param element html element to detach from
  15546. */
  15547. detachControl(element: HTMLElement): void;
  15548. /**
  15549. * @returns the name of this class
  15550. */
  15551. getClassName(): string;
  15552. /**
  15553. * Calls resetPose on the vrDisplay
  15554. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15555. */
  15556. resetToCurrentRotation(): void;
  15557. /**
  15558. * @hidden
  15559. * Updates the rig cameras (left and right eye)
  15560. */
  15561. _updateRigCameras(): void;
  15562. private _workingVector;
  15563. private _oneVector;
  15564. private _workingMatrix;
  15565. private updateCacheCalled;
  15566. private _correctPositionIfNotTrackPosition;
  15567. /**
  15568. * @hidden
  15569. * Updates the cached values of the camera
  15570. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15571. */
  15572. _updateCache(ignoreParentClass?: boolean): void;
  15573. /**
  15574. * @hidden
  15575. * Get current device position in babylon world
  15576. */
  15577. _computeDevicePosition(): void;
  15578. /**
  15579. * Updates the current device position and rotation in the babylon world
  15580. */
  15581. update(): void;
  15582. /**
  15583. * @hidden
  15584. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15585. * @returns an identity matrix
  15586. */
  15587. _getViewMatrix(): Matrix;
  15588. private _tmpMatrix;
  15589. /**
  15590. * This function is called by the two RIG cameras.
  15591. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15592. * @hidden
  15593. */
  15594. _getWebVRViewMatrix(): Matrix;
  15595. /** @hidden */
  15596. _getWebVRProjectionMatrix(): Matrix;
  15597. private _onGamepadConnectedObserver;
  15598. private _onGamepadDisconnectedObserver;
  15599. private _updateCacheWhenTrackingDisabledObserver;
  15600. /**
  15601. * Initializes the controllers and their meshes
  15602. */
  15603. initControllers(): void;
  15604. }
  15605. }
  15606. declare module "babylonjs/PostProcesses/postProcess" {
  15607. import { Nullable } from "babylonjs/types";
  15608. import { SmartArray } from "babylonjs/Misc/smartArray";
  15609. import { Observable } from "babylonjs/Misc/observable";
  15610. import { Vector2 } from "babylonjs/Maths/math.vector";
  15611. import { Camera } from "babylonjs/Cameras/camera";
  15612. import { Effect } from "babylonjs/Materials/effect";
  15613. import "babylonjs/Shaders/postprocess.vertex";
  15614. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15615. import { Engine } from "babylonjs/Engines/engine";
  15616. import { Color4 } from "babylonjs/Maths/math.color";
  15617. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15618. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15619. /**
  15620. * Size options for a post process
  15621. */
  15622. export type PostProcessOptions = {
  15623. width: number;
  15624. height: number;
  15625. };
  15626. /**
  15627. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15628. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15629. */
  15630. export class PostProcess {
  15631. /** Name of the PostProcess. */
  15632. name: string;
  15633. /**
  15634. * Gets or sets the unique id of the post process
  15635. */
  15636. uniqueId: number;
  15637. /**
  15638. * Width of the texture to apply the post process on
  15639. */
  15640. width: number;
  15641. /**
  15642. * Height of the texture to apply the post process on
  15643. */
  15644. height: number;
  15645. /**
  15646. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15647. * @hidden
  15648. */
  15649. _outputTexture: Nullable<InternalTexture>;
  15650. /**
  15651. * Sampling mode used by the shader
  15652. * See https://doc.babylonjs.com/classes/3.1/texture
  15653. */
  15654. renderTargetSamplingMode: number;
  15655. /**
  15656. * Clear color to use when screen clearing
  15657. */
  15658. clearColor: Color4;
  15659. /**
  15660. * If the buffer needs to be cleared before applying the post process. (default: true)
  15661. * Should be set to false if shader will overwrite all previous pixels.
  15662. */
  15663. autoClear: boolean;
  15664. /**
  15665. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15666. */
  15667. alphaMode: number;
  15668. /**
  15669. * Sets the setAlphaBlendConstants of the babylon engine
  15670. */
  15671. alphaConstants: Color4;
  15672. /**
  15673. * Animations to be used for the post processing
  15674. */
  15675. animations: import("babylonjs/Animations/animation").Animation[];
  15676. /**
  15677. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15678. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15679. */
  15680. enablePixelPerfectMode: boolean;
  15681. /**
  15682. * Force the postprocess to be applied without taking in account viewport
  15683. */
  15684. forceFullscreenViewport: boolean;
  15685. /**
  15686. * List of inspectable custom properties (used by the Inspector)
  15687. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15688. */
  15689. inspectableCustomProperties: IInspectable[];
  15690. /**
  15691. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15692. *
  15693. * | Value | Type | Description |
  15694. * | ----- | ----------------------------------- | ----------- |
  15695. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15696. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15697. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15698. *
  15699. */
  15700. scaleMode: number;
  15701. /**
  15702. * Force textures to be a power of two (default: false)
  15703. */
  15704. alwaysForcePOT: boolean;
  15705. private _samples;
  15706. /**
  15707. * Number of sample textures (default: 1)
  15708. */
  15709. samples: number;
  15710. /**
  15711. * Modify the scale of the post process to be the same as the viewport (default: false)
  15712. */
  15713. adaptScaleToCurrentViewport: boolean;
  15714. private _camera;
  15715. private _scene;
  15716. private _engine;
  15717. private _options;
  15718. private _reusable;
  15719. private _textureType;
  15720. /**
  15721. * Smart array of input and output textures for the post process.
  15722. * @hidden
  15723. */
  15724. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15725. /**
  15726. * The index in _textures that corresponds to the output texture.
  15727. * @hidden
  15728. */
  15729. _currentRenderTextureInd: number;
  15730. private _effect;
  15731. private _samplers;
  15732. private _fragmentUrl;
  15733. private _vertexUrl;
  15734. private _parameters;
  15735. private _scaleRatio;
  15736. protected _indexParameters: any;
  15737. private _shareOutputWithPostProcess;
  15738. private _texelSize;
  15739. private _forcedOutputTexture;
  15740. /**
  15741. * Returns the fragment url or shader name used in the post process.
  15742. * @returns the fragment url or name in the shader store.
  15743. */
  15744. getEffectName(): string;
  15745. /**
  15746. * An event triggered when the postprocess is activated.
  15747. */
  15748. onActivateObservable: Observable<Camera>;
  15749. private _onActivateObserver;
  15750. /**
  15751. * A function that is added to the onActivateObservable
  15752. */
  15753. onActivate: Nullable<(camera: Camera) => void>;
  15754. /**
  15755. * An event triggered when the postprocess changes its size.
  15756. */
  15757. onSizeChangedObservable: Observable<PostProcess>;
  15758. private _onSizeChangedObserver;
  15759. /**
  15760. * A function that is added to the onSizeChangedObservable
  15761. */
  15762. onSizeChanged: (postProcess: PostProcess) => void;
  15763. /**
  15764. * An event triggered when the postprocess applies its effect.
  15765. */
  15766. onApplyObservable: Observable<Effect>;
  15767. private _onApplyObserver;
  15768. /**
  15769. * A function that is added to the onApplyObservable
  15770. */
  15771. onApply: (effect: Effect) => void;
  15772. /**
  15773. * An event triggered before rendering the postprocess
  15774. */
  15775. onBeforeRenderObservable: Observable<Effect>;
  15776. private _onBeforeRenderObserver;
  15777. /**
  15778. * A function that is added to the onBeforeRenderObservable
  15779. */
  15780. onBeforeRender: (effect: Effect) => void;
  15781. /**
  15782. * An event triggered after rendering the postprocess
  15783. */
  15784. onAfterRenderObservable: Observable<Effect>;
  15785. private _onAfterRenderObserver;
  15786. /**
  15787. * A function that is added to the onAfterRenderObservable
  15788. */
  15789. onAfterRender: (efect: Effect) => void;
  15790. /**
  15791. * 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
  15792. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15793. */
  15794. inputTexture: InternalTexture;
  15795. /**
  15796. * Gets the camera which post process is applied to.
  15797. * @returns The camera the post process is applied to.
  15798. */
  15799. getCamera(): Camera;
  15800. /**
  15801. * Gets the texel size of the postprocess.
  15802. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15803. */
  15804. readonly texelSize: Vector2;
  15805. /**
  15806. * Creates a new instance PostProcess
  15807. * @param name The name of the PostProcess.
  15808. * @param fragmentUrl The url of the fragment shader to be used.
  15809. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15810. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15811. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15812. * @param camera The camera to apply the render pass to.
  15813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15814. * @param engine The engine which the post process will be applied. (default: current engine)
  15815. * @param reusable If the post process can be reused on the same frame. (default: false)
  15816. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15817. * @param textureType Type of textures used when performing the post process. (default: 0)
  15818. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15819. * @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
  15820. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15821. */
  15822. constructor(
  15823. /** Name of the PostProcess. */
  15824. 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);
  15825. /**
  15826. * Gets a string idenfifying the name of the class
  15827. * @returns "PostProcess" string
  15828. */
  15829. getClassName(): string;
  15830. /**
  15831. * Gets the engine which this post process belongs to.
  15832. * @returns The engine the post process was enabled with.
  15833. */
  15834. getEngine(): Engine;
  15835. /**
  15836. * The effect that is created when initializing the post process.
  15837. * @returns The created effect corresponding the the postprocess.
  15838. */
  15839. getEffect(): Effect;
  15840. /**
  15841. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15842. * @param postProcess The post process to share the output with.
  15843. * @returns This post process.
  15844. */
  15845. shareOutputWith(postProcess: PostProcess): PostProcess;
  15846. /**
  15847. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15848. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15849. */
  15850. useOwnOutput(): void;
  15851. /**
  15852. * Updates the effect with the current post process compile time values and recompiles the shader.
  15853. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15854. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15855. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15856. * @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
  15857. * @param onCompiled Called when the shader has been compiled.
  15858. * @param onError Called if there is an error when compiling a shader.
  15859. */
  15860. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15861. /**
  15862. * The post process is reusable if it can be used multiple times within one frame.
  15863. * @returns If the post process is reusable
  15864. */
  15865. isReusable(): boolean;
  15866. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15867. markTextureDirty(): void;
  15868. /**
  15869. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15870. * 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.
  15871. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15872. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15873. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15874. * @returns The target texture that was bound to be written to.
  15875. */
  15876. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15877. /**
  15878. * If the post process is supported.
  15879. */
  15880. readonly isSupported: boolean;
  15881. /**
  15882. * The aspect ratio of the output texture.
  15883. */
  15884. readonly aspectRatio: number;
  15885. /**
  15886. * Get a value indicating if the post-process is ready to be used
  15887. * @returns true if the post-process is ready (shader is compiled)
  15888. */
  15889. isReady(): boolean;
  15890. /**
  15891. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15892. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15893. */
  15894. apply(): Nullable<Effect>;
  15895. private _disposeTextures;
  15896. /**
  15897. * Disposes the post process.
  15898. * @param camera The camera to dispose the post process on.
  15899. */
  15900. dispose(camera?: Camera): void;
  15901. }
  15902. }
  15903. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15904. /** @hidden */
  15905. export var kernelBlurVaryingDeclaration: {
  15906. name: string;
  15907. shader: string;
  15908. };
  15909. }
  15910. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15911. /** @hidden */
  15912. export var kernelBlurFragment: {
  15913. name: string;
  15914. shader: string;
  15915. };
  15916. }
  15917. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15918. /** @hidden */
  15919. export var kernelBlurFragment2: {
  15920. name: string;
  15921. shader: string;
  15922. };
  15923. }
  15924. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15925. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15926. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15927. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15928. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15929. /** @hidden */
  15930. export var kernelBlurPixelShader: {
  15931. name: string;
  15932. shader: string;
  15933. };
  15934. }
  15935. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15936. /** @hidden */
  15937. export var kernelBlurVertex: {
  15938. name: string;
  15939. shader: string;
  15940. };
  15941. }
  15942. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15943. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15944. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15945. /** @hidden */
  15946. export var kernelBlurVertexShader: {
  15947. name: string;
  15948. shader: string;
  15949. };
  15950. }
  15951. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15952. import { Vector2 } from "babylonjs/Maths/math.vector";
  15953. import { Nullable } from "babylonjs/types";
  15954. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15955. import { Camera } from "babylonjs/Cameras/camera";
  15956. import { Effect } from "babylonjs/Materials/effect";
  15957. import { Engine } from "babylonjs/Engines/engine";
  15958. import "babylonjs/Shaders/kernelBlur.fragment";
  15959. import "babylonjs/Shaders/kernelBlur.vertex";
  15960. /**
  15961. * The Blur Post Process which blurs an image based on a kernel and direction.
  15962. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15963. */
  15964. export class BlurPostProcess extends PostProcess {
  15965. /** The direction in which to blur the image. */
  15966. direction: Vector2;
  15967. private blockCompilation;
  15968. protected _kernel: number;
  15969. protected _idealKernel: number;
  15970. protected _packedFloat: boolean;
  15971. private _staticDefines;
  15972. /**
  15973. * Sets the length in pixels of the blur sample region
  15974. */
  15975. /**
  15976. * Gets the length in pixels of the blur sample region
  15977. */
  15978. kernel: number;
  15979. /**
  15980. * Sets wether or not the blur needs to unpack/repack floats
  15981. */
  15982. /**
  15983. * Gets wether or not the blur is unpacking/repacking floats
  15984. */
  15985. packedFloat: boolean;
  15986. /**
  15987. * Creates a new instance BlurPostProcess
  15988. * @param name The name of the effect.
  15989. * @param direction The direction in which to blur the image.
  15990. * @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.
  15991. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15992. * @param camera The camera to apply the render pass to.
  15993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15994. * @param engine The engine which the post process will be applied. (default: current engine)
  15995. * @param reusable If the post process can be reused on the same frame. (default: false)
  15996. * @param textureType Type of textures used when performing the post process. (default: 0)
  15997. * @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)
  15998. */
  15999. constructor(name: string,
  16000. /** The direction in which to blur the image. */
  16001. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16002. /**
  16003. * Updates the effect with the current post process compile time values and recompiles the shader.
  16004. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16005. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16006. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16007. * @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
  16008. * @param onCompiled Called when the shader has been compiled.
  16009. * @param onError Called if there is an error when compiling a shader.
  16010. */
  16011. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16012. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16013. /**
  16014. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16015. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16016. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16017. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16018. * The gaps between physical kernels are compensated for in the weighting of the samples
  16019. * @param idealKernel Ideal blur kernel.
  16020. * @return Nearest best kernel.
  16021. */
  16022. protected _nearestBestKernel(idealKernel: number): number;
  16023. /**
  16024. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16025. * @param x The point on the Gaussian distribution to sample.
  16026. * @return the value of the Gaussian function at x.
  16027. */
  16028. protected _gaussianWeight(x: number): number;
  16029. /**
  16030. * Generates a string that can be used as a floating point number in GLSL.
  16031. * @param x Value to print.
  16032. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16033. * @return GLSL float string.
  16034. */
  16035. protected _glslFloat(x: number, decimalFigures?: number): string;
  16036. }
  16037. }
  16038. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16039. import { Scene } from "babylonjs/scene";
  16040. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16041. import { Plane } from "babylonjs/Maths/math.plane";
  16042. /**
  16043. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16044. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16045. * You can then easily use it as a reflectionTexture on a flat surface.
  16046. * In case the surface is not a plane, please consider relying on reflection probes.
  16047. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16048. */
  16049. export class MirrorTexture extends RenderTargetTexture {
  16050. private scene;
  16051. /**
  16052. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16053. * 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.
  16054. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16055. */
  16056. mirrorPlane: Plane;
  16057. /**
  16058. * Define the blur ratio used to blur the reflection if needed.
  16059. */
  16060. blurRatio: number;
  16061. /**
  16062. * Define the adaptive blur kernel used to blur the reflection if needed.
  16063. * This will autocompute the closest best match for the `blurKernel`
  16064. */
  16065. adaptiveBlurKernel: number;
  16066. /**
  16067. * Define the blur kernel used to blur the reflection if needed.
  16068. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16069. */
  16070. blurKernel: number;
  16071. /**
  16072. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16073. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16074. */
  16075. blurKernelX: number;
  16076. /**
  16077. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16078. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16079. */
  16080. blurKernelY: number;
  16081. private _autoComputeBlurKernel;
  16082. protected _onRatioRescale(): void;
  16083. private _updateGammaSpace;
  16084. private _imageProcessingConfigChangeObserver;
  16085. private _transformMatrix;
  16086. private _mirrorMatrix;
  16087. private _savedViewMatrix;
  16088. private _blurX;
  16089. private _blurY;
  16090. private _adaptiveBlurKernel;
  16091. private _blurKernelX;
  16092. private _blurKernelY;
  16093. private _blurRatio;
  16094. /**
  16095. * Instantiates a Mirror Texture.
  16096. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16097. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16098. * You can then easily use it as a reflectionTexture on a flat surface.
  16099. * In case the surface is not a plane, please consider relying on reflection probes.
  16100. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16101. * @param name
  16102. * @param size
  16103. * @param scene
  16104. * @param generateMipMaps
  16105. * @param type
  16106. * @param samplingMode
  16107. * @param generateDepthBuffer
  16108. */
  16109. constructor(name: string, size: number | {
  16110. width: number;
  16111. height: number;
  16112. } | {
  16113. ratio: number;
  16114. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16115. private _preparePostProcesses;
  16116. /**
  16117. * Clone the mirror texture.
  16118. * @returns the cloned texture
  16119. */
  16120. clone(): MirrorTexture;
  16121. /**
  16122. * Serialize the texture to a JSON representation you could use in Parse later on
  16123. * @returns the serialized JSON representation
  16124. */
  16125. serialize(): any;
  16126. /**
  16127. * Dispose the texture and release its associated resources.
  16128. */
  16129. dispose(): void;
  16130. }
  16131. }
  16132. declare module "babylonjs/Materials/Textures/texture" {
  16133. import { Observable } from "babylonjs/Misc/observable";
  16134. import { Nullable } from "babylonjs/types";
  16135. import { Scene } from "babylonjs/scene";
  16136. import { Matrix } from "babylonjs/Maths/math.vector";
  16137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16138. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16139. import { Engine } from "babylonjs/Engines/engine";
  16140. /**
  16141. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16142. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16143. */
  16144. export class Texture extends BaseTexture {
  16145. /**
  16146. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16147. */
  16148. static SerializeBuffers: boolean;
  16149. /** @hidden */
  16150. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16151. /** @hidden */
  16152. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16153. /** @hidden */
  16154. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16155. /** nearest is mag = nearest and min = nearest and mip = linear */
  16156. static readonly NEAREST_SAMPLINGMODE: number;
  16157. /** nearest is mag = nearest and min = nearest and mip = linear */
  16158. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16159. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16160. static readonly BILINEAR_SAMPLINGMODE: number;
  16161. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16162. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16163. /** Trilinear is mag = linear and min = linear and mip = linear */
  16164. static readonly TRILINEAR_SAMPLINGMODE: number;
  16165. /** Trilinear is mag = linear and min = linear and mip = linear */
  16166. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16167. /** mag = nearest and min = nearest and mip = nearest */
  16168. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16169. /** mag = nearest and min = linear and mip = nearest */
  16170. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16171. /** mag = nearest and min = linear and mip = linear */
  16172. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16173. /** mag = nearest and min = linear and mip = none */
  16174. static readonly NEAREST_LINEAR: number;
  16175. /** mag = nearest and min = nearest and mip = none */
  16176. static readonly NEAREST_NEAREST: number;
  16177. /** mag = linear and min = nearest and mip = nearest */
  16178. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16179. /** mag = linear and min = nearest and mip = linear */
  16180. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16181. /** mag = linear and min = linear and mip = none */
  16182. static readonly LINEAR_LINEAR: number;
  16183. /** mag = linear and min = nearest and mip = none */
  16184. static readonly LINEAR_NEAREST: number;
  16185. /** Explicit coordinates mode */
  16186. static readonly EXPLICIT_MODE: number;
  16187. /** Spherical coordinates mode */
  16188. static readonly SPHERICAL_MODE: number;
  16189. /** Planar coordinates mode */
  16190. static readonly PLANAR_MODE: number;
  16191. /** Cubic coordinates mode */
  16192. static readonly CUBIC_MODE: number;
  16193. /** Projection coordinates mode */
  16194. static readonly PROJECTION_MODE: number;
  16195. /** Inverse Cubic coordinates mode */
  16196. static readonly SKYBOX_MODE: number;
  16197. /** Inverse Cubic coordinates mode */
  16198. static readonly INVCUBIC_MODE: number;
  16199. /** Equirectangular coordinates mode */
  16200. static readonly EQUIRECTANGULAR_MODE: number;
  16201. /** Equirectangular Fixed coordinates mode */
  16202. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16203. /** Equirectangular Fixed Mirrored coordinates mode */
  16204. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16205. /** Texture is not repeating outside of 0..1 UVs */
  16206. static readonly CLAMP_ADDRESSMODE: number;
  16207. /** Texture is repeating outside of 0..1 UVs */
  16208. static readonly WRAP_ADDRESSMODE: number;
  16209. /** Texture is repeating and mirrored */
  16210. static readonly MIRROR_ADDRESSMODE: number;
  16211. /**
  16212. * 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
  16213. */
  16214. static UseSerializedUrlIfAny: boolean;
  16215. /**
  16216. * Define the url of the texture.
  16217. */
  16218. url: Nullable<string>;
  16219. /**
  16220. * Define an offset on the texture to offset the u coordinates of the UVs
  16221. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16222. */
  16223. uOffset: number;
  16224. /**
  16225. * Define an offset on the texture to offset the v coordinates of the UVs
  16226. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16227. */
  16228. vOffset: number;
  16229. /**
  16230. * Define an offset on the texture to scale the u coordinates of the UVs
  16231. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16232. */
  16233. uScale: number;
  16234. /**
  16235. * Define an offset on the texture to scale the v coordinates of the UVs
  16236. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16237. */
  16238. vScale: number;
  16239. /**
  16240. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16241. * @see http://doc.babylonjs.com/how_to/more_materials
  16242. */
  16243. uAng: number;
  16244. /**
  16245. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16246. * @see http://doc.babylonjs.com/how_to/more_materials
  16247. */
  16248. vAng: number;
  16249. /**
  16250. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16251. * @see http://doc.babylonjs.com/how_to/more_materials
  16252. */
  16253. wAng: number;
  16254. /**
  16255. * Defines the center of rotation (U)
  16256. */
  16257. uRotationCenter: number;
  16258. /**
  16259. * Defines the center of rotation (V)
  16260. */
  16261. vRotationCenter: number;
  16262. /**
  16263. * Defines the center of rotation (W)
  16264. */
  16265. wRotationCenter: number;
  16266. /**
  16267. * Are mip maps generated for this texture or not.
  16268. */
  16269. readonly noMipmap: boolean;
  16270. /**
  16271. * List of inspectable custom properties (used by the Inspector)
  16272. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16273. */
  16274. inspectableCustomProperties: Nullable<IInspectable[]>;
  16275. private _noMipmap;
  16276. /** @hidden */
  16277. _invertY: boolean;
  16278. private _rowGenerationMatrix;
  16279. private _cachedTextureMatrix;
  16280. private _projectionModeMatrix;
  16281. private _t0;
  16282. private _t1;
  16283. private _t2;
  16284. private _cachedUOffset;
  16285. private _cachedVOffset;
  16286. private _cachedUScale;
  16287. private _cachedVScale;
  16288. private _cachedUAng;
  16289. private _cachedVAng;
  16290. private _cachedWAng;
  16291. private _cachedProjectionMatrixId;
  16292. private _cachedCoordinatesMode;
  16293. /** @hidden */
  16294. protected _initialSamplingMode: number;
  16295. /** @hidden */
  16296. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16297. private _deleteBuffer;
  16298. protected _format: Nullable<number>;
  16299. private _delayedOnLoad;
  16300. private _delayedOnError;
  16301. /**
  16302. * Observable triggered once the texture has been loaded.
  16303. */
  16304. onLoadObservable: Observable<Texture>;
  16305. protected _isBlocking: boolean;
  16306. /**
  16307. * Is the texture preventing material to render while loading.
  16308. * If false, a default texture will be used instead of the loading one during the preparation step.
  16309. */
  16310. isBlocking: boolean;
  16311. /**
  16312. * Get the current sampling mode associated with the texture.
  16313. */
  16314. readonly samplingMode: number;
  16315. /**
  16316. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16317. */
  16318. readonly invertY: boolean;
  16319. /**
  16320. * Instantiates a new texture.
  16321. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16322. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16323. * @param url define the url of the picture to load as a texture
  16324. * @param scene define the scene or engine the texture will belong to
  16325. * @param noMipmap define if the texture will require mip maps or not
  16326. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16327. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16328. * @param onLoad define a callback triggered when the texture has been loaded
  16329. * @param onError define a callback triggered when an error occurred during the loading session
  16330. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16331. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16332. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16333. */
  16334. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  16335. /**
  16336. * Update the url (and optional buffer) of this texture if url was null during construction.
  16337. * @param url the url of the texture
  16338. * @param buffer the buffer of the texture (defaults to null)
  16339. * @param onLoad callback called when the texture is loaded (defaults to null)
  16340. */
  16341. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16342. /**
  16343. * Finish the loading sequence of a texture flagged as delayed load.
  16344. * @hidden
  16345. */
  16346. delayLoad(): void;
  16347. private _prepareRowForTextureGeneration;
  16348. /**
  16349. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16350. * @returns the transform matrix of the texture.
  16351. */
  16352. getTextureMatrix(): Matrix;
  16353. /**
  16354. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16355. * @returns The reflection texture transform
  16356. */
  16357. getReflectionTextureMatrix(): Matrix;
  16358. /**
  16359. * Clones the texture.
  16360. * @returns the cloned texture
  16361. */
  16362. clone(): Texture;
  16363. /**
  16364. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16365. * @returns The JSON representation of the texture
  16366. */
  16367. serialize(): any;
  16368. /**
  16369. * Get the current class name of the texture useful for serialization or dynamic coding.
  16370. * @returns "Texture"
  16371. */
  16372. getClassName(): string;
  16373. /**
  16374. * Dispose the texture and release its associated resources.
  16375. */
  16376. dispose(): void;
  16377. /**
  16378. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16379. * @param parsedTexture Define the JSON representation of the texture
  16380. * @param scene Define the scene the parsed texture should be instantiated in
  16381. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16382. * @returns The parsed texture if successful
  16383. */
  16384. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16385. /**
  16386. * Creates a texture from its base 64 representation.
  16387. * @param data Define the base64 payload without the data: prefix
  16388. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16389. * @param scene Define the scene the texture should belong to
  16390. * @param noMipmap Forces the texture to not create mip map information if true
  16391. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16392. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16393. * @param onLoad define a callback triggered when the texture has been loaded
  16394. * @param onError define a callback triggered when an error occurred during the loading session
  16395. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16396. * @returns the created texture
  16397. */
  16398. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16399. /**
  16400. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16401. * @param data Define the base64 payload without the data: prefix
  16402. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16403. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16404. * @param scene Define the scene the texture should belong to
  16405. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16406. * @param noMipmap Forces the texture to not create mip map information if true
  16407. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16408. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16409. * @param onLoad define a callback triggered when the texture has been loaded
  16410. * @param onError define a callback triggered when an error occurred during the loading session
  16411. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16412. * @returns the created texture
  16413. */
  16414. 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;
  16415. }
  16416. }
  16417. declare module "babylonjs/PostProcesses/postProcessManager" {
  16418. import { Nullable } from "babylonjs/types";
  16419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16420. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16421. import { Scene } from "babylonjs/scene";
  16422. /**
  16423. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16424. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16425. */
  16426. export class PostProcessManager {
  16427. private _scene;
  16428. private _indexBuffer;
  16429. private _vertexBuffers;
  16430. /**
  16431. * Creates a new instance PostProcess
  16432. * @param scene The scene that the post process is associated with.
  16433. */
  16434. constructor(scene: Scene);
  16435. private _prepareBuffers;
  16436. private _buildIndexBuffer;
  16437. /**
  16438. * Rebuilds the vertex buffers of the manager.
  16439. * @hidden
  16440. */
  16441. _rebuild(): void;
  16442. /**
  16443. * Prepares a frame to be run through a post process.
  16444. * @param sourceTexture The input texture to the post procesess. (default: null)
  16445. * @param postProcesses An array of post processes to be run. (default: null)
  16446. * @returns True if the post processes were able to be run.
  16447. * @hidden
  16448. */
  16449. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16450. /**
  16451. * Manually render a set of post processes to a texture.
  16452. * @param postProcesses An array of post processes to be run.
  16453. * @param targetTexture The target texture to render to.
  16454. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16455. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16456. * @param lodLevel defines which lod of the texture to render to
  16457. */
  16458. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16459. /**
  16460. * Finalize the result of the output of the postprocesses.
  16461. * @param doNotPresent If true the result will not be displayed to the screen.
  16462. * @param targetTexture The target texture to render to.
  16463. * @param faceIndex The index of the face to bind the target texture to.
  16464. * @param postProcesses The array of post processes to render.
  16465. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16466. * @hidden
  16467. */
  16468. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16469. /**
  16470. * Disposes of the post process manager.
  16471. */
  16472. dispose(): void;
  16473. }
  16474. }
  16475. declare module "babylonjs/Misc/gradients" {
  16476. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16477. /** Interface used by value gradients (color, factor, ...) */
  16478. export interface IValueGradient {
  16479. /**
  16480. * Gets or sets the gradient value (between 0 and 1)
  16481. */
  16482. gradient: number;
  16483. }
  16484. /** Class used to store color4 gradient */
  16485. export class ColorGradient implements IValueGradient {
  16486. /**
  16487. * Gets or sets the gradient value (between 0 and 1)
  16488. */
  16489. gradient: number;
  16490. /**
  16491. * Gets or sets first associated color
  16492. */
  16493. color1: Color4;
  16494. /**
  16495. * Gets or sets second associated color
  16496. */
  16497. color2?: Color4;
  16498. /**
  16499. * Will get a color picked randomly between color1 and color2.
  16500. * If color2 is undefined then color1 will be used
  16501. * @param result defines the target Color4 to store the result in
  16502. */
  16503. getColorToRef(result: Color4): void;
  16504. }
  16505. /** Class used to store color 3 gradient */
  16506. export class Color3Gradient implements IValueGradient {
  16507. /**
  16508. * Gets or sets the gradient value (between 0 and 1)
  16509. */
  16510. gradient: number;
  16511. /**
  16512. * Gets or sets the associated color
  16513. */
  16514. color: Color3;
  16515. }
  16516. /** Class used to store factor gradient */
  16517. export class FactorGradient implements IValueGradient {
  16518. /**
  16519. * Gets or sets the gradient value (between 0 and 1)
  16520. */
  16521. gradient: number;
  16522. /**
  16523. * Gets or sets first associated factor
  16524. */
  16525. factor1: number;
  16526. /**
  16527. * Gets or sets second associated factor
  16528. */
  16529. factor2?: number;
  16530. /**
  16531. * Will get a number picked randomly between factor1 and factor2.
  16532. * If factor2 is undefined then factor1 will be used
  16533. * @returns the picked number
  16534. */
  16535. getFactor(): number;
  16536. }
  16537. /**
  16538. * Helper used to simplify some generic gradient tasks
  16539. */
  16540. export class GradientHelper {
  16541. /**
  16542. * Gets the current gradient from an array of IValueGradient
  16543. * @param ratio defines the current ratio to get
  16544. * @param gradients defines the array of IValueGradient
  16545. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16546. */
  16547. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16548. }
  16549. }
  16550. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16551. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16552. import { Nullable } from "babylonjs/types";
  16553. module "babylonjs/Engines/thinEngine" {
  16554. interface ThinEngine {
  16555. /**
  16556. * Creates a dynamic texture
  16557. * @param width defines the width of the texture
  16558. * @param height defines the height of the texture
  16559. * @param generateMipMaps defines if the engine should generate the mip levels
  16560. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16561. * @returns the dynamic texture inside an InternalTexture
  16562. */
  16563. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16564. /**
  16565. * Update the content of a dynamic texture
  16566. * @param texture defines the texture to update
  16567. * @param canvas defines the canvas containing the source
  16568. * @param invertY defines if data must be stored with Y axis inverted
  16569. * @param premulAlpha defines if alpha is stored as premultiplied
  16570. * @param format defines the format of the data
  16571. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16572. */
  16573. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16574. }
  16575. }
  16576. }
  16577. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16578. import { Scene } from "babylonjs/scene";
  16579. import { Texture } from "babylonjs/Materials/Textures/texture";
  16580. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16581. /**
  16582. * A class extending Texture allowing drawing on a texture
  16583. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16584. */
  16585. export class DynamicTexture extends Texture {
  16586. private _generateMipMaps;
  16587. private _canvas;
  16588. private _context;
  16589. private _engine;
  16590. /**
  16591. * Creates a DynamicTexture
  16592. * @param name defines the name of the texture
  16593. * @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
  16594. * @param scene defines the scene where you want the texture
  16595. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16596. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16597. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16598. */
  16599. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16600. /**
  16601. * Get the current class name of the texture useful for serialization or dynamic coding.
  16602. * @returns "DynamicTexture"
  16603. */
  16604. getClassName(): string;
  16605. /**
  16606. * Gets the current state of canRescale
  16607. */
  16608. readonly canRescale: boolean;
  16609. private _recreate;
  16610. /**
  16611. * Scales the texture
  16612. * @param ratio the scale factor to apply to both width and height
  16613. */
  16614. scale(ratio: number): void;
  16615. /**
  16616. * Resizes the texture
  16617. * @param width the new width
  16618. * @param height the new height
  16619. */
  16620. scaleTo(width: number, height: number): void;
  16621. /**
  16622. * Gets the context of the canvas used by the texture
  16623. * @returns the canvas context of the dynamic texture
  16624. */
  16625. getContext(): CanvasRenderingContext2D;
  16626. /**
  16627. * Clears the texture
  16628. */
  16629. clear(): void;
  16630. /**
  16631. * Updates the texture
  16632. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16633. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16634. */
  16635. update(invertY?: boolean, premulAlpha?: boolean): void;
  16636. /**
  16637. * Draws text onto the texture
  16638. * @param text defines the text to be drawn
  16639. * @param x defines the placement of the text from the left
  16640. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16641. * @param font defines the font to be used with font-style, font-size, font-name
  16642. * @param color defines the color used for the text
  16643. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16644. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16645. * @param update defines whether texture is immediately update (default is true)
  16646. */
  16647. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16648. /**
  16649. * Clones the texture
  16650. * @returns the clone of the texture.
  16651. */
  16652. clone(): DynamicTexture;
  16653. /**
  16654. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16655. * @returns a serialized dynamic texture object
  16656. */
  16657. serialize(): any;
  16658. /** @hidden */
  16659. _rebuild(): void;
  16660. }
  16661. }
  16662. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16663. import { Scene } from "babylonjs/scene";
  16664. import { ISceneComponent } from "babylonjs/sceneComponent";
  16665. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16666. module "babylonjs/abstractScene" {
  16667. interface AbstractScene {
  16668. /**
  16669. * The list of procedural textures added to the scene
  16670. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16671. */
  16672. proceduralTextures: Array<ProceduralTexture>;
  16673. }
  16674. }
  16675. /**
  16676. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16677. * in a given scene.
  16678. */
  16679. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16680. /**
  16681. * The component name helpfull to identify the component in the list of scene components.
  16682. */
  16683. readonly name: string;
  16684. /**
  16685. * The scene the component belongs to.
  16686. */
  16687. scene: Scene;
  16688. /**
  16689. * Creates a new instance of the component for the given scene
  16690. * @param scene Defines the scene to register the component in
  16691. */
  16692. constructor(scene: Scene);
  16693. /**
  16694. * Registers the component in a given scene
  16695. */
  16696. register(): void;
  16697. /**
  16698. * Rebuilds the elements related to this component in case of
  16699. * context lost for instance.
  16700. */
  16701. rebuild(): void;
  16702. /**
  16703. * Disposes the component and the associated ressources.
  16704. */
  16705. dispose(): void;
  16706. private _beforeClear;
  16707. }
  16708. }
  16709. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16711. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16712. module "babylonjs/Engines/thinEngine" {
  16713. interface ThinEngine {
  16714. /**
  16715. * Creates a new render target cube texture
  16716. * @param size defines the size of the texture
  16717. * @param options defines the options used to create the texture
  16718. * @returns a new render target cube texture stored in an InternalTexture
  16719. */
  16720. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16721. }
  16722. }
  16723. }
  16724. declare module "babylonjs/Shaders/procedural.vertex" {
  16725. /** @hidden */
  16726. export var proceduralVertexShader: {
  16727. name: string;
  16728. shader: string;
  16729. };
  16730. }
  16731. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16732. import { Observable } from "babylonjs/Misc/observable";
  16733. import { Nullable } from "babylonjs/types";
  16734. import { Scene } from "babylonjs/scene";
  16735. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16736. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16737. import { Effect } from "babylonjs/Materials/effect";
  16738. import { Texture } from "babylonjs/Materials/Textures/texture";
  16739. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16740. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16741. import "babylonjs/Shaders/procedural.vertex";
  16742. /**
  16743. * 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.
  16744. * This is the base class of any Procedural texture and contains most of the shareable code.
  16745. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16746. */
  16747. export class ProceduralTexture extends Texture {
  16748. isCube: boolean;
  16749. /**
  16750. * Define if the texture is enabled or not (disabled texture will not render)
  16751. */
  16752. isEnabled: boolean;
  16753. /**
  16754. * Define if the texture must be cleared before rendering (default is true)
  16755. */
  16756. autoClear: boolean;
  16757. /**
  16758. * Callback called when the texture is generated
  16759. */
  16760. onGenerated: () => void;
  16761. /**
  16762. * Event raised when the texture is generated
  16763. */
  16764. onGeneratedObservable: Observable<ProceduralTexture>;
  16765. /** @hidden */
  16766. _generateMipMaps: boolean;
  16767. /** @hidden **/
  16768. _effect: Effect;
  16769. /** @hidden */
  16770. _textures: {
  16771. [key: string]: Texture;
  16772. };
  16773. private _size;
  16774. private _currentRefreshId;
  16775. private _refreshRate;
  16776. private _vertexBuffers;
  16777. private _indexBuffer;
  16778. private _uniforms;
  16779. private _samplers;
  16780. private _fragment;
  16781. private _floats;
  16782. private _ints;
  16783. private _floatsArrays;
  16784. private _colors3;
  16785. private _colors4;
  16786. private _vectors2;
  16787. private _vectors3;
  16788. private _matrices;
  16789. private _fallbackTexture;
  16790. private _fallbackTextureUsed;
  16791. private _engine;
  16792. private _cachedDefines;
  16793. private _contentUpdateId;
  16794. private _contentData;
  16795. /**
  16796. * Instantiates a new procedural texture.
  16797. * 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.
  16798. * This is the base class of any Procedural texture and contains most of the shareable code.
  16799. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16800. * @param name Define the name of the texture
  16801. * @param size Define the size of the texture to create
  16802. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16803. * @param scene Define the scene the texture belongs to
  16804. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16805. * @param generateMipMaps Define if the texture should creates mip maps or not
  16806. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16807. */
  16808. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16809. /**
  16810. * The effect that is created when initializing the post process.
  16811. * @returns The created effect corresponding the the postprocess.
  16812. */
  16813. getEffect(): Effect;
  16814. /**
  16815. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16816. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16817. */
  16818. getContent(): Nullable<ArrayBufferView>;
  16819. private _createIndexBuffer;
  16820. /** @hidden */
  16821. _rebuild(): void;
  16822. /**
  16823. * Resets the texture in order to recreate its associated resources.
  16824. * This can be called in case of context loss
  16825. */
  16826. reset(): void;
  16827. protected _getDefines(): string;
  16828. /**
  16829. * Is the texture ready to be used ? (rendered at least once)
  16830. * @returns true if ready, otherwise, false.
  16831. */
  16832. isReady(): boolean;
  16833. /**
  16834. * Resets the refresh counter of the texture and start bak from scratch.
  16835. * Could be useful to regenerate the texture if it is setup to render only once.
  16836. */
  16837. resetRefreshCounter(): void;
  16838. /**
  16839. * Set the fragment shader to use in order to render the texture.
  16840. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16841. */
  16842. setFragment(fragment: any): void;
  16843. /**
  16844. * Define the refresh rate of the texture or the rendering frequency.
  16845. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16846. */
  16847. refreshRate: number;
  16848. /** @hidden */
  16849. _shouldRender(): boolean;
  16850. /**
  16851. * Get the size the texture is rendering at.
  16852. * @returns the size (texture is always squared)
  16853. */
  16854. getRenderSize(): number;
  16855. /**
  16856. * Resize the texture to new value.
  16857. * @param size Define the new size the texture should have
  16858. * @param generateMipMaps Define whether the new texture should create mip maps
  16859. */
  16860. resize(size: number, generateMipMaps: boolean): void;
  16861. private _checkUniform;
  16862. /**
  16863. * Set a texture in the shader program used to render.
  16864. * @param name Define the name of the uniform samplers as defined in the shader
  16865. * @param texture Define the texture to bind to this sampler
  16866. * @return the texture itself allowing "fluent" like uniform updates
  16867. */
  16868. setTexture(name: string, texture: Texture): ProceduralTexture;
  16869. /**
  16870. * Set a float in the shader.
  16871. * @param name Define the name of the uniform as defined in the shader
  16872. * @param value Define the value to give to the uniform
  16873. * @return the texture itself allowing "fluent" like uniform updates
  16874. */
  16875. setFloat(name: string, value: number): ProceduralTexture;
  16876. /**
  16877. * Set a int in the shader.
  16878. * @param name Define the name of the uniform as defined in the shader
  16879. * @param value Define the value to give to the uniform
  16880. * @return the texture itself allowing "fluent" like uniform updates
  16881. */
  16882. setInt(name: string, value: number): ProceduralTexture;
  16883. /**
  16884. * Set an array of floats in the shader.
  16885. * @param name Define the name of the uniform as defined in the shader
  16886. * @param value Define the value to give to the uniform
  16887. * @return the texture itself allowing "fluent" like uniform updates
  16888. */
  16889. setFloats(name: string, value: number[]): ProceduralTexture;
  16890. /**
  16891. * Set a vec3 in the shader from a Color3.
  16892. * @param name Define the name of the uniform as defined in the shader
  16893. * @param value Define the value to give to the uniform
  16894. * @return the texture itself allowing "fluent" like uniform updates
  16895. */
  16896. setColor3(name: string, value: Color3): ProceduralTexture;
  16897. /**
  16898. * Set a vec4 in the shader from a Color4.
  16899. * @param name Define the name of the uniform as defined in the shader
  16900. * @param value Define the value to give to the uniform
  16901. * @return the texture itself allowing "fluent" like uniform updates
  16902. */
  16903. setColor4(name: string, value: Color4): ProceduralTexture;
  16904. /**
  16905. * Set a vec2 in the shader from a Vector2.
  16906. * @param name Define the name of the uniform as defined in the shader
  16907. * @param value Define the value to give to the uniform
  16908. * @return the texture itself allowing "fluent" like uniform updates
  16909. */
  16910. setVector2(name: string, value: Vector2): ProceduralTexture;
  16911. /**
  16912. * Set a vec3 in the shader from a Vector3.
  16913. * @param name Define the name of the uniform as defined in the shader
  16914. * @param value Define the value to give to the uniform
  16915. * @return the texture itself allowing "fluent" like uniform updates
  16916. */
  16917. setVector3(name: string, value: Vector3): ProceduralTexture;
  16918. /**
  16919. * Set a mat4 in the shader from a MAtrix.
  16920. * @param name Define the name of the uniform as defined in the shader
  16921. * @param value Define the value to give to the uniform
  16922. * @return the texture itself allowing "fluent" like uniform updates
  16923. */
  16924. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16925. /**
  16926. * Render the texture to its associated render target.
  16927. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16928. */
  16929. render(useCameraPostProcess?: boolean): void;
  16930. /**
  16931. * Clone the texture.
  16932. * @returns the cloned texture
  16933. */
  16934. clone(): ProceduralTexture;
  16935. /**
  16936. * Dispose the texture and release its asoociated resources.
  16937. */
  16938. dispose(): void;
  16939. }
  16940. }
  16941. declare module "babylonjs/Particles/baseParticleSystem" {
  16942. import { Nullable } from "babylonjs/types";
  16943. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16945. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16946. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16947. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16948. import { Scene } from "babylonjs/scene";
  16949. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16950. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16951. import { Texture } from "babylonjs/Materials/Textures/texture";
  16952. import { Color4 } from "babylonjs/Maths/math.color";
  16953. import { Animation } from "babylonjs/Animations/animation";
  16954. /**
  16955. * This represents the base class for particle system in Babylon.
  16956. * 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.
  16957. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16958. * @example https://doc.babylonjs.com/babylon101/particles
  16959. */
  16960. export class BaseParticleSystem {
  16961. /**
  16962. * Source color is added to the destination color without alpha affecting the result
  16963. */
  16964. static BLENDMODE_ONEONE: number;
  16965. /**
  16966. * Blend current color and particle color using particle’s alpha
  16967. */
  16968. static BLENDMODE_STANDARD: number;
  16969. /**
  16970. * Add current color and particle color multiplied by particle’s alpha
  16971. */
  16972. static BLENDMODE_ADD: number;
  16973. /**
  16974. * Multiply current color with particle color
  16975. */
  16976. static BLENDMODE_MULTIPLY: number;
  16977. /**
  16978. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16979. */
  16980. static BLENDMODE_MULTIPLYADD: number;
  16981. /**
  16982. * List of animations used by the particle system.
  16983. */
  16984. animations: Animation[];
  16985. /**
  16986. * The id of the Particle system.
  16987. */
  16988. id: string;
  16989. /**
  16990. * The friendly name of the Particle system.
  16991. */
  16992. name: string;
  16993. /**
  16994. * The rendering group used by the Particle system to chose when to render.
  16995. */
  16996. renderingGroupId: number;
  16997. /**
  16998. * The emitter represents the Mesh or position we are attaching the particle system to.
  16999. */
  17000. emitter: Nullable<AbstractMesh | Vector3>;
  17001. /**
  17002. * The maximum number of particles to emit per frame
  17003. */
  17004. emitRate: number;
  17005. /**
  17006. * If you want to launch only a few particles at once, that can be done, as well.
  17007. */
  17008. manualEmitCount: number;
  17009. /**
  17010. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17011. */
  17012. updateSpeed: number;
  17013. /**
  17014. * The amount of time the particle system is running (depends of the overall update speed).
  17015. */
  17016. targetStopDuration: number;
  17017. /**
  17018. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17019. */
  17020. disposeOnStop: boolean;
  17021. /**
  17022. * Minimum power of emitting particles.
  17023. */
  17024. minEmitPower: number;
  17025. /**
  17026. * Maximum power of emitting particles.
  17027. */
  17028. maxEmitPower: number;
  17029. /**
  17030. * Minimum life time of emitting particles.
  17031. */
  17032. minLifeTime: number;
  17033. /**
  17034. * Maximum life time of emitting particles.
  17035. */
  17036. maxLifeTime: number;
  17037. /**
  17038. * Minimum Size of emitting particles.
  17039. */
  17040. minSize: number;
  17041. /**
  17042. * Maximum Size of emitting particles.
  17043. */
  17044. maxSize: number;
  17045. /**
  17046. * Minimum scale of emitting particles on X axis.
  17047. */
  17048. minScaleX: number;
  17049. /**
  17050. * Maximum scale of emitting particles on X axis.
  17051. */
  17052. maxScaleX: number;
  17053. /**
  17054. * Minimum scale of emitting particles on Y axis.
  17055. */
  17056. minScaleY: number;
  17057. /**
  17058. * Maximum scale of emitting particles on Y axis.
  17059. */
  17060. maxScaleY: number;
  17061. /**
  17062. * Gets or sets the minimal initial rotation in radians.
  17063. */
  17064. minInitialRotation: number;
  17065. /**
  17066. * Gets or sets the maximal initial rotation in radians.
  17067. */
  17068. maxInitialRotation: number;
  17069. /**
  17070. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17071. */
  17072. minAngularSpeed: number;
  17073. /**
  17074. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17075. */
  17076. maxAngularSpeed: number;
  17077. /**
  17078. * The texture used to render each particle. (this can be a spritesheet)
  17079. */
  17080. particleTexture: Nullable<Texture>;
  17081. /**
  17082. * The layer mask we are rendering the particles through.
  17083. */
  17084. layerMask: number;
  17085. /**
  17086. * This can help using your own shader to render the particle system.
  17087. * The according effect will be created
  17088. */
  17089. customShader: any;
  17090. /**
  17091. * By default particle system starts as soon as they are created. This prevents the
  17092. * automatic start to happen and let you decide when to start emitting particles.
  17093. */
  17094. preventAutoStart: boolean;
  17095. private _noiseTexture;
  17096. /**
  17097. * Gets or sets a texture used to add random noise to particle positions
  17098. */
  17099. noiseTexture: Nullable<ProceduralTexture>;
  17100. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17101. noiseStrength: Vector3;
  17102. /**
  17103. * Callback triggered when the particle animation is ending.
  17104. */
  17105. onAnimationEnd: Nullable<() => void>;
  17106. /**
  17107. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17108. */
  17109. blendMode: number;
  17110. /**
  17111. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17112. * to override the particles.
  17113. */
  17114. forceDepthWrite: boolean;
  17115. /** 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 */
  17116. preWarmCycles: number;
  17117. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17118. preWarmStepOffset: number;
  17119. /**
  17120. * 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)
  17121. */
  17122. spriteCellChangeSpeed: number;
  17123. /**
  17124. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17125. */
  17126. startSpriteCellID: number;
  17127. /**
  17128. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17129. */
  17130. endSpriteCellID: number;
  17131. /**
  17132. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17133. */
  17134. spriteCellWidth: number;
  17135. /**
  17136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17137. */
  17138. spriteCellHeight: number;
  17139. /**
  17140. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17141. */
  17142. spriteRandomStartCell: boolean;
  17143. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17144. translationPivot: Vector2;
  17145. /** @hidden */
  17146. protected _isAnimationSheetEnabled: boolean;
  17147. /**
  17148. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17149. */
  17150. beginAnimationOnStart: boolean;
  17151. /**
  17152. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17153. */
  17154. beginAnimationFrom: number;
  17155. /**
  17156. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17157. */
  17158. beginAnimationTo: number;
  17159. /**
  17160. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17161. */
  17162. beginAnimationLoop: boolean;
  17163. /**
  17164. * Gets or sets a world offset applied to all particles
  17165. */
  17166. worldOffset: Vector3;
  17167. /**
  17168. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17169. */
  17170. isAnimationSheetEnabled: boolean;
  17171. /**
  17172. * Get hosting scene
  17173. * @returns the scene
  17174. */
  17175. getScene(): Scene;
  17176. /**
  17177. * You can use gravity if you want to give an orientation to your particles.
  17178. */
  17179. gravity: Vector3;
  17180. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17181. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17182. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17183. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17184. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17185. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17186. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17187. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17188. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17189. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17190. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17191. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17192. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17193. /**
  17194. * Defines the delay in milliseconds before starting the system (0 by default)
  17195. */
  17196. startDelay: number;
  17197. /**
  17198. * Gets the current list of drag gradients.
  17199. * You must use addDragGradient and removeDragGradient to udpate this list
  17200. * @returns the list of drag gradients
  17201. */
  17202. getDragGradients(): Nullable<Array<FactorGradient>>;
  17203. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17204. limitVelocityDamping: number;
  17205. /**
  17206. * Gets the current list of limit velocity gradients.
  17207. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17208. * @returns the list of limit velocity gradients
  17209. */
  17210. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17211. /**
  17212. * Gets the current list of color gradients.
  17213. * You must use addColorGradient and removeColorGradient to udpate this list
  17214. * @returns the list of color gradients
  17215. */
  17216. getColorGradients(): Nullable<Array<ColorGradient>>;
  17217. /**
  17218. * Gets the current list of size gradients.
  17219. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17220. * @returns the list of size gradients
  17221. */
  17222. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17223. /**
  17224. * Gets the current list of color remap gradients.
  17225. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17226. * @returns the list of color remap gradients
  17227. */
  17228. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17229. /**
  17230. * Gets the current list of alpha remap gradients.
  17231. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17232. * @returns the list of alpha remap gradients
  17233. */
  17234. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17235. /**
  17236. * Gets the current list of life time gradients.
  17237. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17238. * @returns the list of life time gradients
  17239. */
  17240. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17241. /**
  17242. * Gets the current list of angular speed gradients.
  17243. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17244. * @returns the list of angular speed gradients
  17245. */
  17246. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17247. /**
  17248. * Gets the current list of velocity gradients.
  17249. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17250. * @returns the list of velocity gradients
  17251. */
  17252. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17253. /**
  17254. * Gets the current list of start size gradients.
  17255. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17256. * @returns the list of start size gradients
  17257. */
  17258. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17259. /**
  17260. * Gets the current list of emit rate gradients.
  17261. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17262. * @returns the list of emit rate gradients
  17263. */
  17264. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17265. /**
  17266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17267. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17268. */
  17269. direction1: Vector3;
  17270. /**
  17271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17273. */
  17274. direction2: Vector3;
  17275. /**
  17276. * 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.
  17277. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17278. */
  17279. minEmitBox: Vector3;
  17280. /**
  17281. * 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.
  17282. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17283. */
  17284. maxEmitBox: Vector3;
  17285. /**
  17286. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17287. */
  17288. color1: Color4;
  17289. /**
  17290. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17291. */
  17292. color2: Color4;
  17293. /**
  17294. * Color the particle will have at the end of its lifetime
  17295. */
  17296. colorDead: Color4;
  17297. /**
  17298. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17299. */
  17300. textureMask: Color4;
  17301. /**
  17302. * The particle emitter type defines the emitter used by the particle system.
  17303. * It can be for example box, sphere, or cone...
  17304. */
  17305. particleEmitterType: IParticleEmitterType;
  17306. /** @hidden */
  17307. _isSubEmitter: boolean;
  17308. /**
  17309. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17310. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17311. */
  17312. billboardMode: number;
  17313. protected _isBillboardBased: boolean;
  17314. /**
  17315. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17316. */
  17317. isBillboardBased: boolean;
  17318. /**
  17319. * The scene the particle system belongs to.
  17320. */
  17321. protected _scene: Scene;
  17322. /**
  17323. * Local cache of defines for image processing.
  17324. */
  17325. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17326. /**
  17327. * Default configuration related to image processing available in the standard Material.
  17328. */
  17329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17330. /**
  17331. * Gets the image processing configuration used either in this material.
  17332. */
  17333. /**
  17334. * Sets the Default image processing configuration used either in the this material.
  17335. *
  17336. * If sets to null, the scene one is in use.
  17337. */
  17338. imageProcessingConfiguration: ImageProcessingConfiguration;
  17339. /**
  17340. * Attaches a new image processing configuration to the Standard Material.
  17341. * @param configuration
  17342. */
  17343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17344. /** @hidden */
  17345. protected _reset(): void;
  17346. /** @hidden */
  17347. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17348. /**
  17349. * Instantiates a particle system.
  17350. * 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.
  17351. * @param name The name of the particle system
  17352. */
  17353. constructor(name: string);
  17354. /**
  17355. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17356. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17357. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17358. * @returns the emitter
  17359. */
  17360. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17361. /**
  17362. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17363. * @param radius The radius of the hemisphere to emit from
  17364. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17365. * @returns the emitter
  17366. */
  17367. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17368. /**
  17369. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17370. * @param radius The radius of the sphere to emit from
  17371. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17372. * @returns the emitter
  17373. */
  17374. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17375. /**
  17376. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17377. * @param radius The radius of the sphere to emit from
  17378. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17379. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17380. * @returns the emitter
  17381. */
  17382. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17383. /**
  17384. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17385. * @param radius The radius of the emission cylinder
  17386. * @param height The height of the emission cylinder
  17387. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17388. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17389. * @returns the emitter
  17390. */
  17391. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17392. /**
  17393. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17394. * @param radius The radius of the cylinder to emit from
  17395. * @param height The height of the emission cylinder
  17396. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17397. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17398. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17399. * @returns the emitter
  17400. */
  17401. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17402. /**
  17403. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17404. * @param radius The radius of the cone to emit from
  17405. * @param angle The base angle of the cone
  17406. * @returns the emitter
  17407. */
  17408. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17409. /**
  17410. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17411. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17412. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17413. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17414. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17415. * @returns the emitter
  17416. */
  17417. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17418. }
  17419. }
  17420. declare module "babylonjs/Particles/subEmitter" {
  17421. import { Scene } from "babylonjs/scene";
  17422. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17423. /**
  17424. * Type of sub emitter
  17425. */
  17426. export enum SubEmitterType {
  17427. /**
  17428. * Attached to the particle over it's lifetime
  17429. */
  17430. ATTACHED = 0,
  17431. /**
  17432. * Created when the particle dies
  17433. */
  17434. END = 1
  17435. }
  17436. /**
  17437. * Sub emitter class used to emit particles from an existing particle
  17438. */
  17439. export class SubEmitter {
  17440. /**
  17441. * the particle system to be used by the sub emitter
  17442. */
  17443. particleSystem: ParticleSystem;
  17444. /**
  17445. * Type of the submitter (Default: END)
  17446. */
  17447. type: SubEmitterType;
  17448. /**
  17449. * 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)
  17450. * Note: This only is supported when using an emitter of type Mesh
  17451. */
  17452. inheritDirection: boolean;
  17453. /**
  17454. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17455. */
  17456. inheritedVelocityAmount: number;
  17457. /**
  17458. * Creates a sub emitter
  17459. * @param particleSystem the particle system to be used by the sub emitter
  17460. */
  17461. constructor(
  17462. /**
  17463. * the particle system to be used by the sub emitter
  17464. */
  17465. particleSystem: ParticleSystem);
  17466. /**
  17467. * Clones the sub emitter
  17468. * @returns the cloned sub emitter
  17469. */
  17470. clone(): SubEmitter;
  17471. /**
  17472. * Serialize current object to a JSON object
  17473. * @returns the serialized object
  17474. */
  17475. serialize(): any;
  17476. /** @hidden */
  17477. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17478. /**
  17479. * Creates a new SubEmitter from a serialized JSON version
  17480. * @param serializationObject defines the JSON object to read from
  17481. * @param scene defines the hosting scene
  17482. * @param rootUrl defines the rootUrl for data loading
  17483. * @returns a new SubEmitter
  17484. */
  17485. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17486. /** Release associated resources */
  17487. dispose(): void;
  17488. }
  17489. }
  17490. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17491. /** @hidden */
  17492. export var clipPlaneFragmentDeclaration: {
  17493. name: string;
  17494. shader: string;
  17495. };
  17496. }
  17497. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17498. /** @hidden */
  17499. export var imageProcessingDeclaration: {
  17500. name: string;
  17501. shader: string;
  17502. };
  17503. }
  17504. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17505. /** @hidden */
  17506. export var imageProcessingFunctions: {
  17507. name: string;
  17508. shader: string;
  17509. };
  17510. }
  17511. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17512. /** @hidden */
  17513. export var clipPlaneFragment: {
  17514. name: string;
  17515. shader: string;
  17516. };
  17517. }
  17518. declare module "babylonjs/Shaders/particles.fragment" {
  17519. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17520. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17521. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17522. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17523. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17524. /** @hidden */
  17525. export var particlesPixelShader: {
  17526. name: string;
  17527. shader: string;
  17528. };
  17529. }
  17530. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17531. /** @hidden */
  17532. export var clipPlaneVertexDeclaration: {
  17533. name: string;
  17534. shader: string;
  17535. };
  17536. }
  17537. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17538. /** @hidden */
  17539. export var clipPlaneVertex: {
  17540. name: string;
  17541. shader: string;
  17542. };
  17543. }
  17544. declare module "babylonjs/Shaders/particles.vertex" {
  17545. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17546. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17547. /** @hidden */
  17548. export var particlesVertexShader: {
  17549. name: string;
  17550. shader: string;
  17551. };
  17552. }
  17553. declare module "babylonjs/Particles/particleSystem" {
  17554. import { Nullable } from "babylonjs/types";
  17555. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17556. import { Observable } from "babylonjs/Misc/observable";
  17557. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17558. import { Effect } from "babylonjs/Materials/effect";
  17559. import { Scene, IDisposable } from "babylonjs/scene";
  17560. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17561. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17562. import { Particle } from "babylonjs/Particles/particle";
  17563. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17564. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17565. import "babylonjs/Shaders/particles.fragment";
  17566. import "babylonjs/Shaders/particles.vertex";
  17567. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17568. /**
  17569. * This represents a particle system in Babylon.
  17570. * 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.
  17571. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17572. * @example https://doc.babylonjs.com/babylon101/particles
  17573. */
  17574. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17575. /**
  17576. * Billboard mode will only apply to Y axis
  17577. */
  17578. static readonly BILLBOARDMODE_Y: number;
  17579. /**
  17580. * Billboard mode will apply to all axes
  17581. */
  17582. static readonly BILLBOARDMODE_ALL: number;
  17583. /**
  17584. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17585. */
  17586. static readonly BILLBOARDMODE_STRETCHED: number;
  17587. /**
  17588. * This function can be defined to provide custom update for active particles.
  17589. * This function will be called instead of regular update (age, position, color, etc.).
  17590. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17591. */
  17592. updateFunction: (particles: Particle[]) => void;
  17593. private _emitterWorldMatrix;
  17594. /**
  17595. * This function can be defined to specify initial direction for every new particle.
  17596. * It by default use the emitterType defined function
  17597. */
  17598. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17599. /**
  17600. * This function can be defined to specify initial position for every new particle.
  17601. * It by default use the emitterType defined function
  17602. */
  17603. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17604. /**
  17605. * @hidden
  17606. */
  17607. _inheritedVelocityOffset: Vector3;
  17608. /**
  17609. * An event triggered when the system is disposed
  17610. */
  17611. onDisposeObservable: Observable<ParticleSystem>;
  17612. private _onDisposeObserver;
  17613. /**
  17614. * Sets a callback that will be triggered when the system is disposed
  17615. */
  17616. onDispose: () => void;
  17617. private _particles;
  17618. private _epsilon;
  17619. private _capacity;
  17620. private _stockParticles;
  17621. private _newPartsExcess;
  17622. private _vertexData;
  17623. private _vertexBuffer;
  17624. private _vertexBuffers;
  17625. private _spriteBuffer;
  17626. private _indexBuffer;
  17627. private _effect;
  17628. private _customEffect;
  17629. private _cachedDefines;
  17630. private _scaledColorStep;
  17631. private _colorDiff;
  17632. private _scaledDirection;
  17633. private _scaledGravity;
  17634. private _currentRenderId;
  17635. private _alive;
  17636. private _useInstancing;
  17637. private _started;
  17638. private _stopped;
  17639. private _actualFrame;
  17640. private _scaledUpdateSpeed;
  17641. private _vertexBufferSize;
  17642. /** @hidden */
  17643. _currentEmitRateGradient: Nullable<FactorGradient>;
  17644. /** @hidden */
  17645. _currentEmitRate1: number;
  17646. /** @hidden */
  17647. _currentEmitRate2: number;
  17648. /** @hidden */
  17649. _currentStartSizeGradient: Nullable<FactorGradient>;
  17650. /** @hidden */
  17651. _currentStartSize1: number;
  17652. /** @hidden */
  17653. _currentStartSize2: number;
  17654. private readonly _rawTextureWidth;
  17655. private _rampGradientsTexture;
  17656. private _useRampGradients;
  17657. /** Gets or sets a boolean indicating that ramp gradients must be used
  17658. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17659. */
  17660. useRampGradients: boolean;
  17661. /**
  17662. * 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.
  17663. * 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: [])
  17664. */
  17665. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17666. private _subEmitters;
  17667. /**
  17668. * @hidden
  17669. * If the particle systems emitter should be disposed when the particle system is disposed
  17670. */
  17671. _disposeEmitterOnDispose: boolean;
  17672. /**
  17673. * The current active Sub-systems, this property is used by the root particle system only.
  17674. */
  17675. activeSubSystems: Array<ParticleSystem>;
  17676. private _rootParticleSystem;
  17677. /**
  17678. * Gets the current list of active particles
  17679. */
  17680. readonly particles: Particle[];
  17681. /**
  17682. * Returns the string "ParticleSystem"
  17683. * @returns a string containing the class name
  17684. */
  17685. getClassName(): string;
  17686. /**
  17687. * Instantiates a particle system.
  17688. * 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.
  17689. * @param name The name of the particle system
  17690. * @param capacity The max number of particles alive at the same time
  17691. * @param scene The scene the particle system belongs to
  17692. * @param customEffect a custom effect used to change the way particles are rendered by default
  17693. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17694. * @param epsilon Offset used to render the particles
  17695. */
  17696. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17697. private _addFactorGradient;
  17698. private _removeFactorGradient;
  17699. /**
  17700. * Adds a new life time gradient
  17701. * @param gradient defines the gradient to use (between 0 and 1)
  17702. * @param factor defines the life time factor to affect to the specified gradient
  17703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17704. * @returns the current particle system
  17705. */
  17706. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17707. /**
  17708. * Remove a specific life time gradient
  17709. * @param gradient defines the gradient to remove
  17710. * @returns the current particle system
  17711. */
  17712. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17713. /**
  17714. * Adds a new size gradient
  17715. * @param gradient defines the gradient to use (between 0 and 1)
  17716. * @param factor defines the size factor to affect to the specified gradient
  17717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17718. * @returns the current particle system
  17719. */
  17720. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17721. /**
  17722. * Remove a specific size gradient
  17723. * @param gradient defines the gradient to remove
  17724. * @returns the current particle system
  17725. */
  17726. removeSizeGradient(gradient: number): IParticleSystem;
  17727. /**
  17728. * Adds a new color remap gradient
  17729. * @param gradient defines the gradient to use (between 0 and 1)
  17730. * @param min defines the color remap minimal range
  17731. * @param max defines the color remap maximal range
  17732. * @returns the current particle system
  17733. */
  17734. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17735. /**
  17736. * Remove a specific color remap gradient
  17737. * @param gradient defines the gradient to remove
  17738. * @returns the current particle system
  17739. */
  17740. removeColorRemapGradient(gradient: number): IParticleSystem;
  17741. /**
  17742. * Adds a new alpha remap gradient
  17743. * @param gradient defines the gradient to use (between 0 and 1)
  17744. * @param min defines the alpha remap minimal range
  17745. * @param max defines the alpha remap maximal range
  17746. * @returns the current particle system
  17747. */
  17748. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17749. /**
  17750. * Remove a specific alpha remap gradient
  17751. * @param gradient defines the gradient to remove
  17752. * @returns the current particle system
  17753. */
  17754. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17755. /**
  17756. * Adds a new angular speed gradient
  17757. * @param gradient defines the gradient to use (between 0 and 1)
  17758. * @param factor defines the angular speed to affect to the specified gradient
  17759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17760. * @returns the current particle system
  17761. */
  17762. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17763. /**
  17764. * Remove a specific angular speed gradient
  17765. * @param gradient defines the gradient to remove
  17766. * @returns the current particle system
  17767. */
  17768. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17769. /**
  17770. * Adds a new velocity gradient
  17771. * @param gradient defines the gradient to use (between 0 and 1)
  17772. * @param factor defines the velocity to affect to the specified gradient
  17773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17774. * @returns the current particle system
  17775. */
  17776. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17777. /**
  17778. * Remove a specific velocity gradient
  17779. * @param gradient defines the gradient to remove
  17780. * @returns the current particle system
  17781. */
  17782. removeVelocityGradient(gradient: number): IParticleSystem;
  17783. /**
  17784. * Adds a new limit velocity gradient
  17785. * @param gradient defines the gradient to use (between 0 and 1)
  17786. * @param factor defines the limit velocity value to affect to the specified gradient
  17787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17788. * @returns the current particle system
  17789. */
  17790. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17791. /**
  17792. * Remove a specific limit velocity gradient
  17793. * @param gradient defines the gradient to remove
  17794. * @returns the current particle system
  17795. */
  17796. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17797. /**
  17798. * Adds a new drag gradient
  17799. * @param gradient defines the gradient to use (between 0 and 1)
  17800. * @param factor defines the drag value to affect to the specified gradient
  17801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17802. * @returns the current particle system
  17803. */
  17804. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17805. /**
  17806. * Remove a specific drag gradient
  17807. * @param gradient defines the gradient to remove
  17808. * @returns the current particle system
  17809. */
  17810. removeDragGradient(gradient: number): IParticleSystem;
  17811. /**
  17812. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17813. * @param gradient defines the gradient to use (between 0 and 1)
  17814. * @param factor defines the emit rate value to affect to the specified gradient
  17815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17816. * @returns the current particle system
  17817. */
  17818. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17819. /**
  17820. * Remove a specific emit rate gradient
  17821. * @param gradient defines the gradient to remove
  17822. * @returns the current particle system
  17823. */
  17824. removeEmitRateGradient(gradient: number): IParticleSystem;
  17825. /**
  17826. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17827. * @param gradient defines the gradient to use (between 0 and 1)
  17828. * @param factor defines the start size value to affect to the specified gradient
  17829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17830. * @returns the current particle system
  17831. */
  17832. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17833. /**
  17834. * Remove a specific start size gradient
  17835. * @param gradient defines the gradient to remove
  17836. * @returns the current particle system
  17837. */
  17838. removeStartSizeGradient(gradient: number): IParticleSystem;
  17839. private _createRampGradientTexture;
  17840. /**
  17841. * Gets the current list of ramp gradients.
  17842. * You must use addRampGradient and removeRampGradient to udpate this list
  17843. * @returns the list of ramp gradients
  17844. */
  17845. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17846. /**
  17847. * Adds a new ramp gradient used to remap particle colors
  17848. * @param gradient defines the gradient to use (between 0 and 1)
  17849. * @param color defines the color to affect to the specified gradient
  17850. * @returns the current particle system
  17851. */
  17852. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17853. /**
  17854. * Remove a specific ramp gradient
  17855. * @param gradient defines the gradient to remove
  17856. * @returns the current particle system
  17857. */
  17858. removeRampGradient(gradient: number): ParticleSystem;
  17859. /**
  17860. * Adds a new color gradient
  17861. * @param gradient defines the gradient to use (between 0 and 1)
  17862. * @param color1 defines the color to affect to the specified gradient
  17863. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17864. * @returns this particle system
  17865. */
  17866. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17867. /**
  17868. * Remove a specific color gradient
  17869. * @param gradient defines the gradient to remove
  17870. * @returns this particle system
  17871. */
  17872. removeColorGradient(gradient: number): IParticleSystem;
  17873. private _fetchR;
  17874. protected _reset(): void;
  17875. private _resetEffect;
  17876. private _createVertexBuffers;
  17877. private _createIndexBuffer;
  17878. /**
  17879. * Gets the maximum number of particles active at the same time.
  17880. * @returns The max number of active particles.
  17881. */
  17882. getCapacity(): number;
  17883. /**
  17884. * Gets whether there are still active particles in the system.
  17885. * @returns True if it is alive, otherwise false.
  17886. */
  17887. isAlive(): boolean;
  17888. /**
  17889. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17890. * @returns True if it has been started, otherwise false.
  17891. */
  17892. isStarted(): boolean;
  17893. private _prepareSubEmitterInternalArray;
  17894. /**
  17895. * Starts the particle system and begins to emit
  17896. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17897. */
  17898. start(delay?: number): void;
  17899. /**
  17900. * Stops the particle system.
  17901. * @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.
  17902. */
  17903. stop(stopSubEmitters?: boolean): void;
  17904. /**
  17905. * Remove all active particles
  17906. */
  17907. reset(): void;
  17908. /**
  17909. * @hidden (for internal use only)
  17910. */
  17911. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17912. /**
  17913. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17914. * Its lifetime will start back at 0.
  17915. */
  17916. recycleParticle: (particle: Particle) => void;
  17917. private _stopSubEmitters;
  17918. private _createParticle;
  17919. private _removeFromRoot;
  17920. private _emitFromParticle;
  17921. private _update;
  17922. /** @hidden */
  17923. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17924. /** @hidden */
  17925. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17926. /** @hidden */
  17927. private _getEffect;
  17928. /**
  17929. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17930. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17931. */
  17932. animate(preWarmOnly?: boolean): void;
  17933. private _appendParticleVertices;
  17934. /**
  17935. * Rebuilds the particle system.
  17936. */
  17937. rebuild(): void;
  17938. /**
  17939. * Is this system ready to be used/rendered
  17940. * @return true if the system is ready
  17941. */
  17942. isReady(): boolean;
  17943. private _render;
  17944. /**
  17945. * Renders the particle system in its current state.
  17946. * @returns the current number of particles
  17947. */
  17948. render(): number;
  17949. /**
  17950. * Disposes the particle system and free the associated resources
  17951. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17952. */
  17953. dispose(disposeTexture?: boolean): void;
  17954. /**
  17955. * Clones the particle system.
  17956. * @param name The name of the cloned object
  17957. * @param newEmitter The new emitter to use
  17958. * @returns the cloned particle system
  17959. */
  17960. clone(name: string, newEmitter: any): ParticleSystem;
  17961. /**
  17962. * Serializes the particle system to a JSON object.
  17963. * @returns the JSON object
  17964. */
  17965. serialize(): any;
  17966. /** @hidden */
  17967. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17968. /** @hidden */
  17969. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17970. /**
  17971. * Parses a JSON object to create a particle system.
  17972. * @param parsedParticleSystem The JSON object to parse
  17973. * @param scene The scene to create the particle system in
  17974. * @param rootUrl The root url to use to load external dependencies like texture
  17975. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17976. * @returns the Parsed particle system
  17977. */
  17978. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17979. }
  17980. }
  17981. declare module "babylonjs/Particles/particle" {
  17982. import { Nullable } from "babylonjs/types";
  17983. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17984. import { Color4 } from "babylonjs/Maths/math.color";
  17985. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17986. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17987. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17988. /**
  17989. * A particle represents one of the element emitted by a particle system.
  17990. * This is mainly define by its coordinates, direction, velocity and age.
  17991. */
  17992. export class Particle {
  17993. /**
  17994. * The particle system the particle belongs to.
  17995. */
  17996. particleSystem: ParticleSystem;
  17997. private static _Count;
  17998. /**
  17999. * Unique ID of the particle
  18000. */
  18001. id: number;
  18002. /**
  18003. * The world position of the particle in the scene.
  18004. */
  18005. position: Vector3;
  18006. /**
  18007. * The world direction of the particle in the scene.
  18008. */
  18009. direction: Vector3;
  18010. /**
  18011. * The color of the particle.
  18012. */
  18013. color: Color4;
  18014. /**
  18015. * The color change of the particle per step.
  18016. */
  18017. colorStep: Color4;
  18018. /**
  18019. * Defines how long will the life of the particle be.
  18020. */
  18021. lifeTime: number;
  18022. /**
  18023. * The current age of the particle.
  18024. */
  18025. age: number;
  18026. /**
  18027. * The current size of the particle.
  18028. */
  18029. size: number;
  18030. /**
  18031. * The current scale of the particle.
  18032. */
  18033. scale: Vector2;
  18034. /**
  18035. * The current angle of the particle.
  18036. */
  18037. angle: number;
  18038. /**
  18039. * Defines how fast is the angle changing.
  18040. */
  18041. angularSpeed: number;
  18042. /**
  18043. * Defines the cell index used by the particle to be rendered from a sprite.
  18044. */
  18045. cellIndex: number;
  18046. /**
  18047. * The information required to support color remapping
  18048. */
  18049. remapData: Vector4;
  18050. /** @hidden */
  18051. _randomCellOffset?: number;
  18052. /** @hidden */
  18053. _initialDirection: Nullable<Vector3>;
  18054. /** @hidden */
  18055. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18056. /** @hidden */
  18057. _initialStartSpriteCellID: number;
  18058. /** @hidden */
  18059. _initialEndSpriteCellID: number;
  18060. /** @hidden */
  18061. _currentColorGradient: Nullable<ColorGradient>;
  18062. /** @hidden */
  18063. _currentColor1: Color4;
  18064. /** @hidden */
  18065. _currentColor2: Color4;
  18066. /** @hidden */
  18067. _currentSizeGradient: Nullable<FactorGradient>;
  18068. /** @hidden */
  18069. _currentSize1: number;
  18070. /** @hidden */
  18071. _currentSize2: number;
  18072. /** @hidden */
  18073. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18074. /** @hidden */
  18075. _currentAngularSpeed1: number;
  18076. /** @hidden */
  18077. _currentAngularSpeed2: number;
  18078. /** @hidden */
  18079. _currentVelocityGradient: Nullable<FactorGradient>;
  18080. /** @hidden */
  18081. _currentVelocity1: number;
  18082. /** @hidden */
  18083. _currentVelocity2: number;
  18084. /** @hidden */
  18085. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18086. /** @hidden */
  18087. _currentLimitVelocity1: number;
  18088. /** @hidden */
  18089. _currentLimitVelocity2: number;
  18090. /** @hidden */
  18091. _currentDragGradient: Nullable<FactorGradient>;
  18092. /** @hidden */
  18093. _currentDrag1: number;
  18094. /** @hidden */
  18095. _currentDrag2: number;
  18096. /** @hidden */
  18097. _randomNoiseCoordinates1: Vector3;
  18098. /** @hidden */
  18099. _randomNoiseCoordinates2: Vector3;
  18100. /**
  18101. * Creates a new instance Particle
  18102. * @param particleSystem the particle system the particle belongs to
  18103. */
  18104. constructor(
  18105. /**
  18106. * The particle system the particle belongs to.
  18107. */
  18108. particleSystem: ParticleSystem);
  18109. private updateCellInfoFromSystem;
  18110. /**
  18111. * Defines how the sprite cell index is updated for the particle
  18112. */
  18113. updateCellIndex(): void;
  18114. /** @hidden */
  18115. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18116. /** @hidden */
  18117. _inheritParticleInfoToSubEmitters(): void;
  18118. /** @hidden */
  18119. _reset(): void;
  18120. /**
  18121. * Copy the properties of particle to another one.
  18122. * @param other the particle to copy the information to.
  18123. */
  18124. copyTo(other: Particle): void;
  18125. }
  18126. }
  18127. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18129. import { Effect } from "babylonjs/Materials/effect";
  18130. import { Particle } from "babylonjs/Particles/particle";
  18131. /**
  18132. * Particle emitter represents a volume emitting particles.
  18133. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18134. */
  18135. export interface IParticleEmitterType {
  18136. /**
  18137. * Called by the particle System when the direction is computed for the created particle.
  18138. * @param worldMatrix is the world matrix of the particle system
  18139. * @param directionToUpdate is the direction vector to update with the result
  18140. * @param particle is the particle we are computed the direction for
  18141. */
  18142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18143. /**
  18144. * Called by the particle System when the position is computed for the created particle.
  18145. * @param worldMatrix is the world matrix of the particle system
  18146. * @param positionToUpdate is the position vector to update with the result
  18147. * @param particle is the particle we are computed the position for
  18148. */
  18149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18150. /**
  18151. * Clones the current emitter and returns a copy of it
  18152. * @returns the new emitter
  18153. */
  18154. clone(): IParticleEmitterType;
  18155. /**
  18156. * Called by the GPUParticleSystem to setup the update shader
  18157. * @param effect defines the update shader
  18158. */
  18159. applyToShader(effect: Effect): void;
  18160. /**
  18161. * Returns a string to use to update the GPU particles update shader
  18162. * @returns the effect defines string
  18163. */
  18164. getEffectDefines(): string;
  18165. /**
  18166. * Returns a string representing the class name
  18167. * @returns a string containing the class name
  18168. */
  18169. getClassName(): string;
  18170. /**
  18171. * Serializes the particle system to a JSON object.
  18172. * @returns the JSON object
  18173. */
  18174. serialize(): any;
  18175. /**
  18176. * Parse properties from a JSON object
  18177. * @param serializationObject defines the JSON object
  18178. */
  18179. parse(serializationObject: any): void;
  18180. }
  18181. }
  18182. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18183. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18184. import { Effect } from "babylonjs/Materials/effect";
  18185. import { Particle } from "babylonjs/Particles/particle";
  18186. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18187. /**
  18188. * Particle emitter emitting particles from the inside of a box.
  18189. * It emits the particles randomly between 2 given directions.
  18190. */
  18191. export class BoxParticleEmitter implements IParticleEmitterType {
  18192. /**
  18193. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18194. */
  18195. direction1: Vector3;
  18196. /**
  18197. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18198. */
  18199. direction2: Vector3;
  18200. /**
  18201. * 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.
  18202. */
  18203. minEmitBox: Vector3;
  18204. /**
  18205. * 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.
  18206. */
  18207. maxEmitBox: Vector3;
  18208. /**
  18209. * Creates a new instance BoxParticleEmitter
  18210. */
  18211. constructor();
  18212. /**
  18213. * Called by the particle System when the direction is computed for the created particle.
  18214. * @param worldMatrix is the world matrix of the particle system
  18215. * @param directionToUpdate is the direction vector to update with the result
  18216. * @param particle is the particle we are computed the direction for
  18217. */
  18218. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18219. /**
  18220. * Called by the particle System when the position is computed for the created particle.
  18221. * @param worldMatrix is the world matrix of the particle system
  18222. * @param positionToUpdate is the position vector to update with the result
  18223. * @param particle is the particle we are computed the position for
  18224. */
  18225. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18226. /**
  18227. * Clones the current emitter and returns a copy of it
  18228. * @returns the new emitter
  18229. */
  18230. clone(): BoxParticleEmitter;
  18231. /**
  18232. * Called by the GPUParticleSystem to setup the update shader
  18233. * @param effect defines the update shader
  18234. */
  18235. applyToShader(effect: Effect): void;
  18236. /**
  18237. * Returns a string to use to update the GPU particles update shader
  18238. * @returns a string containng the defines string
  18239. */
  18240. getEffectDefines(): string;
  18241. /**
  18242. * Returns the string "BoxParticleEmitter"
  18243. * @returns a string containing the class name
  18244. */
  18245. getClassName(): string;
  18246. /**
  18247. * Serializes the particle system to a JSON object.
  18248. * @returns the JSON object
  18249. */
  18250. serialize(): any;
  18251. /**
  18252. * Parse properties from a JSON object
  18253. * @param serializationObject defines the JSON object
  18254. */
  18255. parse(serializationObject: any): void;
  18256. }
  18257. }
  18258. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18259. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18260. import { Effect } from "babylonjs/Materials/effect";
  18261. import { Particle } from "babylonjs/Particles/particle";
  18262. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18263. /**
  18264. * Particle emitter emitting particles from the inside of a cone.
  18265. * It emits the particles alongside the cone volume from the base to the particle.
  18266. * The emission direction might be randomized.
  18267. */
  18268. export class ConeParticleEmitter implements IParticleEmitterType {
  18269. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18270. directionRandomizer: number;
  18271. private _radius;
  18272. private _angle;
  18273. private _height;
  18274. /**
  18275. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18276. */
  18277. radiusRange: number;
  18278. /**
  18279. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18280. */
  18281. heightRange: number;
  18282. /**
  18283. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18284. */
  18285. emitFromSpawnPointOnly: boolean;
  18286. /**
  18287. * Gets or sets the radius of the emission cone
  18288. */
  18289. radius: number;
  18290. /**
  18291. * Gets or sets the angle of the emission cone
  18292. */
  18293. angle: number;
  18294. private _buildHeight;
  18295. /**
  18296. * Creates a new instance ConeParticleEmitter
  18297. * @param radius the radius of the emission cone (1 by default)
  18298. * @param angle the cone base angle (PI by default)
  18299. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18300. */
  18301. constructor(radius?: number, angle?: number,
  18302. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18303. directionRandomizer?: number);
  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. * Called by the particle System when the position is computed for the created particle.
  18313. * @param worldMatrix is the world matrix of the particle system
  18314. * @param positionToUpdate is the position vector to update with the result
  18315. * @param particle is the particle we are computed the position for
  18316. */
  18317. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18318. /**
  18319. * Clones the current emitter and returns a copy of it
  18320. * @returns the new emitter
  18321. */
  18322. clone(): ConeParticleEmitter;
  18323. /**
  18324. * Called by the GPUParticleSystem to setup the update shader
  18325. * @param effect defines the update shader
  18326. */
  18327. applyToShader(effect: Effect): void;
  18328. /**
  18329. * Returns a string to use to update the GPU particles update shader
  18330. * @returns a string containng the defines string
  18331. */
  18332. getEffectDefines(): string;
  18333. /**
  18334. * Returns the string "ConeParticleEmitter"
  18335. * @returns a string containing the class name
  18336. */
  18337. getClassName(): string;
  18338. /**
  18339. * Serializes the particle system to a JSON object.
  18340. * @returns the JSON object
  18341. */
  18342. serialize(): any;
  18343. /**
  18344. * Parse properties from a JSON object
  18345. * @param serializationObject defines the JSON object
  18346. */
  18347. parse(serializationObject: any): void;
  18348. }
  18349. }
  18350. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18351. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18352. import { Effect } from "babylonjs/Materials/effect";
  18353. import { Particle } from "babylonjs/Particles/particle";
  18354. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18355. /**
  18356. * Particle emitter emitting particles from the inside of a cylinder.
  18357. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18358. */
  18359. export class CylinderParticleEmitter implements IParticleEmitterType {
  18360. /**
  18361. * The radius of the emission cylinder.
  18362. */
  18363. radius: number;
  18364. /**
  18365. * The height of the emission cylinder.
  18366. */
  18367. height: number;
  18368. /**
  18369. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18370. */
  18371. radiusRange: number;
  18372. /**
  18373. * How much to randomize the particle direction [0-1].
  18374. */
  18375. directionRandomizer: number;
  18376. /**
  18377. * Creates a new instance CylinderParticleEmitter
  18378. * @param radius the radius of the emission cylinder (1 by default)
  18379. * @param height the height of the emission cylinder (1 by default)
  18380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18381. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18382. */
  18383. constructor(
  18384. /**
  18385. * The radius of the emission cylinder.
  18386. */
  18387. radius?: number,
  18388. /**
  18389. * The height of the emission cylinder.
  18390. */
  18391. height?: number,
  18392. /**
  18393. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18394. */
  18395. radiusRange?: number,
  18396. /**
  18397. * How much to randomize the particle direction [0-1].
  18398. */
  18399. directionRandomizer?: number);
  18400. /**
  18401. * Called by the particle System when the direction is computed for the created particle.
  18402. * @param worldMatrix is the world matrix of the particle system
  18403. * @param directionToUpdate is the direction vector to update with the result
  18404. * @param particle is the particle we are computed the direction for
  18405. */
  18406. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18407. /**
  18408. * Called by the particle System when the position is computed for the created particle.
  18409. * @param worldMatrix is the world matrix of the particle system
  18410. * @param positionToUpdate is the position vector to update with the result
  18411. * @param particle is the particle we are computed the position for
  18412. */
  18413. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18414. /**
  18415. * Clones the current emitter and returns a copy of it
  18416. * @returns the new emitter
  18417. */
  18418. clone(): CylinderParticleEmitter;
  18419. /**
  18420. * Called by the GPUParticleSystem to setup the update shader
  18421. * @param effect defines the update shader
  18422. */
  18423. applyToShader(effect: Effect): void;
  18424. /**
  18425. * Returns a string to use to update the GPU particles update shader
  18426. * @returns a string containng the defines string
  18427. */
  18428. getEffectDefines(): string;
  18429. /**
  18430. * Returns the string "CylinderParticleEmitter"
  18431. * @returns a string containing the class name
  18432. */
  18433. getClassName(): string;
  18434. /**
  18435. * Serializes the particle system to a JSON object.
  18436. * @returns the JSON object
  18437. */
  18438. serialize(): any;
  18439. /**
  18440. * Parse properties from a JSON object
  18441. * @param serializationObject defines the JSON object
  18442. */
  18443. parse(serializationObject: any): void;
  18444. }
  18445. /**
  18446. * Particle emitter emitting particles from the inside of a cylinder.
  18447. * It emits the particles randomly between two vectors.
  18448. */
  18449. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18450. /**
  18451. * The min limit of the emission direction.
  18452. */
  18453. direction1: Vector3;
  18454. /**
  18455. * The max limit of the emission direction.
  18456. */
  18457. direction2: Vector3;
  18458. /**
  18459. * Creates a new instance CylinderDirectedParticleEmitter
  18460. * @param radius the radius of the emission cylinder (1 by default)
  18461. * @param height the height of the emission cylinder (1 by default)
  18462. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18463. * @param direction1 the min limit of the emission direction (up vector by default)
  18464. * @param direction2 the max limit of the emission direction (up vector by default)
  18465. */
  18466. constructor(radius?: number, height?: number, radiusRange?: number,
  18467. /**
  18468. * The min limit of the emission direction.
  18469. */
  18470. direction1?: Vector3,
  18471. /**
  18472. * The max limit of the emission direction.
  18473. */
  18474. direction2?: Vector3);
  18475. /**
  18476. * Called by the particle System when the direction is computed for the created particle.
  18477. * @param worldMatrix is the world matrix of the particle system
  18478. * @param directionToUpdate is the direction vector to update with the result
  18479. * @param particle is the particle we are computed the direction for
  18480. */
  18481. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18482. /**
  18483. * Clones the current emitter and returns a copy of it
  18484. * @returns the new emitter
  18485. */
  18486. clone(): CylinderDirectedParticleEmitter;
  18487. /**
  18488. * Called by the GPUParticleSystem to setup the update shader
  18489. * @param effect defines the update shader
  18490. */
  18491. applyToShader(effect: Effect): void;
  18492. /**
  18493. * Returns a string to use to update the GPU particles update shader
  18494. * @returns a string containng the defines string
  18495. */
  18496. getEffectDefines(): string;
  18497. /**
  18498. * Returns the string "CylinderDirectedParticleEmitter"
  18499. * @returns a string containing the class name
  18500. */
  18501. getClassName(): string;
  18502. /**
  18503. * Serializes the particle system to a JSON object.
  18504. * @returns the JSON object
  18505. */
  18506. serialize(): any;
  18507. /**
  18508. * Parse properties from a JSON object
  18509. * @param serializationObject defines the JSON object
  18510. */
  18511. parse(serializationObject: any): void;
  18512. }
  18513. }
  18514. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18515. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18516. import { Effect } from "babylonjs/Materials/effect";
  18517. import { Particle } from "babylonjs/Particles/particle";
  18518. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18519. /**
  18520. * Particle emitter emitting particles from the inside of a hemisphere.
  18521. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18522. */
  18523. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18524. /**
  18525. * The radius of the emission hemisphere.
  18526. */
  18527. radius: number;
  18528. /**
  18529. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18530. */
  18531. radiusRange: number;
  18532. /**
  18533. * How much to randomize the particle direction [0-1].
  18534. */
  18535. directionRandomizer: number;
  18536. /**
  18537. * Creates a new instance HemisphericParticleEmitter
  18538. * @param radius the radius of the emission hemisphere (1 by default)
  18539. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18540. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18541. */
  18542. constructor(
  18543. /**
  18544. * The radius of the emission hemisphere.
  18545. */
  18546. radius?: number,
  18547. /**
  18548. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18549. */
  18550. radiusRange?: number,
  18551. /**
  18552. * How much to randomize the particle direction [0-1].
  18553. */
  18554. directionRandomizer?: number);
  18555. /**
  18556. * Called by the particle System when the direction is computed for the created particle.
  18557. * @param worldMatrix is the world matrix of the particle system
  18558. * @param directionToUpdate is the direction vector to update with the result
  18559. * @param particle is the particle we are computed the direction for
  18560. */
  18561. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18562. /**
  18563. * Called by the particle System when the position is computed for the created particle.
  18564. * @param worldMatrix is the world matrix of the particle system
  18565. * @param positionToUpdate is the position vector to update with the result
  18566. * @param particle is the particle we are computed the position for
  18567. */
  18568. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18569. /**
  18570. * Clones the current emitter and returns a copy of it
  18571. * @returns the new emitter
  18572. */
  18573. clone(): HemisphericParticleEmitter;
  18574. /**
  18575. * Called by the GPUParticleSystem to setup the update shader
  18576. * @param effect defines the update shader
  18577. */
  18578. applyToShader(effect: Effect): void;
  18579. /**
  18580. * Returns a string to use to update the GPU particles update shader
  18581. * @returns a string containng the defines string
  18582. */
  18583. getEffectDefines(): string;
  18584. /**
  18585. * Returns the string "HemisphericParticleEmitter"
  18586. * @returns a string containing the class name
  18587. */
  18588. getClassName(): string;
  18589. /**
  18590. * Serializes the particle system to a JSON object.
  18591. * @returns the JSON object
  18592. */
  18593. serialize(): any;
  18594. /**
  18595. * Parse properties from a JSON object
  18596. * @param serializationObject defines the JSON object
  18597. */
  18598. parse(serializationObject: any): void;
  18599. }
  18600. }
  18601. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18602. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18603. import { Effect } from "babylonjs/Materials/effect";
  18604. import { Particle } from "babylonjs/Particles/particle";
  18605. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18606. /**
  18607. * Particle emitter emitting particles from a point.
  18608. * It emits the particles randomly between 2 given directions.
  18609. */
  18610. export class PointParticleEmitter implements IParticleEmitterType {
  18611. /**
  18612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18613. */
  18614. direction1: Vector3;
  18615. /**
  18616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18617. */
  18618. direction2: Vector3;
  18619. /**
  18620. * Creates a new instance PointParticleEmitter
  18621. */
  18622. constructor();
  18623. /**
  18624. * Called by the particle System when the direction is computed for the created particle.
  18625. * @param worldMatrix is the world matrix of the particle system
  18626. * @param directionToUpdate is the direction vector to update with the result
  18627. * @param particle is the particle we are computed the direction for
  18628. */
  18629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18630. /**
  18631. * Called by the particle System when the position is computed for the created particle.
  18632. * @param worldMatrix is the world matrix of the particle system
  18633. * @param positionToUpdate is the position vector to update with the result
  18634. * @param particle is the particle we are computed the position for
  18635. */
  18636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18637. /**
  18638. * Clones the current emitter and returns a copy of it
  18639. * @returns the new emitter
  18640. */
  18641. clone(): PointParticleEmitter;
  18642. /**
  18643. * Called by the GPUParticleSystem to setup the update shader
  18644. * @param effect defines the update shader
  18645. */
  18646. applyToShader(effect: Effect): void;
  18647. /**
  18648. * Returns a string to use to update the GPU particles update shader
  18649. * @returns a string containng the defines string
  18650. */
  18651. getEffectDefines(): string;
  18652. /**
  18653. * Returns the string "PointParticleEmitter"
  18654. * @returns a string containing the class name
  18655. */
  18656. getClassName(): string;
  18657. /**
  18658. * Serializes the particle system to a JSON object.
  18659. * @returns the JSON object
  18660. */
  18661. serialize(): any;
  18662. /**
  18663. * Parse properties from a JSON object
  18664. * @param serializationObject defines the JSON object
  18665. */
  18666. parse(serializationObject: any): void;
  18667. }
  18668. }
  18669. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18670. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18671. import { Effect } from "babylonjs/Materials/effect";
  18672. import { Particle } from "babylonjs/Particles/particle";
  18673. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18674. /**
  18675. * Particle emitter emitting particles from the inside of a sphere.
  18676. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18677. */
  18678. export class SphereParticleEmitter implements IParticleEmitterType {
  18679. /**
  18680. * The radius of the emission sphere.
  18681. */
  18682. radius: number;
  18683. /**
  18684. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18685. */
  18686. radiusRange: number;
  18687. /**
  18688. * How much to randomize the particle direction [0-1].
  18689. */
  18690. directionRandomizer: number;
  18691. /**
  18692. * Creates a new instance SphereParticleEmitter
  18693. * @param radius the radius of the emission sphere (1 by default)
  18694. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18695. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18696. */
  18697. constructor(
  18698. /**
  18699. * The radius of the emission sphere.
  18700. */
  18701. radius?: number,
  18702. /**
  18703. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18704. */
  18705. radiusRange?: number,
  18706. /**
  18707. * How much to randomize the particle direction [0-1].
  18708. */
  18709. directionRandomizer?: number);
  18710. /**
  18711. * Called by the particle System when the direction is computed for the created particle.
  18712. * @param worldMatrix is the world matrix of the particle system
  18713. * @param directionToUpdate is the direction vector to update with the result
  18714. * @param particle is the particle we are computed the direction for
  18715. */
  18716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18717. /**
  18718. * Called by the particle System when the position is computed for the created particle.
  18719. * @param worldMatrix is the world matrix of the particle system
  18720. * @param positionToUpdate is the position vector to update with the result
  18721. * @param particle is the particle we are computed the position for
  18722. */
  18723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18724. /**
  18725. * Clones the current emitter and returns a copy of it
  18726. * @returns the new emitter
  18727. */
  18728. clone(): SphereParticleEmitter;
  18729. /**
  18730. * Called by the GPUParticleSystem to setup the update shader
  18731. * @param effect defines the update shader
  18732. */
  18733. applyToShader(effect: Effect): void;
  18734. /**
  18735. * Returns a string to use to update the GPU particles update shader
  18736. * @returns a string containng the defines string
  18737. */
  18738. getEffectDefines(): string;
  18739. /**
  18740. * Returns the string "SphereParticleEmitter"
  18741. * @returns a string containing the class name
  18742. */
  18743. getClassName(): string;
  18744. /**
  18745. * Serializes the particle system to a JSON object.
  18746. * @returns the JSON object
  18747. */
  18748. serialize(): any;
  18749. /**
  18750. * Parse properties from a JSON object
  18751. * @param serializationObject defines the JSON object
  18752. */
  18753. parse(serializationObject: any): void;
  18754. }
  18755. /**
  18756. * Particle emitter emitting particles from the inside of a sphere.
  18757. * It emits the particles randomly between two vectors.
  18758. */
  18759. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18760. /**
  18761. * The min limit of the emission direction.
  18762. */
  18763. direction1: Vector3;
  18764. /**
  18765. * The max limit of the emission direction.
  18766. */
  18767. direction2: Vector3;
  18768. /**
  18769. * Creates a new instance SphereDirectedParticleEmitter
  18770. * @param radius the radius of the emission sphere (1 by default)
  18771. * @param direction1 the min limit of the emission direction (up vector by default)
  18772. * @param direction2 the max limit of the emission direction (up vector by default)
  18773. */
  18774. constructor(radius?: number,
  18775. /**
  18776. * The min limit of the emission direction.
  18777. */
  18778. direction1?: Vector3,
  18779. /**
  18780. * The max limit of the emission direction.
  18781. */
  18782. direction2?: Vector3);
  18783. /**
  18784. * Called by the particle System when the direction is computed for the created particle.
  18785. * @param worldMatrix is the world matrix of the particle system
  18786. * @param directionToUpdate is the direction vector to update with the result
  18787. * @param particle is the particle we are computed the direction for
  18788. */
  18789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18790. /**
  18791. * Clones the current emitter and returns a copy of it
  18792. * @returns the new emitter
  18793. */
  18794. clone(): SphereDirectedParticleEmitter;
  18795. /**
  18796. * Called by the GPUParticleSystem to setup the update shader
  18797. * @param effect defines the update shader
  18798. */
  18799. applyToShader(effect: Effect): void;
  18800. /**
  18801. * Returns a string to use to update the GPU particles update shader
  18802. * @returns a string containng the defines string
  18803. */
  18804. getEffectDefines(): string;
  18805. /**
  18806. * Returns the string "SphereDirectedParticleEmitter"
  18807. * @returns a string containing the class name
  18808. */
  18809. getClassName(): string;
  18810. /**
  18811. * Serializes the particle system to a JSON object.
  18812. * @returns the JSON object
  18813. */
  18814. serialize(): any;
  18815. /**
  18816. * Parse properties from a JSON object
  18817. * @param serializationObject defines the JSON object
  18818. */
  18819. parse(serializationObject: any): void;
  18820. }
  18821. }
  18822. declare module "babylonjs/Particles/EmitterTypes/index" {
  18823. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18824. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18825. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18826. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18827. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18828. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18829. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18830. }
  18831. declare module "babylonjs/Particles/IParticleSystem" {
  18832. import { Nullable } from "babylonjs/types";
  18833. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18834. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18837. import { Texture } from "babylonjs/Materials/Textures/texture";
  18838. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18839. import { Scene } from "babylonjs/scene";
  18840. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18841. import { Animation } from "babylonjs/Animations/animation";
  18842. /**
  18843. * Interface representing a particle system in Babylon.js.
  18844. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18845. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18846. */
  18847. export interface IParticleSystem {
  18848. /**
  18849. * List of animations used by the particle system.
  18850. */
  18851. animations: Animation[];
  18852. /**
  18853. * The id of the Particle system.
  18854. */
  18855. id: string;
  18856. /**
  18857. * The name of the Particle system.
  18858. */
  18859. name: string;
  18860. /**
  18861. * The emitter represents the Mesh or position we are attaching the particle system to.
  18862. */
  18863. emitter: Nullable<AbstractMesh | Vector3>;
  18864. /**
  18865. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18866. */
  18867. isBillboardBased: boolean;
  18868. /**
  18869. * The rendering group used by the Particle system to chose when to render.
  18870. */
  18871. renderingGroupId: number;
  18872. /**
  18873. * The layer mask we are rendering the particles through.
  18874. */
  18875. layerMask: number;
  18876. /**
  18877. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18878. */
  18879. updateSpeed: number;
  18880. /**
  18881. * The amount of time the particle system is running (depends of the overall update speed).
  18882. */
  18883. targetStopDuration: number;
  18884. /**
  18885. * The texture used to render each particle. (this can be a spritesheet)
  18886. */
  18887. particleTexture: Nullable<Texture>;
  18888. /**
  18889. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18890. */
  18891. blendMode: number;
  18892. /**
  18893. * Minimum life time of emitting particles.
  18894. */
  18895. minLifeTime: number;
  18896. /**
  18897. * Maximum life time of emitting particles.
  18898. */
  18899. maxLifeTime: number;
  18900. /**
  18901. * Minimum Size of emitting particles.
  18902. */
  18903. minSize: number;
  18904. /**
  18905. * Maximum Size of emitting particles.
  18906. */
  18907. maxSize: number;
  18908. /**
  18909. * Minimum scale of emitting particles on X axis.
  18910. */
  18911. minScaleX: number;
  18912. /**
  18913. * Maximum scale of emitting particles on X axis.
  18914. */
  18915. maxScaleX: number;
  18916. /**
  18917. * Minimum scale of emitting particles on Y axis.
  18918. */
  18919. minScaleY: number;
  18920. /**
  18921. * Maximum scale of emitting particles on Y axis.
  18922. */
  18923. maxScaleY: number;
  18924. /**
  18925. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18926. */
  18927. color1: Color4;
  18928. /**
  18929. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18930. */
  18931. color2: Color4;
  18932. /**
  18933. * Color the particle will have at the end of its lifetime.
  18934. */
  18935. colorDead: Color4;
  18936. /**
  18937. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18938. */
  18939. emitRate: number;
  18940. /**
  18941. * You can use gravity if you want to give an orientation to your particles.
  18942. */
  18943. gravity: Vector3;
  18944. /**
  18945. * Minimum power of emitting particles.
  18946. */
  18947. minEmitPower: number;
  18948. /**
  18949. * Maximum power of emitting particles.
  18950. */
  18951. maxEmitPower: number;
  18952. /**
  18953. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18954. */
  18955. minAngularSpeed: number;
  18956. /**
  18957. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18958. */
  18959. maxAngularSpeed: number;
  18960. /**
  18961. * Gets or sets the minimal initial rotation in radians.
  18962. */
  18963. minInitialRotation: number;
  18964. /**
  18965. * Gets or sets the maximal initial rotation in radians.
  18966. */
  18967. maxInitialRotation: number;
  18968. /**
  18969. * The particle emitter type defines the emitter used by the particle system.
  18970. * It can be for example box, sphere, or cone...
  18971. */
  18972. particleEmitterType: Nullable<IParticleEmitterType>;
  18973. /**
  18974. * Defines the delay in milliseconds before starting the system (0 by default)
  18975. */
  18976. startDelay: number;
  18977. /**
  18978. * 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
  18979. */
  18980. preWarmCycles: number;
  18981. /**
  18982. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18983. */
  18984. preWarmStepOffset: number;
  18985. /**
  18986. * 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)
  18987. */
  18988. spriteCellChangeSpeed: number;
  18989. /**
  18990. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18991. */
  18992. startSpriteCellID: number;
  18993. /**
  18994. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18995. */
  18996. endSpriteCellID: number;
  18997. /**
  18998. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18999. */
  19000. spriteCellWidth: number;
  19001. /**
  19002. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19003. */
  19004. spriteCellHeight: number;
  19005. /**
  19006. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19007. */
  19008. spriteRandomStartCell: boolean;
  19009. /**
  19010. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19011. */
  19012. isAnimationSheetEnabled: boolean;
  19013. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19014. translationPivot: Vector2;
  19015. /**
  19016. * Gets or sets a texture used to add random noise to particle positions
  19017. */
  19018. noiseTexture: Nullable<BaseTexture>;
  19019. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19020. noiseStrength: Vector3;
  19021. /**
  19022. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19023. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19024. */
  19025. billboardMode: number;
  19026. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19027. limitVelocityDamping: number;
  19028. /**
  19029. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19030. */
  19031. beginAnimationOnStart: boolean;
  19032. /**
  19033. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19034. */
  19035. beginAnimationFrom: number;
  19036. /**
  19037. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19038. */
  19039. beginAnimationTo: number;
  19040. /**
  19041. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19042. */
  19043. beginAnimationLoop: boolean;
  19044. /**
  19045. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19046. */
  19047. disposeOnStop: boolean;
  19048. /**
  19049. * Gets the maximum number of particles active at the same time.
  19050. * @returns The max number of active particles.
  19051. */
  19052. getCapacity(): number;
  19053. /**
  19054. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19055. * @returns True if it has been started, otherwise false.
  19056. */
  19057. isStarted(): boolean;
  19058. /**
  19059. * Animates the particle system for this frame.
  19060. */
  19061. animate(): void;
  19062. /**
  19063. * Renders the particle system in its current state.
  19064. * @returns the current number of particles
  19065. */
  19066. render(): number;
  19067. /**
  19068. * Dispose the particle system and frees its associated resources.
  19069. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19070. */
  19071. dispose(disposeTexture?: boolean): void;
  19072. /**
  19073. * Clones the particle system.
  19074. * @param name The name of the cloned object
  19075. * @param newEmitter The new emitter to use
  19076. * @returns the cloned particle system
  19077. */
  19078. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19079. /**
  19080. * Serializes the particle system to a JSON object.
  19081. * @returns the JSON object
  19082. */
  19083. serialize(): any;
  19084. /**
  19085. * Rebuild the particle system
  19086. */
  19087. rebuild(): void;
  19088. /**
  19089. * Starts the particle system and begins to emit
  19090. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19091. */
  19092. start(delay?: number): void;
  19093. /**
  19094. * Stops the particle system.
  19095. */
  19096. stop(): void;
  19097. /**
  19098. * Remove all active particles
  19099. */
  19100. reset(): void;
  19101. /**
  19102. * Is this system ready to be used/rendered
  19103. * @return true if the system is ready
  19104. */
  19105. isReady(): boolean;
  19106. /**
  19107. * Adds a new color gradient
  19108. * @param gradient defines the gradient to use (between 0 and 1)
  19109. * @param color1 defines the color to affect to the specified gradient
  19110. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19111. * @returns the current particle system
  19112. */
  19113. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19114. /**
  19115. * Remove a specific color gradient
  19116. * @param gradient defines the gradient to remove
  19117. * @returns the current particle system
  19118. */
  19119. removeColorGradient(gradient: number): IParticleSystem;
  19120. /**
  19121. * Adds a new size gradient
  19122. * @param gradient defines the gradient to use (between 0 and 1)
  19123. * @param factor defines the size factor to affect to the specified gradient
  19124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19125. * @returns the current particle system
  19126. */
  19127. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19128. /**
  19129. * Remove a specific size gradient
  19130. * @param gradient defines the gradient to remove
  19131. * @returns the current particle system
  19132. */
  19133. removeSizeGradient(gradient: number): IParticleSystem;
  19134. /**
  19135. * Gets the current list of color gradients.
  19136. * You must use addColorGradient and removeColorGradient to udpate this list
  19137. * @returns the list of color gradients
  19138. */
  19139. getColorGradients(): Nullable<Array<ColorGradient>>;
  19140. /**
  19141. * Gets the current list of size gradients.
  19142. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19143. * @returns the list of size gradients
  19144. */
  19145. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19146. /**
  19147. * Gets the current list of angular speed gradients.
  19148. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19149. * @returns the list of angular speed gradients
  19150. */
  19151. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new angular speed gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param factor defines the angular speed to affect to the specified gradient
  19156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19157. * @returns the current particle system
  19158. */
  19159. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19160. /**
  19161. * Remove a specific angular speed gradient
  19162. * @param gradient defines the gradient to remove
  19163. * @returns the current particle system
  19164. */
  19165. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19166. /**
  19167. * Gets the current list of velocity gradients.
  19168. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19169. * @returns the list of velocity gradients
  19170. */
  19171. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19172. /**
  19173. * Adds a new velocity gradient
  19174. * @param gradient defines the gradient to use (between 0 and 1)
  19175. * @param factor defines the velocity to affect to the specified gradient
  19176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19177. * @returns the current particle system
  19178. */
  19179. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19180. /**
  19181. * Remove a specific velocity gradient
  19182. * @param gradient defines the gradient to remove
  19183. * @returns the current particle system
  19184. */
  19185. removeVelocityGradient(gradient: number): IParticleSystem;
  19186. /**
  19187. * Gets the current list of limit velocity gradients.
  19188. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19189. * @returns the list of limit velocity gradients
  19190. */
  19191. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19192. /**
  19193. * Adds a new limit velocity gradient
  19194. * @param gradient defines the gradient to use (between 0 and 1)
  19195. * @param factor defines the limit velocity to affect to the specified gradient
  19196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19197. * @returns the current particle system
  19198. */
  19199. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19200. /**
  19201. * Remove a specific limit velocity gradient
  19202. * @param gradient defines the gradient to remove
  19203. * @returns the current particle system
  19204. */
  19205. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19206. /**
  19207. * Adds a new drag gradient
  19208. * @param gradient defines the gradient to use (between 0 and 1)
  19209. * @param factor defines the drag to affect to the specified gradient
  19210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19211. * @returns the current particle system
  19212. */
  19213. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19214. /**
  19215. * Remove a specific drag gradient
  19216. * @param gradient defines the gradient to remove
  19217. * @returns the current particle system
  19218. */
  19219. removeDragGradient(gradient: number): IParticleSystem;
  19220. /**
  19221. * Gets the current list of drag gradients.
  19222. * You must use addDragGradient and removeDragGradient to udpate this list
  19223. * @returns the list of drag gradients
  19224. */
  19225. getDragGradients(): Nullable<Array<FactorGradient>>;
  19226. /**
  19227. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19228. * @param gradient defines the gradient to use (between 0 and 1)
  19229. * @param factor defines the emit rate to affect to the specified gradient
  19230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19231. * @returns the current particle system
  19232. */
  19233. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19234. /**
  19235. * Remove a specific emit rate gradient
  19236. * @param gradient defines the gradient to remove
  19237. * @returns the current particle system
  19238. */
  19239. removeEmitRateGradient(gradient: number): IParticleSystem;
  19240. /**
  19241. * Gets the current list of emit rate gradients.
  19242. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19243. * @returns the list of emit rate gradients
  19244. */
  19245. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19246. /**
  19247. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19248. * @param gradient defines the gradient to use (between 0 and 1)
  19249. * @param factor defines the start size to affect to the specified gradient
  19250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19251. * @returns the current particle system
  19252. */
  19253. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19254. /**
  19255. * Remove a specific start size gradient
  19256. * @param gradient defines the gradient to remove
  19257. * @returns the current particle system
  19258. */
  19259. removeStartSizeGradient(gradient: number): IParticleSystem;
  19260. /**
  19261. * Gets the current list of start size gradients.
  19262. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19263. * @returns the list of start size gradients
  19264. */
  19265. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19266. /**
  19267. * Adds a new life time gradient
  19268. * @param gradient defines the gradient to use (between 0 and 1)
  19269. * @param factor defines the life time factor to affect to the specified gradient
  19270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19271. * @returns the current particle system
  19272. */
  19273. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19274. /**
  19275. * Remove a specific life time gradient
  19276. * @param gradient defines the gradient to remove
  19277. * @returns the current particle system
  19278. */
  19279. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19280. /**
  19281. * Gets the current list of life time gradients.
  19282. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19283. * @returns the list of life time gradients
  19284. */
  19285. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19286. /**
  19287. * Gets the current list of color gradients.
  19288. * You must use addColorGradient and removeColorGradient to udpate this list
  19289. * @returns the list of color gradients
  19290. */
  19291. getColorGradients(): Nullable<Array<ColorGradient>>;
  19292. /**
  19293. * Adds a new ramp gradient used to remap particle colors
  19294. * @param gradient defines the gradient to use (between 0 and 1)
  19295. * @param color defines the color to affect to the specified gradient
  19296. * @returns the current particle system
  19297. */
  19298. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19299. /**
  19300. * Gets the current list of ramp gradients.
  19301. * You must use addRampGradient and removeRampGradient to udpate this list
  19302. * @returns the list of ramp gradients
  19303. */
  19304. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19305. /** Gets or sets a boolean indicating that ramp gradients must be used
  19306. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19307. */
  19308. useRampGradients: boolean;
  19309. /**
  19310. * Adds a new color remap gradient
  19311. * @param gradient defines the gradient to use (between 0 and 1)
  19312. * @param min defines the color remap minimal range
  19313. * @param max defines the color remap maximal range
  19314. * @returns the current particle system
  19315. */
  19316. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19317. /**
  19318. * Gets the current list of color remap gradients.
  19319. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19320. * @returns the list of color remap gradients
  19321. */
  19322. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19323. /**
  19324. * Adds a new alpha remap gradient
  19325. * @param gradient defines the gradient to use (between 0 and 1)
  19326. * @param min defines the alpha remap minimal range
  19327. * @param max defines the alpha remap maximal range
  19328. * @returns the current particle system
  19329. */
  19330. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19331. /**
  19332. * Gets the current list of alpha remap gradients.
  19333. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19334. * @returns the list of alpha remap gradients
  19335. */
  19336. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19337. /**
  19338. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19341. * @returns the emitter
  19342. */
  19343. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19344. /**
  19345. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19346. * @param radius The radius of the hemisphere to emit from
  19347. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19348. * @returns the emitter
  19349. */
  19350. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19351. /**
  19352. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19353. * @param radius The radius of the sphere to emit from
  19354. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19355. * @returns the emitter
  19356. */
  19357. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19358. /**
  19359. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19360. * @param radius The radius of the sphere to emit from
  19361. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19362. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19363. * @returns the emitter
  19364. */
  19365. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19366. /**
  19367. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19368. * @param radius The radius of the emission cylinder
  19369. * @param height The height of the emission cylinder
  19370. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19371. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19372. * @returns the emitter
  19373. */
  19374. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19375. /**
  19376. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19377. * @param radius The radius of the cylinder to emit from
  19378. * @param height The height of the emission cylinder
  19379. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19380. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19381. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19382. * @returns the emitter
  19383. */
  19384. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19385. /**
  19386. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19387. * @param radius The radius of the cone to emit from
  19388. * @param angle The base angle of the cone
  19389. * @returns the emitter
  19390. */
  19391. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19392. /**
  19393. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19394. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19395. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19396. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19397. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19398. * @returns the emitter
  19399. */
  19400. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19401. /**
  19402. * Get hosting scene
  19403. * @returns the scene
  19404. */
  19405. getScene(): Scene;
  19406. }
  19407. }
  19408. declare module "babylonjs/Meshes/instancedMesh" {
  19409. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19410. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19411. import { Camera } from "babylonjs/Cameras/camera";
  19412. import { Node } from "babylonjs/node";
  19413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19414. import { Mesh } from "babylonjs/Meshes/mesh";
  19415. import { Material } from "babylonjs/Materials/material";
  19416. import { Skeleton } from "babylonjs/Bones/skeleton";
  19417. import { Light } from "babylonjs/Lights/light";
  19418. /**
  19419. * Creates an instance based on a source mesh.
  19420. */
  19421. export class InstancedMesh extends AbstractMesh {
  19422. private _sourceMesh;
  19423. private _currentLOD;
  19424. /** @hidden */
  19425. _indexInSourceMeshInstanceArray: number;
  19426. constructor(name: string, source: Mesh);
  19427. /**
  19428. * Returns the string "InstancedMesh".
  19429. */
  19430. getClassName(): string;
  19431. /** Gets the list of lights affecting that mesh */
  19432. readonly lightSources: Light[];
  19433. _resyncLightSources(): void;
  19434. _resyncLighSource(light: Light): void;
  19435. _removeLightSource(light: Light, dispose: boolean): void;
  19436. /**
  19437. * If the source mesh receives shadows
  19438. */
  19439. readonly receiveShadows: boolean;
  19440. /**
  19441. * The material of the source mesh
  19442. */
  19443. readonly material: Nullable<Material>;
  19444. /**
  19445. * Visibility of the source mesh
  19446. */
  19447. readonly visibility: number;
  19448. /**
  19449. * Skeleton of the source mesh
  19450. */
  19451. readonly skeleton: Nullable<Skeleton>;
  19452. /**
  19453. * Rendering ground id of the source mesh
  19454. */
  19455. renderingGroupId: number;
  19456. /**
  19457. * Returns the total number of vertices (integer).
  19458. */
  19459. getTotalVertices(): number;
  19460. /**
  19461. * Returns a positive integer : the total number of indices in this mesh geometry.
  19462. * @returns the numner of indices or zero if the mesh has no geometry.
  19463. */
  19464. getTotalIndices(): number;
  19465. /**
  19466. * The source mesh of the instance
  19467. */
  19468. readonly sourceMesh: Mesh;
  19469. /**
  19470. * Is this node ready to be used/rendered
  19471. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19472. * @return {boolean} is it ready
  19473. */
  19474. isReady(completeCheck?: boolean): boolean;
  19475. /**
  19476. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19477. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19478. * @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.
  19479. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19480. */
  19481. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19482. /**
  19483. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19484. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19485. * The `data` are either a numeric array either a Float32Array.
  19486. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19487. * 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).
  19488. * Note that a new underlying VertexBuffer object is created each call.
  19489. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19490. *
  19491. * Possible `kind` values :
  19492. * - VertexBuffer.PositionKind
  19493. * - VertexBuffer.UVKind
  19494. * - VertexBuffer.UV2Kind
  19495. * - VertexBuffer.UV3Kind
  19496. * - VertexBuffer.UV4Kind
  19497. * - VertexBuffer.UV5Kind
  19498. * - VertexBuffer.UV6Kind
  19499. * - VertexBuffer.ColorKind
  19500. * - VertexBuffer.MatricesIndicesKind
  19501. * - VertexBuffer.MatricesIndicesExtraKind
  19502. * - VertexBuffer.MatricesWeightsKind
  19503. * - VertexBuffer.MatricesWeightsExtraKind
  19504. *
  19505. * Returns the Mesh.
  19506. */
  19507. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19508. /**
  19509. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19510. * If the mesh has no geometry, it is simply returned as it is.
  19511. * The `data` are either a numeric array either a Float32Array.
  19512. * No new underlying VertexBuffer object is created.
  19513. * 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.
  19514. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19515. *
  19516. * Possible `kind` values :
  19517. * - VertexBuffer.PositionKind
  19518. * - VertexBuffer.UVKind
  19519. * - VertexBuffer.UV2Kind
  19520. * - VertexBuffer.UV3Kind
  19521. * - VertexBuffer.UV4Kind
  19522. * - VertexBuffer.UV5Kind
  19523. * - VertexBuffer.UV6Kind
  19524. * - VertexBuffer.ColorKind
  19525. * - VertexBuffer.MatricesIndicesKind
  19526. * - VertexBuffer.MatricesIndicesExtraKind
  19527. * - VertexBuffer.MatricesWeightsKind
  19528. * - VertexBuffer.MatricesWeightsExtraKind
  19529. *
  19530. * Returns the Mesh.
  19531. */
  19532. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19533. /**
  19534. * Sets the mesh indices.
  19535. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19536. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19537. * This method creates a new index buffer each call.
  19538. * Returns the Mesh.
  19539. */
  19540. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19541. /**
  19542. * Boolean : True if the mesh owns the requested kind of data.
  19543. */
  19544. isVerticesDataPresent(kind: string): boolean;
  19545. /**
  19546. * Returns an array of indices (IndicesArray).
  19547. */
  19548. getIndices(): Nullable<IndicesArray>;
  19549. readonly _positions: Nullable<Vector3[]>;
  19550. /**
  19551. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19552. * This means the mesh underlying bounding box and sphere are recomputed.
  19553. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19554. * @returns the current mesh
  19555. */
  19556. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19557. /** @hidden */
  19558. _preActivate(): InstancedMesh;
  19559. /** @hidden */
  19560. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19561. /** @hidden */
  19562. _postActivate(): void;
  19563. getWorldMatrix(): Matrix;
  19564. readonly isAnInstance: boolean;
  19565. /**
  19566. * Returns the current associated LOD AbstractMesh.
  19567. */
  19568. getLOD(camera: Camera): AbstractMesh;
  19569. /** @hidden */
  19570. _syncSubMeshes(): InstancedMesh;
  19571. /** @hidden */
  19572. _generatePointsArray(): boolean;
  19573. /**
  19574. * Creates a new InstancedMesh from the current mesh.
  19575. * - name (string) : the cloned mesh name
  19576. * - newParent (optional Node) : the optional Node to parent the clone to.
  19577. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19578. *
  19579. * Returns the clone.
  19580. */
  19581. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19582. /**
  19583. * Disposes the InstancedMesh.
  19584. * Returns nothing.
  19585. */
  19586. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19587. }
  19588. }
  19589. declare module "babylonjs/Materials/shaderMaterial" {
  19590. import { Scene } from "babylonjs/scene";
  19591. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19593. import { Mesh } from "babylonjs/Meshes/mesh";
  19594. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19595. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19596. import { Texture } from "babylonjs/Materials/Textures/texture";
  19597. import { Material } from "babylonjs/Materials/material";
  19598. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19599. /**
  19600. * Defines the options associated with the creation of a shader material.
  19601. */
  19602. export interface IShaderMaterialOptions {
  19603. /**
  19604. * Does the material work in alpha blend mode
  19605. */
  19606. needAlphaBlending: boolean;
  19607. /**
  19608. * Does the material work in alpha test mode
  19609. */
  19610. needAlphaTesting: boolean;
  19611. /**
  19612. * The list of attribute names used in the shader
  19613. */
  19614. attributes: string[];
  19615. /**
  19616. * The list of unifrom names used in the shader
  19617. */
  19618. uniforms: string[];
  19619. /**
  19620. * The list of UBO names used in the shader
  19621. */
  19622. uniformBuffers: string[];
  19623. /**
  19624. * The list of sampler names used in the shader
  19625. */
  19626. samplers: string[];
  19627. /**
  19628. * The list of defines used in the shader
  19629. */
  19630. defines: string[];
  19631. }
  19632. /**
  19633. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19634. *
  19635. * This returned material effects how the mesh will look based on the code in the shaders.
  19636. *
  19637. * @see http://doc.babylonjs.com/how_to/shader_material
  19638. */
  19639. export class ShaderMaterial extends Material {
  19640. private _shaderPath;
  19641. private _options;
  19642. private _textures;
  19643. private _textureArrays;
  19644. private _floats;
  19645. private _ints;
  19646. private _floatsArrays;
  19647. private _colors3;
  19648. private _colors3Arrays;
  19649. private _colors4;
  19650. private _colors4Arrays;
  19651. private _vectors2;
  19652. private _vectors3;
  19653. private _vectors4;
  19654. private _matrices;
  19655. private _matrices3x3;
  19656. private _matrices2x2;
  19657. private _vectors2Arrays;
  19658. private _vectors3Arrays;
  19659. private _vectors4Arrays;
  19660. private _cachedWorldViewMatrix;
  19661. private _cachedWorldViewProjectionMatrix;
  19662. private _renderId;
  19663. /**
  19664. * Instantiate a new shader material.
  19665. * 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.
  19666. * This returned material effects how the mesh will look based on the code in the shaders.
  19667. * @see http://doc.babylonjs.com/how_to/shader_material
  19668. * @param name Define the name of the material in the scene
  19669. * @param scene Define the scene the material belongs to
  19670. * @param shaderPath Defines the route to the shader code in one of three ways:
  19671. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19672. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19673. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19674. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19675. * @param options Define the options used to create the shader
  19676. */
  19677. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19678. /**
  19679. * Gets the options used to compile the shader.
  19680. * They can be modified to trigger a new compilation
  19681. */
  19682. readonly options: IShaderMaterialOptions;
  19683. /**
  19684. * Gets the current class name of the material e.g. "ShaderMaterial"
  19685. * Mainly use in serialization.
  19686. * @returns the class name
  19687. */
  19688. getClassName(): string;
  19689. /**
  19690. * Specifies if the material will require alpha blending
  19691. * @returns a boolean specifying if alpha blending is needed
  19692. */
  19693. needAlphaBlending(): boolean;
  19694. /**
  19695. * Specifies if this material should be rendered in alpha test mode
  19696. * @returns a boolean specifying if an alpha test is needed.
  19697. */
  19698. needAlphaTesting(): boolean;
  19699. private _checkUniform;
  19700. /**
  19701. * Set a texture in the shader.
  19702. * @param name Define the name of the uniform samplers as defined in the shader
  19703. * @param texture Define the texture to bind to this sampler
  19704. * @return the material itself allowing "fluent" like uniform updates
  19705. */
  19706. setTexture(name: string, texture: Texture): ShaderMaterial;
  19707. /**
  19708. * Set a texture array in the shader.
  19709. * @param name Define the name of the uniform sampler array as defined in the shader
  19710. * @param textures Define the list of textures to bind to this sampler
  19711. * @return the material itself allowing "fluent" like uniform updates
  19712. */
  19713. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19714. /**
  19715. * Set a float in the shader.
  19716. * @param name Define the name of the uniform as defined in the shader
  19717. * @param value Define the value to give to the uniform
  19718. * @return the material itself allowing "fluent" like uniform updates
  19719. */
  19720. setFloat(name: string, value: number): ShaderMaterial;
  19721. /**
  19722. * Set a int in the shader.
  19723. * @param name Define the name of the uniform as defined in the shader
  19724. * @param value Define the value to give to the uniform
  19725. * @return the material itself allowing "fluent" like uniform updates
  19726. */
  19727. setInt(name: string, value: number): ShaderMaterial;
  19728. /**
  19729. * Set an array of floats in the shader.
  19730. * @param name Define the name of the uniform as defined in the shader
  19731. * @param value Define the value to give to the uniform
  19732. * @return the material itself allowing "fluent" like uniform updates
  19733. */
  19734. setFloats(name: string, value: number[]): ShaderMaterial;
  19735. /**
  19736. * Set a vec3 in the shader from a Color3.
  19737. * @param name Define the name of the uniform as defined in the shader
  19738. * @param value Define the value to give to the uniform
  19739. * @return the material itself allowing "fluent" like uniform updates
  19740. */
  19741. setColor3(name: string, value: Color3): ShaderMaterial;
  19742. /**
  19743. * Set a vec3 array in the shader from a Color3 array.
  19744. * @param name Define the name of the uniform as defined in the shader
  19745. * @param value Define the value to give to the uniform
  19746. * @return the material itself allowing "fluent" like uniform updates
  19747. */
  19748. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19749. /**
  19750. * Set a vec4 in the shader from a Color4.
  19751. * @param name Define the name of the uniform as defined in the shader
  19752. * @param value Define the value to give to the uniform
  19753. * @return the material itself allowing "fluent" like uniform updates
  19754. */
  19755. setColor4(name: string, value: Color4): ShaderMaterial;
  19756. /**
  19757. * Set a vec4 array in the shader from a Color4 array.
  19758. * @param name Define the name of the uniform as defined in the shader
  19759. * @param value Define the value to give to the uniform
  19760. * @return the material itself allowing "fluent" like uniform updates
  19761. */
  19762. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19763. /**
  19764. * Set a vec2 in the shader from a Vector2.
  19765. * @param name Define the name of the uniform as defined in the shader
  19766. * @param value Define the value to give to the uniform
  19767. * @return the material itself allowing "fluent" like uniform updates
  19768. */
  19769. setVector2(name: string, value: Vector2): ShaderMaterial;
  19770. /**
  19771. * Set a vec3 in the shader from a Vector3.
  19772. * @param name Define the name of the uniform as defined in the shader
  19773. * @param value Define the value to give to the uniform
  19774. * @return the material itself allowing "fluent" like uniform updates
  19775. */
  19776. setVector3(name: string, value: Vector3): ShaderMaterial;
  19777. /**
  19778. * Set a vec4 in the shader from a Vector4.
  19779. * @param name Define the name of the uniform as defined in the shader
  19780. * @param value Define the value to give to the uniform
  19781. * @return the material itself allowing "fluent" like uniform updates
  19782. */
  19783. setVector4(name: string, value: Vector4): ShaderMaterial;
  19784. /**
  19785. * Set a mat4 in the shader from a Matrix.
  19786. * @param name Define the name of the uniform as defined in the shader
  19787. * @param value Define the value to give to the uniform
  19788. * @return the material itself allowing "fluent" like uniform updates
  19789. */
  19790. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19791. /**
  19792. * Set a mat3 in the shader from a Float32Array.
  19793. * @param name Define the name of the uniform as defined in the shader
  19794. * @param value Define the value to give to the uniform
  19795. * @return the material itself allowing "fluent" like uniform updates
  19796. */
  19797. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19798. /**
  19799. * Set a mat2 in the shader from a Float32Array.
  19800. * @param name Define the name of the uniform as defined in the shader
  19801. * @param value Define the value to give to the uniform
  19802. * @return the material itself allowing "fluent" like uniform updates
  19803. */
  19804. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19805. /**
  19806. * Set a vec2 array in the shader from a number array.
  19807. * @param name Define the name of the uniform as defined in the shader
  19808. * @param value Define the value to give to the uniform
  19809. * @return the material itself allowing "fluent" like uniform updates
  19810. */
  19811. setArray2(name: string, value: number[]): ShaderMaterial;
  19812. /**
  19813. * Set a vec3 array in the shader from a number array.
  19814. * @param name Define the name of the uniform as defined in the shader
  19815. * @param value Define the value to give to the uniform
  19816. * @return the material itself allowing "fluent" like uniform updates
  19817. */
  19818. setArray3(name: string, value: number[]): ShaderMaterial;
  19819. /**
  19820. * Set a vec4 array in the shader from a number array.
  19821. * @param name Define the name of the uniform as defined in the shader
  19822. * @param value Define the value to give to the uniform
  19823. * @return the material itself allowing "fluent" like uniform updates
  19824. */
  19825. setArray4(name: string, value: number[]): ShaderMaterial;
  19826. private _checkCache;
  19827. /**
  19828. * Specifies that the submesh is ready to be used
  19829. * @param mesh defines the mesh to check
  19830. * @param subMesh defines which submesh to check
  19831. * @param useInstances specifies that instances should be used
  19832. * @returns a boolean indicating that the submesh is ready or not
  19833. */
  19834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19835. /**
  19836. * Checks if the material is ready to render the requested mesh
  19837. * @param mesh Define the mesh to render
  19838. * @param useInstances Define whether or not the material is used with instances
  19839. * @returns true if ready, otherwise false
  19840. */
  19841. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19842. /**
  19843. * Binds the world matrix to the material
  19844. * @param world defines the world transformation matrix
  19845. */
  19846. bindOnlyWorldMatrix(world: Matrix): void;
  19847. /**
  19848. * Binds the material to the mesh
  19849. * @param world defines the world transformation matrix
  19850. * @param mesh defines the mesh to bind the material to
  19851. */
  19852. bind(world: Matrix, mesh?: Mesh): void;
  19853. /**
  19854. * Gets the active textures from the material
  19855. * @returns an array of textures
  19856. */
  19857. getActiveTextures(): BaseTexture[];
  19858. /**
  19859. * Specifies if the material uses a texture
  19860. * @param texture defines the texture to check against the material
  19861. * @returns a boolean specifying if the material uses the texture
  19862. */
  19863. hasTexture(texture: BaseTexture): boolean;
  19864. /**
  19865. * Makes a duplicate of the material, and gives it a new name
  19866. * @param name defines the new name for the duplicated material
  19867. * @returns the cloned material
  19868. */
  19869. clone(name: string): ShaderMaterial;
  19870. /**
  19871. * Disposes the material
  19872. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19873. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19874. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19875. */
  19876. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19877. /**
  19878. * Serializes this material in a JSON representation
  19879. * @returns the serialized material object
  19880. */
  19881. serialize(): any;
  19882. /**
  19883. * Creates a shader material from parsed shader material data
  19884. * @param source defines the JSON represnetation of the material
  19885. * @param scene defines the hosting scene
  19886. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19887. * @returns a new material
  19888. */
  19889. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19890. }
  19891. }
  19892. declare module "babylonjs/Shaders/color.fragment" {
  19893. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19894. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19895. /** @hidden */
  19896. export var colorPixelShader: {
  19897. name: string;
  19898. shader: string;
  19899. };
  19900. }
  19901. declare module "babylonjs/Shaders/color.vertex" {
  19902. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19903. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19904. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19905. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19906. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19907. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19908. /** @hidden */
  19909. export var colorVertexShader: {
  19910. name: string;
  19911. shader: string;
  19912. };
  19913. }
  19914. declare module "babylonjs/Meshes/linesMesh" {
  19915. import { Nullable } from "babylonjs/types";
  19916. import { Scene } from "babylonjs/scene";
  19917. import { Color3 } from "babylonjs/Maths/math.color";
  19918. import { Node } from "babylonjs/node";
  19919. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19920. import { Mesh } from "babylonjs/Meshes/mesh";
  19921. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19922. import { Effect } from "babylonjs/Materials/effect";
  19923. import { Material } from "babylonjs/Materials/material";
  19924. import "babylonjs/Shaders/color.fragment";
  19925. import "babylonjs/Shaders/color.vertex";
  19926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19927. /**
  19928. * Line mesh
  19929. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19930. */
  19931. export class LinesMesh extends Mesh {
  19932. /**
  19933. * If vertex color should be applied to the mesh
  19934. */
  19935. readonly useVertexColor?: boolean | undefined;
  19936. /**
  19937. * If vertex alpha should be applied to the mesh
  19938. */
  19939. readonly useVertexAlpha?: boolean | undefined;
  19940. /**
  19941. * Color of the line (Default: White)
  19942. */
  19943. color: Color3;
  19944. /**
  19945. * Alpha of the line (Default: 1)
  19946. */
  19947. alpha: number;
  19948. /**
  19949. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19950. * This margin is expressed in world space coordinates, so its value may vary.
  19951. * Default value is 0.1
  19952. */
  19953. intersectionThreshold: number;
  19954. private _colorShader;
  19955. private color4;
  19956. /**
  19957. * Creates a new LinesMesh
  19958. * @param name defines the name
  19959. * @param scene defines the hosting scene
  19960. * @param parent defines the parent mesh if any
  19961. * @param source defines the optional source LinesMesh used to clone data from
  19962. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19963. * When false, achieved by calling a clone(), also passing False.
  19964. * This will make creation of children, recursive.
  19965. * @param useVertexColor defines if this LinesMesh supports vertex color
  19966. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19967. */
  19968. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19969. /**
  19970. * If vertex color should be applied to the mesh
  19971. */
  19972. useVertexColor?: boolean | undefined,
  19973. /**
  19974. * If vertex alpha should be applied to the mesh
  19975. */
  19976. useVertexAlpha?: boolean | undefined);
  19977. private _addClipPlaneDefine;
  19978. private _removeClipPlaneDefine;
  19979. isReady(): boolean;
  19980. /**
  19981. * Returns the string "LineMesh"
  19982. */
  19983. getClassName(): string;
  19984. /**
  19985. * @hidden
  19986. */
  19987. /**
  19988. * @hidden
  19989. */
  19990. material: Material;
  19991. /**
  19992. * @hidden
  19993. */
  19994. readonly checkCollisions: boolean;
  19995. /** @hidden */
  19996. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19997. /** @hidden */
  19998. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19999. /**
  20000. * Disposes of the line mesh
  20001. * @param doNotRecurse If children should be disposed
  20002. */
  20003. dispose(doNotRecurse?: boolean): void;
  20004. /**
  20005. * Returns a new LineMesh object cloned from the current one.
  20006. */
  20007. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20008. /**
  20009. * Creates a new InstancedLinesMesh object from the mesh model.
  20010. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20011. * @param name defines the name of the new instance
  20012. * @returns a new InstancedLinesMesh
  20013. */
  20014. createInstance(name: string): InstancedLinesMesh;
  20015. }
  20016. /**
  20017. * Creates an instance based on a source LinesMesh
  20018. */
  20019. export class InstancedLinesMesh extends InstancedMesh {
  20020. /**
  20021. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20022. * This margin is expressed in world space coordinates, so its value may vary.
  20023. * Initilized with the intersectionThreshold value of the source LinesMesh
  20024. */
  20025. intersectionThreshold: number;
  20026. constructor(name: string, source: LinesMesh);
  20027. /**
  20028. * Returns the string "InstancedLinesMesh".
  20029. */
  20030. getClassName(): string;
  20031. }
  20032. }
  20033. declare module "babylonjs/Shaders/line.fragment" {
  20034. /** @hidden */
  20035. export var linePixelShader: {
  20036. name: string;
  20037. shader: string;
  20038. };
  20039. }
  20040. declare module "babylonjs/Shaders/line.vertex" {
  20041. /** @hidden */
  20042. export var lineVertexShader: {
  20043. name: string;
  20044. shader: string;
  20045. };
  20046. }
  20047. declare module "babylonjs/Rendering/edgesRenderer" {
  20048. import { Nullable } from "babylonjs/types";
  20049. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20051. import { Vector3 } from "babylonjs/Maths/math.vector";
  20052. import { IDisposable } from "babylonjs/scene";
  20053. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20054. import "babylonjs/Shaders/line.fragment";
  20055. import "babylonjs/Shaders/line.vertex";
  20056. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20057. module "babylonjs/Meshes/abstractMesh" {
  20058. interface AbstractMesh {
  20059. /**
  20060. * Gets the edgesRenderer associated with the mesh
  20061. */
  20062. edgesRenderer: Nullable<EdgesRenderer>;
  20063. }
  20064. }
  20065. module "babylonjs/Meshes/linesMesh" {
  20066. interface LinesMesh {
  20067. /**
  20068. * Enables the edge rendering mode on the mesh.
  20069. * This mode makes the mesh edges visible
  20070. * @param epsilon defines the maximal distance between two angles to detect a face
  20071. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20072. * @returns the currentAbstractMesh
  20073. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20074. */
  20075. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20076. }
  20077. }
  20078. module "babylonjs/Meshes/linesMesh" {
  20079. interface InstancedLinesMesh {
  20080. /**
  20081. * Enables the edge rendering mode on the mesh.
  20082. * This mode makes the mesh edges visible
  20083. * @param epsilon defines the maximal distance between two angles to detect a face
  20084. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20085. * @returns the current InstancedLinesMesh
  20086. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20087. */
  20088. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20089. }
  20090. }
  20091. /**
  20092. * Defines the minimum contract an Edges renderer should follow.
  20093. */
  20094. export interface IEdgesRenderer extends IDisposable {
  20095. /**
  20096. * Gets or sets a boolean indicating if the edgesRenderer is active
  20097. */
  20098. isEnabled: boolean;
  20099. /**
  20100. * Renders the edges of the attached mesh,
  20101. */
  20102. render(): void;
  20103. /**
  20104. * Checks wether or not the edges renderer is ready to render.
  20105. * @return true if ready, otherwise false.
  20106. */
  20107. isReady(): boolean;
  20108. }
  20109. /**
  20110. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20111. */
  20112. export class EdgesRenderer implements IEdgesRenderer {
  20113. /**
  20114. * Define the size of the edges with an orthographic camera
  20115. */
  20116. edgesWidthScalerForOrthographic: number;
  20117. /**
  20118. * Define the size of the edges with a perspective camera
  20119. */
  20120. edgesWidthScalerForPerspective: number;
  20121. protected _source: AbstractMesh;
  20122. protected _linesPositions: number[];
  20123. protected _linesNormals: number[];
  20124. protected _linesIndices: number[];
  20125. protected _epsilon: number;
  20126. protected _indicesCount: number;
  20127. protected _lineShader: ShaderMaterial;
  20128. protected _ib: DataBuffer;
  20129. protected _buffers: {
  20130. [key: string]: Nullable<VertexBuffer>;
  20131. };
  20132. protected _checkVerticesInsteadOfIndices: boolean;
  20133. private _meshRebuildObserver;
  20134. private _meshDisposeObserver;
  20135. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20136. isEnabled: boolean;
  20137. /**
  20138. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20139. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20140. * @param source Mesh used to create edges
  20141. * @param epsilon sum of angles in adjacency to check for edge
  20142. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20143. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20144. */
  20145. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20146. protected _prepareRessources(): void;
  20147. /** @hidden */
  20148. _rebuild(): void;
  20149. /**
  20150. * Releases the required resources for the edges renderer
  20151. */
  20152. dispose(): void;
  20153. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20154. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20155. /**
  20156. * Checks if the pair of p0 and p1 is en edge
  20157. * @param faceIndex
  20158. * @param edge
  20159. * @param faceNormals
  20160. * @param p0
  20161. * @param p1
  20162. * @private
  20163. */
  20164. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20165. /**
  20166. * push line into the position, normal and index buffer
  20167. * @protected
  20168. */
  20169. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20170. /**
  20171. * Generates lines edges from adjacencjes
  20172. * @private
  20173. */
  20174. _generateEdgesLines(): void;
  20175. /**
  20176. * Checks wether or not the edges renderer is ready to render.
  20177. * @return true if ready, otherwise false.
  20178. */
  20179. isReady(): boolean;
  20180. /**
  20181. * Renders the edges of the attached mesh,
  20182. */
  20183. render(): void;
  20184. }
  20185. /**
  20186. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20187. */
  20188. export class LineEdgesRenderer extends EdgesRenderer {
  20189. /**
  20190. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20191. * @param source LineMesh used to generate edges
  20192. * @param epsilon not important (specified angle for edge detection)
  20193. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20194. */
  20195. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20196. /**
  20197. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20198. */
  20199. _generateEdgesLines(): void;
  20200. }
  20201. }
  20202. declare module "babylonjs/Rendering/renderingGroup" {
  20203. import { SmartArray } from "babylonjs/Misc/smartArray";
  20204. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20206. import { Nullable } from "babylonjs/types";
  20207. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20208. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20209. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20210. import { Material } from "babylonjs/Materials/material";
  20211. import { Scene } from "babylonjs/scene";
  20212. /**
  20213. * This represents the object necessary to create a rendering group.
  20214. * This is exclusively used and created by the rendering manager.
  20215. * To modify the behavior, you use the available helpers in your scene or meshes.
  20216. * @hidden
  20217. */
  20218. export class RenderingGroup {
  20219. index: number;
  20220. private static _zeroVector;
  20221. private _scene;
  20222. private _opaqueSubMeshes;
  20223. private _transparentSubMeshes;
  20224. private _alphaTestSubMeshes;
  20225. private _depthOnlySubMeshes;
  20226. private _particleSystems;
  20227. private _spriteManagers;
  20228. private _opaqueSortCompareFn;
  20229. private _alphaTestSortCompareFn;
  20230. private _transparentSortCompareFn;
  20231. private _renderOpaque;
  20232. private _renderAlphaTest;
  20233. private _renderTransparent;
  20234. /** @hidden */
  20235. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20236. onBeforeTransparentRendering: () => void;
  20237. /**
  20238. * Set the opaque sort comparison function.
  20239. * If null the sub meshes will be render in the order they were created
  20240. */
  20241. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20242. /**
  20243. * Set the alpha test sort comparison function.
  20244. * If null the sub meshes will be render in the order they were created
  20245. */
  20246. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20247. /**
  20248. * Set the transparent sort comparison function.
  20249. * If null the sub meshes will be render in the order they were created
  20250. */
  20251. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20252. /**
  20253. * Creates a new rendering group.
  20254. * @param index The rendering group index
  20255. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20256. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20257. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20258. */
  20259. 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>);
  20260. /**
  20261. * Render all the sub meshes contained in the group.
  20262. * @param customRenderFunction Used to override the default render behaviour of the group.
  20263. * @returns true if rendered some submeshes.
  20264. */
  20265. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20266. /**
  20267. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20268. * @param subMeshes The submeshes to render
  20269. */
  20270. private renderOpaqueSorted;
  20271. /**
  20272. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20273. * @param subMeshes The submeshes to render
  20274. */
  20275. private renderAlphaTestSorted;
  20276. /**
  20277. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20278. * @param subMeshes The submeshes to render
  20279. */
  20280. private renderTransparentSorted;
  20281. /**
  20282. * Renders the submeshes in a specified order.
  20283. * @param subMeshes The submeshes to sort before render
  20284. * @param sortCompareFn The comparison function use to sort
  20285. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20286. * @param transparent Specifies to activate blending if true
  20287. */
  20288. private static renderSorted;
  20289. /**
  20290. * Renders the submeshes in the order they were dispatched (no sort applied).
  20291. * @param subMeshes The submeshes to render
  20292. */
  20293. private static renderUnsorted;
  20294. /**
  20295. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20296. * are rendered back to front if in the same alpha index.
  20297. *
  20298. * @param a The first submesh
  20299. * @param b The second submesh
  20300. * @returns The result of the comparison
  20301. */
  20302. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20303. /**
  20304. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20305. * are rendered back to front.
  20306. *
  20307. * @param a The first submesh
  20308. * @param b The second submesh
  20309. * @returns The result of the comparison
  20310. */
  20311. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20312. /**
  20313. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20314. * are rendered front to back (prevent overdraw).
  20315. *
  20316. * @param a The first submesh
  20317. * @param b The second submesh
  20318. * @returns The result of the comparison
  20319. */
  20320. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20321. /**
  20322. * Resets the different lists of submeshes to prepare a new frame.
  20323. */
  20324. prepare(): void;
  20325. dispose(): void;
  20326. /**
  20327. * Inserts the submesh in its correct queue depending on its material.
  20328. * @param subMesh The submesh to dispatch
  20329. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20330. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20331. */
  20332. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20333. dispatchSprites(spriteManager: ISpriteManager): void;
  20334. dispatchParticles(particleSystem: IParticleSystem): void;
  20335. private _renderParticles;
  20336. private _renderSprites;
  20337. }
  20338. }
  20339. declare module "babylonjs/Rendering/renderingManager" {
  20340. import { Nullable } from "babylonjs/types";
  20341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20343. import { SmartArray } from "babylonjs/Misc/smartArray";
  20344. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20345. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20346. import { Material } from "babylonjs/Materials/material";
  20347. import { Scene } from "babylonjs/scene";
  20348. import { Camera } from "babylonjs/Cameras/camera";
  20349. /**
  20350. * Interface describing the different options available in the rendering manager
  20351. * regarding Auto Clear between groups.
  20352. */
  20353. export interface IRenderingManagerAutoClearSetup {
  20354. /**
  20355. * Defines whether or not autoclear is enable.
  20356. */
  20357. autoClear: boolean;
  20358. /**
  20359. * Defines whether or not to autoclear the depth buffer.
  20360. */
  20361. depth: boolean;
  20362. /**
  20363. * Defines whether or not to autoclear the stencil buffer.
  20364. */
  20365. stencil: boolean;
  20366. }
  20367. /**
  20368. * This class is used by the onRenderingGroupObservable
  20369. */
  20370. export class RenderingGroupInfo {
  20371. /**
  20372. * The Scene that being rendered
  20373. */
  20374. scene: Scene;
  20375. /**
  20376. * The camera currently used for the rendering pass
  20377. */
  20378. camera: Nullable<Camera>;
  20379. /**
  20380. * The ID of the renderingGroup being processed
  20381. */
  20382. renderingGroupId: number;
  20383. }
  20384. /**
  20385. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20386. * It is enable to manage the different groups as well as the different necessary sort functions.
  20387. * This should not be used directly aside of the few static configurations
  20388. */
  20389. export class RenderingManager {
  20390. /**
  20391. * The max id used for rendering groups (not included)
  20392. */
  20393. static MAX_RENDERINGGROUPS: number;
  20394. /**
  20395. * The min id used for rendering groups (included)
  20396. */
  20397. static MIN_RENDERINGGROUPS: number;
  20398. /**
  20399. * Used to globally prevent autoclearing scenes.
  20400. */
  20401. static AUTOCLEAR: boolean;
  20402. /**
  20403. * @hidden
  20404. */
  20405. _useSceneAutoClearSetup: boolean;
  20406. private _scene;
  20407. private _renderingGroups;
  20408. private _depthStencilBufferAlreadyCleaned;
  20409. private _autoClearDepthStencil;
  20410. private _customOpaqueSortCompareFn;
  20411. private _customAlphaTestSortCompareFn;
  20412. private _customTransparentSortCompareFn;
  20413. private _renderingGroupInfo;
  20414. /**
  20415. * Instantiates a new rendering group for a particular scene
  20416. * @param scene Defines the scene the groups belongs to
  20417. */
  20418. constructor(scene: Scene);
  20419. private _clearDepthStencilBuffer;
  20420. /**
  20421. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20422. * @hidden
  20423. */
  20424. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20425. /**
  20426. * Resets the different information of the group to prepare a new frame
  20427. * @hidden
  20428. */
  20429. reset(): void;
  20430. /**
  20431. * Dispose and release the group and its associated resources.
  20432. * @hidden
  20433. */
  20434. dispose(): void;
  20435. /**
  20436. * Clear the info related to rendering groups preventing retention points during dispose.
  20437. */
  20438. freeRenderingGroups(): void;
  20439. private _prepareRenderingGroup;
  20440. /**
  20441. * Add a sprite manager to the rendering manager in order to render it this frame.
  20442. * @param spriteManager Define the sprite manager to render
  20443. */
  20444. dispatchSprites(spriteManager: ISpriteManager): void;
  20445. /**
  20446. * Add a particle system to the rendering manager in order to render it this frame.
  20447. * @param particleSystem Define the particle system to render
  20448. */
  20449. dispatchParticles(particleSystem: IParticleSystem): void;
  20450. /**
  20451. * Add a submesh to the manager in order to render it this frame
  20452. * @param subMesh The submesh to dispatch
  20453. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20454. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20455. */
  20456. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20457. /**
  20458. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20459. * This allowed control for front to back rendering or reversly depending of the special needs.
  20460. *
  20461. * @param renderingGroupId The rendering group id corresponding to its index
  20462. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20463. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20464. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20465. */
  20466. 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;
  20467. /**
  20468. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20469. *
  20470. * @param renderingGroupId The rendering group id corresponding to its index
  20471. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20472. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20473. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20474. */
  20475. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20476. /**
  20477. * Gets the current auto clear configuration for one rendering group of the rendering
  20478. * manager.
  20479. * @param index the rendering group index to get the information for
  20480. * @returns The auto clear setup for the requested rendering group
  20481. */
  20482. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20483. }
  20484. }
  20485. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20486. import { Observable } from "babylonjs/Misc/observable";
  20487. import { SmartArray } from "babylonjs/Misc/smartArray";
  20488. import { Nullable } from "babylonjs/types";
  20489. import { Camera } from "babylonjs/Cameras/camera";
  20490. import { Scene } from "babylonjs/scene";
  20491. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20492. import { Color4 } from "babylonjs/Maths/math.color";
  20493. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20495. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20497. import { Texture } from "babylonjs/Materials/Textures/texture";
  20498. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20499. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20500. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20501. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20502. import { Engine } from "babylonjs/Engines/engine";
  20503. /**
  20504. * This Helps creating a texture that will be created from a camera in your scene.
  20505. * It is basically a dynamic texture that could be used to create special effects for instance.
  20506. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20507. */
  20508. export class RenderTargetTexture extends Texture {
  20509. isCube: boolean;
  20510. /**
  20511. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20512. */
  20513. static readonly REFRESHRATE_RENDER_ONCE: number;
  20514. /**
  20515. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20516. */
  20517. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20518. /**
  20519. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20520. * the central point of your effect and can save a lot of performances.
  20521. */
  20522. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20523. /**
  20524. * Use this predicate to dynamically define the list of mesh you want to render.
  20525. * If set, the renderList property will be overwritten.
  20526. */
  20527. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20528. private _renderList;
  20529. /**
  20530. * Use this list to define the list of mesh you want to render.
  20531. */
  20532. renderList: Nullable<Array<AbstractMesh>>;
  20533. private _hookArray;
  20534. /**
  20535. * Define if particles should be rendered in your texture.
  20536. */
  20537. renderParticles: boolean;
  20538. /**
  20539. * Define if sprites should be rendered in your texture.
  20540. */
  20541. renderSprites: boolean;
  20542. /**
  20543. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20544. */
  20545. coordinatesMode: number;
  20546. /**
  20547. * Define the camera used to render the texture.
  20548. */
  20549. activeCamera: Nullable<Camera>;
  20550. /**
  20551. * Override the render function of the texture with your own one.
  20552. */
  20553. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20554. /**
  20555. * Define if camera post processes should be use while rendering the texture.
  20556. */
  20557. useCameraPostProcesses: boolean;
  20558. /**
  20559. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20560. */
  20561. ignoreCameraViewport: boolean;
  20562. private _postProcessManager;
  20563. private _postProcesses;
  20564. private _resizeObserver;
  20565. /**
  20566. * An event triggered when the texture is unbind.
  20567. */
  20568. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20569. /**
  20570. * An event triggered when the texture is unbind.
  20571. */
  20572. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20573. private _onAfterUnbindObserver;
  20574. /**
  20575. * Set a after unbind callback in the texture.
  20576. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20577. */
  20578. onAfterUnbind: () => void;
  20579. /**
  20580. * An event triggered before rendering the texture
  20581. */
  20582. onBeforeRenderObservable: Observable<number>;
  20583. private _onBeforeRenderObserver;
  20584. /**
  20585. * Set a before render callback in the texture.
  20586. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20587. */
  20588. onBeforeRender: (faceIndex: number) => void;
  20589. /**
  20590. * An event triggered after rendering the texture
  20591. */
  20592. onAfterRenderObservable: Observable<number>;
  20593. private _onAfterRenderObserver;
  20594. /**
  20595. * Set a after render callback in the texture.
  20596. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20597. */
  20598. onAfterRender: (faceIndex: number) => void;
  20599. /**
  20600. * An event triggered after the texture clear
  20601. */
  20602. onClearObservable: Observable<Engine>;
  20603. private _onClearObserver;
  20604. /**
  20605. * Set a clear callback in the texture.
  20606. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20607. */
  20608. onClear: (Engine: Engine) => void;
  20609. /**
  20610. * An event triggered when the texture is resized.
  20611. */
  20612. onResizeObservable: Observable<RenderTargetTexture>;
  20613. /**
  20614. * Define the clear color of the Render Target if it should be different from the scene.
  20615. */
  20616. clearColor: Color4;
  20617. protected _size: number | {
  20618. width: number;
  20619. height: number;
  20620. };
  20621. protected _initialSizeParameter: number | {
  20622. width: number;
  20623. height: number;
  20624. } | {
  20625. ratio: number;
  20626. };
  20627. protected _sizeRatio: Nullable<number>;
  20628. /** @hidden */
  20629. _generateMipMaps: boolean;
  20630. protected _renderingManager: RenderingManager;
  20631. /** @hidden */
  20632. _waitingRenderList: string[];
  20633. protected _doNotChangeAspectRatio: boolean;
  20634. protected _currentRefreshId: number;
  20635. protected _refreshRate: number;
  20636. protected _textureMatrix: Matrix;
  20637. protected _samples: number;
  20638. protected _renderTargetOptions: RenderTargetCreationOptions;
  20639. /**
  20640. * Gets render target creation options that were used.
  20641. */
  20642. readonly renderTargetOptions: RenderTargetCreationOptions;
  20643. protected _engine: Engine;
  20644. protected _onRatioRescale(): void;
  20645. /**
  20646. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20647. * It must define where the camera used to render the texture is set
  20648. */
  20649. boundingBoxPosition: Vector3;
  20650. private _boundingBoxSize;
  20651. /**
  20652. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20653. * When defined, the cubemap will switch to local mode
  20654. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20655. * @example https://www.babylonjs-playground.com/#RNASML
  20656. */
  20657. boundingBoxSize: Vector3;
  20658. /**
  20659. * In case the RTT has been created with a depth texture, get the associated
  20660. * depth texture.
  20661. * Otherwise, return null.
  20662. */
  20663. depthStencilTexture: Nullable<InternalTexture>;
  20664. /**
  20665. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20666. * or used a shadow, depth texture...
  20667. * @param name The friendly name of the texture
  20668. * @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)
  20669. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20670. * @param generateMipMaps True if mip maps need to be generated after render.
  20671. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20672. * @param type The type of the buffer in the RTT (int, half float, float...)
  20673. * @param isCube True if a cube texture needs to be created
  20674. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20675. * @param generateDepthBuffer True to generate a depth buffer
  20676. * @param generateStencilBuffer True to generate a stencil buffer
  20677. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20678. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20679. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20680. */
  20681. constructor(name: string, size: number | {
  20682. width: number;
  20683. height: number;
  20684. } | {
  20685. ratio: number;
  20686. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20687. /**
  20688. * Creates a depth stencil texture.
  20689. * This is only available in WebGL 2 or with the depth texture extension available.
  20690. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20691. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20692. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20693. */
  20694. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20695. private _processSizeParameter;
  20696. /**
  20697. * Define the number of samples to use in case of MSAA.
  20698. * It defaults to one meaning no MSAA has been enabled.
  20699. */
  20700. samples: number;
  20701. /**
  20702. * Resets the refresh counter of the texture and start bak from scratch.
  20703. * Could be useful to regenerate the texture if it is setup to render only once.
  20704. */
  20705. resetRefreshCounter(): void;
  20706. /**
  20707. * Define the refresh rate of the texture or the rendering frequency.
  20708. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20709. */
  20710. refreshRate: number;
  20711. /**
  20712. * Adds a post process to the render target rendering passes.
  20713. * @param postProcess define the post process to add
  20714. */
  20715. addPostProcess(postProcess: PostProcess): void;
  20716. /**
  20717. * Clear all the post processes attached to the render target
  20718. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20719. */
  20720. clearPostProcesses(dispose?: boolean): void;
  20721. /**
  20722. * Remove one of the post process from the list of attached post processes to the texture
  20723. * @param postProcess define the post process to remove from the list
  20724. */
  20725. removePostProcess(postProcess: PostProcess): void;
  20726. /** @hidden */
  20727. _shouldRender(): boolean;
  20728. /**
  20729. * Gets the actual render size of the texture.
  20730. * @returns the width of the render size
  20731. */
  20732. getRenderSize(): number;
  20733. /**
  20734. * Gets the actual render width of the texture.
  20735. * @returns the width of the render size
  20736. */
  20737. getRenderWidth(): number;
  20738. /**
  20739. * Gets the actual render height of the texture.
  20740. * @returns the height of the render size
  20741. */
  20742. getRenderHeight(): number;
  20743. /**
  20744. * Get if the texture can be rescaled or not.
  20745. */
  20746. readonly canRescale: boolean;
  20747. /**
  20748. * Resize the texture using a ratio.
  20749. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20750. */
  20751. scale(ratio: number): void;
  20752. /**
  20753. * Get the texture reflection matrix used to rotate/transform the reflection.
  20754. * @returns the reflection matrix
  20755. */
  20756. getReflectionTextureMatrix(): Matrix;
  20757. /**
  20758. * Resize the texture to a new desired size.
  20759. * Be carrefull as it will recreate all the data in the new texture.
  20760. * @param size Define the new size. It can be:
  20761. * - a number for squared texture,
  20762. * - an object containing { width: number, height: number }
  20763. * - or an object containing a ratio { ratio: number }
  20764. */
  20765. resize(size: number | {
  20766. width: number;
  20767. height: number;
  20768. } | {
  20769. ratio: number;
  20770. }): void;
  20771. /**
  20772. * Renders all the objects from the render list into the texture.
  20773. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20774. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20775. */
  20776. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20777. private _bestReflectionRenderTargetDimension;
  20778. /**
  20779. * @hidden
  20780. * @param faceIndex face index to bind to if this is a cubetexture
  20781. */
  20782. _bindFrameBuffer(faceIndex?: number): void;
  20783. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20784. private renderToTarget;
  20785. /**
  20786. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20787. * This allowed control for front to back rendering or reversly depending of the special needs.
  20788. *
  20789. * @param renderingGroupId The rendering group id corresponding to its index
  20790. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20791. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20792. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20793. */
  20794. 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;
  20795. /**
  20796. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20797. *
  20798. * @param renderingGroupId The rendering group id corresponding to its index
  20799. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20800. */
  20801. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20802. /**
  20803. * Clones the texture.
  20804. * @returns the cloned texture
  20805. */
  20806. clone(): RenderTargetTexture;
  20807. /**
  20808. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20809. * @returns The JSON representation of the texture
  20810. */
  20811. serialize(): any;
  20812. /**
  20813. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20814. */
  20815. disposeFramebufferObjects(): void;
  20816. /**
  20817. * Dispose the texture and release its associated resources.
  20818. */
  20819. dispose(): void;
  20820. /** @hidden */
  20821. _rebuild(): void;
  20822. /**
  20823. * Clear the info related to rendering groups preventing retention point in material dispose.
  20824. */
  20825. freeRenderingGroups(): void;
  20826. /**
  20827. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20828. * @returns the view count
  20829. */
  20830. getViewCount(): number;
  20831. }
  20832. }
  20833. declare module "babylonjs/Materials/material" {
  20834. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20835. import { SmartArray } from "babylonjs/Misc/smartArray";
  20836. import { Observable } from "babylonjs/Misc/observable";
  20837. import { Nullable } from "babylonjs/types";
  20838. import { Scene } from "babylonjs/scene";
  20839. import { Matrix } from "babylonjs/Maths/math.vector";
  20840. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20842. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20843. import { Effect } from "babylonjs/Materials/effect";
  20844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20846. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20847. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20848. import { Mesh } from "babylonjs/Meshes/mesh";
  20849. import { Animation } from "babylonjs/Animations/animation";
  20850. /**
  20851. * Base class for the main features of a material in Babylon.js
  20852. */
  20853. export class Material implements IAnimatable {
  20854. /**
  20855. * Returns the triangle fill mode
  20856. */
  20857. static readonly TriangleFillMode: number;
  20858. /**
  20859. * Returns the wireframe mode
  20860. */
  20861. static readonly WireFrameFillMode: number;
  20862. /**
  20863. * Returns the point fill mode
  20864. */
  20865. static readonly PointFillMode: number;
  20866. /**
  20867. * Returns the point list draw mode
  20868. */
  20869. static readonly PointListDrawMode: number;
  20870. /**
  20871. * Returns the line list draw mode
  20872. */
  20873. static readonly LineListDrawMode: number;
  20874. /**
  20875. * Returns the line loop draw mode
  20876. */
  20877. static readonly LineLoopDrawMode: number;
  20878. /**
  20879. * Returns the line strip draw mode
  20880. */
  20881. static readonly LineStripDrawMode: number;
  20882. /**
  20883. * Returns the triangle strip draw mode
  20884. */
  20885. static readonly TriangleStripDrawMode: number;
  20886. /**
  20887. * Returns the triangle fan draw mode
  20888. */
  20889. static readonly TriangleFanDrawMode: number;
  20890. /**
  20891. * Stores the clock-wise side orientation
  20892. */
  20893. static readonly ClockWiseSideOrientation: number;
  20894. /**
  20895. * Stores the counter clock-wise side orientation
  20896. */
  20897. static readonly CounterClockWiseSideOrientation: number;
  20898. /**
  20899. * The dirty texture flag value
  20900. */
  20901. static readonly TextureDirtyFlag: number;
  20902. /**
  20903. * The dirty light flag value
  20904. */
  20905. static readonly LightDirtyFlag: number;
  20906. /**
  20907. * The dirty fresnel flag value
  20908. */
  20909. static readonly FresnelDirtyFlag: number;
  20910. /**
  20911. * The dirty attribute flag value
  20912. */
  20913. static readonly AttributesDirtyFlag: number;
  20914. /**
  20915. * The dirty misc flag value
  20916. */
  20917. static readonly MiscDirtyFlag: number;
  20918. /**
  20919. * The all dirty flag value
  20920. */
  20921. static readonly AllDirtyFlag: number;
  20922. /**
  20923. * The ID of the material
  20924. */
  20925. id: string;
  20926. /**
  20927. * Gets or sets the unique id of the material
  20928. */
  20929. uniqueId: number;
  20930. /**
  20931. * The name of the material
  20932. */
  20933. name: string;
  20934. /**
  20935. * Gets or sets user defined metadata
  20936. */
  20937. metadata: any;
  20938. /**
  20939. * For internal use only. Please do not use.
  20940. */
  20941. reservedDataStore: any;
  20942. /**
  20943. * Specifies if the ready state should be checked on each call
  20944. */
  20945. checkReadyOnEveryCall: boolean;
  20946. /**
  20947. * Specifies if the ready state should be checked once
  20948. */
  20949. checkReadyOnlyOnce: boolean;
  20950. /**
  20951. * The state of the material
  20952. */
  20953. state: string;
  20954. /**
  20955. * The alpha value of the material
  20956. */
  20957. protected _alpha: number;
  20958. /**
  20959. * List of inspectable custom properties (used by the Inspector)
  20960. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20961. */
  20962. inspectableCustomProperties: IInspectable[];
  20963. /**
  20964. * Sets the alpha value of the material
  20965. */
  20966. /**
  20967. * Gets the alpha value of the material
  20968. */
  20969. alpha: number;
  20970. /**
  20971. * Specifies if back face culling is enabled
  20972. */
  20973. protected _backFaceCulling: boolean;
  20974. /**
  20975. * Sets the back-face culling state
  20976. */
  20977. /**
  20978. * Gets the back-face culling state
  20979. */
  20980. backFaceCulling: boolean;
  20981. /**
  20982. * Stores the value for side orientation
  20983. */
  20984. sideOrientation: number;
  20985. /**
  20986. * Callback triggered when the material is compiled
  20987. */
  20988. onCompiled: Nullable<(effect: Effect) => void>;
  20989. /**
  20990. * Callback triggered when an error occurs
  20991. */
  20992. onError: Nullable<(effect: Effect, errors: string) => void>;
  20993. /**
  20994. * Callback triggered to get the render target textures
  20995. */
  20996. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20997. /**
  20998. * Gets a boolean indicating that current material needs to register RTT
  20999. */
  21000. readonly hasRenderTargetTextures: boolean;
  21001. /**
  21002. * Specifies if the material should be serialized
  21003. */
  21004. doNotSerialize: boolean;
  21005. /**
  21006. * @hidden
  21007. */
  21008. _storeEffectOnSubMeshes: boolean;
  21009. /**
  21010. * Stores the animations for the material
  21011. */
  21012. animations: Nullable<Array<Animation>>;
  21013. /**
  21014. * An event triggered when the material is disposed
  21015. */
  21016. onDisposeObservable: Observable<Material>;
  21017. /**
  21018. * An observer which watches for dispose events
  21019. */
  21020. private _onDisposeObserver;
  21021. private _onUnBindObservable;
  21022. /**
  21023. * Called during a dispose event
  21024. */
  21025. onDispose: () => void;
  21026. private _onBindObservable;
  21027. /**
  21028. * An event triggered when the material is bound
  21029. */
  21030. readonly onBindObservable: Observable<AbstractMesh>;
  21031. /**
  21032. * An observer which watches for bind events
  21033. */
  21034. private _onBindObserver;
  21035. /**
  21036. * Called during a bind event
  21037. */
  21038. onBind: (Mesh: AbstractMesh) => void;
  21039. /**
  21040. * An event triggered when the material is unbound
  21041. */
  21042. readonly onUnBindObservable: Observable<Material>;
  21043. /**
  21044. * Stores the value of the alpha mode
  21045. */
  21046. private _alphaMode;
  21047. /**
  21048. * Sets the value of the alpha mode.
  21049. *
  21050. * | Value | Type | Description |
  21051. * | --- | --- | --- |
  21052. * | 0 | ALPHA_DISABLE | |
  21053. * | 1 | ALPHA_ADD | |
  21054. * | 2 | ALPHA_COMBINE | |
  21055. * | 3 | ALPHA_SUBTRACT | |
  21056. * | 4 | ALPHA_MULTIPLY | |
  21057. * | 5 | ALPHA_MAXIMIZED | |
  21058. * | 6 | ALPHA_ONEONE | |
  21059. * | 7 | ALPHA_PREMULTIPLIED | |
  21060. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21061. * | 9 | ALPHA_INTERPOLATE | |
  21062. * | 10 | ALPHA_SCREENMODE | |
  21063. *
  21064. */
  21065. /**
  21066. * Gets the value of the alpha mode
  21067. */
  21068. alphaMode: number;
  21069. /**
  21070. * Stores the state of the need depth pre-pass value
  21071. */
  21072. private _needDepthPrePass;
  21073. /**
  21074. * Sets the need depth pre-pass value
  21075. */
  21076. /**
  21077. * Gets the depth pre-pass value
  21078. */
  21079. needDepthPrePass: boolean;
  21080. /**
  21081. * Specifies if depth writing should be disabled
  21082. */
  21083. disableDepthWrite: boolean;
  21084. /**
  21085. * Specifies if depth writing should be forced
  21086. */
  21087. forceDepthWrite: boolean;
  21088. /**
  21089. * Specifies if there should be a separate pass for culling
  21090. */
  21091. separateCullingPass: boolean;
  21092. /**
  21093. * Stores the state specifing if fog should be enabled
  21094. */
  21095. private _fogEnabled;
  21096. /**
  21097. * Sets the state for enabling fog
  21098. */
  21099. /**
  21100. * Gets the value of the fog enabled state
  21101. */
  21102. fogEnabled: boolean;
  21103. /**
  21104. * Stores the size of points
  21105. */
  21106. pointSize: number;
  21107. /**
  21108. * Stores the z offset value
  21109. */
  21110. zOffset: number;
  21111. /**
  21112. * Gets a value specifying if wireframe mode is enabled
  21113. */
  21114. /**
  21115. * Sets the state of wireframe mode
  21116. */
  21117. wireframe: boolean;
  21118. /**
  21119. * Gets the value specifying if point clouds are enabled
  21120. */
  21121. /**
  21122. * Sets the state of point cloud mode
  21123. */
  21124. pointsCloud: boolean;
  21125. /**
  21126. * Gets the material fill mode
  21127. */
  21128. /**
  21129. * Sets the material fill mode
  21130. */
  21131. fillMode: number;
  21132. /**
  21133. * @hidden
  21134. * Stores the effects for the material
  21135. */
  21136. _effect: Nullable<Effect>;
  21137. /**
  21138. * @hidden
  21139. * Specifies if the material was previously ready
  21140. */
  21141. _wasPreviouslyReady: boolean;
  21142. /**
  21143. * Specifies if uniform buffers should be used
  21144. */
  21145. private _useUBO;
  21146. /**
  21147. * Stores a reference to the scene
  21148. */
  21149. private _scene;
  21150. /**
  21151. * Stores the fill mode state
  21152. */
  21153. private _fillMode;
  21154. /**
  21155. * Specifies if the depth write state should be cached
  21156. */
  21157. private _cachedDepthWriteState;
  21158. /**
  21159. * Stores the uniform buffer
  21160. */
  21161. protected _uniformBuffer: UniformBuffer;
  21162. /** @hidden */
  21163. _indexInSceneMaterialArray: number;
  21164. /** @hidden */
  21165. meshMap: Nullable<{
  21166. [id: string]: AbstractMesh | undefined;
  21167. }>;
  21168. /**
  21169. * Creates a material instance
  21170. * @param name defines the name of the material
  21171. * @param scene defines the scene to reference
  21172. * @param doNotAdd specifies if the material should be added to the scene
  21173. */
  21174. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21175. /**
  21176. * Returns a string representation of the current material
  21177. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21178. * @returns a string with material information
  21179. */
  21180. toString(fullDetails?: boolean): string;
  21181. /**
  21182. * Gets the class name of the material
  21183. * @returns a string with the class name of the material
  21184. */
  21185. getClassName(): string;
  21186. /**
  21187. * Specifies if updates for the material been locked
  21188. */
  21189. readonly isFrozen: boolean;
  21190. /**
  21191. * Locks updates for the material
  21192. */
  21193. freeze(): void;
  21194. /**
  21195. * Unlocks updates for the material
  21196. */
  21197. unfreeze(): void;
  21198. /**
  21199. * Specifies if the material is ready to be used
  21200. * @param mesh defines the mesh to check
  21201. * @param useInstances specifies if instances should be used
  21202. * @returns a boolean indicating if the material is ready to be used
  21203. */
  21204. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21205. /**
  21206. * Specifies that the submesh is ready to be used
  21207. * @param mesh defines the mesh to check
  21208. * @param subMesh defines which submesh to check
  21209. * @param useInstances specifies that instances should be used
  21210. * @returns a boolean indicating that the submesh is ready or not
  21211. */
  21212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21213. /**
  21214. * Returns the material effect
  21215. * @returns the effect associated with the material
  21216. */
  21217. getEffect(): Nullable<Effect>;
  21218. /**
  21219. * Returns the current scene
  21220. * @returns a Scene
  21221. */
  21222. getScene(): Scene;
  21223. /**
  21224. * Specifies if the material will require alpha blending
  21225. * @returns a boolean specifying if alpha blending is needed
  21226. */
  21227. needAlphaBlending(): boolean;
  21228. /**
  21229. * Specifies if the mesh will require alpha blending
  21230. * @param mesh defines the mesh to check
  21231. * @returns a boolean specifying if alpha blending is needed for the mesh
  21232. */
  21233. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21234. /**
  21235. * Specifies if this material should be rendered in alpha test mode
  21236. * @returns a boolean specifying if an alpha test is needed.
  21237. */
  21238. needAlphaTesting(): boolean;
  21239. /**
  21240. * Gets the texture used for the alpha test
  21241. * @returns the texture to use for alpha testing
  21242. */
  21243. getAlphaTestTexture(): Nullable<BaseTexture>;
  21244. /**
  21245. * Marks the material to indicate that it needs to be re-calculated
  21246. */
  21247. markDirty(): void;
  21248. /** @hidden */
  21249. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21250. /**
  21251. * Binds the material to the mesh
  21252. * @param world defines the world transformation matrix
  21253. * @param mesh defines the mesh to bind the material to
  21254. */
  21255. bind(world: Matrix, mesh?: Mesh): void;
  21256. /**
  21257. * Binds the submesh to the material
  21258. * @param world defines the world transformation matrix
  21259. * @param mesh defines the mesh containing the submesh
  21260. * @param subMesh defines the submesh to bind the material to
  21261. */
  21262. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21263. /**
  21264. * Binds the world matrix to the material
  21265. * @param world defines the world transformation matrix
  21266. */
  21267. bindOnlyWorldMatrix(world: Matrix): void;
  21268. /**
  21269. * Binds the scene's uniform buffer to the effect.
  21270. * @param effect defines the effect to bind to the scene uniform buffer
  21271. * @param sceneUbo defines the uniform buffer storing scene data
  21272. */
  21273. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21274. /**
  21275. * Binds the view matrix to the effect
  21276. * @param effect defines the effect to bind the view matrix to
  21277. */
  21278. bindView(effect: Effect): void;
  21279. /**
  21280. * Binds the view projection matrix to the effect
  21281. * @param effect defines the effect to bind the view projection matrix to
  21282. */
  21283. bindViewProjection(effect: Effect): void;
  21284. /**
  21285. * Specifies if material alpha testing should be turned on for the mesh
  21286. * @param mesh defines the mesh to check
  21287. */
  21288. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21289. /**
  21290. * Processes to execute after binding the material to a mesh
  21291. * @param mesh defines the rendered mesh
  21292. */
  21293. protected _afterBind(mesh?: Mesh): void;
  21294. /**
  21295. * Unbinds the material from the mesh
  21296. */
  21297. unbind(): void;
  21298. /**
  21299. * Gets the active textures from the material
  21300. * @returns an array of textures
  21301. */
  21302. getActiveTextures(): BaseTexture[];
  21303. /**
  21304. * Specifies if the material uses a texture
  21305. * @param texture defines the texture to check against the material
  21306. * @returns a boolean specifying if the material uses the texture
  21307. */
  21308. hasTexture(texture: BaseTexture): boolean;
  21309. /**
  21310. * Makes a duplicate of the material, and gives it a new name
  21311. * @param name defines the new name for the duplicated material
  21312. * @returns the cloned material
  21313. */
  21314. clone(name: string): Nullable<Material>;
  21315. /**
  21316. * Gets the meshes bound to the material
  21317. * @returns an array of meshes bound to the material
  21318. */
  21319. getBindedMeshes(): AbstractMesh[];
  21320. /**
  21321. * Force shader compilation
  21322. * @param mesh defines the mesh associated with this material
  21323. * @param onCompiled defines a function to execute once the material is compiled
  21324. * @param options defines the options to configure the compilation
  21325. */
  21326. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21327. clipPlane: boolean;
  21328. }>): void;
  21329. /**
  21330. * Force shader compilation
  21331. * @param mesh defines the mesh that will use this material
  21332. * @param options defines additional options for compiling the shaders
  21333. * @returns a promise that resolves when the compilation completes
  21334. */
  21335. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21336. clipPlane: boolean;
  21337. }>): Promise<void>;
  21338. private static readonly _AllDirtyCallBack;
  21339. private static readonly _ImageProcessingDirtyCallBack;
  21340. private static readonly _TextureDirtyCallBack;
  21341. private static readonly _FresnelDirtyCallBack;
  21342. private static readonly _MiscDirtyCallBack;
  21343. private static readonly _LightsDirtyCallBack;
  21344. private static readonly _AttributeDirtyCallBack;
  21345. private static _FresnelAndMiscDirtyCallBack;
  21346. private static _TextureAndMiscDirtyCallBack;
  21347. private static readonly _DirtyCallbackArray;
  21348. private static readonly _RunDirtyCallBacks;
  21349. /**
  21350. * Marks a define in the material to indicate that it needs to be re-computed
  21351. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21352. */
  21353. markAsDirty(flag: number): void;
  21354. /**
  21355. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21356. * @param func defines a function which checks material defines against the submeshes
  21357. */
  21358. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21359. /**
  21360. * Indicates that we need to re-calculated for all submeshes
  21361. */
  21362. protected _markAllSubMeshesAsAllDirty(): void;
  21363. /**
  21364. * Indicates that image processing needs to be re-calculated for all submeshes
  21365. */
  21366. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21367. /**
  21368. * Indicates that textures need to be re-calculated for all submeshes
  21369. */
  21370. protected _markAllSubMeshesAsTexturesDirty(): void;
  21371. /**
  21372. * Indicates that fresnel needs to be re-calculated for all submeshes
  21373. */
  21374. protected _markAllSubMeshesAsFresnelDirty(): void;
  21375. /**
  21376. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21377. */
  21378. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21379. /**
  21380. * Indicates that lights need to be re-calculated for all submeshes
  21381. */
  21382. protected _markAllSubMeshesAsLightsDirty(): void;
  21383. /**
  21384. * Indicates that attributes need to be re-calculated for all submeshes
  21385. */
  21386. protected _markAllSubMeshesAsAttributesDirty(): void;
  21387. /**
  21388. * Indicates that misc needs to be re-calculated for all submeshes
  21389. */
  21390. protected _markAllSubMeshesAsMiscDirty(): void;
  21391. /**
  21392. * Indicates that textures and misc need to be re-calculated for all submeshes
  21393. */
  21394. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21395. /**
  21396. * Disposes the material
  21397. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21398. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21399. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21400. */
  21401. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21402. /** @hidden */
  21403. private releaseVertexArrayObject;
  21404. /**
  21405. * Serializes this material
  21406. * @returns the serialized material object
  21407. */
  21408. serialize(): any;
  21409. /**
  21410. * Creates a material from parsed material data
  21411. * @param parsedMaterial defines parsed material data
  21412. * @param scene defines the hosting scene
  21413. * @param rootUrl defines the root URL to use to load textures
  21414. * @returns a new material
  21415. */
  21416. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21417. }
  21418. }
  21419. declare module "babylonjs/Materials/multiMaterial" {
  21420. import { Nullable } from "babylonjs/types";
  21421. import { Scene } from "babylonjs/scene";
  21422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21423. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21425. import { Material } from "babylonjs/Materials/material";
  21426. /**
  21427. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21428. * separate meshes. This can be use to improve performances.
  21429. * @see http://doc.babylonjs.com/how_to/multi_materials
  21430. */
  21431. export class MultiMaterial extends Material {
  21432. private _subMaterials;
  21433. /**
  21434. * Gets or Sets the list of Materials used within the multi material.
  21435. * They need to be ordered according to the submeshes order in the associated mesh
  21436. */
  21437. subMaterials: Nullable<Material>[];
  21438. /**
  21439. * Function used to align with Node.getChildren()
  21440. * @returns the list of Materials used within the multi material
  21441. */
  21442. getChildren(): Nullable<Material>[];
  21443. /**
  21444. * Instantiates a new Multi Material
  21445. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21446. * separate meshes. This can be use to improve performances.
  21447. * @see http://doc.babylonjs.com/how_to/multi_materials
  21448. * @param name Define the name in the scene
  21449. * @param scene Define the scene the material belongs to
  21450. */
  21451. constructor(name: string, scene: Scene);
  21452. private _hookArray;
  21453. /**
  21454. * Get one of the submaterial by its index in the submaterials array
  21455. * @param index The index to look the sub material at
  21456. * @returns The Material if the index has been defined
  21457. */
  21458. getSubMaterial(index: number): Nullable<Material>;
  21459. /**
  21460. * Get the list of active textures for the whole sub materials list.
  21461. * @returns All the textures that will be used during the rendering
  21462. */
  21463. getActiveTextures(): BaseTexture[];
  21464. /**
  21465. * Gets the current class name of the material e.g. "MultiMaterial"
  21466. * Mainly use in serialization.
  21467. * @returns the class name
  21468. */
  21469. getClassName(): string;
  21470. /**
  21471. * Checks if the material is ready to render the requested sub mesh
  21472. * @param mesh Define the mesh the submesh belongs to
  21473. * @param subMesh Define the sub mesh to look readyness for
  21474. * @param useInstances Define whether or not the material is used with instances
  21475. * @returns true if ready, otherwise false
  21476. */
  21477. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21478. /**
  21479. * Clones the current material and its related sub materials
  21480. * @param name Define the name of the newly cloned material
  21481. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21482. * @returns the cloned material
  21483. */
  21484. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21485. /**
  21486. * Serializes the materials into a JSON representation.
  21487. * @returns the JSON representation
  21488. */
  21489. serialize(): any;
  21490. /**
  21491. * Dispose the material and release its associated resources
  21492. * @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)
  21493. * @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)
  21494. * @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)
  21495. */
  21496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21497. /**
  21498. * Creates a MultiMaterial from parsed MultiMaterial data.
  21499. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21500. * @param scene defines the hosting scene
  21501. * @returns a new MultiMaterial
  21502. */
  21503. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21504. }
  21505. }
  21506. declare module "babylonjs/Meshes/subMesh" {
  21507. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21508. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21509. import { Engine } from "babylonjs/Engines/engine";
  21510. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21511. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21512. import { Effect } from "babylonjs/Materials/effect";
  21513. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21514. import { Plane } from "babylonjs/Maths/math.plane";
  21515. import { Collider } from "babylonjs/Collisions/collider";
  21516. import { Material } from "babylonjs/Materials/material";
  21517. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21519. import { Mesh } from "babylonjs/Meshes/mesh";
  21520. import { Ray } from "babylonjs/Culling/ray";
  21521. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21522. /**
  21523. * Base class for submeshes
  21524. */
  21525. export class BaseSubMesh {
  21526. /** @hidden */
  21527. _materialDefines: Nullable<MaterialDefines>;
  21528. /** @hidden */
  21529. _materialEffect: Nullable<Effect>;
  21530. /**
  21531. * Gets associated effect
  21532. */
  21533. readonly effect: Nullable<Effect>;
  21534. /**
  21535. * Sets associated effect (effect used to render this submesh)
  21536. * @param effect defines the effect to associate with
  21537. * @param defines defines the set of defines used to compile this effect
  21538. */
  21539. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21540. }
  21541. /**
  21542. * Defines a subdivision inside a mesh
  21543. */
  21544. export class SubMesh extends BaseSubMesh implements ICullable {
  21545. /** the material index to use */
  21546. materialIndex: number;
  21547. /** vertex index start */
  21548. verticesStart: number;
  21549. /** vertices count */
  21550. verticesCount: number;
  21551. /** index start */
  21552. indexStart: number;
  21553. /** indices count */
  21554. indexCount: number;
  21555. /** @hidden */
  21556. _linesIndexCount: number;
  21557. private _mesh;
  21558. private _renderingMesh;
  21559. private _boundingInfo;
  21560. private _linesIndexBuffer;
  21561. /** @hidden */
  21562. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21563. /** @hidden */
  21564. _trianglePlanes: Plane[];
  21565. /** @hidden */
  21566. _lastColliderTransformMatrix: Nullable<Matrix>;
  21567. /** @hidden */
  21568. _renderId: number;
  21569. /** @hidden */
  21570. _alphaIndex: number;
  21571. /** @hidden */
  21572. _distanceToCamera: number;
  21573. /** @hidden */
  21574. _id: number;
  21575. private _currentMaterial;
  21576. /**
  21577. * Add a new submesh to a mesh
  21578. * @param materialIndex defines the material index to use
  21579. * @param verticesStart defines vertex index start
  21580. * @param verticesCount defines vertices count
  21581. * @param indexStart defines index start
  21582. * @param indexCount defines indices count
  21583. * @param mesh defines the parent mesh
  21584. * @param renderingMesh defines an optional rendering mesh
  21585. * @param createBoundingBox defines if bounding box should be created for this submesh
  21586. * @returns the new submesh
  21587. */
  21588. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21589. /**
  21590. * Creates a new submesh
  21591. * @param materialIndex defines the material index to use
  21592. * @param verticesStart defines vertex index start
  21593. * @param verticesCount defines vertices count
  21594. * @param indexStart defines index start
  21595. * @param indexCount defines indices count
  21596. * @param mesh defines the parent mesh
  21597. * @param renderingMesh defines an optional rendering mesh
  21598. * @param createBoundingBox defines if bounding box should be created for this submesh
  21599. */
  21600. constructor(
  21601. /** the material index to use */
  21602. materialIndex: number,
  21603. /** vertex index start */
  21604. verticesStart: number,
  21605. /** vertices count */
  21606. verticesCount: number,
  21607. /** index start */
  21608. indexStart: number,
  21609. /** indices count */
  21610. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21611. /**
  21612. * Returns true if this submesh covers the entire parent mesh
  21613. * @ignorenaming
  21614. */
  21615. readonly IsGlobal: boolean;
  21616. /**
  21617. * Returns the submesh BoudingInfo object
  21618. * @returns current bounding info (or mesh's one if the submesh is global)
  21619. */
  21620. getBoundingInfo(): BoundingInfo;
  21621. /**
  21622. * Sets the submesh BoundingInfo
  21623. * @param boundingInfo defines the new bounding info to use
  21624. * @returns the SubMesh
  21625. */
  21626. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21627. /**
  21628. * Returns the mesh of the current submesh
  21629. * @return the parent mesh
  21630. */
  21631. getMesh(): AbstractMesh;
  21632. /**
  21633. * Returns the rendering mesh of the submesh
  21634. * @returns the rendering mesh (could be different from parent mesh)
  21635. */
  21636. getRenderingMesh(): Mesh;
  21637. /**
  21638. * Returns the submesh material
  21639. * @returns null or the current material
  21640. */
  21641. getMaterial(): Nullable<Material>;
  21642. /**
  21643. * Sets a new updated BoundingInfo object to the submesh
  21644. * @param data defines an optional position array to use to determine the bounding info
  21645. * @returns the SubMesh
  21646. */
  21647. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21648. /** @hidden */
  21649. _checkCollision(collider: Collider): boolean;
  21650. /**
  21651. * Updates the submesh BoundingInfo
  21652. * @param world defines the world matrix to use to update the bounding info
  21653. * @returns the submesh
  21654. */
  21655. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21656. /**
  21657. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21658. * @param frustumPlanes defines the frustum planes
  21659. * @returns true if the submesh is intersecting with the frustum
  21660. */
  21661. isInFrustum(frustumPlanes: Plane[]): boolean;
  21662. /**
  21663. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21664. * @param frustumPlanes defines the frustum planes
  21665. * @returns true if the submesh is inside the frustum
  21666. */
  21667. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21668. /**
  21669. * Renders the submesh
  21670. * @param enableAlphaMode defines if alpha needs to be used
  21671. * @returns the submesh
  21672. */
  21673. render(enableAlphaMode: boolean): SubMesh;
  21674. /**
  21675. * @hidden
  21676. */
  21677. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21678. /**
  21679. * Checks if the submesh intersects with a ray
  21680. * @param ray defines the ray to test
  21681. * @returns true is the passed ray intersects the submesh bounding box
  21682. */
  21683. canIntersects(ray: Ray): boolean;
  21684. /**
  21685. * Intersects current submesh with a ray
  21686. * @param ray defines the ray to test
  21687. * @param positions defines mesh's positions array
  21688. * @param indices defines mesh's indices array
  21689. * @param fastCheck defines if only bounding info should be used
  21690. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21691. * @returns intersection info or null if no intersection
  21692. */
  21693. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21694. /** @hidden */
  21695. private _intersectLines;
  21696. /** @hidden */
  21697. private _intersectUnIndexedLines;
  21698. /** @hidden */
  21699. private _intersectTriangles;
  21700. /** @hidden */
  21701. private _intersectUnIndexedTriangles;
  21702. /** @hidden */
  21703. _rebuild(): void;
  21704. /**
  21705. * Creates a new submesh from the passed mesh
  21706. * @param newMesh defines the new hosting mesh
  21707. * @param newRenderingMesh defines an optional rendering mesh
  21708. * @returns the new submesh
  21709. */
  21710. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21711. /**
  21712. * Release associated resources
  21713. */
  21714. dispose(): void;
  21715. /**
  21716. * Gets the class name
  21717. * @returns the string "SubMesh".
  21718. */
  21719. getClassName(): string;
  21720. /**
  21721. * Creates a new submesh from indices data
  21722. * @param materialIndex the index of the main mesh material
  21723. * @param startIndex the index where to start the copy in the mesh indices array
  21724. * @param indexCount the number of indices to copy then from the startIndex
  21725. * @param mesh the main mesh to create the submesh from
  21726. * @param renderingMesh the optional rendering mesh
  21727. * @returns a new submesh
  21728. */
  21729. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21730. }
  21731. }
  21732. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21733. /**
  21734. * Class used to represent data loading progression
  21735. */
  21736. export class SceneLoaderFlags {
  21737. private static _ForceFullSceneLoadingForIncremental;
  21738. private static _ShowLoadingScreen;
  21739. private static _CleanBoneMatrixWeights;
  21740. private static _loggingLevel;
  21741. /**
  21742. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21743. */
  21744. static ForceFullSceneLoadingForIncremental: boolean;
  21745. /**
  21746. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21747. */
  21748. static ShowLoadingScreen: boolean;
  21749. /**
  21750. * Defines the current logging level (while loading the scene)
  21751. * @ignorenaming
  21752. */
  21753. static loggingLevel: number;
  21754. /**
  21755. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21756. */
  21757. static CleanBoneMatrixWeights: boolean;
  21758. }
  21759. }
  21760. declare module "babylonjs/Meshes/geometry" {
  21761. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21762. import { Scene } from "babylonjs/scene";
  21763. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21764. import { Engine } from "babylonjs/Engines/engine";
  21765. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21766. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21767. import { Effect } from "babylonjs/Materials/effect";
  21768. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21769. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21770. import { Mesh } from "babylonjs/Meshes/mesh";
  21771. /**
  21772. * Class used to store geometry data (vertex buffers + index buffer)
  21773. */
  21774. export class Geometry implements IGetSetVerticesData {
  21775. /**
  21776. * Gets or sets the ID of the geometry
  21777. */
  21778. id: string;
  21779. /**
  21780. * Gets or sets the unique ID of the geometry
  21781. */
  21782. uniqueId: number;
  21783. /**
  21784. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21785. */
  21786. delayLoadState: number;
  21787. /**
  21788. * Gets the file containing the data to load when running in delay load state
  21789. */
  21790. delayLoadingFile: Nullable<string>;
  21791. /**
  21792. * Callback called when the geometry is updated
  21793. */
  21794. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21795. private _scene;
  21796. private _engine;
  21797. private _meshes;
  21798. private _totalVertices;
  21799. /** @hidden */
  21800. _indices: IndicesArray;
  21801. /** @hidden */
  21802. _vertexBuffers: {
  21803. [key: string]: VertexBuffer;
  21804. };
  21805. private _isDisposed;
  21806. private _extend;
  21807. private _boundingBias;
  21808. /** @hidden */
  21809. _delayInfo: Array<string>;
  21810. private _indexBuffer;
  21811. private _indexBufferIsUpdatable;
  21812. /** @hidden */
  21813. _boundingInfo: Nullable<BoundingInfo>;
  21814. /** @hidden */
  21815. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21816. /** @hidden */
  21817. _softwareSkinningFrameId: number;
  21818. private _vertexArrayObjects;
  21819. private _updatable;
  21820. /** @hidden */
  21821. _positions: Nullable<Vector3[]>;
  21822. /**
  21823. * 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
  21824. */
  21825. /**
  21826. * 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
  21827. */
  21828. boundingBias: Vector2;
  21829. /**
  21830. * Static function used to attach a new empty geometry to a mesh
  21831. * @param mesh defines the mesh to attach the geometry to
  21832. * @returns the new Geometry
  21833. */
  21834. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21835. /**
  21836. * Creates a new geometry
  21837. * @param id defines the unique ID
  21838. * @param scene defines the hosting scene
  21839. * @param vertexData defines the VertexData used to get geometry data
  21840. * @param updatable defines if geometry must be updatable (false by default)
  21841. * @param mesh defines the mesh that will be associated with the geometry
  21842. */
  21843. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21844. /**
  21845. * Gets the current extend of the geometry
  21846. */
  21847. readonly extend: {
  21848. minimum: Vector3;
  21849. maximum: Vector3;
  21850. };
  21851. /**
  21852. * Gets the hosting scene
  21853. * @returns the hosting Scene
  21854. */
  21855. getScene(): Scene;
  21856. /**
  21857. * Gets the hosting engine
  21858. * @returns the hosting Engine
  21859. */
  21860. getEngine(): Engine;
  21861. /**
  21862. * Defines if the geometry is ready to use
  21863. * @returns true if the geometry is ready to be used
  21864. */
  21865. isReady(): boolean;
  21866. /**
  21867. * Gets a value indicating that the geometry should not be serialized
  21868. */
  21869. readonly doNotSerialize: boolean;
  21870. /** @hidden */
  21871. _rebuild(): void;
  21872. /**
  21873. * Affects all geometry data in one call
  21874. * @param vertexData defines the geometry data
  21875. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21876. */
  21877. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21878. /**
  21879. * Set specific vertex data
  21880. * @param kind defines the data kind (Position, normal, etc...)
  21881. * @param data defines the vertex data to use
  21882. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21883. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21884. */
  21885. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21886. /**
  21887. * Removes a specific vertex data
  21888. * @param kind defines the data kind (Position, normal, etc...)
  21889. */
  21890. removeVerticesData(kind: string): void;
  21891. /**
  21892. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21893. * @param buffer defines the vertex buffer to use
  21894. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21895. */
  21896. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21897. /**
  21898. * Update a specific vertex buffer
  21899. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21900. * It will do nothing if the buffer is not updatable
  21901. * @param kind defines the data kind (Position, normal, etc...)
  21902. * @param data defines the data to use
  21903. * @param offset defines the offset in the target buffer where to store the data
  21904. * @param useBytes set to true if the offset is in bytes
  21905. */
  21906. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21907. /**
  21908. * Update a specific vertex buffer
  21909. * This function will create a new buffer if the current one is not updatable
  21910. * @param kind defines the data kind (Position, normal, etc...)
  21911. * @param data defines the data to use
  21912. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21913. */
  21914. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21915. private _updateBoundingInfo;
  21916. /** @hidden */
  21917. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21918. /**
  21919. * Gets total number of vertices
  21920. * @returns the total number of vertices
  21921. */
  21922. getTotalVertices(): number;
  21923. /**
  21924. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21925. * @param kind defines the data kind (Position, normal, etc...)
  21926. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21927. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21928. * @returns a float array containing vertex data
  21929. */
  21930. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21931. /**
  21932. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21933. * @param kind defines the data kind (Position, normal, etc...)
  21934. * @returns true if the vertex buffer with the specified kind is updatable
  21935. */
  21936. isVertexBufferUpdatable(kind: string): boolean;
  21937. /**
  21938. * Gets a specific vertex buffer
  21939. * @param kind defines the data kind (Position, normal, etc...)
  21940. * @returns a VertexBuffer
  21941. */
  21942. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21943. /**
  21944. * Returns all vertex buffers
  21945. * @return an object holding all vertex buffers indexed by kind
  21946. */
  21947. getVertexBuffers(): Nullable<{
  21948. [key: string]: VertexBuffer;
  21949. }>;
  21950. /**
  21951. * Gets a boolean indicating if specific vertex buffer is present
  21952. * @param kind defines the data kind (Position, normal, etc...)
  21953. * @returns true if data is present
  21954. */
  21955. isVerticesDataPresent(kind: string): boolean;
  21956. /**
  21957. * Gets a list of all attached data kinds (Position, normal, etc...)
  21958. * @returns a list of string containing all kinds
  21959. */
  21960. getVerticesDataKinds(): string[];
  21961. /**
  21962. * Update index buffer
  21963. * @param indices defines the indices to store in the index buffer
  21964. * @param offset defines the offset in the target buffer where to store the data
  21965. * @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)
  21966. */
  21967. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21968. /**
  21969. * Creates a new index buffer
  21970. * @param indices defines the indices to store in the index buffer
  21971. * @param totalVertices defines the total number of vertices (could be null)
  21972. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21973. */
  21974. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21975. /**
  21976. * Return the total number of indices
  21977. * @returns the total number of indices
  21978. */
  21979. getTotalIndices(): number;
  21980. /**
  21981. * Gets the index buffer array
  21982. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21983. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21984. * @returns the index buffer array
  21985. */
  21986. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21987. /**
  21988. * Gets the index buffer
  21989. * @return the index buffer
  21990. */
  21991. getIndexBuffer(): Nullable<DataBuffer>;
  21992. /** @hidden */
  21993. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21994. /**
  21995. * Release the associated resources for a specific mesh
  21996. * @param mesh defines the source mesh
  21997. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21998. */
  21999. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22000. /**
  22001. * Apply current geometry to a given mesh
  22002. * @param mesh defines the mesh to apply geometry to
  22003. */
  22004. applyToMesh(mesh: Mesh): void;
  22005. private _updateExtend;
  22006. private _applyToMesh;
  22007. private notifyUpdate;
  22008. /**
  22009. * Load the geometry if it was flagged as delay loaded
  22010. * @param scene defines the hosting scene
  22011. * @param onLoaded defines a callback called when the geometry is loaded
  22012. */
  22013. load(scene: Scene, onLoaded?: () => void): void;
  22014. private _queueLoad;
  22015. /**
  22016. * Invert the geometry to move from a right handed system to a left handed one.
  22017. */
  22018. toLeftHanded(): void;
  22019. /** @hidden */
  22020. _resetPointsArrayCache(): void;
  22021. /** @hidden */
  22022. _generatePointsArray(): boolean;
  22023. /**
  22024. * Gets a value indicating if the geometry is disposed
  22025. * @returns true if the geometry was disposed
  22026. */
  22027. isDisposed(): boolean;
  22028. private _disposeVertexArrayObjects;
  22029. /**
  22030. * Free all associated resources
  22031. */
  22032. dispose(): void;
  22033. /**
  22034. * Clone the current geometry into a new geometry
  22035. * @param id defines the unique ID of the new geometry
  22036. * @returns a new geometry object
  22037. */
  22038. copy(id: string): Geometry;
  22039. /**
  22040. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22041. * @return a JSON representation of the current geometry data (without the vertices data)
  22042. */
  22043. serialize(): any;
  22044. private toNumberArray;
  22045. /**
  22046. * Serialize all vertices data into a JSON oject
  22047. * @returns a JSON representation of the current geometry data
  22048. */
  22049. serializeVerticeData(): any;
  22050. /**
  22051. * Extracts a clone of a mesh geometry
  22052. * @param mesh defines the source mesh
  22053. * @param id defines the unique ID of the new geometry object
  22054. * @returns the new geometry object
  22055. */
  22056. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22057. /**
  22058. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22059. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22060. * Be aware Math.random() could cause collisions, but:
  22061. * "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"
  22062. * @returns a string containing a new GUID
  22063. */
  22064. static RandomId(): string;
  22065. /** @hidden */
  22066. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22067. private static _CleanMatricesWeights;
  22068. /**
  22069. * Create a new geometry from persisted data (Using .babylon file format)
  22070. * @param parsedVertexData defines the persisted data
  22071. * @param scene defines the hosting scene
  22072. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22073. * @returns the new geometry object
  22074. */
  22075. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22076. }
  22077. }
  22078. declare module "babylonjs/Meshes/mesh.vertexData" {
  22079. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22080. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22081. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22082. import { Geometry } from "babylonjs/Meshes/geometry";
  22083. import { Mesh } from "babylonjs/Meshes/mesh";
  22084. /**
  22085. * Define an interface for all classes that will get and set the data on vertices
  22086. */
  22087. export interface IGetSetVerticesData {
  22088. /**
  22089. * Gets a boolean indicating if specific vertex data is present
  22090. * @param kind defines the vertex data kind to use
  22091. * @returns true is data kind is present
  22092. */
  22093. isVerticesDataPresent(kind: string): boolean;
  22094. /**
  22095. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22096. * @param kind defines the data kind (Position, normal, etc...)
  22097. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22098. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22099. * @returns a float array containing vertex data
  22100. */
  22101. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22102. /**
  22103. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22104. * @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.
  22105. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22106. * @returns the indices array or an empty array if the mesh has no geometry
  22107. */
  22108. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22109. /**
  22110. * Set specific vertex data
  22111. * @param kind defines the data kind (Position, normal, etc...)
  22112. * @param data defines the vertex data to use
  22113. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22114. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22115. */
  22116. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22117. /**
  22118. * Update a specific associated vertex buffer
  22119. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22120. * - VertexBuffer.PositionKind
  22121. * - VertexBuffer.UVKind
  22122. * - VertexBuffer.UV2Kind
  22123. * - VertexBuffer.UV3Kind
  22124. * - VertexBuffer.UV4Kind
  22125. * - VertexBuffer.UV5Kind
  22126. * - VertexBuffer.UV6Kind
  22127. * - VertexBuffer.ColorKind
  22128. * - VertexBuffer.MatricesIndicesKind
  22129. * - VertexBuffer.MatricesIndicesExtraKind
  22130. * - VertexBuffer.MatricesWeightsKind
  22131. * - VertexBuffer.MatricesWeightsExtraKind
  22132. * @param data defines the data source
  22133. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22134. * @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)
  22135. */
  22136. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22137. /**
  22138. * Creates a new index buffer
  22139. * @param indices defines the indices to store in the index buffer
  22140. * @param totalVertices defines the total number of vertices (could be null)
  22141. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22142. */
  22143. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22144. }
  22145. /**
  22146. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22147. */
  22148. export class VertexData {
  22149. /**
  22150. * Mesh side orientation : usually the external or front surface
  22151. */
  22152. static readonly FRONTSIDE: number;
  22153. /**
  22154. * Mesh side orientation : usually the internal or back surface
  22155. */
  22156. static readonly BACKSIDE: number;
  22157. /**
  22158. * Mesh side orientation : both internal and external or front and back surfaces
  22159. */
  22160. static readonly DOUBLESIDE: number;
  22161. /**
  22162. * Mesh side orientation : by default, `FRONTSIDE`
  22163. */
  22164. static readonly DEFAULTSIDE: number;
  22165. /**
  22166. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22167. */
  22168. positions: Nullable<FloatArray>;
  22169. /**
  22170. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22171. */
  22172. normals: Nullable<FloatArray>;
  22173. /**
  22174. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22175. */
  22176. tangents: Nullable<FloatArray>;
  22177. /**
  22178. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22179. */
  22180. uvs: Nullable<FloatArray>;
  22181. /**
  22182. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22183. */
  22184. uvs2: Nullable<FloatArray>;
  22185. /**
  22186. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22187. */
  22188. uvs3: Nullable<FloatArray>;
  22189. /**
  22190. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22191. */
  22192. uvs4: Nullable<FloatArray>;
  22193. /**
  22194. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22195. */
  22196. uvs5: Nullable<FloatArray>;
  22197. /**
  22198. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22199. */
  22200. uvs6: Nullable<FloatArray>;
  22201. /**
  22202. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22203. */
  22204. colors: Nullable<FloatArray>;
  22205. /**
  22206. * 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).
  22207. */
  22208. matricesIndices: Nullable<FloatArray>;
  22209. /**
  22210. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22211. */
  22212. matricesWeights: Nullable<FloatArray>;
  22213. /**
  22214. * An array extending the number of possible indices
  22215. */
  22216. matricesIndicesExtra: Nullable<FloatArray>;
  22217. /**
  22218. * An array extending the number of possible weights when the number of indices is extended
  22219. */
  22220. matricesWeightsExtra: Nullable<FloatArray>;
  22221. /**
  22222. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22223. */
  22224. indices: Nullable<IndicesArray>;
  22225. /**
  22226. * Uses the passed data array to set the set the values for the specified kind of data
  22227. * @param data a linear array of floating numbers
  22228. * @param kind the type of data that is being set, eg positions, colors etc
  22229. */
  22230. set(data: FloatArray, kind: string): void;
  22231. /**
  22232. * Associates the vertexData to the passed Mesh.
  22233. * Sets it as updatable or not (default `false`)
  22234. * @param mesh the mesh the vertexData is applied to
  22235. * @param updatable when used and having the value true allows new data to update the vertexData
  22236. * @returns the VertexData
  22237. */
  22238. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22239. /**
  22240. * Associates the vertexData to the passed Geometry.
  22241. * Sets it as updatable or not (default `false`)
  22242. * @param geometry the geometry the vertexData is applied to
  22243. * @param updatable when used and having the value true allows new data to update the vertexData
  22244. * @returns VertexData
  22245. */
  22246. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22247. /**
  22248. * Updates the associated mesh
  22249. * @param mesh the mesh to be updated
  22250. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22251. * @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
  22252. * @returns VertexData
  22253. */
  22254. updateMesh(mesh: Mesh): VertexData;
  22255. /**
  22256. * Updates the associated geometry
  22257. * @param geometry the geometry to be updated
  22258. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22259. * @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
  22260. * @returns VertexData.
  22261. */
  22262. updateGeometry(geometry: Geometry): VertexData;
  22263. private _applyTo;
  22264. private _update;
  22265. /**
  22266. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22267. * @param matrix the transforming matrix
  22268. * @returns the VertexData
  22269. */
  22270. transform(matrix: Matrix): VertexData;
  22271. /**
  22272. * Merges the passed VertexData into the current one
  22273. * @param other the VertexData to be merged into the current one
  22274. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22275. * @returns the modified VertexData
  22276. */
  22277. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22278. private _mergeElement;
  22279. private _validate;
  22280. /**
  22281. * Serializes the VertexData
  22282. * @returns a serialized object
  22283. */
  22284. serialize(): any;
  22285. /**
  22286. * Extracts the vertexData from a mesh
  22287. * @param mesh the mesh from which to extract the VertexData
  22288. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22289. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22290. * @returns the object VertexData associated to the passed mesh
  22291. */
  22292. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22293. /**
  22294. * Extracts the vertexData from the geometry
  22295. * @param geometry the geometry from which to extract the VertexData
  22296. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22297. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22298. * @returns the object VertexData associated to the passed mesh
  22299. */
  22300. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22301. private static _ExtractFrom;
  22302. /**
  22303. * Creates the VertexData for a Ribbon
  22304. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22305. * * pathArray array of paths, each of which an array of successive Vector3
  22306. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22307. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22308. * * 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
  22309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22310. * * 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)
  22311. * * 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)
  22312. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22313. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22314. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22315. * @returns the VertexData of the ribbon
  22316. */
  22317. static CreateRibbon(options: {
  22318. pathArray: Vector3[][];
  22319. closeArray?: boolean;
  22320. closePath?: boolean;
  22321. offset?: number;
  22322. sideOrientation?: number;
  22323. frontUVs?: Vector4;
  22324. backUVs?: Vector4;
  22325. invertUV?: boolean;
  22326. uvs?: Vector2[];
  22327. colors?: Color4[];
  22328. }): VertexData;
  22329. /**
  22330. * Creates the VertexData for a box
  22331. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22332. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22333. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22334. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22335. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22336. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22337. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22339. * * 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)
  22340. * * 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)
  22341. * @returns the VertexData of the box
  22342. */
  22343. static CreateBox(options: {
  22344. size?: number;
  22345. width?: number;
  22346. height?: number;
  22347. depth?: number;
  22348. faceUV?: Vector4[];
  22349. faceColors?: Color4[];
  22350. sideOrientation?: number;
  22351. frontUVs?: Vector4;
  22352. backUVs?: Vector4;
  22353. }): VertexData;
  22354. /**
  22355. * Creates the VertexData for a tiled box
  22356. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22357. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22358. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22359. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22360. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22361. * @returns the VertexData of the box
  22362. */
  22363. static CreateTiledBox(options: {
  22364. pattern?: number;
  22365. width?: number;
  22366. height?: number;
  22367. depth?: number;
  22368. tileSize?: number;
  22369. tileWidth?: number;
  22370. tileHeight?: number;
  22371. alignHorizontal?: number;
  22372. alignVertical?: number;
  22373. faceUV?: Vector4[];
  22374. faceColors?: Color4[];
  22375. sideOrientation?: number;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for a tiled plane
  22379. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22380. * * pattern a limited pattern arrangement depending on the number
  22381. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22382. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22383. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22385. * * 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)
  22386. * * 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)
  22387. * @returns the VertexData of the tiled plane
  22388. */
  22389. static CreateTiledPlane(options: {
  22390. pattern?: number;
  22391. tileSize?: number;
  22392. tileWidth?: number;
  22393. tileHeight?: number;
  22394. size?: number;
  22395. width?: number;
  22396. height?: number;
  22397. alignHorizontal?: number;
  22398. alignVertical?: number;
  22399. sideOrientation?: number;
  22400. frontUVs?: Vector4;
  22401. backUVs?: Vector4;
  22402. }): VertexData;
  22403. /**
  22404. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22405. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22406. * * segments sets the number of horizontal strips optional, default 32
  22407. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22408. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22409. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22410. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22411. * * 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
  22412. * * 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
  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 ellipsoid
  22417. */
  22418. static CreateSphere(options: {
  22419. segments?: number;
  22420. diameter?: number;
  22421. diameterX?: number;
  22422. diameterY?: number;
  22423. diameterZ?: number;
  22424. arc?: number;
  22425. slice?: number;
  22426. sideOrientation?: number;
  22427. frontUVs?: Vector4;
  22428. backUVs?: Vector4;
  22429. }): VertexData;
  22430. /**
  22431. * Creates the VertexData for a cylinder, cone or prism
  22432. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22433. * * height sets the height (y direction) of the cylinder, optional, default 2
  22434. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22435. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22436. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22437. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22438. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22439. * * 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
  22440. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22441. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22442. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22443. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22444. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22445. * * 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)
  22446. * * 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)
  22447. * @returns the VertexData of the cylinder, cone or prism
  22448. */
  22449. static CreateCylinder(options: {
  22450. height?: number;
  22451. diameterTop?: number;
  22452. diameterBottom?: number;
  22453. diameter?: number;
  22454. tessellation?: number;
  22455. subdivisions?: number;
  22456. arc?: number;
  22457. faceColors?: Color4[];
  22458. faceUV?: Vector4[];
  22459. hasRings?: boolean;
  22460. enclose?: boolean;
  22461. sideOrientation?: number;
  22462. frontUVs?: Vector4;
  22463. backUVs?: Vector4;
  22464. }): VertexData;
  22465. /**
  22466. * Creates the VertexData for a torus
  22467. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22468. * * diameter the diameter of the torus, optional default 1
  22469. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22470. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22472. * * 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)
  22473. * * 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)
  22474. * @returns the VertexData of the torus
  22475. */
  22476. static CreateTorus(options: {
  22477. diameter?: number;
  22478. thickness?: number;
  22479. tessellation?: number;
  22480. sideOrientation?: number;
  22481. frontUVs?: Vector4;
  22482. backUVs?: Vector4;
  22483. }): VertexData;
  22484. /**
  22485. * Creates the VertexData of the LineSystem
  22486. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22487. * - lines an array of lines, each line being an array of successive Vector3
  22488. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22489. * @returns the VertexData of the LineSystem
  22490. */
  22491. static CreateLineSystem(options: {
  22492. lines: Vector3[][];
  22493. colors?: Nullable<Color4[][]>;
  22494. }): VertexData;
  22495. /**
  22496. * Create the VertexData for a DashedLines
  22497. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22498. * - points an array successive Vector3
  22499. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22500. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22501. * - dashNb the intended total number of dashes, optional, default 200
  22502. * @returns the VertexData for the DashedLines
  22503. */
  22504. static CreateDashedLines(options: {
  22505. points: Vector3[];
  22506. dashSize?: number;
  22507. gapSize?: number;
  22508. dashNb?: number;
  22509. }): VertexData;
  22510. /**
  22511. * Creates the VertexData for a Ground
  22512. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22513. * - width the width (x direction) of the ground, optional, default 1
  22514. * - height the height (z direction) of the ground, optional, default 1
  22515. * - subdivisions the number of subdivisions per side, optional, default 1
  22516. * @returns the VertexData of the Ground
  22517. */
  22518. static CreateGround(options: {
  22519. width?: number;
  22520. height?: number;
  22521. subdivisions?: number;
  22522. subdivisionsX?: number;
  22523. subdivisionsY?: number;
  22524. }): VertexData;
  22525. /**
  22526. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22527. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22528. * * xmin the ground minimum X coordinate, optional, default -1
  22529. * * zmin the ground minimum Z coordinate, optional, default -1
  22530. * * xmax the ground maximum X coordinate, optional, default 1
  22531. * * zmax the ground maximum Z coordinate, optional, default 1
  22532. * * 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}
  22533. * * 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}
  22534. * @returns the VertexData of the TiledGround
  22535. */
  22536. static CreateTiledGround(options: {
  22537. xmin: number;
  22538. zmin: number;
  22539. xmax: number;
  22540. zmax: number;
  22541. subdivisions?: {
  22542. w: number;
  22543. h: number;
  22544. };
  22545. precision?: {
  22546. w: number;
  22547. h: number;
  22548. };
  22549. }): VertexData;
  22550. /**
  22551. * Creates the VertexData of the Ground designed from a heightmap
  22552. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22553. * * width the width (x direction) of the ground
  22554. * * height the height (z direction) of the ground
  22555. * * subdivisions the number of subdivisions per side
  22556. * * minHeight the minimum altitude on the ground, optional, default 0
  22557. * * maxHeight the maximum altitude on the ground, optional default 1
  22558. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22559. * * buffer the array holding the image color data
  22560. * * bufferWidth the width of image
  22561. * * bufferHeight the height of image
  22562. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22563. * @returns the VertexData of the Ground designed from a heightmap
  22564. */
  22565. static CreateGroundFromHeightMap(options: {
  22566. width: number;
  22567. height: number;
  22568. subdivisions: number;
  22569. minHeight: number;
  22570. maxHeight: number;
  22571. colorFilter: Color3;
  22572. buffer: Uint8Array;
  22573. bufferWidth: number;
  22574. bufferHeight: number;
  22575. alphaFilter: number;
  22576. }): VertexData;
  22577. /**
  22578. * Creates the VertexData for a Plane
  22579. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22580. * * size sets the width and height of the plane to the value of size, optional default 1
  22581. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22582. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22584. * * 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)
  22585. * * 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)
  22586. * @returns the VertexData of the box
  22587. */
  22588. static CreatePlane(options: {
  22589. size?: number;
  22590. width?: number;
  22591. height?: number;
  22592. sideOrientation?: number;
  22593. frontUVs?: Vector4;
  22594. backUVs?: Vector4;
  22595. }): VertexData;
  22596. /**
  22597. * Creates the VertexData of the Disc or regular Polygon
  22598. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22599. * * radius the radius of the disc, optional default 0.5
  22600. * * tessellation the number of polygon sides, optional, default 64
  22601. * * 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
  22602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22603. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22604. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22605. * @returns the VertexData of the box
  22606. */
  22607. static CreateDisc(options: {
  22608. radius?: number;
  22609. tessellation?: number;
  22610. arc?: number;
  22611. sideOrientation?: number;
  22612. frontUVs?: Vector4;
  22613. backUVs?: Vector4;
  22614. }): VertexData;
  22615. /**
  22616. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22617. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22618. * @param polygon a mesh built from polygonTriangulation.build()
  22619. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22620. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22621. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22622. * @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)
  22623. * @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)
  22624. * @returns the VertexData of the Polygon
  22625. */
  22626. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22627. /**
  22628. * Creates the VertexData of the IcoSphere
  22629. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22630. * * radius the radius of the IcoSphere, optional default 1
  22631. * * radiusX allows stretching in the x direction, optional, default radius
  22632. * * radiusY allows stretching in the y direction, optional, default radius
  22633. * * radiusZ allows stretching in the z direction, optional, default radius
  22634. * * flat when true creates a flat shaded mesh, optional, default true
  22635. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22637. * * 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)
  22638. * * 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)
  22639. * @returns the VertexData of the IcoSphere
  22640. */
  22641. static CreateIcoSphere(options: {
  22642. radius?: number;
  22643. radiusX?: number;
  22644. radiusY?: number;
  22645. radiusZ?: number;
  22646. flat?: boolean;
  22647. subdivisions?: number;
  22648. sideOrientation?: number;
  22649. frontUVs?: Vector4;
  22650. backUVs?: Vector4;
  22651. }): VertexData;
  22652. /**
  22653. * Creates the VertexData for a Polyhedron
  22654. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22655. * * type provided types are:
  22656. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22657. * * 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)
  22658. * * size the size of the IcoSphere, optional default 1
  22659. * * sizeX allows stretching in the x direction, optional, default size
  22660. * * sizeY allows stretching in the y direction, optional, default size
  22661. * * sizeZ allows stretching in the z direction, optional, default size
  22662. * * 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
  22663. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22664. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22665. * * flat when true creates a flat shaded mesh, optional, default true
  22666. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22667. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22668. * * 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)
  22669. * * 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)
  22670. * @returns the VertexData of the Polyhedron
  22671. */
  22672. static CreatePolyhedron(options: {
  22673. type?: number;
  22674. size?: number;
  22675. sizeX?: number;
  22676. sizeY?: number;
  22677. sizeZ?: number;
  22678. custom?: any;
  22679. faceUV?: Vector4[];
  22680. faceColors?: Color4[];
  22681. flat?: boolean;
  22682. sideOrientation?: number;
  22683. frontUVs?: Vector4;
  22684. backUVs?: Vector4;
  22685. }): VertexData;
  22686. /**
  22687. * Creates the VertexData for a TorusKnot
  22688. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22689. * * radius the radius of the torus knot, optional, default 2
  22690. * * tube the thickness of the tube, optional, default 0.5
  22691. * * radialSegments the number of sides on each tube segments, optional, default 32
  22692. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22693. * * p the number of windings around the z axis, optional, default 2
  22694. * * q the number of windings around the x axis, optional, default 3
  22695. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22696. * * 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)
  22697. * * 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)
  22698. * @returns the VertexData of the Torus Knot
  22699. */
  22700. static CreateTorusKnot(options: {
  22701. radius?: number;
  22702. tube?: number;
  22703. radialSegments?: number;
  22704. tubularSegments?: number;
  22705. p?: number;
  22706. q?: number;
  22707. sideOrientation?: number;
  22708. frontUVs?: Vector4;
  22709. backUVs?: Vector4;
  22710. }): VertexData;
  22711. /**
  22712. * Compute normals for given positions and indices
  22713. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22714. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22715. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22716. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22717. * * facetNormals : optional array of facet normals (vector3)
  22718. * * facetPositions : optional array of facet positions (vector3)
  22719. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22720. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22721. * * bInfo : optional bounding info, required for facetPartitioning computation
  22722. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22723. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22724. * * useRightHandedSystem: optional boolean to for right handed system computation
  22725. * * depthSort : optional boolean to enable the facet depth sort computation
  22726. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22727. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22728. */
  22729. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22730. facetNormals?: any;
  22731. facetPositions?: any;
  22732. facetPartitioning?: any;
  22733. ratio?: number;
  22734. bInfo?: any;
  22735. bbSize?: Vector3;
  22736. subDiv?: any;
  22737. useRightHandedSystem?: boolean;
  22738. depthSort?: boolean;
  22739. distanceTo?: Vector3;
  22740. depthSortedFacets?: any;
  22741. }): void;
  22742. /** @hidden */
  22743. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22744. /**
  22745. * Applies VertexData created from the imported parameters to the geometry
  22746. * @param parsedVertexData the parsed data from an imported file
  22747. * @param geometry the geometry to apply the VertexData to
  22748. */
  22749. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22750. }
  22751. }
  22752. declare module "babylonjs/Morph/morphTarget" {
  22753. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22754. import { Observable } from "babylonjs/Misc/observable";
  22755. import { Nullable, FloatArray } from "babylonjs/types";
  22756. import { Scene } from "babylonjs/scene";
  22757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22758. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22759. /**
  22760. * Defines a target to use with MorphTargetManager
  22761. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22762. */
  22763. export class MorphTarget implements IAnimatable {
  22764. /** defines the name of the target */
  22765. name: string;
  22766. /**
  22767. * Gets or sets the list of animations
  22768. */
  22769. animations: import("babylonjs/Animations/animation").Animation[];
  22770. private _scene;
  22771. private _positions;
  22772. private _normals;
  22773. private _tangents;
  22774. private _uvs;
  22775. private _influence;
  22776. /**
  22777. * Observable raised when the influence changes
  22778. */
  22779. onInfluenceChanged: Observable<boolean>;
  22780. /** @hidden */
  22781. _onDataLayoutChanged: Observable<void>;
  22782. /**
  22783. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22784. */
  22785. influence: number;
  22786. /**
  22787. * Gets or sets the id of the morph Target
  22788. */
  22789. id: string;
  22790. private _animationPropertiesOverride;
  22791. /**
  22792. * Gets or sets the animation properties override
  22793. */
  22794. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22795. /**
  22796. * Creates a new MorphTarget
  22797. * @param name defines the name of the target
  22798. * @param influence defines the influence to use
  22799. * @param scene defines the scene the morphtarget belongs to
  22800. */
  22801. constructor(
  22802. /** defines the name of the target */
  22803. name: string, influence?: number, scene?: Nullable<Scene>);
  22804. /**
  22805. * Gets a boolean defining if the target contains position data
  22806. */
  22807. readonly hasPositions: boolean;
  22808. /**
  22809. * Gets a boolean defining if the target contains normal data
  22810. */
  22811. readonly hasNormals: boolean;
  22812. /**
  22813. * Gets a boolean defining if the target contains tangent data
  22814. */
  22815. readonly hasTangents: boolean;
  22816. /**
  22817. * Gets a boolean defining if the target contains texture coordinates data
  22818. */
  22819. readonly hasUVs: boolean;
  22820. /**
  22821. * Affects position data to this target
  22822. * @param data defines the position data to use
  22823. */
  22824. setPositions(data: Nullable<FloatArray>): void;
  22825. /**
  22826. * Gets the position data stored in this target
  22827. * @returns a FloatArray containing the position data (or null if not present)
  22828. */
  22829. getPositions(): Nullable<FloatArray>;
  22830. /**
  22831. * Affects normal data to this target
  22832. * @param data defines the normal data to use
  22833. */
  22834. setNormals(data: Nullable<FloatArray>): void;
  22835. /**
  22836. * Gets the normal data stored in this target
  22837. * @returns a FloatArray containing the normal data (or null if not present)
  22838. */
  22839. getNormals(): Nullable<FloatArray>;
  22840. /**
  22841. * Affects tangent data to this target
  22842. * @param data defines the tangent data to use
  22843. */
  22844. setTangents(data: Nullable<FloatArray>): void;
  22845. /**
  22846. * Gets the tangent data stored in this target
  22847. * @returns a FloatArray containing the tangent data (or null if not present)
  22848. */
  22849. getTangents(): Nullable<FloatArray>;
  22850. /**
  22851. * Affects texture coordinates data to this target
  22852. * @param data defines the texture coordinates data to use
  22853. */
  22854. setUVs(data: Nullable<FloatArray>): void;
  22855. /**
  22856. * Gets the texture coordinates data stored in this target
  22857. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22858. */
  22859. getUVs(): Nullable<FloatArray>;
  22860. /**
  22861. * Serializes the current target into a Serialization object
  22862. * @returns the serialized object
  22863. */
  22864. serialize(): any;
  22865. /**
  22866. * Returns the string "MorphTarget"
  22867. * @returns "MorphTarget"
  22868. */
  22869. getClassName(): string;
  22870. /**
  22871. * Creates a new target from serialized data
  22872. * @param serializationObject defines the serialized data to use
  22873. * @returns a new MorphTarget
  22874. */
  22875. static Parse(serializationObject: any): MorphTarget;
  22876. /**
  22877. * Creates a MorphTarget from mesh data
  22878. * @param mesh defines the source mesh
  22879. * @param name defines the name to use for the new target
  22880. * @param influence defines the influence to attach to the target
  22881. * @returns a new MorphTarget
  22882. */
  22883. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22884. }
  22885. }
  22886. declare module "babylonjs/Morph/morphTargetManager" {
  22887. import { Nullable } from "babylonjs/types";
  22888. import { Scene } from "babylonjs/scene";
  22889. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22890. /**
  22891. * This class is used to deform meshes using morphing between different targets
  22892. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22893. */
  22894. export class MorphTargetManager {
  22895. private _targets;
  22896. private _targetInfluenceChangedObservers;
  22897. private _targetDataLayoutChangedObservers;
  22898. private _activeTargets;
  22899. private _scene;
  22900. private _influences;
  22901. private _supportsNormals;
  22902. private _supportsTangents;
  22903. private _supportsUVs;
  22904. private _vertexCount;
  22905. private _uniqueId;
  22906. private _tempInfluences;
  22907. /**
  22908. * Gets or sets a boolean indicating if normals must be morphed
  22909. */
  22910. enableNormalMorphing: boolean;
  22911. /**
  22912. * Gets or sets a boolean indicating if tangents must be morphed
  22913. */
  22914. enableTangentMorphing: boolean;
  22915. /**
  22916. * Gets or sets a boolean indicating if UV must be morphed
  22917. */
  22918. enableUVMorphing: boolean;
  22919. /**
  22920. * Creates a new MorphTargetManager
  22921. * @param scene defines the current scene
  22922. */
  22923. constructor(scene?: Nullable<Scene>);
  22924. /**
  22925. * Gets the unique ID of this manager
  22926. */
  22927. readonly uniqueId: number;
  22928. /**
  22929. * Gets the number of vertices handled by this manager
  22930. */
  22931. readonly vertexCount: number;
  22932. /**
  22933. * Gets a boolean indicating if this manager supports morphing of normals
  22934. */
  22935. readonly supportsNormals: boolean;
  22936. /**
  22937. * Gets a boolean indicating if this manager supports morphing of tangents
  22938. */
  22939. readonly supportsTangents: boolean;
  22940. /**
  22941. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22942. */
  22943. readonly supportsUVs: boolean;
  22944. /**
  22945. * Gets the number of targets stored in this manager
  22946. */
  22947. readonly numTargets: number;
  22948. /**
  22949. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22950. */
  22951. readonly numInfluencers: number;
  22952. /**
  22953. * Gets the list of influences (one per target)
  22954. */
  22955. readonly influences: Float32Array;
  22956. /**
  22957. * Gets the active target at specified index. An active target is a target with an influence > 0
  22958. * @param index defines the index to check
  22959. * @returns the requested target
  22960. */
  22961. getActiveTarget(index: number): MorphTarget;
  22962. /**
  22963. * Gets the target at specified index
  22964. * @param index defines the index to check
  22965. * @returns the requested target
  22966. */
  22967. getTarget(index: number): MorphTarget;
  22968. /**
  22969. * Add a new target to this manager
  22970. * @param target defines the target to add
  22971. */
  22972. addTarget(target: MorphTarget): void;
  22973. /**
  22974. * Removes a target from the manager
  22975. * @param target defines the target to remove
  22976. */
  22977. removeTarget(target: MorphTarget): void;
  22978. /**
  22979. * Serializes the current manager into a Serialization object
  22980. * @returns the serialized object
  22981. */
  22982. serialize(): any;
  22983. private _syncActiveTargets;
  22984. /**
  22985. * Syncrhonize the targets with all the meshes using this morph target manager
  22986. */
  22987. synchronize(): void;
  22988. /**
  22989. * Creates a new MorphTargetManager from serialized data
  22990. * @param serializationObject defines the serialized data
  22991. * @param scene defines the hosting scene
  22992. * @returns the new MorphTargetManager
  22993. */
  22994. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22995. }
  22996. }
  22997. declare module "babylonjs/Meshes/meshLODLevel" {
  22998. import { Mesh } from "babylonjs/Meshes/mesh";
  22999. import { Nullable } from "babylonjs/types";
  23000. /**
  23001. * Class used to represent a specific level of detail of a mesh
  23002. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23003. */
  23004. export class MeshLODLevel {
  23005. /** Defines the distance where this level should start being displayed */
  23006. distance: number;
  23007. /** Defines the mesh to use to render this level */
  23008. mesh: Nullable<Mesh>;
  23009. /**
  23010. * Creates a new LOD level
  23011. * @param distance defines the distance where this level should star being displayed
  23012. * @param mesh defines the mesh to use to render this level
  23013. */
  23014. constructor(
  23015. /** Defines the distance where this level should start being displayed */
  23016. distance: number,
  23017. /** Defines the mesh to use to render this level */
  23018. mesh: Nullable<Mesh>);
  23019. }
  23020. }
  23021. declare module "babylonjs/Meshes/groundMesh" {
  23022. import { Scene } from "babylonjs/scene";
  23023. import { Vector3 } from "babylonjs/Maths/math.vector";
  23024. import { Mesh } from "babylonjs/Meshes/mesh";
  23025. /**
  23026. * Mesh representing the gorund
  23027. */
  23028. export class GroundMesh extends Mesh {
  23029. /** If octree should be generated */
  23030. generateOctree: boolean;
  23031. private _heightQuads;
  23032. /** @hidden */
  23033. _subdivisionsX: number;
  23034. /** @hidden */
  23035. _subdivisionsY: number;
  23036. /** @hidden */
  23037. _width: number;
  23038. /** @hidden */
  23039. _height: number;
  23040. /** @hidden */
  23041. _minX: number;
  23042. /** @hidden */
  23043. _maxX: number;
  23044. /** @hidden */
  23045. _minZ: number;
  23046. /** @hidden */
  23047. _maxZ: number;
  23048. constructor(name: string, scene: Scene);
  23049. /**
  23050. * "GroundMesh"
  23051. * @returns "GroundMesh"
  23052. */
  23053. getClassName(): string;
  23054. /**
  23055. * The minimum of x and y subdivisions
  23056. */
  23057. readonly subdivisions: number;
  23058. /**
  23059. * X subdivisions
  23060. */
  23061. readonly subdivisionsX: number;
  23062. /**
  23063. * Y subdivisions
  23064. */
  23065. readonly subdivisionsY: number;
  23066. /**
  23067. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23068. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23069. * @param chunksCount the number of subdivisions for x and y
  23070. * @param octreeBlocksSize (Default: 32)
  23071. */
  23072. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23073. /**
  23074. * Returns a height (y) value in the Worl system :
  23075. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23076. * @param x x coordinate
  23077. * @param z z coordinate
  23078. * @returns the ground y position if (x, z) are outside the ground surface.
  23079. */
  23080. getHeightAtCoordinates(x: number, z: number): number;
  23081. /**
  23082. * Returns a normalized vector (Vector3) orthogonal to the ground
  23083. * at the ground coordinates (x, z) expressed in the World system.
  23084. * @param x x coordinate
  23085. * @param z z coordinate
  23086. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23087. */
  23088. getNormalAtCoordinates(x: number, z: number): Vector3;
  23089. /**
  23090. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23091. * at the ground coordinates (x, z) expressed in the World system.
  23092. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23093. * @param x x coordinate
  23094. * @param z z coordinate
  23095. * @param ref vector to store the result
  23096. * @returns the GroundMesh.
  23097. */
  23098. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23099. /**
  23100. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23101. * if the ground has been updated.
  23102. * This can be used in the render loop.
  23103. * @returns the GroundMesh.
  23104. */
  23105. updateCoordinateHeights(): GroundMesh;
  23106. private _getFacetAt;
  23107. private _initHeightQuads;
  23108. private _computeHeightQuads;
  23109. /**
  23110. * Serializes this ground mesh
  23111. * @param serializationObject object to write serialization to
  23112. */
  23113. serialize(serializationObject: any): void;
  23114. /**
  23115. * Parses a serialized ground mesh
  23116. * @param parsedMesh the serialized mesh
  23117. * @param scene the scene to create the ground mesh in
  23118. * @returns the created ground mesh
  23119. */
  23120. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23121. }
  23122. }
  23123. declare module "babylonjs/Physics/physicsJoint" {
  23124. import { Vector3 } from "babylonjs/Maths/math.vector";
  23125. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23126. /**
  23127. * Interface for Physics-Joint data
  23128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23129. */
  23130. export interface PhysicsJointData {
  23131. /**
  23132. * The main pivot of the joint
  23133. */
  23134. mainPivot?: Vector3;
  23135. /**
  23136. * The connected pivot of the joint
  23137. */
  23138. connectedPivot?: Vector3;
  23139. /**
  23140. * The main axis of the joint
  23141. */
  23142. mainAxis?: Vector3;
  23143. /**
  23144. * The connected axis of the joint
  23145. */
  23146. connectedAxis?: Vector3;
  23147. /**
  23148. * The collision of the joint
  23149. */
  23150. collision?: boolean;
  23151. /**
  23152. * Native Oimo/Cannon/Energy data
  23153. */
  23154. nativeParams?: any;
  23155. }
  23156. /**
  23157. * This is a holder class for the physics joint created by the physics plugin
  23158. * It holds a set of functions to control the underlying joint
  23159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23160. */
  23161. export class PhysicsJoint {
  23162. /**
  23163. * The type of the physics joint
  23164. */
  23165. type: number;
  23166. /**
  23167. * The data for the physics joint
  23168. */
  23169. jointData: PhysicsJointData;
  23170. private _physicsJoint;
  23171. protected _physicsPlugin: IPhysicsEnginePlugin;
  23172. /**
  23173. * Initializes the physics joint
  23174. * @param type The type of the physics joint
  23175. * @param jointData The data for the physics joint
  23176. */
  23177. constructor(
  23178. /**
  23179. * The type of the physics joint
  23180. */
  23181. type: number,
  23182. /**
  23183. * The data for the physics joint
  23184. */
  23185. jointData: PhysicsJointData);
  23186. /**
  23187. * Gets the physics joint
  23188. */
  23189. /**
  23190. * Sets the physics joint
  23191. */
  23192. physicsJoint: any;
  23193. /**
  23194. * Sets the physics plugin
  23195. */
  23196. physicsPlugin: IPhysicsEnginePlugin;
  23197. /**
  23198. * Execute a function that is physics-plugin specific.
  23199. * @param {Function} func the function that will be executed.
  23200. * It accepts two parameters: the physics world and the physics joint
  23201. */
  23202. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23203. /**
  23204. * Distance-Joint type
  23205. */
  23206. static DistanceJoint: number;
  23207. /**
  23208. * Hinge-Joint type
  23209. */
  23210. static HingeJoint: number;
  23211. /**
  23212. * Ball-and-Socket joint type
  23213. */
  23214. static BallAndSocketJoint: number;
  23215. /**
  23216. * Wheel-Joint type
  23217. */
  23218. static WheelJoint: number;
  23219. /**
  23220. * Slider-Joint type
  23221. */
  23222. static SliderJoint: number;
  23223. /**
  23224. * Prismatic-Joint type
  23225. */
  23226. static PrismaticJoint: number;
  23227. /**
  23228. * Universal-Joint type
  23229. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23230. */
  23231. static UniversalJoint: number;
  23232. /**
  23233. * Hinge-Joint 2 type
  23234. */
  23235. static Hinge2Joint: number;
  23236. /**
  23237. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23238. */
  23239. static PointToPointJoint: number;
  23240. /**
  23241. * Spring-Joint type
  23242. */
  23243. static SpringJoint: number;
  23244. /**
  23245. * Lock-Joint type
  23246. */
  23247. static LockJoint: number;
  23248. }
  23249. /**
  23250. * A class representing a physics distance joint
  23251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23252. */
  23253. export class DistanceJoint extends PhysicsJoint {
  23254. /**
  23255. *
  23256. * @param jointData The data for the Distance-Joint
  23257. */
  23258. constructor(jointData: DistanceJointData);
  23259. /**
  23260. * Update the predefined distance.
  23261. * @param maxDistance The maximum preferred distance
  23262. * @param minDistance The minimum preferred distance
  23263. */
  23264. updateDistance(maxDistance: number, minDistance?: number): void;
  23265. }
  23266. /**
  23267. * Represents a Motor-Enabled Joint
  23268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23269. */
  23270. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23271. /**
  23272. * Initializes the Motor-Enabled Joint
  23273. * @param type The type of the joint
  23274. * @param jointData The physica joint data for the joint
  23275. */
  23276. constructor(type: number, jointData: PhysicsJointData);
  23277. /**
  23278. * Set the motor values.
  23279. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23280. * @param force the force to apply
  23281. * @param maxForce max force for this motor.
  23282. */
  23283. setMotor(force?: number, maxForce?: number): void;
  23284. /**
  23285. * Set the motor's limits.
  23286. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23287. * @param upperLimit The upper limit of the motor
  23288. * @param lowerLimit The lower limit of the motor
  23289. */
  23290. setLimit(upperLimit: number, lowerLimit?: number): void;
  23291. }
  23292. /**
  23293. * This class represents a single physics Hinge-Joint
  23294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23295. */
  23296. export class HingeJoint extends MotorEnabledJoint {
  23297. /**
  23298. * Initializes the Hinge-Joint
  23299. * @param jointData The joint data for the Hinge-Joint
  23300. */
  23301. constructor(jointData: PhysicsJointData);
  23302. /**
  23303. * Set the motor values.
  23304. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23305. * @param {number} force the force to apply
  23306. * @param {number} maxForce max force for this motor.
  23307. */
  23308. setMotor(force?: number, maxForce?: number): void;
  23309. /**
  23310. * Set the motor's limits.
  23311. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23312. * @param upperLimit The upper limit of the motor
  23313. * @param lowerLimit The lower limit of the motor
  23314. */
  23315. setLimit(upperLimit: number, lowerLimit?: number): void;
  23316. }
  23317. /**
  23318. * This class represents a dual hinge physics joint (same as wheel joint)
  23319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23320. */
  23321. export class Hinge2Joint extends MotorEnabledJoint {
  23322. /**
  23323. * Initializes the Hinge2-Joint
  23324. * @param jointData The joint data for the Hinge2-Joint
  23325. */
  23326. constructor(jointData: PhysicsJointData);
  23327. /**
  23328. * Set the motor values.
  23329. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23330. * @param {number} targetSpeed the speed the motor is to reach
  23331. * @param {number} maxForce max force for this motor.
  23332. * @param {motorIndex} the motor's index, 0 or 1.
  23333. */
  23334. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23335. /**
  23336. * Set the motor limits.
  23337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23338. * @param {number} upperLimit the upper limit
  23339. * @param {number} lowerLimit lower limit
  23340. * @param {motorIndex} the motor's index, 0 or 1.
  23341. */
  23342. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23343. }
  23344. /**
  23345. * Interface for a motor enabled joint
  23346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23347. */
  23348. export interface IMotorEnabledJoint {
  23349. /**
  23350. * Physics joint
  23351. */
  23352. physicsJoint: any;
  23353. /**
  23354. * Sets the motor of the motor-enabled joint
  23355. * @param force The force of the motor
  23356. * @param maxForce The maximum force of the motor
  23357. * @param motorIndex The index of the motor
  23358. */
  23359. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23360. /**
  23361. * Sets the limit of the motor
  23362. * @param upperLimit The upper limit of the motor
  23363. * @param lowerLimit The lower limit of the motor
  23364. * @param motorIndex The index of the motor
  23365. */
  23366. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23367. }
  23368. /**
  23369. * Joint data for a Distance-Joint
  23370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23371. */
  23372. export interface DistanceJointData extends PhysicsJointData {
  23373. /**
  23374. * Max distance the 2 joint objects can be apart
  23375. */
  23376. maxDistance: number;
  23377. }
  23378. /**
  23379. * Joint data from a spring joint
  23380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23381. */
  23382. export interface SpringJointData extends PhysicsJointData {
  23383. /**
  23384. * Length of the spring
  23385. */
  23386. length: number;
  23387. /**
  23388. * Stiffness of the spring
  23389. */
  23390. stiffness: number;
  23391. /**
  23392. * Damping of the spring
  23393. */
  23394. damping: number;
  23395. /** this callback will be called when applying the force to the impostors. */
  23396. forceApplicationCallback: () => void;
  23397. }
  23398. }
  23399. declare module "babylonjs/Physics/physicsRaycastResult" {
  23400. import { Vector3 } from "babylonjs/Maths/math.vector";
  23401. /**
  23402. * Holds the data for the raycast result
  23403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23404. */
  23405. export class PhysicsRaycastResult {
  23406. private _hasHit;
  23407. private _hitDistance;
  23408. private _hitNormalWorld;
  23409. private _hitPointWorld;
  23410. private _rayFromWorld;
  23411. private _rayToWorld;
  23412. /**
  23413. * Gets if there was a hit
  23414. */
  23415. readonly hasHit: boolean;
  23416. /**
  23417. * Gets the distance from the hit
  23418. */
  23419. readonly hitDistance: number;
  23420. /**
  23421. * Gets the hit normal/direction in the world
  23422. */
  23423. readonly hitNormalWorld: Vector3;
  23424. /**
  23425. * Gets the hit point in the world
  23426. */
  23427. readonly hitPointWorld: Vector3;
  23428. /**
  23429. * Gets the ray "start point" of the ray in the world
  23430. */
  23431. readonly rayFromWorld: Vector3;
  23432. /**
  23433. * Gets the ray "end point" of the ray in the world
  23434. */
  23435. readonly rayToWorld: Vector3;
  23436. /**
  23437. * Sets the hit data (normal & point in world space)
  23438. * @param hitNormalWorld defines the normal in world space
  23439. * @param hitPointWorld defines the point in world space
  23440. */
  23441. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23442. /**
  23443. * Sets the distance from the start point to the hit point
  23444. * @param distance
  23445. */
  23446. setHitDistance(distance: number): void;
  23447. /**
  23448. * Calculates the distance manually
  23449. */
  23450. calculateHitDistance(): void;
  23451. /**
  23452. * Resets all the values to default
  23453. * @param from The from point on world space
  23454. * @param to The to point on world space
  23455. */
  23456. reset(from?: Vector3, to?: Vector3): void;
  23457. }
  23458. /**
  23459. * Interface for the size containing width and height
  23460. */
  23461. interface IXYZ {
  23462. /**
  23463. * X
  23464. */
  23465. x: number;
  23466. /**
  23467. * Y
  23468. */
  23469. y: number;
  23470. /**
  23471. * Z
  23472. */
  23473. z: number;
  23474. }
  23475. }
  23476. declare module "babylonjs/Physics/IPhysicsEngine" {
  23477. import { Nullable } from "babylonjs/types";
  23478. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23480. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23481. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23482. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23483. /**
  23484. * Interface used to describe a physics joint
  23485. */
  23486. export interface PhysicsImpostorJoint {
  23487. /** Defines the main impostor to which the joint is linked */
  23488. mainImpostor: PhysicsImpostor;
  23489. /** Defines the impostor that is connected to the main impostor using this joint */
  23490. connectedImpostor: PhysicsImpostor;
  23491. /** Defines the joint itself */
  23492. joint: PhysicsJoint;
  23493. }
  23494. /** @hidden */
  23495. export interface IPhysicsEnginePlugin {
  23496. world: any;
  23497. name: string;
  23498. setGravity(gravity: Vector3): void;
  23499. setTimeStep(timeStep: number): void;
  23500. getTimeStep(): number;
  23501. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23502. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23503. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23504. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23505. removePhysicsBody(impostor: PhysicsImpostor): void;
  23506. generateJoint(joint: PhysicsImpostorJoint): void;
  23507. removeJoint(joint: PhysicsImpostorJoint): void;
  23508. isSupported(): boolean;
  23509. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23510. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23511. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23512. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23513. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23514. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23515. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23516. getBodyMass(impostor: PhysicsImpostor): number;
  23517. getBodyFriction(impostor: PhysicsImpostor): number;
  23518. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23519. getBodyRestitution(impostor: PhysicsImpostor): number;
  23520. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23521. getBodyPressure?(impostor: PhysicsImpostor): number;
  23522. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23523. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23524. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23525. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23526. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23527. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23528. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23529. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23530. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23531. sleepBody(impostor: PhysicsImpostor): void;
  23532. wakeUpBody(impostor: PhysicsImpostor): void;
  23533. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23534. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23535. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23536. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23537. getRadius(impostor: PhysicsImpostor): number;
  23538. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23539. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23540. dispose(): void;
  23541. }
  23542. /**
  23543. * Interface used to define a physics engine
  23544. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23545. */
  23546. export interface IPhysicsEngine {
  23547. /**
  23548. * Gets the gravity vector used by the simulation
  23549. */
  23550. gravity: Vector3;
  23551. /**
  23552. * Sets the gravity vector used by the simulation
  23553. * @param gravity defines the gravity vector to use
  23554. */
  23555. setGravity(gravity: Vector3): void;
  23556. /**
  23557. * Set the time step of the physics engine.
  23558. * Default is 1/60.
  23559. * To slow it down, enter 1/600 for example.
  23560. * To speed it up, 1/30
  23561. * @param newTimeStep the new timestep to apply to this world.
  23562. */
  23563. setTimeStep(newTimeStep: number): void;
  23564. /**
  23565. * Get the time step of the physics engine.
  23566. * @returns the current time step
  23567. */
  23568. getTimeStep(): number;
  23569. /**
  23570. * Release all resources
  23571. */
  23572. dispose(): void;
  23573. /**
  23574. * Gets the name of the current physics plugin
  23575. * @returns the name of the plugin
  23576. */
  23577. getPhysicsPluginName(): string;
  23578. /**
  23579. * Adding a new impostor for the impostor tracking.
  23580. * This will be done by the impostor itself.
  23581. * @param impostor the impostor to add
  23582. */
  23583. addImpostor(impostor: PhysicsImpostor): void;
  23584. /**
  23585. * Remove an impostor from the engine.
  23586. * This impostor and its mesh will not longer be updated by the physics engine.
  23587. * @param impostor the impostor to remove
  23588. */
  23589. removeImpostor(impostor: PhysicsImpostor): void;
  23590. /**
  23591. * Add a joint to the physics engine
  23592. * @param mainImpostor defines the main impostor to which the joint is added.
  23593. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23594. * @param joint defines the joint that will connect both impostors.
  23595. */
  23596. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23597. /**
  23598. * Removes a joint from the simulation
  23599. * @param mainImpostor defines the impostor used with the joint
  23600. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23601. * @param joint defines the joint to remove
  23602. */
  23603. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23604. /**
  23605. * Gets the current plugin used to run the simulation
  23606. * @returns current plugin
  23607. */
  23608. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23609. /**
  23610. * Gets the list of physic impostors
  23611. * @returns an array of PhysicsImpostor
  23612. */
  23613. getImpostors(): Array<PhysicsImpostor>;
  23614. /**
  23615. * Gets the impostor for a physics enabled object
  23616. * @param object defines the object impersonated by the impostor
  23617. * @returns the PhysicsImpostor or null if not found
  23618. */
  23619. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23620. /**
  23621. * Gets the impostor for a physics body object
  23622. * @param body defines physics body used by the impostor
  23623. * @returns the PhysicsImpostor or null if not found
  23624. */
  23625. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23626. /**
  23627. * Does a raycast in the physics world
  23628. * @param from when should the ray start?
  23629. * @param to when should the ray end?
  23630. * @returns PhysicsRaycastResult
  23631. */
  23632. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23633. /**
  23634. * Called by the scene. No need to call it.
  23635. * @param delta defines the timespam between frames
  23636. */
  23637. _step(delta: number): void;
  23638. }
  23639. }
  23640. declare module "babylonjs/Physics/physicsImpostor" {
  23641. import { Nullable, IndicesArray } from "babylonjs/types";
  23642. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23643. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23645. import { Scene } from "babylonjs/scene";
  23646. import { Bone } from "babylonjs/Bones/bone";
  23647. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23648. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23649. import { Space } from "babylonjs/Maths/math.axis";
  23650. /**
  23651. * The interface for the physics imposter parameters
  23652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23653. */
  23654. export interface PhysicsImpostorParameters {
  23655. /**
  23656. * The mass of the physics imposter
  23657. */
  23658. mass: number;
  23659. /**
  23660. * The friction of the physics imposter
  23661. */
  23662. friction?: number;
  23663. /**
  23664. * The coefficient of restitution of the physics imposter
  23665. */
  23666. restitution?: number;
  23667. /**
  23668. * The native options of the physics imposter
  23669. */
  23670. nativeOptions?: any;
  23671. /**
  23672. * Specifies if the parent should be ignored
  23673. */
  23674. ignoreParent?: boolean;
  23675. /**
  23676. * Specifies if bi-directional transformations should be disabled
  23677. */
  23678. disableBidirectionalTransformation?: boolean;
  23679. /**
  23680. * The pressure inside the physics imposter, soft object only
  23681. */
  23682. pressure?: number;
  23683. /**
  23684. * The stiffness the physics imposter, soft object only
  23685. */
  23686. stiffness?: number;
  23687. /**
  23688. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23689. */
  23690. velocityIterations?: number;
  23691. /**
  23692. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23693. */
  23694. positionIterations?: number;
  23695. /**
  23696. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23697. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23698. * Add to fix multiple points
  23699. */
  23700. fixedPoints?: number;
  23701. /**
  23702. * The collision margin around a soft object
  23703. */
  23704. margin?: number;
  23705. /**
  23706. * The collision margin around a soft object
  23707. */
  23708. damping?: number;
  23709. /**
  23710. * The path for a rope based on an extrusion
  23711. */
  23712. path?: any;
  23713. /**
  23714. * The shape of an extrusion used for a rope based on an extrusion
  23715. */
  23716. shape?: any;
  23717. }
  23718. /**
  23719. * Interface for a physics-enabled object
  23720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23721. */
  23722. export interface IPhysicsEnabledObject {
  23723. /**
  23724. * The position of the physics-enabled object
  23725. */
  23726. position: Vector3;
  23727. /**
  23728. * The rotation of the physics-enabled object
  23729. */
  23730. rotationQuaternion: Nullable<Quaternion>;
  23731. /**
  23732. * The scale of the physics-enabled object
  23733. */
  23734. scaling: Vector3;
  23735. /**
  23736. * The rotation of the physics-enabled object
  23737. */
  23738. rotation?: Vector3;
  23739. /**
  23740. * The parent of the physics-enabled object
  23741. */
  23742. parent?: any;
  23743. /**
  23744. * The bounding info of the physics-enabled object
  23745. * @returns The bounding info of the physics-enabled object
  23746. */
  23747. getBoundingInfo(): BoundingInfo;
  23748. /**
  23749. * Computes the world matrix
  23750. * @param force Specifies if the world matrix should be computed by force
  23751. * @returns A world matrix
  23752. */
  23753. computeWorldMatrix(force: boolean): Matrix;
  23754. /**
  23755. * Gets the world matrix
  23756. * @returns A world matrix
  23757. */
  23758. getWorldMatrix?(): Matrix;
  23759. /**
  23760. * Gets the child meshes
  23761. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23762. * @returns An array of abstract meshes
  23763. */
  23764. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23765. /**
  23766. * Gets the vertex data
  23767. * @param kind The type of vertex data
  23768. * @returns A nullable array of numbers, or a float32 array
  23769. */
  23770. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23771. /**
  23772. * Gets the indices from the mesh
  23773. * @returns A nullable array of index arrays
  23774. */
  23775. getIndices?(): Nullable<IndicesArray>;
  23776. /**
  23777. * Gets the scene from the mesh
  23778. * @returns the indices array or null
  23779. */
  23780. getScene?(): Scene;
  23781. /**
  23782. * Gets the absolute position from the mesh
  23783. * @returns the absolute position
  23784. */
  23785. getAbsolutePosition(): Vector3;
  23786. /**
  23787. * Gets the absolute pivot point from the mesh
  23788. * @returns the absolute pivot point
  23789. */
  23790. getAbsolutePivotPoint(): Vector3;
  23791. /**
  23792. * Rotates the mesh
  23793. * @param axis The axis of rotation
  23794. * @param amount The amount of rotation
  23795. * @param space The space of the rotation
  23796. * @returns The rotation transform node
  23797. */
  23798. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23799. /**
  23800. * Translates the mesh
  23801. * @param axis The axis of translation
  23802. * @param distance The distance of translation
  23803. * @param space The space of the translation
  23804. * @returns The transform node
  23805. */
  23806. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23807. /**
  23808. * Sets the absolute position of the mesh
  23809. * @param absolutePosition The absolute position of the mesh
  23810. * @returns The transform node
  23811. */
  23812. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23813. /**
  23814. * Gets the class name of the mesh
  23815. * @returns The class name
  23816. */
  23817. getClassName(): string;
  23818. }
  23819. /**
  23820. * Represents a physics imposter
  23821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23822. */
  23823. export class PhysicsImpostor {
  23824. /**
  23825. * The physics-enabled object used as the physics imposter
  23826. */
  23827. object: IPhysicsEnabledObject;
  23828. /**
  23829. * The type of the physics imposter
  23830. */
  23831. type: number;
  23832. private _options;
  23833. private _scene?;
  23834. /**
  23835. * The default object size of the imposter
  23836. */
  23837. static DEFAULT_OBJECT_SIZE: Vector3;
  23838. /**
  23839. * The identity quaternion of the imposter
  23840. */
  23841. static IDENTITY_QUATERNION: Quaternion;
  23842. /** @hidden */
  23843. _pluginData: any;
  23844. private _physicsEngine;
  23845. private _physicsBody;
  23846. private _bodyUpdateRequired;
  23847. private _onBeforePhysicsStepCallbacks;
  23848. private _onAfterPhysicsStepCallbacks;
  23849. /** @hidden */
  23850. _onPhysicsCollideCallbacks: Array<{
  23851. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23852. otherImpostors: Array<PhysicsImpostor>;
  23853. }>;
  23854. private _deltaPosition;
  23855. private _deltaRotation;
  23856. private _deltaRotationConjugated;
  23857. /** @hidden */
  23858. _isFromLine: boolean;
  23859. private _parent;
  23860. private _isDisposed;
  23861. private static _tmpVecs;
  23862. private static _tmpQuat;
  23863. /**
  23864. * Specifies if the physics imposter is disposed
  23865. */
  23866. readonly isDisposed: boolean;
  23867. /**
  23868. * Gets the mass of the physics imposter
  23869. */
  23870. mass: number;
  23871. /**
  23872. * Gets the coefficient of friction
  23873. */
  23874. /**
  23875. * Sets the coefficient of friction
  23876. */
  23877. friction: number;
  23878. /**
  23879. * Gets the coefficient of restitution
  23880. */
  23881. /**
  23882. * Sets the coefficient of restitution
  23883. */
  23884. restitution: number;
  23885. /**
  23886. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23887. */
  23888. /**
  23889. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23890. */
  23891. pressure: number;
  23892. /**
  23893. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23894. */
  23895. /**
  23896. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23897. */
  23898. stiffness: number;
  23899. /**
  23900. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23901. */
  23902. /**
  23903. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23904. */
  23905. velocityIterations: number;
  23906. /**
  23907. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23908. */
  23909. /**
  23910. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23911. */
  23912. positionIterations: number;
  23913. /**
  23914. * The unique id of the physics imposter
  23915. * set by the physics engine when adding this impostor to the array
  23916. */
  23917. uniqueId: number;
  23918. /**
  23919. * @hidden
  23920. */
  23921. soft: boolean;
  23922. /**
  23923. * @hidden
  23924. */
  23925. segments: number;
  23926. private _joints;
  23927. /**
  23928. * Initializes the physics imposter
  23929. * @param object The physics-enabled object used as the physics imposter
  23930. * @param type The type of the physics imposter
  23931. * @param _options The options for the physics imposter
  23932. * @param _scene The Babylon scene
  23933. */
  23934. constructor(
  23935. /**
  23936. * The physics-enabled object used as the physics imposter
  23937. */
  23938. object: IPhysicsEnabledObject,
  23939. /**
  23940. * The type of the physics imposter
  23941. */
  23942. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23943. /**
  23944. * This function will completly initialize this impostor.
  23945. * It will create a new body - but only if this mesh has no parent.
  23946. * If it has, this impostor will not be used other than to define the impostor
  23947. * of the child mesh.
  23948. * @hidden
  23949. */
  23950. _init(): void;
  23951. private _getPhysicsParent;
  23952. /**
  23953. * Should a new body be generated.
  23954. * @returns boolean specifying if body initialization is required
  23955. */
  23956. isBodyInitRequired(): boolean;
  23957. /**
  23958. * Sets the updated scaling
  23959. * @param updated Specifies if the scaling is updated
  23960. */
  23961. setScalingUpdated(): void;
  23962. /**
  23963. * Force a regeneration of this or the parent's impostor's body.
  23964. * Use under cautious - This will remove all joints already implemented.
  23965. */
  23966. forceUpdate(): void;
  23967. /**
  23968. * Gets the body that holds this impostor. Either its own, or its parent.
  23969. */
  23970. /**
  23971. * Set the physics body. Used mainly by the physics engine/plugin
  23972. */
  23973. physicsBody: any;
  23974. /**
  23975. * Get the parent of the physics imposter
  23976. * @returns Physics imposter or null
  23977. */
  23978. /**
  23979. * Sets the parent of the physics imposter
  23980. */
  23981. parent: Nullable<PhysicsImpostor>;
  23982. /**
  23983. * Resets the update flags
  23984. */
  23985. resetUpdateFlags(): void;
  23986. /**
  23987. * Gets the object extend size
  23988. * @returns the object extend size
  23989. */
  23990. getObjectExtendSize(): Vector3;
  23991. /**
  23992. * Gets the object center
  23993. * @returns The object center
  23994. */
  23995. getObjectCenter(): Vector3;
  23996. /**
  23997. * Get a specific parametes from the options parameter
  23998. * @param paramName The object parameter name
  23999. * @returns The object parameter
  24000. */
  24001. getParam(paramName: string): any;
  24002. /**
  24003. * Sets a specific parameter in the options given to the physics plugin
  24004. * @param paramName The parameter name
  24005. * @param value The value of the parameter
  24006. */
  24007. setParam(paramName: string, value: number): void;
  24008. /**
  24009. * Specifically change the body's mass option. Won't recreate the physics body object
  24010. * @param mass The mass of the physics imposter
  24011. */
  24012. setMass(mass: number): void;
  24013. /**
  24014. * Gets the linear velocity
  24015. * @returns linear velocity or null
  24016. */
  24017. getLinearVelocity(): Nullable<Vector3>;
  24018. /**
  24019. * Sets the linear velocity
  24020. * @param velocity linear velocity or null
  24021. */
  24022. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24023. /**
  24024. * Gets the angular velocity
  24025. * @returns angular velocity or null
  24026. */
  24027. getAngularVelocity(): Nullable<Vector3>;
  24028. /**
  24029. * Sets the angular velocity
  24030. * @param velocity The velocity or null
  24031. */
  24032. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24033. /**
  24034. * Execute a function with the physics plugin native code
  24035. * Provide a function the will have two variables - the world object and the physics body object
  24036. * @param func The function to execute with the physics plugin native code
  24037. */
  24038. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24039. /**
  24040. * Register a function that will be executed before the physics world is stepping forward
  24041. * @param func The function to execute before the physics world is stepped forward
  24042. */
  24043. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24044. /**
  24045. * Unregister a function that will be executed before the physics world is stepping forward
  24046. * @param func The function to execute before the physics world is stepped forward
  24047. */
  24048. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24049. /**
  24050. * Register a function that will be executed after the physics step
  24051. * @param func The function to execute after physics step
  24052. */
  24053. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24054. /**
  24055. * Unregisters a function that will be executed after the physics step
  24056. * @param func The function to execute after physics step
  24057. */
  24058. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24059. /**
  24060. * register a function that will be executed when this impostor collides against a different body
  24061. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24062. * @param func Callback that is executed on collision
  24063. */
  24064. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24065. /**
  24066. * Unregisters the physics imposter on contact
  24067. * @param collideAgainst The physics object to collide against
  24068. * @param func Callback to execute on collision
  24069. */
  24070. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24071. private _tmpQuat;
  24072. private _tmpQuat2;
  24073. /**
  24074. * Get the parent rotation
  24075. * @returns The parent rotation
  24076. */
  24077. getParentsRotation(): Quaternion;
  24078. /**
  24079. * this function is executed by the physics engine.
  24080. */
  24081. beforeStep: () => void;
  24082. /**
  24083. * this function is executed by the physics engine
  24084. */
  24085. afterStep: () => void;
  24086. /**
  24087. * Legacy collision detection event support
  24088. */
  24089. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24090. /**
  24091. * event and body object due to cannon's event-based architecture.
  24092. */
  24093. onCollide: (e: {
  24094. body: any;
  24095. }) => void;
  24096. /**
  24097. * Apply a force
  24098. * @param force The force to apply
  24099. * @param contactPoint The contact point for the force
  24100. * @returns The physics imposter
  24101. */
  24102. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24103. /**
  24104. * Apply an impulse
  24105. * @param force The impulse force
  24106. * @param contactPoint The contact point for the impulse force
  24107. * @returns The physics imposter
  24108. */
  24109. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24110. /**
  24111. * A help function to create a joint
  24112. * @param otherImpostor A physics imposter used to create a joint
  24113. * @param jointType The type of joint
  24114. * @param jointData The data for the joint
  24115. * @returns The physics imposter
  24116. */
  24117. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24118. /**
  24119. * Add a joint to this impostor with a different impostor
  24120. * @param otherImpostor A physics imposter used to add a joint
  24121. * @param joint The joint to add
  24122. * @returns The physics imposter
  24123. */
  24124. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24125. /**
  24126. * Add an anchor to a cloth impostor
  24127. * @param otherImpostor rigid impostor to anchor to
  24128. * @param width ratio across width from 0 to 1
  24129. * @param height ratio up height from 0 to 1
  24130. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24131. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24132. * @returns impostor the soft imposter
  24133. */
  24134. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24135. /**
  24136. * Add a hook to a rope impostor
  24137. * @param otherImpostor rigid impostor to anchor to
  24138. * @param length ratio across rope from 0 to 1
  24139. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24140. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24141. * @returns impostor the rope imposter
  24142. */
  24143. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24144. /**
  24145. * Will keep this body still, in a sleep mode.
  24146. * @returns the physics imposter
  24147. */
  24148. sleep(): PhysicsImpostor;
  24149. /**
  24150. * Wake the body up.
  24151. * @returns The physics imposter
  24152. */
  24153. wakeUp(): PhysicsImpostor;
  24154. /**
  24155. * Clones the physics imposter
  24156. * @param newObject The physics imposter clones to this physics-enabled object
  24157. * @returns A nullable physics imposter
  24158. */
  24159. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24160. /**
  24161. * Disposes the physics imposter
  24162. */
  24163. dispose(): void;
  24164. /**
  24165. * Sets the delta position
  24166. * @param position The delta position amount
  24167. */
  24168. setDeltaPosition(position: Vector3): void;
  24169. /**
  24170. * Sets the delta rotation
  24171. * @param rotation The delta rotation amount
  24172. */
  24173. setDeltaRotation(rotation: Quaternion): void;
  24174. /**
  24175. * Gets the box size of the physics imposter and stores the result in the input parameter
  24176. * @param result Stores the box size
  24177. * @returns The physics imposter
  24178. */
  24179. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24180. /**
  24181. * Gets the radius of the physics imposter
  24182. * @returns Radius of the physics imposter
  24183. */
  24184. getRadius(): number;
  24185. /**
  24186. * Sync a bone with this impostor
  24187. * @param bone The bone to sync to the impostor.
  24188. * @param boneMesh The mesh that the bone is influencing.
  24189. * @param jointPivot The pivot of the joint / bone in local space.
  24190. * @param distToJoint Optional distance from the impostor to the joint.
  24191. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24192. */
  24193. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24194. /**
  24195. * Sync impostor to a bone
  24196. * @param bone The bone that the impostor will be synced to.
  24197. * @param boneMesh The mesh that the bone is influencing.
  24198. * @param jointPivot The pivot of the joint / bone in local space.
  24199. * @param distToJoint Optional distance from the impostor to the joint.
  24200. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24201. * @param boneAxis Optional vector3 axis the bone is aligned with
  24202. */
  24203. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24204. /**
  24205. * No-Imposter type
  24206. */
  24207. static NoImpostor: number;
  24208. /**
  24209. * Sphere-Imposter type
  24210. */
  24211. static SphereImpostor: number;
  24212. /**
  24213. * Box-Imposter type
  24214. */
  24215. static BoxImpostor: number;
  24216. /**
  24217. * Plane-Imposter type
  24218. */
  24219. static PlaneImpostor: number;
  24220. /**
  24221. * Mesh-imposter type
  24222. */
  24223. static MeshImpostor: number;
  24224. /**
  24225. * Capsule-Impostor type (Ammo.js plugin only)
  24226. */
  24227. static CapsuleImpostor: number;
  24228. /**
  24229. * Cylinder-Imposter type
  24230. */
  24231. static CylinderImpostor: number;
  24232. /**
  24233. * Particle-Imposter type
  24234. */
  24235. static ParticleImpostor: number;
  24236. /**
  24237. * Heightmap-Imposter type
  24238. */
  24239. static HeightmapImpostor: number;
  24240. /**
  24241. * ConvexHull-Impostor type (Ammo.js plugin only)
  24242. */
  24243. static ConvexHullImpostor: number;
  24244. /**
  24245. * Rope-Imposter type
  24246. */
  24247. static RopeImpostor: number;
  24248. /**
  24249. * Cloth-Imposter type
  24250. */
  24251. static ClothImpostor: number;
  24252. /**
  24253. * Softbody-Imposter type
  24254. */
  24255. static SoftbodyImpostor: number;
  24256. }
  24257. }
  24258. declare module "babylonjs/Meshes/mesh" {
  24259. import { Observable } from "babylonjs/Misc/observable";
  24260. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24261. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24262. import { Camera } from "babylonjs/Cameras/camera";
  24263. import { Scene } from "babylonjs/scene";
  24264. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24265. import { Color4 } from "babylonjs/Maths/math.color";
  24266. import { Engine } from "babylonjs/Engines/engine";
  24267. import { Node } from "babylonjs/node";
  24268. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24269. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24270. import { Buffer } from "babylonjs/Meshes/buffer";
  24271. import { Geometry } from "babylonjs/Meshes/geometry";
  24272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24273. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24274. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24275. import { Effect } from "babylonjs/Materials/effect";
  24276. import { Material } from "babylonjs/Materials/material";
  24277. import { Skeleton } from "babylonjs/Bones/skeleton";
  24278. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24279. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24280. import { Path3D } from "babylonjs/Maths/math.path";
  24281. import { Plane } from "babylonjs/Maths/math.plane";
  24282. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24283. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24284. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24285. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24286. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24287. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24288. /**
  24289. * @hidden
  24290. **/
  24291. export class _CreationDataStorage {
  24292. closePath?: boolean;
  24293. closeArray?: boolean;
  24294. idx: number[];
  24295. dashSize: number;
  24296. gapSize: number;
  24297. path3D: Path3D;
  24298. pathArray: Vector3[][];
  24299. arc: number;
  24300. radius: number;
  24301. cap: number;
  24302. tessellation: number;
  24303. }
  24304. /**
  24305. * @hidden
  24306. **/
  24307. class _InstanceDataStorage {
  24308. visibleInstances: any;
  24309. batchCache: _InstancesBatch;
  24310. instancesBufferSize: number;
  24311. instancesBuffer: Nullable<Buffer>;
  24312. instancesData: Float32Array;
  24313. overridenInstanceCount: number;
  24314. isFrozen: boolean;
  24315. previousBatch: Nullable<_InstancesBatch>;
  24316. hardwareInstancedRendering: boolean;
  24317. sideOrientation: number;
  24318. }
  24319. /**
  24320. * @hidden
  24321. **/
  24322. export class _InstancesBatch {
  24323. mustReturn: boolean;
  24324. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24325. renderSelf: boolean[];
  24326. hardwareInstancedRendering: boolean[];
  24327. }
  24328. /**
  24329. * Class used to represent renderable models
  24330. */
  24331. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24332. /**
  24333. * Mesh side orientation : usually the external or front surface
  24334. */
  24335. static readonly FRONTSIDE: number;
  24336. /**
  24337. * Mesh side orientation : usually the internal or back surface
  24338. */
  24339. static readonly BACKSIDE: number;
  24340. /**
  24341. * Mesh side orientation : both internal and external or front and back surfaces
  24342. */
  24343. static readonly DOUBLESIDE: number;
  24344. /**
  24345. * Mesh side orientation : by default, `FRONTSIDE`
  24346. */
  24347. static readonly DEFAULTSIDE: number;
  24348. /**
  24349. * Mesh cap setting : no cap
  24350. */
  24351. static readonly NO_CAP: number;
  24352. /**
  24353. * Mesh cap setting : one cap at the beginning of the mesh
  24354. */
  24355. static readonly CAP_START: number;
  24356. /**
  24357. * Mesh cap setting : one cap at the end of the mesh
  24358. */
  24359. static readonly CAP_END: number;
  24360. /**
  24361. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24362. */
  24363. static readonly CAP_ALL: number;
  24364. /**
  24365. * Mesh pattern setting : no flip or rotate
  24366. */
  24367. static readonly NO_FLIP: number;
  24368. /**
  24369. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24370. */
  24371. static readonly FLIP_TILE: number;
  24372. /**
  24373. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24374. */
  24375. static readonly ROTATE_TILE: number;
  24376. /**
  24377. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24378. */
  24379. static readonly FLIP_ROW: number;
  24380. /**
  24381. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24382. */
  24383. static readonly ROTATE_ROW: number;
  24384. /**
  24385. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24386. */
  24387. static readonly FLIP_N_ROTATE_TILE: number;
  24388. /**
  24389. * Mesh pattern setting : rotate pattern and rotate
  24390. */
  24391. static readonly FLIP_N_ROTATE_ROW: number;
  24392. /**
  24393. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24394. */
  24395. static readonly CENTER: number;
  24396. /**
  24397. * Mesh tile positioning : part tiles on left
  24398. */
  24399. static readonly LEFT: number;
  24400. /**
  24401. * Mesh tile positioning : part tiles on right
  24402. */
  24403. static readonly RIGHT: number;
  24404. /**
  24405. * Mesh tile positioning : part tiles on top
  24406. */
  24407. static readonly TOP: number;
  24408. /**
  24409. * Mesh tile positioning : part tiles on bottom
  24410. */
  24411. static readonly BOTTOM: number;
  24412. /**
  24413. * Gets the default side orientation.
  24414. * @param orientation the orientation to value to attempt to get
  24415. * @returns the default orientation
  24416. * @hidden
  24417. */
  24418. static _GetDefaultSideOrientation(orientation?: number): number;
  24419. private _internalMeshDataInfo;
  24420. /**
  24421. * An event triggered before rendering the mesh
  24422. */
  24423. readonly onBeforeRenderObservable: Observable<Mesh>;
  24424. /**
  24425. * An event triggered before binding the mesh
  24426. */
  24427. readonly onBeforeBindObservable: Observable<Mesh>;
  24428. /**
  24429. * An event triggered after rendering the mesh
  24430. */
  24431. readonly onAfterRenderObservable: Observable<Mesh>;
  24432. /**
  24433. * An event triggered before drawing the mesh
  24434. */
  24435. readonly onBeforeDrawObservable: Observable<Mesh>;
  24436. private _onBeforeDrawObserver;
  24437. /**
  24438. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24439. */
  24440. onBeforeDraw: () => void;
  24441. readonly hasInstances: boolean;
  24442. /**
  24443. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24444. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24445. */
  24446. delayLoadState: number;
  24447. /**
  24448. * Gets the list of instances created from this mesh
  24449. * it is not supposed to be modified manually.
  24450. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24451. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24452. */
  24453. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24454. /**
  24455. * Gets the file containing delay loading data for this mesh
  24456. */
  24457. delayLoadingFile: string;
  24458. /** @hidden */
  24459. _binaryInfo: any;
  24460. /**
  24461. * User defined function used to change how LOD level selection is done
  24462. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24463. */
  24464. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24465. /**
  24466. * Gets or sets the morph target manager
  24467. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24468. */
  24469. morphTargetManager: Nullable<MorphTargetManager>;
  24470. /** @hidden */
  24471. _creationDataStorage: Nullable<_CreationDataStorage>;
  24472. /** @hidden */
  24473. _geometry: Nullable<Geometry>;
  24474. /** @hidden */
  24475. _delayInfo: Array<string>;
  24476. /** @hidden */
  24477. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24478. /** @hidden */
  24479. _instanceDataStorage: _InstanceDataStorage;
  24480. private _effectiveMaterial;
  24481. /** @hidden */
  24482. _shouldGenerateFlatShading: boolean;
  24483. /** @hidden */
  24484. _originalBuilderSideOrientation: number;
  24485. /**
  24486. * Use this property to change the original side orientation defined at construction time
  24487. */
  24488. overrideMaterialSideOrientation: Nullable<number>;
  24489. /**
  24490. * Gets the source mesh (the one used to clone this one from)
  24491. */
  24492. readonly source: Nullable<Mesh>;
  24493. /**
  24494. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24495. */
  24496. isUnIndexed: boolean;
  24497. /**
  24498. * @constructor
  24499. * @param name The value used by scene.getMeshByName() to do a lookup.
  24500. * @param scene The scene to add this mesh to.
  24501. * @param parent The parent of this mesh, if it has one
  24502. * @param source An optional Mesh from which geometry is shared, cloned.
  24503. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24504. * When false, achieved by calling a clone(), also passing False.
  24505. * This will make creation of children, recursive.
  24506. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24507. */
  24508. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24509. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24510. /**
  24511. * Gets the class name
  24512. * @returns the string "Mesh".
  24513. */
  24514. getClassName(): string;
  24515. /** @hidden */
  24516. readonly _isMesh: boolean;
  24517. /**
  24518. * Returns a description of this mesh
  24519. * @param fullDetails define if full details about this mesh must be used
  24520. * @returns a descriptive string representing this mesh
  24521. */
  24522. toString(fullDetails?: boolean): string;
  24523. /** @hidden */
  24524. _unBindEffect(): void;
  24525. /**
  24526. * Gets a boolean indicating if this mesh has LOD
  24527. */
  24528. readonly hasLODLevels: boolean;
  24529. /**
  24530. * Gets the list of MeshLODLevel associated with the current mesh
  24531. * @returns an array of MeshLODLevel
  24532. */
  24533. getLODLevels(): MeshLODLevel[];
  24534. private _sortLODLevels;
  24535. /**
  24536. * Add a mesh as LOD level triggered at the given distance.
  24537. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24538. * @param distance The distance from the center of the object to show this level
  24539. * @param mesh The mesh to be added as LOD level (can be null)
  24540. * @return This mesh (for chaining)
  24541. */
  24542. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24543. /**
  24544. * Returns the LOD level mesh at the passed distance or null if not found.
  24545. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24546. * @param distance The distance from the center of the object to show this level
  24547. * @returns a Mesh or `null`
  24548. */
  24549. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24550. /**
  24551. * Remove a mesh from the LOD array
  24552. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24553. * @param mesh defines the mesh to be removed
  24554. * @return This mesh (for chaining)
  24555. */
  24556. removeLODLevel(mesh: Mesh): Mesh;
  24557. /**
  24558. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24559. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24560. * @param camera defines the camera to use to compute distance
  24561. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24562. * @return This mesh (for chaining)
  24563. */
  24564. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24565. /**
  24566. * Gets the mesh internal Geometry object
  24567. */
  24568. readonly geometry: Nullable<Geometry>;
  24569. /**
  24570. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24571. * @returns the total number of vertices
  24572. */
  24573. getTotalVertices(): number;
  24574. /**
  24575. * Returns the content of an associated vertex buffer
  24576. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24577. * - VertexBuffer.PositionKind
  24578. * - VertexBuffer.UVKind
  24579. * - VertexBuffer.UV2Kind
  24580. * - VertexBuffer.UV3Kind
  24581. * - VertexBuffer.UV4Kind
  24582. * - VertexBuffer.UV5Kind
  24583. * - VertexBuffer.UV6Kind
  24584. * - VertexBuffer.ColorKind
  24585. * - VertexBuffer.MatricesIndicesKind
  24586. * - VertexBuffer.MatricesIndicesExtraKind
  24587. * - VertexBuffer.MatricesWeightsKind
  24588. * - VertexBuffer.MatricesWeightsExtraKind
  24589. * @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
  24590. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24591. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24592. */
  24593. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24594. /**
  24595. * Returns the mesh VertexBuffer object from the requested `kind`
  24596. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24597. * - VertexBuffer.PositionKind
  24598. * - VertexBuffer.NormalKind
  24599. * - VertexBuffer.UVKind
  24600. * - VertexBuffer.UV2Kind
  24601. * - VertexBuffer.UV3Kind
  24602. * - VertexBuffer.UV4Kind
  24603. * - VertexBuffer.UV5Kind
  24604. * - VertexBuffer.UV6Kind
  24605. * - VertexBuffer.ColorKind
  24606. * - VertexBuffer.MatricesIndicesKind
  24607. * - VertexBuffer.MatricesIndicesExtraKind
  24608. * - VertexBuffer.MatricesWeightsKind
  24609. * - VertexBuffer.MatricesWeightsExtraKind
  24610. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24611. */
  24612. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24613. /**
  24614. * Tests if a specific vertex buffer is associated with this mesh
  24615. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24616. * - VertexBuffer.PositionKind
  24617. * - VertexBuffer.NormalKind
  24618. * - VertexBuffer.UVKind
  24619. * - VertexBuffer.UV2Kind
  24620. * - VertexBuffer.UV3Kind
  24621. * - VertexBuffer.UV4Kind
  24622. * - VertexBuffer.UV5Kind
  24623. * - VertexBuffer.UV6Kind
  24624. * - VertexBuffer.ColorKind
  24625. * - VertexBuffer.MatricesIndicesKind
  24626. * - VertexBuffer.MatricesIndicesExtraKind
  24627. * - VertexBuffer.MatricesWeightsKind
  24628. * - VertexBuffer.MatricesWeightsExtraKind
  24629. * @returns a boolean
  24630. */
  24631. isVerticesDataPresent(kind: string): boolean;
  24632. /**
  24633. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24634. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24635. * - VertexBuffer.PositionKind
  24636. * - VertexBuffer.UVKind
  24637. * - VertexBuffer.UV2Kind
  24638. * - VertexBuffer.UV3Kind
  24639. * - VertexBuffer.UV4Kind
  24640. * - VertexBuffer.UV5Kind
  24641. * - VertexBuffer.UV6Kind
  24642. * - VertexBuffer.ColorKind
  24643. * - VertexBuffer.MatricesIndicesKind
  24644. * - VertexBuffer.MatricesIndicesExtraKind
  24645. * - VertexBuffer.MatricesWeightsKind
  24646. * - VertexBuffer.MatricesWeightsExtraKind
  24647. * @returns a boolean
  24648. */
  24649. isVertexBufferUpdatable(kind: string): boolean;
  24650. /**
  24651. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24652. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24653. * - VertexBuffer.PositionKind
  24654. * - VertexBuffer.NormalKind
  24655. * - VertexBuffer.UVKind
  24656. * - VertexBuffer.UV2Kind
  24657. * - VertexBuffer.UV3Kind
  24658. * - VertexBuffer.UV4Kind
  24659. * - VertexBuffer.UV5Kind
  24660. * - VertexBuffer.UV6Kind
  24661. * - VertexBuffer.ColorKind
  24662. * - VertexBuffer.MatricesIndicesKind
  24663. * - VertexBuffer.MatricesIndicesExtraKind
  24664. * - VertexBuffer.MatricesWeightsKind
  24665. * - VertexBuffer.MatricesWeightsExtraKind
  24666. * @returns an array of strings
  24667. */
  24668. getVerticesDataKinds(): string[];
  24669. /**
  24670. * Returns a positive integer : the total number of indices in this mesh geometry.
  24671. * @returns the numner of indices or zero if the mesh has no geometry.
  24672. */
  24673. getTotalIndices(): number;
  24674. /**
  24675. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24676. * @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.
  24677. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24678. * @returns the indices array or an empty array if the mesh has no geometry
  24679. */
  24680. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24681. readonly isBlocked: boolean;
  24682. /**
  24683. * Determine if the current mesh is ready to be rendered
  24684. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24685. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24686. * @returns true if all associated assets are ready (material, textures, shaders)
  24687. */
  24688. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24689. /**
  24690. * 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.
  24691. */
  24692. readonly areNormalsFrozen: boolean;
  24693. /**
  24694. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24695. * @returns the current mesh
  24696. */
  24697. freezeNormals(): Mesh;
  24698. /**
  24699. * 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
  24700. * @returns the current mesh
  24701. */
  24702. unfreezeNormals(): Mesh;
  24703. /**
  24704. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24705. */
  24706. overridenInstanceCount: number;
  24707. /** @hidden */
  24708. _preActivate(): Mesh;
  24709. /** @hidden */
  24710. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24711. /** @hidden */
  24712. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24713. /**
  24714. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24715. * This means the mesh underlying bounding box and sphere are recomputed.
  24716. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24717. * @returns the current mesh
  24718. */
  24719. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24720. /** @hidden */
  24721. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24722. /**
  24723. * This function will subdivide the mesh into multiple submeshes
  24724. * @param count defines the expected number of submeshes
  24725. */
  24726. subdivide(count: number): void;
  24727. /**
  24728. * Copy a FloatArray into a specific associated vertex buffer
  24729. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24730. * - VertexBuffer.PositionKind
  24731. * - VertexBuffer.UVKind
  24732. * - VertexBuffer.UV2Kind
  24733. * - VertexBuffer.UV3Kind
  24734. * - VertexBuffer.UV4Kind
  24735. * - VertexBuffer.UV5Kind
  24736. * - VertexBuffer.UV6Kind
  24737. * - VertexBuffer.ColorKind
  24738. * - VertexBuffer.MatricesIndicesKind
  24739. * - VertexBuffer.MatricesIndicesExtraKind
  24740. * - VertexBuffer.MatricesWeightsKind
  24741. * - VertexBuffer.MatricesWeightsExtraKind
  24742. * @param data defines the data source
  24743. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24744. * @param stride defines the data stride size (can be null)
  24745. * @returns the current mesh
  24746. */
  24747. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24748. /**
  24749. * Flags an associated vertex buffer as updatable
  24750. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24751. * - VertexBuffer.PositionKind
  24752. * - VertexBuffer.UVKind
  24753. * - VertexBuffer.UV2Kind
  24754. * - VertexBuffer.UV3Kind
  24755. * - VertexBuffer.UV4Kind
  24756. * - VertexBuffer.UV5Kind
  24757. * - VertexBuffer.UV6Kind
  24758. * - VertexBuffer.ColorKind
  24759. * - VertexBuffer.MatricesIndicesKind
  24760. * - VertexBuffer.MatricesIndicesExtraKind
  24761. * - VertexBuffer.MatricesWeightsKind
  24762. * - VertexBuffer.MatricesWeightsExtraKind
  24763. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24764. */
  24765. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24766. /**
  24767. * Sets the mesh global Vertex Buffer
  24768. * @param buffer defines the buffer to use
  24769. * @returns the current mesh
  24770. */
  24771. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24772. /**
  24773. * Update a specific associated vertex buffer
  24774. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24775. * - VertexBuffer.PositionKind
  24776. * - VertexBuffer.UVKind
  24777. * - VertexBuffer.UV2Kind
  24778. * - VertexBuffer.UV3Kind
  24779. * - VertexBuffer.UV4Kind
  24780. * - VertexBuffer.UV5Kind
  24781. * - VertexBuffer.UV6Kind
  24782. * - VertexBuffer.ColorKind
  24783. * - VertexBuffer.MatricesIndicesKind
  24784. * - VertexBuffer.MatricesIndicesExtraKind
  24785. * - VertexBuffer.MatricesWeightsKind
  24786. * - VertexBuffer.MatricesWeightsExtraKind
  24787. * @param data defines the data source
  24788. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24789. * @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)
  24790. * @returns the current mesh
  24791. */
  24792. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24793. /**
  24794. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24795. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24796. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24797. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24798. * @returns the current mesh
  24799. */
  24800. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24801. /**
  24802. * Creates a un-shared specific occurence of the geometry for the mesh.
  24803. * @returns the current mesh
  24804. */
  24805. makeGeometryUnique(): Mesh;
  24806. /**
  24807. * Set the index buffer of this mesh
  24808. * @param indices defines the source data
  24809. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24810. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24811. * @returns the current mesh
  24812. */
  24813. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24814. /**
  24815. * Update the current index buffer
  24816. * @param indices defines the source data
  24817. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24818. * @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)
  24819. * @returns the current mesh
  24820. */
  24821. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24822. /**
  24823. * Invert the geometry to move from a right handed system to a left handed one.
  24824. * @returns the current mesh
  24825. */
  24826. toLeftHanded(): Mesh;
  24827. /** @hidden */
  24828. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24829. /** @hidden */
  24830. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24831. /**
  24832. * Registers for this mesh a javascript function called just before the rendering process
  24833. * @param func defines the function to call before rendering this mesh
  24834. * @returns the current mesh
  24835. */
  24836. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24837. /**
  24838. * Disposes a previously registered javascript function called before the rendering
  24839. * @param func defines the function to remove
  24840. * @returns the current mesh
  24841. */
  24842. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24843. /**
  24844. * Registers for this mesh a javascript function called just after the rendering is complete
  24845. * @param func defines the function to call after rendering this mesh
  24846. * @returns the current mesh
  24847. */
  24848. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24849. /**
  24850. * Disposes a previously registered javascript function called after the rendering.
  24851. * @param func defines the function to remove
  24852. * @returns the current mesh
  24853. */
  24854. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24855. /** @hidden */
  24856. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24857. /** @hidden */
  24858. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24859. /** @hidden */
  24860. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24861. /** @hidden */
  24862. _rebuild(): void;
  24863. /** @hidden */
  24864. _freeze(): void;
  24865. /** @hidden */
  24866. _unFreeze(): void;
  24867. /**
  24868. * 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
  24869. * @param subMesh defines the subMesh to render
  24870. * @param enableAlphaMode defines if alpha mode can be changed
  24871. * @returns the current mesh
  24872. */
  24873. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24874. private _onBeforeDraw;
  24875. /**
  24876. * Renormalize the mesh and patch it up if there are no weights
  24877. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24878. * However in the case of zero weights then we set just a single influence to 1.
  24879. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24880. */
  24881. cleanMatrixWeights(): void;
  24882. private normalizeSkinFourWeights;
  24883. private normalizeSkinWeightsAndExtra;
  24884. /**
  24885. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24886. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24887. * the user know there was an issue with importing the mesh
  24888. * @returns a validation object with skinned, valid and report string
  24889. */
  24890. validateSkinning(): {
  24891. skinned: boolean;
  24892. valid: boolean;
  24893. report: string;
  24894. };
  24895. /** @hidden */
  24896. _checkDelayState(): Mesh;
  24897. private _queueLoad;
  24898. /**
  24899. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24900. * A mesh is in the frustum if its bounding box intersects the frustum
  24901. * @param frustumPlanes defines the frustum to test
  24902. * @returns true if the mesh is in the frustum planes
  24903. */
  24904. isInFrustum(frustumPlanes: Plane[]): boolean;
  24905. /**
  24906. * Sets the mesh material by the material or multiMaterial `id` property
  24907. * @param id is a string identifying the material or the multiMaterial
  24908. * @returns the current mesh
  24909. */
  24910. setMaterialByID(id: string): Mesh;
  24911. /**
  24912. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24913. * @returns an array of IAnimatable
  24914. */
  24915. getAnimatables(): IAnimatable[];
  24916. /**
  24917. * Modifies the mesh geometry according to the passed transformation matrix.
  24918. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24919. * The mesh normals are modified using the same transformation.
  24920. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24921. * @param transform defines the transform matrix to use
  24922. * @see http://doc.babylonjs.com/resources/baking_transformations
  24923. * @returns the current mesh
  24924. */
  24925. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24926. /**
  24927. * Modifies the mesh geometry according to its own current World Matrix.
  24928. * The mesh World Matrix is then reset.
  24929. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24930. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24931. * @see http://doc.babylonjs.com/resources/baking_transformations
  24932. * @returns the current mesh
  24933. */
  24934. bakeCurrentTransformIntoVertices(): Mesh;
  24935. /** @hidden */
  24936. readonly _positions: Nullable<Vector3[]>;
  24937. /** @hidden */
  24938. _resetPointsArrayCache(): Mesh;
  24939. /** @hidden */
  24940. _generatePointsArray(): boolean;
  24941. /**
  24942. * Returns a new Mesh object generated from the current mesh properties.
  24943. * This method must not get confused with createInstance()
  24944. * @param name is a string, the name given to the new mesh
  24945. * @param newParent can be any Node object (default `null`)
  24946. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24947. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24948. * @returns a new mesh
  24949. */
  24950. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24951. /**
  24952. * Releases resources associated with this mesh.
  24953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24955. */
  24956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24957. /**
  24958. * Modifies the mesh geometry according to a displacement map.
  24959. * 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.
  24960. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24961. * @param url is a string, the URL from the image file is to be downloaded.
  24962. * @param minHeight is the lower limit of the displacement.
  24963. * @param maxHeight is the upper limit of the displacement.
  24964. * @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.
  24965. * @param uvOffset is an optional vector2 used to offset UV.
  24966. * @param uvScale is an optional vector2 used to scale UV.
  24967. * @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.
  24968. * @returns the Mesh.
  24969. */
  24970. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24971. /**
  24972. * Modifies the mesh geometry according to a displacementMap buffer.
  24973. * 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.
  24974. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24975. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24976. * @param heightMapWidth is the width of the buffer image.
  24977. * @param heightMapHeight is the height of the buffer image.
  24978. * @param minHeight is the lower limit of the displacement.
  24979. * @param maxHeight is the upper limit of the displacement.
  24980. * @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.
  24981. * @param uvOffset is an optional vector2 used to offset UV.
  24982. * @param uvScale is an optional vector2 used to scale UV.
  24983. * @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.
  24984. * @returns the Mesh.
  24985. */
  24986. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24987. /**
  24988. * Modify the mesh to get a flat shading rendering.
  24989. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24990. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24991. * @returns current mesh
  24992. */
  24993. convertToFlatShadedMesh(): Mesh;
  24994. /**
  24995. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24996. * In other words, more vertices, no more indices and a single bigger VBO.
  24997. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24998. * @returns current mesh
  24999. */
  25000. convertToUnIndexedMesh(): Mesh;
  25001. /**
  25002. * Inverses facet orientations.
  25003. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25004. * @param flipNormals will also inverts the normals
  25005. * @returns current mesh
  25006. */
  25007. flipFaces(flipNormals?: boolean): Mesh;
  25008. /**
  25009. * Increase the number of facets and hence vertices in a mesh
  25010. * Vertex normals are interpolated from existing vertex normals
  25011. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25012. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25013. */
  25014. increaseVertices(numberPerEdge: number): void;
  25015. /**
  25016. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25017. * This will undo any application of covertToFlatShadedMesh
  25018. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25019. */
  25020. forceSharedVertices(): void;
  25021. /** @hidden */
  25022. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25023. /** @hidden */
  25024. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25025. /**
  25026. * Creates a new InstancedMesh object from the mesh model.
  25027. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25028. * @param name defines the name of the new instance
  25029. * @returns a new InstancedMesh
  25030. */
  25031. createInstance(name: string): InstancedMesh;
  25032. /**
  25033. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25034. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25035. * @returns the current mesh
  25036. */
  25037. synchronizeInstances(): Mesh;
  25038. /**
  25039. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25040. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25041. * This should be used together with the simplification to avoid disappearing triangles.
  25042. * @param successCallback an optional success callback to be called after the optimization finished.
  25043. * @returns the current mesh
  25044. */
  25045. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25046. /**
  25047. * Serialize current mesh
  25048. * @param serializationObject defines the object which will receive the serialization data
  25049. */
  25050. serialize(serializationObject: any): void;
  25051. /** @hidden */
  25052. _syncGeometryWithMorphTargetManager(): void;
  25053. /** @hidden */
  25054. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25055. /**
  25056. * Returns a new Mesh object parsed from the source provided.
  25057. * @param parsedMesh is the source
  25058. * @param scene defines the hosting scene
  25059. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25060. * @returns a new Mesh
  25061. */
  25062. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25063. /**
  25064. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25065. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25066. * @param name defines the name of the mesh to create
  25067. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25068. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25069. * @param closePath creates a seam between the first and the last points of each path of the path array
  25070. * @param offset is taken in account only if the `pathArray` is containing a single path
  25071. * @param scene defines the hosting scene
  25072. * @param updatable defines if the mesh must be flagged as updatable
  25073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25074. * @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)
  25075. * @returns a new Mesh
  25076. */
  25077. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25078. /**
  25079. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25080. * @param name defines the name of the mesh to create
  25081. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25082. * @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
  25083. * @param scene defines the hosting scene
  25084. * @param updatable defines if the mesh must be flagged as updatable
  25085. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25086. * @returns a new Mesh
  25087. */
  25088. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25089. /**
  25090. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25091. * @param name defines the name of the mesh to create
  25092. * @param size sets the size (float) of each box side (default 1)
  25093. * @param scene defines the hosting scene
  25094. * @param updatable defines if the mesh must be flagged as updatable
  25095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25096. * @returns a new Mesh
  25097. */
  25098. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25099. /**
  25100. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25101. * @param name defines the name of the mesh to create
  25102. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25103. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25104. * @param scene defines the hosting scene
  25105. * @param updatable defines if the mesh must be flagged as updatable
  25106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25107. * @returns a new Mesh
  25108. */
  25109. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25110. /**
  25111. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25112. * @param name defines the name of the mesh to create
  25113. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25114. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25115. * @param scene defines the hosting scene
  25116. * @returns a new Mesh
  25117. */
  25118. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25119. /**
  25120. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25121. * @param name defines the name of the mesh to create
  25122. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25123. * @param diameterTop set the top cap diameter (floats, default 1)
  25124. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25125. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25126. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25127. * @param scene defines the hosting scene
  25128. * @param updatable defines if the mesh must be flagged as updatable
  25129. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25130. * @returns a new Mesh
  25131. */
  25132. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25133. /**
  25134. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25135. * @param name defines the name of the mesh to create
  25136. * @param diameter sets the diameter size (float) of the torus (default 1)
  25137. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25138. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25139. * @param scene defines the hosting scene
  25140. * @param updatable defines if the mesh must be flagged as updatable
  25141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25142. * @returns a new Mesh
  25143. */
  25144. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25145. /**
  25146. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25147. * @param name defines the name of the mesh to create
  25148. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25149. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25150. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25151. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25152. * @param p the number of windings on X axis (positive integers, default 2)
  25153. * @param q the number of windings on Y axis (positive integers, default 3)
  25154. * @param scene defines the hosting scene
  25155. * @param updatable defines if the mesh must be flagged as updatable
  25156. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25157. * @returns a new Mesh
  25158. */
  25159. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25160. /**
  25161. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25162. * @param name defines the name of the mesh to create
  25163. * @param points is an array successive Vector3
  25164. * @param scene defines the hosting scene
  25165. * @param updatable defines if the mesh must be flagged as updatable
  25166. * @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).
  25167. * @returns a new Mesh
  25168. */
  25169. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25170. /**
  25171. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25172. * @param name defines the name of the mesh to create
  25173. * @param points is an array successive Vector3
  25174. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25175. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25176. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25177. * @param scene defines the hosting scene
  25178. * @param updatable defines if the mesh must be flagged as updatable
  25179. * @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)
  25180. * @returns a new Mesh
  25181. */
  25182. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25183. /**
  25184. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25185. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25186. * 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.
  25187. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25188. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25189. * Remember you can only change the shape positions, not their number when updating a polygon.
  25190. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25191. * @param name defines the name of the mesh to create
  25192. * @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
  25193. * @param scene defines the hosting scene
  25194. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25195. * @param updatable defines if the mesh must be flagged as updatable
  25196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25197. * @param earcutInjection can be used to inject your own earcut reference
  25198. * @returns a new Mesh
  25199. */
  25200. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25201. /**
  25202. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25203. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25204. * @param name defines the name of the mesh to create
  25205. * @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
  25206. * @param depth defines the height of extrusion
  25207. * @param scene defines the hosting scene
  25208. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25209. * @param updatable defines if the mesh must be flagged as updatable
  25210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25211. * @param earcutInjection can be used to inject your own earcut reference
  25212. * @returns a new Mesh
  25213. */
  25214. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25215. /**
  25216. * Creates an extruded shape mesh.
  25217. * 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
  25218. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25219. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25220. * @param name defines the name of the mesh to create
  25221. * @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
  25222. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25223. * @param scale is the value to scale the shape
  25224. * @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
  25225. * @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
  25226. * @param scene defines the hosting scene
  25227. * @param updatable defines if the mesh must be flagged as updatable
  25228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25229. * @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)
  25230. * @returns a new Mesh
  25231. */
  25232. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25233. /**
  25234. * Creates an custom extruded shape mesh.
  25235. * The custom extrusion is a parametric shape.
  25236. * It has no predefined shape. Its final shape will depend on the input parameters.
  25237. * Please consider using the same method from the MeshBuilder class instead
  25238. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25239. * @param name defines the name of the mesh to create
  25240. * @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
  25241. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25242. * @param scaleFunction is a custom Javascript function called on each path point
  25243. * @param rotationFunction is a custom Javascript function called on each path point
  25244. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25245. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25246. * @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
  25247. * @param scene defines the hosting scene
  25248. * @param updatable defines if the mesh must be flagged as updatable
  25249. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25250. * @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)
  25251. * @returns a new Mesh
  25252. */
  25253. 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;
  25254. /**
  25255. * Creates lathe mesh.
  25256. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25257. * Please consider using the same method from the MeshBuilder class instead
  25258. * @param name defines the name of the mesh to create
  25259. * @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
  25260. * @param radius is the radius value of the lathe
  25261. * @param tessellation is the side number of the lathe.
  25262. * @param scene defines the hosting scene
  25263. * @param updatable defines if the mesh must be flagged as updatable
  25264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25265. * @returns a new Mesh
  25266. */
  25267. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25268. /**
  25269. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25270. * @param name defines the name of the mesh to create
  25271. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25272. * @param scene defines the hosting scene
  25273. * @param updatable defines if the mesh must be flagged as updatable
  25274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25275. * @returns a new Mesh
  25276. */
  25277. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25278. /**
  25279. * Creates a ground mesh.
  25280. * Please consider using the same method from the MeshBuilder class instead
  25281. * @param name defines the name of the mesh to create
  25282. * @param width set the width of the ground
  25283. * @param height set the height of the ground
  25284. * @param subdivisions sets the number of subdivisions per side
  25285. * @param scene defines the hosting scene
  25286. * @param updatable defines if the mesh must be flagged as updatable
  25287. * @returns a new Mesh
  25288. */
  25289. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25290. /**
  25291. * Creates a tiled ground mesh.
  25292. * Please consider using the same method from the MeshBuilder class instead
  25293. * @param name defines the name of the mesh to create
  25294. * @param xmin set the ground minimum X coordinate
  25295. * @param zmin set the ground minimum Y coordinate
  25296. * @param xmax set the ground maximum X coordinate
  25297. * @param zmax set the ground maximum Z coordinate
  25298. * @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
  25299. * @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
  25300. * @param scene defines the hosting scene
  25301. * @param updatable defines if the mesh must be flagged as updatable
  25302. * @returns a new Mesh
  25303. */
  25304. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25305. w: number;
  25306. h: number;
  25307. }, precision: {
  25308. w: number;
  25309. h: number;
  25310. }, scene: Scene, updatable?: boolean): Mesh;
  25311. /**
  25312. * Creates a ground mesh from a height map.
  25313. * Please consider using the same method from the MeshBuilder class instead
  25314. * @see http://doc.babylonjs.com/babylon101/height_map
  25315. * @param name defines the name of the mesh to create
  25316. * @param url sets the URL of the height map image resource
  25317. * @param width set the ground width size
  25318. * @param height set the ground height size
  25319. * @param subdivisions sets the number of subdivision per side
  25320. * @param minHeight is the minimum altitude on the ground
  25321. * @param maxHeight is the maximum altitude on the ground
  25322. * @param scene defines the hosting scene
  25323. * @param updatable defines if the mesh must be flagged as updatable
  25324. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25325. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25326. * @returns a new Mesh
  25327. */
  25328. 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;
  25329. /**
  25330. * Creates a tube mesh.
  25331. * The tube is a parametric shape.
  25332. * It has no predefined shape. Its final shape will depend on the input parameters.
  25333. * Please consider using the same method from the MeshBuilder class instead
  25334. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25335. * @param name defines the name of the mesh to create
  25336. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25337. * @param radius sets the tube radius size
  25338. * @param tessellation is the number of sides on the tubular surface
  25339. * @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
  25340. * @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
  25341. * @param scene defines the hosting scene
  25342. * @param updatable defines if the mesh must be flagged as updatable
  25343. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25344. * @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)
  25345. * @returns a new Mesh
  25346. */
  25347. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25348. (i: number, distance: number): number;
  25349. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25350. /**
  25351. * Creates a polyhedron mesh.
  25352. * Please consider using the same method from the MeshBuilder class instead.
  25353. * * 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
  25354. * * The parameter `size` (positive float, default 1) sets the polygon size
  25355. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25356. * * 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`
  25357. * * 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
  25358. * * 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)`)
  25359. * * 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
  25360. * * 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
  25361. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25362. * * If you create a double-sided mesh, you can choose what parts of 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
  25363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25364. * @param name defines the name of the mesh to create
  25365. * @param options defines the options used to create the mesh
  25366. * @param scene defines the hosting scene
  25367. * @returns a new Mesh
  25368. */
  25369. static CreatePolyhedron(name: string, options: {
  25370. type?: number;
  25371. size?: number;
  25372. sizeX?: number;
  25373. sizeY?: number;
  25374. sizeZ?: number;
  25375. custom?: any;
  25376. faceUV?: Vector4[];
  25377. faceColors?: Color4[];
  25378. updatable?: boolean;
  25379. sideOrientation?: number;
  25380. }, scene: Scene): Mesh;
  25381. /**
  25382. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25383. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25384. * * 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`)
  25385. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25386. * * 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
  25387. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25388. * * If you create a double-sided mesh, you can choose what parts of 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
  25389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25390. * @param name defines the name of the mesh
  25391. * @param options defines the options used to create the mesh
  25392. * @param scene defines the hosting scene
  25393. * @returns a new Mesh
  25394. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25395. */
  25396. static CreateIcoSphere(name: string, options: {
  25397. radius?: number;
  25398. flat?: boolean;
  25399. subdivisions?: number;
  25400. sideOrientation?: number;
  25401. updatable?: boolean;
  25402. }, scene: Scene): Mesh;
  25403. /**
  25404. * Creates a decal mesh.
  25405. * Please consider using the same method from the MeshBuilder class instead.
  25406. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25407. * @param name defines the name of the mesh
  25408. * @param sourceMesh defines the mesh receiving the decal
  25409. * @param position sets the position of the decal in world coordinates
  25410. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25411. * @param size sets the decal scaling
  25412. * @param angle sets the angle to rotate the decal
  25413. * @returns a new Mesh
  25414. */
  25415. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25416. /**
  25417. * Prepare internal position array for software CPU skinning
  25418. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25419. */
  25420. setPositionsForCPUSkinning(): Float32Array;
  25421. /**
  25422. * Prepare internal normal array for software CPU skinning
  25423. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25424. */
  25425. setNormalsForCPUSkinning(): Float32Array;
  25426. /**
  25427. * Updates the vertex buffer by applying transformation from the bones
  25428. * @param skeleton defines the skeleton to apply to current mesh
  25429. * @returns the current mesh
  25430. */
  25431. applySkeleton(skeleton: Skeleton): Mesh;
  25432. /**
  25433. * 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
  25434. * @param meshes defines the list of meshes to scan
  25435. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25436. */
  25437. static MinMax(meshes: AbstractMesh[]): {
  25438. min: Vector3;
  25439. max: Vector3;
  25440. };
  25441. /**
  25442. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25443. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25444. * @returns a vector3
  25445. */
  25446. static Center(meshesOrMinMaxVector: {
  25447. min: Vector3;
  25448. max: Vector3;
  25449. } | AbstractMesh[]): Vector3;
  25450. /**
  25451. * Merge the array of meshes into a single mesh for performance reasons.
  25452. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25453. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25454. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25455. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25456. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25457. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25458. * @returns a new mesh
  25459. */
  25460. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25461. /** @hidden */
  25462. addInstance(instance: InstancedMesh): void;
  25463. /** @hidden */
  25464. removeInstance(instance: InstancedMesh): void;
  25465. }
  25466. }
  25467. declare module "babylonjs/Cameras/camera" {
  25468. import { SmartArray } from "babylonjs/Misc/smartArray";
  25469. import { Observable } from "babylonjs/Misc/observable";
  25470. import { Nullable } from "babylonjs/types";
  25471. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25472. import { Scene } from "babylonjs/scene";
  25473. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25474. import { Node } from "babylonjs/node";
  25475. import { Mesh } from "babylonjs/Meshes/mesh";
  25476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25477. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25478. import { Viewport } from "babylonjs/Maths/math.viewport";
  25479. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25480. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25481. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25482. import { Ray } from "babylonjs/Culling/ray";
  25483. /**
  25484. * This is the base class of all the camera used in the application.
  25485. * @see http://doc.babylonjs.com/features/cameras
  25486. */
  25487. export class Camera extends Node {
  25488. /** @hidden */
  25489. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25490. /**
  25491. * This is the default projection mode used by the cameras.
  25492. * It helps recreating a feeling of perspective and better appreciate depth.
  25493. * This is the best way to simulate real life cameras.
  25494. */
  25495. static readonly PERSPECTIVE_CAMERA: number;
  25496. /**
  25497. * This helps creating camera with an orthographic mode.
  25498. * 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.
  25499. */
  25500. static readonly ORTHOGRAPHIC_CAMERA: number;
  25501. /**
  25502. * This is the default FOV mode for perspective cameras.
  25503. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25504. */
  25505. static readonly FOVMODE_VERTICAL_FIXED: number;
  25506. /**
  25507. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25508. */
  25509. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25510. /**
  25511. * This specifies ther is no need for a camera rig.
  25512. * Basically only one eye is rendered corresponding to the camera.
  25513. */
  25514. static readonly RIG_MODE_NONE: number;
  25515. /**
  25516. * Simulates a camera Rig with one blue eye and one red eye.
  25517. * This can be use with 3d blue and red glasses.
  25518. */
  25519. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25520. /**
  25521. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25522. */
  25523. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25524. /**
  25525. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25526. */
  25527. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25528. /**
  25529. * Defines that both eyes of the camera will be rendered over under each other.
  25530. */
  25531. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25532. /**
  25533. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25534. */
  25535. static readonly RIG_MODE_VR: number;
  25536. /**
  25537. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25538. */
  25539. static readonly RIG_MODE_WEBVR: number;
  25540. /**
  25541. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25542. */
  25543. static readonly RIG_MODE_CUSTOM: number;
  25544. /**
  25545. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25546. */
  25547. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25548. /**
  25549. * Define the input manager associated with the camera.
  25550. */
  25551. inputs: CameraInputsManager<Camera>;
  25552. /** @hidden */
  25553. _position: Vector3;
  25554. /**
  25555. * Define the current local position of the camera in the scene
  25556. */
  25557. position: Vector3;
  25558. /**
  25559. * The vector the camera should consider as up.
  25560. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25561. */
  25562. upVector: Vector3;
  25563. /**
  25564. * Define the current limit on the left side for an orthographic camera
  25565. * In scene unit
  25566. */
  25567. orthoLeft: Nullable<number>;
  25568. /**
  25569. * Define the current limit on the right side for an orthographic camera
  25570. * In scene unit
  25571. */
  25572. orthoRight: Nullable<number>;
  25573. /**
  25574. * Define the current limit on the bottom side for an orthographic camera
  25575. * In scene unit
  25576. */
  25577. orthoBottom: Nullable<number>;
  25578. /**
  25579. * Define the current limit on the top side for an orthographic camera
  25580. * In scene unit
  25581. */
  25582. orthoTop: Nullable<number>;
  25583. /**
  25584. * Field Of View is set in Radians. (default is 0.8)
  25585. */
  25586. fov: number;
  25587. /**
  25588. * Define the minimum distance the camera can see from.
  25589. * This is important to note that the depth buffer are not infinite and the closer it starts
  25590. * the more your scene might encounter depth fighting issue.
  25591. */
  25592. minZ: number;
  25593. /**
  25594. * Define the maximum distance the camera can see to.
  25595. * This is important to note that the depth buffer are not infinite and the further it end
  25596. * the more your scene might encounter depth fighting issue.
  25597. */
  25598. maxZ: number;
  25599. /**
  25600. * Define the default inertia of the camera.
  25601. * This helps giving a smooth feeling to the camera movement.
  25602. */
  25603. inertia: number;
  25604. /**
  25605. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25606. */
  25607. mode: number;
  25608. /**
  25609. * Define wether the camera is intermediate.
  25610. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25611. */
  25612. isIntermediate: boolean;
  25613. /**
  25614. * Define the viewport of the camera.
  25615. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25616. */
  25617. viewport: Viewport;
  25618. /**
  25619. * Restricts the camera to viewing objects with the same layerMask.
  25620. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25621. */
  25622. layerMask: number;
  25623. /**
  25624. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25625. */
  25626. fovMode: number;
  25627. /**
  25628. * Rig mode of the camera.
  25629. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25630. * This is normally controlled byt the camera themselves as internal use.
  25631. */
  25632. cameraRigMode: number;
  25633. /**
  25634. * Defines the distance between both "eyes" in case of a RIG
  25635. */
  25636. interaxialDistance: number;
  25637. /**
  25638. * Defines if stereoscopic rendering is done side by side or over under.
  25639. */
  25640. isStereoscopicSideBySide: boolean;
  25641. /**
  25642. * 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
  25643. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25644. * else in the scene. (Eg. security camera)
  25645. *
  25646. * 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)
  25647. */
  25648. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25649. /**
  25650. * When set, the camera will render to this render target instead of the default canvas
  25651. *
  25652. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25653. */
  25654. outputRenderTarget: Nullable<RenderTargetTexture>;
  25655. /**
  25656. * Observable triggered when the camera view matrix has changed.
  25657. */
  25658. onViewMatrixChangedObservable: Observable<Camera>;
  25659. /**
  25660. * Observable triggered when the camera Projection matrix has changed.
  25661. */
  25662. onProjectionMatrixChangedObservable: Observable<Camera>;
  25663. /**
  25664. * Observable triggered when the inputs have been processed.
  25665. */
  25666. onAfterCheckInputsObservable: Observable<Camera>;
  25667. /**
  25668. * Observable triggered when reset has been called and applied to the camera.
  25669. */
  25670. onRestoreStateObservable: Observable<Camera>;
  25671. /** @hidden */
  25672. _cameraRigParams: any;
  25673. /** @hidden */
  25674. _rigCameras: Camera[];
  25675. /** @hidden */
  25676. _rigPostProcess: Nullable<PostProcess>;
  25677. protected _webvrViewMatrix: Matrix;
  25678. /** @hidden */
  25679. _skipRendering: boolean;
  25680. /** @hidden */
  25681. _projectionMatrix: Matrix;
  25682. /** @hidden */
  25683. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25684. /** @hidden */
  25685. _activeMeshes: SmartArray<AbstractMesh>;
  25686. protected _globalPosition: Vector3;
  25687. /** @hidden */
  25688. _computedViewMatrix: Matrix;
  25689. private _doNotComputeProjectionMatrix;
  25690. private _transformMatrix;
  25691. private _frustumPlanes;
  25692. private _refreshFrustumPlanes;
  25693. private _storedFov;
  25694. private _stateStored;
  25695. /**
  25696. * Instantiates a new camera object.
  25697. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25698. * @see http://doc.babylonjs.com/features/cameras
  25699. * @param name Defines the name of the camera in the scene
  25700. * @param position Defines the position of the camera
  25701. * @param scene Defines the scene the camera belongs too
  25702. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25703. */
  25704. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25705. /**
  25706. * Store current camera state (fov, position, etc..)
  25707. * @returns the camera
  25708. */
  25709. storeState(): Camera;
  25710. /**
  25711. * Restores the camera state values if it has been stored. You must call storeState() first
  25712. */
  25713. protected _restoreStateValues(): boolean;
  25714. /**
  25715. * Restored camera state. You must call storeState() first.
  25716. * @returns true if restored and false otherwise
  25717. */
  25718. restoreState(): boolean;
  25719. /**
  25720. * Gets the class name of the camera.
  25721. * @returns the class name
  25722. */
  25723. getClassName(): string;
  25724. /** @hidden */
  25725. readonly _isCamera: boolean;
  25726. /**
  25727. * Gets a string representation of the camera useful for debug purpose.
  25728. * @param fullDetails Defines that a more verboe level of logging is required
  25729. * @returns the string representation
  25730. */
  25731. toString(fullDetails?: boolean): string;
  25732. /**
  25733. * Gets the current world space position of the camera.
  25734. */
  25735. readonly globalPosition: Vector3;
  25736. /**
  25737. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25738. * @returns the active meshe list
  25739. */
  25740. getActiveMeshes(): SmartArray<AbstractMesh>;
  25741. /**
  25742. * Check wether a mesh is part of the current active mesh list of the camera
  25743. * @param mesh Defines the mesh to check
  25744. * @returns true if active, false otherwise
  25745. */
  25746. isActiveMesh(mesh: Mesh): boolean;
  25747. /**
  25748. * Is this camera ready to be used/rendered
  25749. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25750. * @return true if the camera is ready
  25751. */
  25752. isReady(completeCheck?: boolean): boolean;
  25753. /** @hidden */
  25754. _initCache(): void;
  25755. /** @hidden */
  25756. _updateCache(ignoreParentClass?: boolean): void;
  25757. /** @hidden */
  25758. _isSynchronized(): boolean;
  25759. /** @hidden */
  25760. _isSynchronizedViewMatrix(): boolean;
  25761. /** @hidden */
  25762. _isSynchronizedProjectionMatrix(): boolean;
  25763. /**
  25764. * Attach the input controls to a specific dom element to get the input from.
  25765. * @param element Defines the element the controls should be listened from
  25766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25767. */
  25768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25769. /**
  25770. * Detach the current controls from the specified dom element.
  25771. * @param element Defines the element to stop listening the inputs from
  25772. */
  25773. detachControl(element: HTMLElement): void;
  25774. /**
  25775. * Update the camera state according to the different inputs gathered during the frame.
  25776. */
  25777. update(): void;
  25778. /** @hidden */
  25779. _checkInputs(): void;
  25780. /** @hidden */
  25781. readonly rigCameras: Camera[];
  25782. /**
  25783. * Gets the post process used by the rig cameras
  25784. */
  25785. readonly rigPostProcess: Nullable<PostProcess>;
  25786. /**
  25787. * Internal, gets the first post proces.
  25788. * @returns the first post process to be run on this camera.
  25789. */
  25790. _getFirstPostProcess(): Nullable<PostProcess>;
  25791. private _cascadePostProcessesToRigCams;
  25792. /**
  25793. * Attach a post process to the camera.
  25794. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25795. * @param postProcess The post process to attach to the camera
  25796. * @param insertAt The position of the post process in case several of them are in use in the scene
  25797. * @returns the position the post process has been inserted at
  25798. */
  25799. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25800. /**
  25801. * Detach a post process to the camera.
  25802. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25803. * @param postProcess The post process to detach from the camera
  25804. */
  25805. detachPostProcess(postProcess: PostProcess): void;
  25806. /**
  25807. * Gets the current world matrix of the camera
  25808. */
  25809. getWorldMatrix(): Matrix;
  25810. /** @hidden */
  25811. _getViewMatrix(): Matrix;
  25812. /**
  25813. * Gets the current view matrix of the camera.
  25814. * @param force forces the camera to recompute the matrix without looking at the cached state
  25815. * @returns the view matrix
  25816. */
  25817. getViewMatrix(force?: boolean): Matrix;
  25818. /**
  25819. * Freeze the projection matrix.
  25820. * It will prevent the cache check of the camera projection compute and can speed up perf
  25821. * if no parameter of the camera are meant to change
  25822. * @param projection Defines manually a projection if necessary
  25823. */
  25824. freezeProjectionMatrix(projection?: Matrix): void;
  25825. /**
  25826. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25827. */
  25828. unfreezeProjectionMatrix(): void;
  25829. /**
  25830. * Gets the current projection matrix of the camera.
  25831. * @param force forces the camera to recompute the matrix without looking at the cached state
  25832. * @returns the projection matrix
  25833. */
  25834. getProjectionMatrix(force?: boolean): Matrix;
  25835. /**
  25836. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25837. * @returns a Matrix
  25838. */
  25839. getTransformationMatrix(): Matrix;
  25840. private _updateFrustumPlanes;
  25841. /**
  25842. * Checks if a cullable object (mesh...) is in the camera frustum
  25843. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25844. * @param target The object to check
  25845. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25846. * @returns true if the object is in frustum otherwise false
  25847. */
  25848. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25849. /**
  25850. * Checks if a cullable object (mesh...) is in the camera frustum
  25851. * Unlike isInFrustum this cheks the full bounding box
  25852. * @param target The object to check
  25853. * @returns true if the object is in frustum otherwise false
  25854. */
  25855. isCompletelyInFrustum(target: ICullable): boolean;
  25856. /**
  25857. * Gets a ray in the forward direction from the camera.
  25858. * @param length Defines the length of the ray to create
  25859. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25860. * @param origin Defines the start point of the ray which defaults to the camera position
  25861. * @returns the forward ray
  25862. */
  25863. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25864. /**
  25865. * Releases resources associated with this node.
  25866. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25867. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25868. */
  25869. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25870. /** @hidden */
  25871. _isLeftCamera: boolean;
  25872. /**
  25873. * Gets the left camera of a rig setup in case of Rigged Camera
  25874. */
  25875. readonly isLeftCamera: boolean;
  25876. /** @hidden */
  25877. _isRightCamera: boolean;
  25878. /**
  25879. * Gets the right camera of a rig setup in case of Rigged Camera
  25880. */
  25881. readonly isRightCamera: boolean;
  25882. /**
  25883. * Gets the left camera of a rig setup in case of Rigged Camera
  25884. */
  25885. readonly leftCamera: Nullable<FreeCamera>;
  25886. /**
  25887. * Gets the right camera of a rig setup in case of Rigged Camera
  25888. */
  25889. readonly rightCamera: Nullable<FreeCamera>;
  25890. /**
  25891. * Gets the left camera target of a rig setup in case of Rigged Camera
  25892. * @returns the target position
  25893. */
  25894. getLeftTarget(): Nullable<Vector3>;
  25895. /**
  25896. * Gets the right camera target of a rig setup in case of Rigged Camera
  25897. * @returns the target position
  25898. */
  25899. getRightTarget(): Nullable<Vector3>;
  25900. /**
  25901. * @hidden
  25902. */
  25903. setCameraRigMode(mode: number, rigParams: any): void;
  25904. /** @hidden */
  25905. static _setStereoscopicRigMode(camera: Camera): void;
  25906. /** @hidden */
  25907. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25908. /** @hidden */
  25909. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25910. /** @hidden */
  25911. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25912. /** @hidden */
  25913. _getVRProjectionMatrix(): Matrix;
  25914. protected _updateCameraRotationMatrix(): void;
  25915. protected _updateWebVRCameraRotationMatrix(): void;
  25916. /**
  25917. * This function MUST be overwritten by the different WebVR cameras available.
  25918. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25919. * @hidden
  25920. */
  25921. _getWebVRProjectionMatrix(): Matrix;
  25922. /**
  25923. * This function MUST be overwritten by the different WebVR cameras available.
  25924. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25925. * @hidden
  25926. */
  25927. _getWebVRViewMatrix(): Matrix;
  25928. /** @hidden */
  25929. setCameraRigParameter(name: string, value: any): void;
  25930. /**
  25931. * needs to be overridden by children so sub has required properties to be copied
  25932. * @hidden
  25933. */
  25934. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25935. /**
  25936. * May need to be overridden by children
  25937. * @hidden
  25938. */
  25939. _updateRigCameras(): void;
  25940. /** @hidden */
  25941. _setupInputs(): void;
  25942. /**
  25943. * Serialiaze the camera setup to a json represention
  25944. * @returns the JSON representation
  25945. */
  25946. serialize(): any;
  25947. /**
  25948. * Clones the current camera.
  25949. * @param name The cloned camera name
  25950. * @returns the cloned camera
  25951. */
  25952. clone(name: string): Camera;
  25953. /**
  25954. * Gets the direction of the camera relative to a given local axis.
  25955. * @param localAxis Defines the reference axis to provide a relative direction.
  25956. * @return the direction
  25957. */
  25958. getDirection(localAxis: Vector3): Vector3;
  25959. /**
  25960. * Returns the current camera absolute rotation
  25961. */
  25962. readonly absoluteRotation: Quaternion;
  25963. /**
  25964. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25965. * @param localAxis Defines the reference axis to provide a relative direction.
  25966. * @param result Defines the vector to store the result in
  25967. */
  25968. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25969. /**
  25970. * Gets a camera constructor for a given camera type
  25971. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25972. * @param name The name of the camera the result will be able to instantiate
  25973. * @param scene The scene the result will construct the camera in
  25974. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25975. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25976. * @returns a factory method to construc the camera
  25977. */
  25978. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25979. /**
  25980. * Compute the world matrix of the camera.
  25981. * @returns the camera workd matrix
  25982. */
  25983. computeWorldMatrix(): Matrix;
  25984. /**
  25985. * Parse a JSON and creates the camera from the parsed information
  25986. * @param parsedCamera The JSON to parse
  25987. * @param scene The scene to instantiate the camera in
  25988. * @returns the newly constructed camera
  25989. */
  25990. static Parse(parsedCamera: any, scene: Scene): Camera;
  25991. }
  25992. }
  25993. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25994. import { Nullable } from "babylonjs/types";
  25995. import { Scene } from "babylonjs/scene";
  25996. import { Vector4 } from "babylonjs/Maths/math.vector";
  25997. import { Mesh } from "babylonjs/Meshes/mesh";
  25998. /**
  25999. * Class containing static functions to help procedurally build meshes
  26000. */
  26001. export class DiscBuilder {
  26002. /**
  26003. * Creates a plane polygonal mesh. By default, this is a disc
  26004. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26005. * * 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
  26006. * * 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
  26007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26010. * @param name defines the name of the mesh
  26011. * @param options defines the options used to create the mesh
  26012. * @param scene defines the hosting scene
  26013. * @returns the plane polygonal mesh
  26014. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26015. */
  26016. static CreateDisc(name: string, options: {
  26017. radius?: number;
  26018. tessellation?: number;
  26019. arc?: number;
  26020. updatable?: boolean;
  26021. sideOrientation?: number;
  26022. frontUVs?: Vector4;
  26023. backUVs?: Vector4;
  26024. }, scene?: Nullable<Scene>): Mesh;
  26025. }
  26026. }
  26027. declare module "babylonjs/Particles/solidParticleSystem" {
  26028. import { Vector3 } from "babylonjs/Maths/math.vector";
  26029. import { Mesh } from "babylonjs/Meshes/mesh";
  26030. import { Scene, IDisposable } from "babylonjs/scene";
  26031. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26032. /**
  26033. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26034. *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.
  26035. * The SPS is also a particle system. It provides some methods to manage the particles.
  26036. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26037. *
  26038. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26039. */
  26040. export class SolidParticleSystem implements IDisposable {
  26041. /**
  26042. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26043. * Example : var p = SPS.particles[i];
  26044. */
  26045. particles: SolidParticle[];
  26046. /**
  26047. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26048. */
  26049. nbParticles: number;
  26050. /**
  26051. * If the particles must ever face the camera (default false). Useful for planar particles.
  26052. */
  26053. billboard: boolean;
  26054. /**
  26055. * Recompute normals when adding a shape
  26056. */
  26057. recomputeNormals: boolean;
  26058. /**
  26059. * This a counter ofr your own usage. It's not set by any SPS functions.
  26060. */
  26061. counter: number;
  26062. /**
  26063. * The SPS name. This name is also given to the underlying mesh.
  26064. */
  26065. name: string;
  26066. /**
  26067. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26068. */
  26069. mesh: Mesh;
  26070. /**
  26071. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26072. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26073. */
  26074. vars: any;
  26075. /**
  26076. * This array is populated when the SPS is set as 'pickable'.
  26077. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26078. * Each element of this array is an object `{idx: int, faceId: int}`.
  26079. * `idx` is the picked particle index in the `SPS.particles` array
  26080. * `faceId` is the picked face index counted within this particle.
  26081. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26082. */
  26083. pickedParticles: {
  26084. idx: number;
  26085. faceId: number;
  26086. }[];
  26087. /**
  26088. * This array is populated when `enableDepthSort` is set to true.
  26089. * Each element of this array is an instance of the class DepthSortedParticle.
  26090. */
  26091. depthSortedParticles: DepthSortedParticle[];
  26092. /**
  26093. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26094. * @hidden
  26095. */
  26096. _bSphereOnly: boolean;
  26097. /**
  26098. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26099. * @hidden
  26100. */
  26101. _bSphereRadiusFactor: number;
  26102. private _scene;
  26103. private _positions;
  26104. private _indices;
  26105. private _normals;
  26106. private _colors;
  26107. private _uvs;
  26108. private _indices32;
  26109. private _positions32;
  26110. private _normals32;
  26111. private _fixedNormal32;
  26112. private _colors32;
  26113. private _uvs32;
  26114. private _index;
  26115. private _updatable;
  26116. private _pickable;
  26117. private _isVisibilityBoxLocked;
  26118. private _alwaysVisible;
  26119. private _depthSort;
  26120. private _shapeCounter;
  26121. private _copy;
  26122. private _color;
  26123. private _computeParticleColor;
  26124. private _computeParticleTexture;
  26125. private _computeParticleRotation;
  26126. private _computeParticleVertex;
  26127. private _computeBoundingBox;
  26128. private _depthSortParticles;
  26129. private _camera;
  26130. private _mustUnrotateFixedNormals;
  26131. private _particlesIntersect;
  26132. private _needs32Bits;
  26133. /**
  26134. * Creates a SPS (Solid Particle System) object.
  26135. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26136. * @param scene (Scene) is the scene in which the SPS is added.
  26137. * @param options defines the options of the sps e.g.
  26138. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26139. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26140. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26141. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26142. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26143. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26144. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26145. */
  26146. constructor(name: string, scene: Scene, options?: {
  26147. updatable?: boolean;
  26148. isPickable?: boolean;
  26149. enableDepthSort?: boolean;
  26150. particleIntersection?: boolean;
  26151. boundingSphereOnly?: boolean;
  26152. bSphereRadiusFactor?: number;
  26153. });
  26154. /**
  26155. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26156. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26157. * @returns the created mesh
  26158. */
  26159. buildMesh(): Mesh;
  26160. /**
  26161. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26162. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26163. * Thus the particles generated from `digest()` have their property `position` set yet.
  26164. * @param mesh ( Mesh ) is the mesh to be digested
  26165. * @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
  26166. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26167. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26168. * @returns the current SPS
  26169. */
  26170. digest(mesh: Mesh, options?: {
  26171. facetNb?: number;
  26172. number?: number;
  26173. delta?: number;
  26174. }): SolidParticleSystem;
  26175. private _unrotateFixedNormals;
  26176. private _resetCopy;
  26177. private _meshBuilder;
  26178. private _posToShape;
  26179. private _uvsToShapeUV;
  26180. private _addParticle;
  26181. /**
  26182. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26183. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26184. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26185. * @param nb (positive integer) the number of particles to be created from this model
  26186. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26187. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26188. * @returns the number of shapes in the system
  26189. */
  26190. addShape(mesh: Mesh, nb: number, options?: {
  26191. positionFunction?: any;
  26192. vertexFunction?: any;
  26193. }): number;
  26194. private _rebuildParticle;
  26195. /**
  26196. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26197. * @returns the SPS.
  26198. */
  26199. rebuildMesh(): SolidParticleSystem;
  26200. /**
  26201. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26202. * This method calls `updateParticle()` for each particle of the SPS.
  26203. * For an animated SPS, it is usually called within the render loop.
  26204. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26205. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26206. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26207. * @returns the SPS.
  26208. */
  26209. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26210. /**
  26211. * Disposes the SPS.
  26212. */
  26213. dispose(): void;
  26214. /**
  26215. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26216. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26217. * @returns the SPS.
  26218. */
  26219. refreshVisibleSize(): SolidParticleSystem;
  26220. /**
  26221. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26222. * @param size the size (float) of the visibility box
  26223. * note : this doesn't lock the SPS mesh bounding box.
  26224. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26225. */
  26226. setVisibilityBox(size: number): void;
  26227. /**
  26228. * Gets whether the SPS as always visible or not
  26229. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26230. */
  26231. /**
  26232. * Sets the SPS as always visible or not
  26233. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26234. */
  26235. isAlwaysVisible: boolean;
  26236. /**
  26237. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26238. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26239. */
  26240. /**
  26241. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26242. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26243. */
  26244. isVisibilityBoxLocked: boolean;
  26245. /**
  26246. * Tells to `setParticles()` to compute the particle rotations or not.
  26247. * Default value : true. The SPS is faster when it's set to false.
  26248. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26249. */
  26250. /**
  26251. * Gets if `setParticles()` computes the particle rotations or not.
  26252. * Default value : true. The SPS is faster when it's set to false.
  26253. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26254. */
  26255. computeParticleRotation: boolean;
  26256. /**
  26257. * Tells to `setParticles()` to compute the particle colors or not.
  26258. * Default value : true. The SPS is faster when it's set to false.
  26259. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26260. */
  26261. /**
  26262. * Gets if `setParticles()` computes the particle colors or not.
  26263. * Default value : true. The SPS is faster when it's set to false.
  26264. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26265. */
  26266. computeParticleColor: boolean;
  26267. /**
  26268. * Gets if `setParticles()` computes the particle textures or not.
  26269. * Default value : true. The SPS is faster when it's set to false.
  26270. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26271. */
  26272. computeParticleTexture: boolean;
  26273. /**
  26274. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26275. * Default value : false. The SPS is faster when it's set to false.
  26276. * Note : the particle custom vertex positions aren't stored values.
  26277. */
  26278. /**
  26279. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26280. * Default value : false. The SPS is faster when it's set to false.
  26281. * Note : the particle custom vertex positions aren't stored values.
  26282. */
  26283. computeParticleVertex: boolean;
  26284. /**
  26285. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26286. */
  26287. /**
  26288. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26289. */
  26290. computeBoundingBox: boolean;
  26291. /**
  26292. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26293. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26294. * Default : `true`
  26295. */
  26296. /**
  26297. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26298. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26299. * Default : `true`
  26300. */
  26301. depthSortParticles: boolean;
  26302. /**
  26303. * This function does nothing. It may be overwritten to set all the particle first values.
  26304. * The SPS doesn't call this function, you may have to call it by your own.
  26305. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26306. */
  26307. initParticles(): void;
  26308. /**
  26309. * This function does nothing. It may be overwritten to recycle a particle.
  26310. * The SPS doesn't call this function, you may have to call it by your own.
  26311. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26312. * @param particle The particle to recycle
  26313. * @returns the recycled particle
  26314. */
  26315. recycleParticle(particle: SolidParticle): SolidParticle;
  26316. /**
  26317. * Updates a particle : this function should be overwritten by the user.
  26318. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26319. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26320. * @example : just set a particle position or velocity and recycle conditions
  26321. * @param particle The particle to update
  26322. * @returns the updated particle
  26323. */
  26324. updateParticle(particle: SolidParticle): SolidParticle;
  26325. /**
  26326. * Updates a vertex of a particle : it can be overwritten by the user.
  26327. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26328. * @param particle the current particle
  26329. * @param vertex the current index of the current particle
  26330. * @param pt the index of the current vertex in the particle shape
  26331. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26332. * @example : just set a vertex particle position
  26333. * @returns the updated vertex
  26334. */
  26335. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26336. /**
  26337. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26338. * This does nothing and may be overwritten by the user.
  26339. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26340. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26341. * @param update the boolean update value actually passed to setParticles()
  26342. */
  26343. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26344. /**
  26345. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26346. * This will be passed three parameters.
  26347. * This does nothing and may be overwritten by the user.
  26348. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26349. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26350. * @param update the boolean update value actually passed to setParticles()
  26351. */
  26352. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26353. }
  26354. }
  26355. declare module "babylonjs/Particles/solidParticle" {
  26356. import { Nullable } from "babylonjs/types";
  26357. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26358. import { Color4 } from "babylonjs/Maths/math.color";
  26359. import { Mesh } from "babylonjs/Meshes/mesh";
  26360. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26361. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26362. import { Plane } from "babylonjs/Maths/math.plane";
  26363. /**
  26364. * Represents one particle of a solid particle system.
  26365. */
  26366. export class SolidParticle {
  26367. /**
  26368. * particle global index
  26369. */
  26370. idx: number;
  26371. /**
  26372. * The color of the particle
  26373. */
  26374. color: Nullable<Color4>;
  26375. /**
  26376. * The world space position of the particle.
  26377. */
  26378. position: Vector3;
  26379. /**
  26380. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26381. */
  26382. rotation: Vector3;
  26383. /**
  26384. * The world space rotation quaternion of the particle.
  26385. */
  26386. rotationQuaternion: Nullable<Quaternion>;
  26387. /**
  26388. * The scaling of the particle.
  26389. */
  26390. scaling: Vector3;
  26391. /**
  26392. * The uvs of the particle.
  26393. */
  26394. uvs: Vector4;
  26395. /**
  26396. * The current speed of the particle.
  26397. */
  26398. velocity: Vector3;
  26399. /**
  26400. * The pivot point in the particle local space.
  26401. */
  26402. pivot: Vector3;
  26403. /**
  26404. * Must the particle be translated from its pivot point in its local space ?
  26405. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26406. * Default : false
  26407. */
  26408. translateFromPivot: boolean;
  26409. /**
  26410. * Is the particle active or not ?
  26411. */
  26412. alive: boolean;
  26413. /**
  26414. * Is the particle visible or not ?
  26415. */
  26416. isVisible: boolean;
  26417. /**
  26418. * Index of this particle in the global "positions" array (Internal use)
  26419. * @hidden
  26420. */
  26421. _pos: number;
  26422. /**
  26423. * @hidden Index of this particle in the global "indices" array (Internal use)
  26424. */
  26425. _ind: number;
  26426. /**
  26427. * @hidden ModelShape of this particle (Internal use)
  26428. */
  26429. _model: ModelShape;
  26430. /**
  26431. * ModelShape id of this particle
  26432. */
  26433. shapeId: number;
  26434. /**
  26435. * Index of the particle in its shape id
  26436. */
  26437. idxInShape: number;
  26438. /**
  26439. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26440. */
  26441. _modelBoundingInfo: BoundingInfo;
  26442. /**
  26443. * @hidden Particle BoundingInfo object (Internal use)
  26444. */
  26445. _boundingInfo: BoundingInfo;
  26446. /**
  26447. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26448. */
  26449. _sps: SolidParticleSystem;
  26450. /**
  26451. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26452. */
  26453. _stillInvisible: boolean;
  26454. /**
  26455. * @hidden Last computed particle rotation matrix
  26456. */
  26457. _rotationMatrix: number[];
  26458. /**
  26459. * Parent particle Id, if any.
  26460. * Default null.
  26461. */
  26462. parentId: Nullable<number>;
  26463. /**
  26464. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26465. * The possible values are :
  26466. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26467. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26468. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26469. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26470. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26471. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26472. * */
  26473. cullingStrategy: number;
  26474. /**
  26475. * @hidden Internal global position in the SPS.
  26476. */
  26477. _globalPosition: Vector3;
  26478. /**
  26479. * Creates a Solid Particle object.
  26480. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26481. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26482. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26483. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26484. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26485. * @param shapeId (integer) is the model shape identifier in the SPS.
  26486. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26487. * @param sps defines the sps it is associated to
  26488. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26489. */
  26490. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26491. /**
  26492. * Legacy support, changed scale to scaling
  26493. */
  26494. /**
  26495. * Legacy support, changed scale to scaling
  26496. */
  26497. scale: Vector3;
  26498. /**
  26499. * Legacy support, changed quaternion to rotationQuaternion
  26500. */
  26501. /**
  26502. * Legacy support, changed quaternion to rotationQuaternion
  26503. */
  26504. quaternion: Nullable<Quaternion>;
  26505. /**
  26506. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26507. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26508. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26509. * @returns true if it intersects
  26510. */
  26511. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26512. /**
  26513. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26514. * A particle is in the frustum if its bounding box intersects the frustum
  26515. * @param frustumPlanes defines the frustum to test
  26516. * @returns true if the particle is in the frustum planes
  26517. */
  26518. isInFrustum(frustumPlanes: Plane[]): boolean;
  26519. /**
  26520. * get the rotation matrix of the particle
  26521. * @hidden
  26522. */
  26523. getRotationMatrix(m: Matrix): void;
  26524. }
  26525. /**
  26526. * Represents the shape of the model used by one particle of a solid particle system.
  26527. * SPS internal tool, don't use it manually.
  26528. */
  26529. export class ModelShape {
  26530. /**
  26531. * The shape id
  26532. * @hidden
  26533. */
  26534. shapeID: number;
  26535. /**
  26536. * flat array of model positions (internal use)
  26537. * @hidden
  26538. */
  26539. _shape: Vector3[];
  26540. /**
  26541. * flat array of model UVs (internal use)
  26542. * @hidden
  26543. */
  26544. _shapeUV: number[];
  26545. /**
  26546. * length of the shape in the model indices array (internal use)
  26547. * @hidden
  26548. */
  26549. _indicesLength: number;
  26550. /**
  26551. * Custom position function (internal use)
  26552. * @hidden
  26553. */
  26554. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26555. /**
  26556. * Custom vertex function (internal use)
  26557. * @hidden
  26558. */
  26559. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26560. /**
  26561. * 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.
  26562. * SPS internal tool, don't use it manually.
  26563. * @hidden
  26564. */
  26565. 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>);
  26566. }
  26567. /**
  26568. * Represents a Depth Sorted Particle in the solid particle system.
  26569. */
  26570. export class DepthSortedParticle {
  26571. /**
  26572. * Index of the particle in the "indices" array
  26573. */
  26574. ind: number;
  26575. /**
  26576. * Length of the particle shape in the "indices" array
  26577. */
  26578. indicesLength: number;
  26579. /**
  26580. * Squared distance from the particle to the camera
  26581. */
  26582. sqDistance: number;
  26583. }
  26584. }
  26585. declare module "babylonjs/Collisions/meshCollisionData" {
  26586. import { Collider } from "babylonjs/Collisions/collider";
  26587. import { Vector3 } from "babylonjs/Maths/math.vector";
  26588. import { Nullable } from "babylonjs/types";
  26589. import { Observer } from "babylonjs/Misc/observable";
  26590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26591. /**
  26592. * @hidden
  26593. */
  26594. export class _MeshCollisionData {
  26595. _checkCollisions: boolean;
  26596. _collisionMask: number;
  26597. _collisionGroup: number;
  26598. _collider: Nullable<Collider>;
  26599. _oldPositionForCollisions: Vector3;
  26600. _diffPositionForCollisions: Vector3;
  26601. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26602. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26603. }
  26604. }
  26605. declare module "babylonjs/Meshes/abstractMesh" {
  26606. import { Observable } from "babylonjs/Misc/observable";
  26607. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26608. import { Camera } from "babylonjs/Cameras/camera";
  26609. import { Scene, IDisposable } from "babylonjs/scene";
  26610. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26611. import { Node } from "babylonjs/node";
  26612. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26615. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26616. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26617. import { Material } from "babylonjs/Materials/material";
  26618. import { Light } from "babylonjs/Lights/light";
  26619. import { Skeleton } from "babylonjs/Bones/skeleton";
  26620. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26621. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26622. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26623. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26624. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26625. import { Plane } from "babylonjs/Maths/math.plane";
  26626. import { Ray } from "babylonjs/Culling/ray";
  26627. import { Collider } from "babylonjs/Collisions/collider";
  26628. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26629. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26630. /** @hidden */
  26631. class _FacetDataStorage {
  26632. facetPositions: Vector3[];
  26633. facetNormals: Vector3[];
  26634. facetPartitioning: number[][];
  26635. facetNb: number;
  26636. partitioningSubdivisions: number;
  26637. partitioningBBoxRatio: number;
  26638. facetDataEnabled: boolean;
  26639. facetParameters: any;
  26640. bbSize: Vector3;
  26641. subDiv: {
  26642. max: number;
  26643. X: number;
  26644. Y: number;
  26645. Z: number;
  26646. };
  26647. facetDepthSort: boolean;
  26648. facetDepthSortEnabled: boolean;
  26649. depthSortedIndices: IndicesArray;
  26650. depthSortedFacets: {
  26651. ind: number;
  26652. sqDistance: number;
  26653. }[];
  26654. facetDepthSortFunction: (f1: {
  26655. ind: number;
  26656. sqDistance: number;
  26657. }, f2: {
  26658. ind: number;
  26659. sqDistance: number;
  26660. }) => number;
  26661. facetDepthSortFrom: Vector3;
  26662. facetDepthSortOrigin: Vector3;
  26663. invertedMatrix: Matrix;
  26664. }
  26665. /**
  26666. * @hidden
  26667. **/
  26668. class _InternalAbstractMeshDataInfo {
  26669. _hasVertexAlpha: boolean;
  26670. _useVertexColors: boolean;
  26671. _numBoneInfluencers: number;
  26672. _applyFog: boolean;
  26673. _receiveShadows: boolean;
  26674. _facetData: _FacetDataStorage;
  26675. _visibility: number;
  26676. _skeleton: Nullable<Skeleton>;
  26677. _layerMask: number;
  26678. _computeBonesUsingShaders: boolean;
  26679. _isActive: boolean;
  26680. _onlyForInstances: boolean;
  26681. _isActiveIntermediate: boolean;
  26682. _onlyForInstancesIntermediate: boolean;
  26683. }
  26684. /**
  26685. * Class used to store all common mesh properties
  26686. */
  26687. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26688. /** No occlusion */
  26689. static OCCLUSION_TYPE_NONE: number;
  26690. /** Occlusion set to optimisitic */
  26691. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26692. /** Occlusion set to strict */
  26693. static OCCLUSION_TYPE_STRICT: number;
  26694. /** Use an accurante occlusion algorithm */
  26695. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26696. /** Use a conservative occlusion algorithm */
  26697. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26698. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26699. * Test order :
  26700. * Is the bounding sphere outside the frustum ?
  26701. * If not, are the bounding box vertices outside the frustum ?
  26702. * It not, then the cullable object is in the frustum.
  26703. */
  26704. static readonly CULLINGSTRATEGY_STANDARD: number;
  26705. /** Culling strategy : Bounding Sphere Only.
  26706. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26707. * It's also less accurate than the standard because some not visible objects can still be selected.
  26708. * Test : is the bounding sphere outside the frustum ?
  26709. * If not, then the cullable object is in the frustum.
  26710. */
  26711. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26712. /** Culling strategy : Optimistic Inclusion.
  26713. * This in an inclusion test first, then the standard exclusion test.
  26714. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26715. * 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.
  26716. * Anyway, it's as accurate as the standard strategy.
  26717. * Test :
  26718. * Is the cullable object bounding sphere center in the frustum ?
  26719. * If not, apply the default culling strategy.
  26720. */
  26721. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26722. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26723. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26724. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26725. * 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.
  26726. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26727. * Test :
  26728. * Is the cullable object bounding sphere center in the frustum ?
  26729. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26730. */
  26731. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26732. /**
  26733. * No billboard
  26734. */
  26735. static readonly BILLBOARDMODE_NONE: number;
  26736. /** Billboard on X axis */
  26737. static readonly BILLBOARDMODE_X: number;
  26738. /** Billboard on Y axis */
  26739. static readonly BILLBOARDMODE_Y: number;
  26740. /** Billboard on Z axis */
  26741. static readonly BILLBOARDMODE_Z: number;
  26742. /** Billboard on all axes */
  26743. static readonly BILLBOARDMODE_ALL: number;
  26744. /** Billboard on using position instead of orientation */
  26745. static readonly BILLBOARDMODE_USE_POSITION: number;
  26746. /** @hidden */
  26747. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26748. /**
  26749. * The culling strategy to use to check whether the mesh must be rendered or not.
  26750. * This value can be changed at any time and will be used on the next render mesh selection.
  26751. * The possible values are :
  26752. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26753. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26754. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26755. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26756. * Please read each static variable documentation to get details about the culling process.
  26757. * */
  26758. cullingStrategy: number;
  26759. /**
  26760. * Gets the number of facets in the mesh
  26761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26762. */
  26763. readonly facetNb: number;
  26764. /**
  26765. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26767. */
  26768. partitioningSubdivisions: number;
  26769. /**
  26770. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26771. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26773. */
  26774. partitioningBBoxRatio: number;
  26775. /**
  26776. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26777. * Works only for updatable meshes.
  26778. * Doesn't work with multi-materials
  26779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26780. */
  26781. mustDepthSortFacets: boolean;
  26782. /**
  26783. * The location (Vector3) where the facet depth sort must be computed from.
  26784. * By default, the active camera position.
  26785. * Used only when facet depth sort is enabled
  26786. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26787. */
  26788. facetDepthSortFrom: Vector3;
  26789. /**
  26790. * gets a boolean indicating if facetData is enabled
  26791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26792. */
  26793. readonly isFacetDataEnabled: boolean;
  26794. /** @hidden */
  26795. _updateNonUniformScalingState(value: boolean): boolean;
  26796. /**
  26797. * An event triggered when this mesh collides with another one
  26798. */
  26799. onCollideObservable: Observable<AbstractMesh>;
  26800. /** Set a function to call when this mesh collides with another one */
  26801. onCollide: () => void;
  26802. /**
  26803. * An event triggered when the collision's position changes
  26804. */
  26805. onCollisionPositionChangeObservable: Observable<Vector3>;
  26806. /** Set a function to call when the collision's position changes */
  26807. onCollisionPositionChange: () => void;
  26808. /**
  26809. * An event triggered when material is changed
  26810. */
  26811. onMaterialChangedObservable: Observable<AbstractMesh>;
  26812. /**
  26813. * Gets or sets the orientation for POV movement & rotation
  26814. */
  26815. definedFacingForward: boolean;
  26816. /** @hidden */
  26817. _occlusionQuery: Nullable<WebGLQuery>;
  26818. /** @hidden */
  26819. _renderingGroup: Nullable<RenderingGroup>;
  26820. /**
  26821. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26822. */
  26823. /**
  26824. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26825. */
  26826. visibility: number;
  26827. /** Gets or sets the alpha index used to sort transparent meshes
  26828. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26829. */
  26830. alphaIndex: number;
  26831. /**
  26832. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26833. */
  26834. isVisible: boolean;
  26835. /**
  26836. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26837. */
  26838. isPickable: boolean;
  26839. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26840. showSubMeshesBoundingBox: boolean;
  26841. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26842. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26843. */
  26844. isBlocker: boolean;
  26845. /**
  26846. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26847. */
  26848. enablePointerMoveEvents: boolean;
  26849. /**
  26850. * Specifies the rendering group id for this mesh (0 by default)
  26851. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26852. */
  26853. renderingGroupId: number;
  26854. private _material;
  26855. /** Gets or sets current material */
  26856. material: Nullable<Material>;
  26857. /**
  26858. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26859. * @see http://doc.babylonjs.com/babylon101/shadows
  26860. */
  26861. receiveShadows: boolean;
  26862. /** Defines color to use when rendering outline */
  26863. outlineColor: Color3;
  26864. /** Define width to use when rendering outline */
  26865. outlineWidth: number;
  26866. /** Defines color to use when rendering overlay */
  26867. overlayColor: Color3;
  26868. /** Defines alpha to use when rendering overlay */
  26869. overlayAlpha: number;
  26870. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26871. hasVertexAlpha: boolean;
  26872. /** 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) */
  26873. useVertexColors: boolean;
  26874. /**
  26875. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26876. */
  26877. computeBonesUsingShaders: boolean;
  26878. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26879. numBoneInfluencers: number;
  26880. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26881. applyFog: boolean;
  26882. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26883. useOctreeForRenderingSelection: boolean;
  26884. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26885. useOctreeForPicking: boolean;
  26886. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26887. useOctreeForCollisions: boolean;
  26888. /**
  26889. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26890. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26891. */
  26892. layerMask: number;
  26893. /**
  26894. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26895. */
  26896. alwaysSelectAsActiveMesh: boolean;
  26897. /**
  26898. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26899. */
  26900. doNotSyncBoundingInfo: boolean;
  26901. /**
  26902. * Gets or sets the current action manager
  26903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26904. */
  26905. actionManager: Nullable<AbstractActionManager>;
  26906. private _meshCollisionData;
  26907. /**
  26908. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26909. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26910. */
  26911. ellipsoid: Vector3;
  26912. /**
  26913. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26914. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26915. */
  26916. ellipsoidOffset: Vector3;
  26917. /**
  26918. * Gets or sets a collision mask used to mask collisions (default is -1).
  26919. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26920. */
  26921. collisionMask: number;
  26922. /**
  26923. * Gets or sets the current collision group mask (-1 by default).
  26924. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26925. */
  26926. collisionGroup: number;
  26927. /**
  26928. * Defines edge width used when edgesRenderer is enabled
  26929. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26930. */
  26931. edgesWidth: number;
  26932. /**
  26933. * Defines edge color used when edgesRenderer is enabled
  26934. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26935. */
  26936. edgesColor: Color4;
  26937. /** @hidden */
  26938. _edgesRenderer: Nullable<IEdgesRenderer>;
  26939. /** @hidden */
  26940. _masterMesh: Nullable<AbstractMesh>;
  26941. /** @hidden */
  26942. _boundingInfo: Nullable<BoundingInfo>;
  26943. /** @hidden */
  26944. _renderId: number;
  26945. /**
  26946. * Gets or sets the list of subMeshes
  26947. * @see http://doc.babylonjs.com/how_to/multi_materials
  26948. */
  26949. subMeshes: SubMesh[];
  26950. /** @hidden */
  26951. _intersectionsInProgress: AbstractMesh[];
  26952. /** @hidden */
  26953. _unIndexed: boolean;
  26954. /** @hidden */
  26955. _lightSources: Light[];
  26956. /** Gets the list of lights affecting that mesh */
  26957. readonly lightSources: Light[];
  26958. /** @hidden */
  26959. readonly _positions: Nullable<Vector3[]>;
  26960. /** @hidden */
  26961. _waitingData: {
  26962. lods: Nullable<any>;
  26963. actions: Nullable<any>;
  26964. freezeWorldMatrix: Nullable<boolean>;
  26965. };
  26966. /** @hidden */
  26967. _bonesTransformMatrices: Nullable<Float32Array>;
  26968. /** @hidden */
  26969. _transformMatrixTexture: Nullable<RawTexture>;
  26970. /**
  26971. * Gets or sets a skeleton to apply skining transformations
  26972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26973. */
  26974. skeleton: Nullable<Skeleton>;
  26975. /**
  26976. * An event triggered when the mesh is rebuilt.
  26977. */
  26978. onRebuildObservable: Observable<AbstractMesh>;
  26979. /**
  26980. * Creates a new AbstractMesh
  26981. * @param name defines the name of the mesh
  26982. * @param scene defines the hosting scene
  26983. */
  26984. constructor(name: string, scene?: Nullable<Scene>);
  26985. /**
  26986. * Returns the string "AbstractMesh"
  26987. * @returns "AbstractMesh"
  26988. */
  26989. getClassName(): string;
  26990. /**
  26991. * Gets a string representation of the current mesh
  26992. * @param fullDetails defines a boolean indicating if full details must be included
  26993. * @returns a string representation of the current mesh
  26994. */
  26995. toString(fullDetails?: boolean): string;
  26996. /**
  26997. * @hidden
  26998. */
  26999. protected _getEffectiveParent(): Nullable<Node>;
  27000. /** @hidden */
  27001. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27002. /** @hidden */
  27003. _rebuild(): void;
  27004. /** @hidden */
  27005. _resyncLightSources(): void;
  27006. /** @hidden */
  27007. _resyncLighSource(light: Light): void;
  27008. /** @hidden */
  27009. _unBindEffect(): void;
  27010. /** @hidden */
  27011. _removeLightSource(light: Light, dispose: boolean): void;
  27012. private _markSubMeshesAsDirty;
  27013. /** @hidden */
  27014. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27015. /** @hidden */
  27016. _markSubMeshesAsAttributesDirty(): void;
  27017. /** @hidden */
  27018. _markSubMeshesAsMiscDirty(): void;
  27019. /**
  27020. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27021. */
  27022. scaling: Vector3;
  27023. /**
  27024. * Returns true if the mesh is blocked. Implemented by child classes
  27025. */
  27026. readonly isBlocked: boolean;
  27027. /**
  27028. * Returns the mesh itself by default. Implemented by child classes
  27029. * @param camera defines the camera to use to pick the right LOD level
  27030. * @returns the currentAbstractMesh
  27031. */
  27032. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27033. /**
  27034. * Returns 0 by default. Implemented by child classes
  27035. * @returns an integer
  27036. */
  27037. getTotalVertices(): number;
  27038. /**
  27039. * Returns a positive integer : the total number of indices in this mesh geometry.
  27040. * @returns the numner of indices or zero if the mesh has no geometry.
  27041. */
  27042. getTotalIndices(): number;
  27043. /**
  27044. * Returns null by default. Implemented by child classes
  27045. * @returns null
  27046. */
  27047. getIndices(): Nullable<IndicesArray>;
  27048. /**
  27049. * Returns the array of the requested vertex data kind. Implemented by child classes
  27050. * @param kind defines the vertex data kind to use
  27051. * @returns null
  27052. */
  27053. getVerticesData(kind: string): Nullable<FloatArray>;
  27054. /**
  27055. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27056. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27057. * Note that a new underlying VertexBuffer object is created each call.
  27058. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27059. * @param kind defines vertex data kind:
  27060. * * VertexBuffer.PositionKind
  27061. * * VertexBuffer.UVKind
  27062. * * VertexBuffer.UV2Kind
  27063. * * VertexBuffer.UV3Kind
  27064. * * VertexBuffer.UV4Kind
  27065. * * VertexBuffer.UV5Kind
  27066. * * VertexBuffer.UV6Kind
  27067. * * VertexBuffer.ColorKind
  27068. * * VertexBuffer.MatricesIndicesKind
  27069. * * VertexBuffer.MatricesIndicesExtraKind
  27070. * * VertexBuffer.MatricesWeightsKind
  27071. * * VertexBuffer.MatricesWeightsExtraKind
  27072. * @param data defines the data source
  27073. * @param updatable defines if the data must be flagged as updatable (or static)
  27074. * @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
  27075. * @returns the current mesh
  27076. */
  27077. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27078. /**
  27079. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27080. * If the mesh has no geometry, it is simply returned as it is.
  27081. * @param kind defines vertex data kind:
  27082. * * VertexBuffer.PositionKind
  27083. * * VertexBuffer.UVKind
  27084. * * VertexBuffer.UV2Kind
  27085. * * VertexBuffer.UV3Kind
  27086. * * VertexBuffer.UV4Kind
  27087. * * VertexBuffer.UV5Kind
  27088. * * VertexBuffer.UV6Kind
  27089. * * VertexBuffer.ColorKind
  27090. * * VertexBuffer.MatricesIndicesKind
  27091. * * VertexBuffer.MatricesIndicesExtraKind
  27092. * * VertexBuffer.MatricesWeightsKind
  27093. * * VertexBuffer.MatricesWeightsExtraKind
  27094. * @param data defines the data source
  27095. * @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
  27096. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27097. * @returns the current mesh
  27098. */
  27099. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27100. /**
  27101. * Sets the mesh indices,
  27102. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27103. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27104. * @param totalVertices Defines the total number of vertices
  27105. * @returns the current mesh
  27106. */
  27107. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27108. /**
  27109. * Gets a boolean indicating if specific vertex data is present
  27110. * @param kind defines the vertex data kind to use
  27111. * @returns true is data kind is present
  27112. */
  27113. isVerticesDataPresent(kind: string): boolean;
  27114. /**
  27115. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27116. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27117. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27118. * @returns a BoundingInfo
  27119. */
  27120. getBoundingInfo(): BoundingInfo;
  27121. /**
  27122. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27123. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27124. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27125. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27126. * @returns the current mesh
  27127. */
  27128. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27129. /**
  27130. * Overwrite the current bounding info
  27131. * @param boundingInfo defines the new bounding info
  27132. * @returns the current mesh
  27133. */
  27134. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27135. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27136. readonly useBones: boolean;
  27137. /** @hidden */
  27138. _preActivate(): void;
  27139. /** @hidden */
  27140. _preActivateForIntermediateRendering(renderId: number): void;
  27141. /** @hidden */
  27142. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27143. /** @hidden */
  27144. _postActivate(): void;
  27145. /** @hidden */
  27146. _freeze(): void;
  27147. /** @hidden */
  27148. _unFreeze(): void;
  27149. /**
  27150. * Gets the current world matrix
  27151. * @returns a Matrix
  27152. */
  27153. getWorldMatrix(): Matrix;
  27154. /** @hidden */
  27155. _getWorldMatrixDeterminant(): number;
  27156. /**
  27157. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27158. */
  27159. readonly isAnInstance: boolean;
  27160. /**
  27161. * Gets a boolean indicating if this mesh has instances
  27162. */
  27163. readonly hasInstances: boolean;
  27164. /**
  27165. * Perform relative position change from the point of view of behind the front of the mesh.
  27166. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27167. * Supports definition of mesh facing forward or backward
  27168. * @param amountRight defines the distance on the right axis
  27169. * @param amountUp defines the distance on the up axis
  27170. * @param amountForward defines the distance on the forward axis
  27171. * @returns the current mesh
  27172. */
  27173. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27174. /**
  27175. * Calculate relative position change from the point of view of behind the front of the mesh.
  27176. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27177. * Supports definition of mesh facing forward or backward
  27178. * @param amountRight defines the distance on the right axis
  27179. * @param amountUp defines the distance on the up axis
  27180. * @param amountForward defines the distance on the forward axis
  27181. * @returns the new displacement vector
  27182. */
  27183. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27184. /**
  27185. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27186. * Supports definition of mesh facing forward or backward
  27187. * @param flipBack defines the flip
  27188. * @param twirlClockwise defines the twirl
  27189. * @param tiltRight defines the tilt
  27190. * @returns the current mesh
  27191. */
  27192. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27193. /**
  27194. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27195. * Supports definition of mesh facing forward or backward.
  27196. * @param flipBack defines the flip
  27197. * @param twirlClockwise defines the twirl
  27198. * @param tiltRight defines the tilt
  27199. * @returns the new rotation vector
  27200. */
  27201. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27202. /**
  27203. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27204. * This means the mesh underlying bounding box and sphere are recomputed.
  27205. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27206. * @returns the current mesh
  27207. */
  27208. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27209. /** @hidden */
  27210. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27211. /** @hidden */
  27212. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27213. /** @hidden */
  27214. _updateBoundingInfo(): AbstractMesh;
  27215. /** @hidden */
  27216. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27217. /** @hidden */
  27218. protected _afterComputeWorldMatrix(): void;
  27219. /** @hidden */
  27220. readonly _effectiveMesh: AbstractMesh;
  27221. /**
  27222. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27223. * A mesh is in the frustum if its bounding box intersects the frustum
  27224. * @param frustumPlanes defines the frustum to test
  27225. * @returns true if the mesh is in the frustum planes
  27226. */
  27227. isInFrustum(frustumPlanes: Plane[]): boolean;
  27228. /**
  27229. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27230. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27231. * @param frustumPlanes defines the frustum to test
  27232. * @returns true if the mesh is completely in the frustum planes
  27233. */
  27234. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27235. /**
  27236. * True if the mesh intersects another mesh or a SolidParticle object
  27237. * @param mesh defines a target mesh or SolidParticle to test
  27238. * @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)
  27239. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27240. * @returns true if there is an intersection
  27241. */
  27242. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27243. /**
  27244. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27245. * @param point defines the point to test
  27246. * @returns true if there is an intersection
  27247. */
  27248. intersectsPoint(point: Vector3): boolean;
  27249. /**
  27250. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27252. */
  27253. checkCollisions: boolean;
  27254. /**
  27255. * Gets Collider object used to compute collisions (not physics)
  27256. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27257. */
  27258. readonly collider: Nullable<Collider>;
  27259. /**
  27260. * Move the mesh using collision engine
  27261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27262. * @param displacement defines the requested displacement vector
  27263. * @returns the current mesh
  27264. */
  27265. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27266. private _onCollisionPositionChange;
  27267. /** @hidden */
  27268. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27269. /** @hidden */
  27270. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27271. /** @hidden */
  27272. _checkCollision(collider: Collider): AbstractMesh;
  27273. /** @hidden */
  27274. _generatePointsArray(): boolean;
  27275. /**
  27276. * Checks if the passed Ray intersects with the mesh
  27277. * @param ray defines the ray to use
  27278. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27279. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27280. * @returns the picking info
  27281. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27282. */
  27283. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27284. /**
  27285. * Clones the current mesh
  27286. * @param name defines the mesh name
  27287. * @param newParent defines the new mesh parent
  27288. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27289. * @returns the new mesh
  27290. */
  27291. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27292. /**
  27293. * Disposes all the submeshes of the current meshnp
  27294. * @returns the current mesh
  27295. */
  27296. releaseSubMeshes(): AbstractMesh;
  27297. /**
  27298. * Releases resources associated with this abstract mesh.
  27299. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27300. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27301. */
  27302. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27303. /**
  27304. * Adds the passed mesh as a child to the current mesh
  27305. * @param mesh defines the child mesh
  27306. * @returns the current mesh
  27307. */
  27308. addChild(mesh: AbstractMesh): AbstractMesh;
  27309. /**
  27310. * Removes the passed mesh from the current mesh children list
  27311. * @param mesh defines the child mesh
  27312. * @returns the current mesh
  27313. */
  27314. removeChild(mesh: AbstractMesh): AbstractMesh;
  27315. /** @hidden */
  27316. private _initFacetData;
  27317. /**
  27318. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27319. * This method can be called within the render loop.
  27320. * 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
  27321. * @returns the current mesh
  27322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27323. */
  27324. updateFacetData(): AbstractMesh;
  27325. /**
  27326. * Returns the facetLocalNormals array.
  27327. * The normals are expressed in the mesh local spac
  27328. * @returns an array of Vector3
  27329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27330. */
  27331. getFacetLocalNormals(): Vector3[];
  27332. /**
  27333. * Returns the facetLocalPositions array.
  27334. * The facet positions are expressed in the mesh local space
  27335. * @returns an array of Vector3
  27336. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27337. */
  27338. getFacetLocalPositions(): Vector3[];
  27339. /**
  27340. * Returns the facetLocalPartioning array
  27341. * @returns an array of array of numbers
  27342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27343. */
  27344. getFacetLocalPartitioning(): number[][];
  27345. /**
  27346. * Returns the i-th facet position in the world system.
  27347. * This method allocates a new Vector3 per call
  27348. * @param i defines the facet index
  27349. * @returns a new Vector3
  27350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27351. */
  27352. getFacetPosition(i: number): Vector3;
  27353. /**
  27354. * Sets the reference Vector3 with the i-th facet position in the world system
  27355. * @param i defines the facet index
  27356. * @param ref defines the target vector
  27357. * @returns the current mesh
  27358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27359. */
  27360. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27361. /**
  27362. * Returns the i-th facet normal in the world system.
  27363. * This method allocates a new Vector3 per call
  27364. * @param i defines the facet index
  27365. * @returns a new Vector3
  27366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27367. */
  27368. getFacetNormal(i: number): Vector3;
  27369. /**
  27370. * Sets the reference Vector3 with the i-th facet normal in the world system
  27371. * @param i defines the facet index
  27372. * @param ref defines the target vector
  27373. * @returns the current mesh
  27374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27375. */
  27376. getFacetNormalToRef(i: number, ref: Vector3): this;
  27377. /**
  27378. * 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)
  27379. * @param x defines x coordinate
  27380. * @param y defines y coordinate
  27381. * @param z defines z coordinate
  27382. * @returns the array of facet indexes
  27383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27384. */
  27385. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27386. /**
  27387. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27388. * @param projected sets as the (x,y,z) world projection on the facet
  27389. * @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
  27390. * @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
  27391. * @param x defines x coordinate
  27392. * @param y defines y coordinate
  27393. * @param z defines z coordinate
  27394. * @returns the face index if found (or null instead)
  27395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27396. */
  27397. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27398. /**
  27399. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27400. * @param projected sets as the (x,y,z) local projection on the facet
  27401. * @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
  27402. * @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
  27403. * @param x defines x coordinate
  27404. * @param y defines y coordinate
  27405. * @param z defines z coordinate
  27406. * @returns the face index if found (or null instead)
  27407. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27408. */
  27409. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27410. /**
  27411. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27412. * @returns the parameters
  27413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27414. */
  27415. getFacetDataParameters(): any;
  27416. /**
  27417. * Disables the feature FacetData and frees the related memory
  27418. * @returns the current mesh
  27419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27420. */
  27421. disableFacetData(): AbstractMesh;
  27422. /**
  27423. * Updates the AbstractMesh indices array
  27424. * @param indices defines the data source
  27425. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27426. * @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)
  27427. * @returns the current mesh
  27428. */
  27429. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27430. /**
  27431. * Creates new normals data for the mesh
  27432. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27433. * @returns the current mesh
  27434. */
  27435. createNormals(updatable: boolean): AbstractMesh;
  27436. /**
  27437. * Align the mesh with a normal
  27438. * @param normal defines the normal to use
  27439. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27440. * @returns the current mesh
  27441. */
  27442. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27443. /** @hidden */
  27444. _checkOcclusionQuery(): boolean;
  27445. /**
  27446. * Disables the mesh edge rendering mode
  27447. * @returns the currentAbstractMesh
  27448. */
  27449. disableEdgesRendering(): AbstractMesh;
  27450. /**
  27451. * Enables the edge rendering mode on the mesh.
  27452. * This mode makes the mesh edges visible
  27453. * @param epsilon defines the maximal distance between two angles to detect a face
  27454. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27455. * @returns the currentAbstractMesh
  27456. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27457. */
  27458. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27459. }
  27460. }
  27461. declare module "babylonjs/Actions/actionEvent" {
  27462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27463. import { Nullable } from "babylonjs/types";
  27464. import { Sprite } from "babylonjs/Sprites/sprite";
  27465. import { Scene } from "babylonjs/scene";
  27466. import { Vector2 } from "babylonjs/Maths/math.vector";
  27467. /**
  27468. * Interface used to define ActionEvent
  27469. */
  27470. export interface IActionEvent {
  27471. /** The mesh or sprite that triggered the action */
  27472. source: any;
  27473. /** The X mouse cursor position at the time of the event */
  27474. pointerX: number;
  27475. /** The Y mouse cursor position at the time of the event */
  27476. pointerY: number;
  27477. /** The mesh that is currently pointed at (can be null) */
  27478. meshUnderPointer: Nullable<AbstractMesh>;
  27479. /** the original (browser) event that triggered the ActionEvent */
  27480. sourceEvent?: any;
  27481. /** additional data for the event */
  27482. additionalData?: any;
  27483. }
  27484. /**
  27485. * ActionEvent is the event being sent when an action is triggered.
  27486. */
  27487. export class ActionEvent implements IActionEvent {
  27488. /** The mesh or sprite that triggered the action */
  27489. source: any;
  27490. /** The X mouse cursor position at the time of the event */
  27491. pointerX: number;
  27492. /** The Y mouse cursor position at the time of the event */
  27493. pointerY: number;
  27494. /** The mesh that is currently pointed at (can be null) */
  27495. meshUnderPointer: Nullable<AbstractMesh>;
  27496. /** the original (browser) event that triggered the ActionEvent */
  27497. sourceEvent?: any;
  27498. /** additional data for the event */
  27499. additionalData?: any;
  27500. /**
  27501. * Creates a new ActionEvent
  27502. * @param source The mesh or sprite that triggered the action
  27503. * @param pointerX The X mouse cursor position at the time of the event
  27504. * @param pointerY The Y mouse cursor position at the time of the event
  27505. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27506. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27507. * @param additionalData additional data for the event
  27508. */
  27509. constructor(
  27510. /** The mesh or sprite that triggered the action */
  27511. source: any,
  27512. /** The X mouse cursor position at the time of the event */
  27513. pointerX: number,
  27514. /** The Y mouse cursor position at the time of the event */
  27515. pointerY: number,
  27516. /** The mesh that is currently pointed at (can be null) */
  27517. meshUnderPointer: Nullable<AbstractMesh>,
  27518. /** the original (browser) event that triggered the ActionEvent */
  27519. sourceEvent?: any,
  27520. /** additional data for the event */
  27521. additionalData?: any);
  27522. /**
  27523. * Helper function to auto-create an ActionEvent from a source mesh.
  27524. * @param source The source mesh that triggered the event
  27525. * @param evt The original (browser) event
  27526. * @param additionalData additional data for the event
  27527. * @returns the new ActionEvent
  27528. */
  27529. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27530. /**
  27531. * Helper function to auto-create an ActionEvent from a source sprite
  27532. * @param source The source sprite that triggered the event
  27533. * @param scene Scene associated with the sprite
  27534. * @param evt The original (browser) event
  27535. * @param additionalData additional data for the event
  27536. * @returns the new ActionEvent
  27537. */
  27538. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27539. /**
  27540. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27541. * @param scene the scene where the event occurred
  27542. * @param evt The original (browser) event
  27543. * @returns the new ActionEvent
  27544. */
  27545. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27546. /**
  27547. * Helper function to auto-create an ActionEvent from a primitive
  27548. * @param prim defines the target primitive
  27549. * @param pointerPos defines the pointer position
  27550. * @param evt The original (browser) event
  27551. * @param additionalData additional data for the event
  27552. * @returns the new ActionEvent
  27553. */
  27554. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27555. }
  27556. }
  27557. declare module "babylonjs/Actions/abstractActionManager" {
  27558. import { IDisposable } from "babylonjs/scene";
  27559. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27560. import { IAction } from "babylonjs/Actions/action";
  27561. import { Nullable } from "babylonjs/types";
  27562. /**
  27563. * Abstract class used to decouple action Manager from scene and meshes.
  27564. * Do not instantiate.
  27565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27566. */
  27567. export abstract class AbstractActionManager implements IDisposable {
  27568. /** Gets the list of active triggers */
  27569. static Triggers: {
  27570. [key: string]: number;
  27571. };
  27572. /** Gets the cursor to use when hovering items */
  27573. hoverCursor: string;
  27574. /** Gets the list of actions */
  27575. actions: IAction[];
  27576. /**
  27577. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27578. */
  27579. isRecursive: boolean;
  27580. /**
  27581. * Releases all associated resources
  27582. */
  27583. abstract dispose(): void;
  27584. /**
  27585. * Does this action manager has pointer triggers
  27586. */
  27587. abstract readonly hasPointerTriggers: boolean;
  27588. /**
  27589. * Does this action manager has pick triggers
  27590. */
  27591. abstract readonly hasPickTriggers: boolean;
  27592. /**
  27593. * Process a specific trigger
  27594. * @param trigger defines the trigger to process
  27595. * @param evt defines the event details to be processed
  27596. */
  27597. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27598. /**
  27599. * Does this action manager handles actions of any of the given triggers
  27600. * @param triggers defines the triggers to be tested
  27601. * @return a boolean indicating whether one (or more) of the triggers is handled
  27602. */
  27603. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27604. /**
  27605. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27606. * speed.
  27607. * @param triggerA defines the trigger to be tested
  27608. * @param triggerB defines the trigger to be tested
  27609. * @return a boolean indicating whether one (or more) of the triggers is handled
  27610. */
  27611. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27612. /**
  27613. * Does this action manager handles actions of a given trigger
  27614. * @param trigger defines the trigger to be tested
  27615. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27616. * @return whether the trigger is handled
  27617. */
  27618. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27619. /**
  27620. * Serialize this manager to a JSON object
  27621. * @param name defines the property name to store this manager
  27622. * @returns a JSON representation of this manager
  27623. */
  27624. abstract serialize(name: string): any;
  27625. /**
  27626. * Registers an action to this action manager
  27627. * @param action defines the action to be registered
  27628. * @return the action amended (prepared) after registration
  27629. */
  27630. abstract registerAction(action: IAction): Nullable<IAction>;
  27631. /**
  27632. * Unregisters an action to this action manager
  27633. * @param action defines the action to be unregistered
  27634. * @return a boolean indicating whether the action has been unregistered
  27635. */
  27636. abstract unregisterAction(action: IAction): Boolean;
  27637. /**
  27638. * Does exist one action manager with at least one trigger
  27639. **/
  27640. static readonly HasTriggers: boolean;
  27641. /**
  27642. * Does exist one action manager with at least one pick trigger
  27643. **/
  27644. static readonly HasPickTriggers: boolean;
  27645. /**
  27646. * Does exist one action manager that handles actions of a given trigger
  27647. * @param trigger defines the trigger to be tested
  27648. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27649. **/
  27650. static HasSpecificTrigger(trigger: number): boolean;
  27651. }
  27652. }
  27653. declare module "babylonjs/node" {
  27654. import { Scene } from "babylonjs/scene";
  27655. import { Nullable } from "babylonjs/types";
  27656. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27657. import { Engine } from "babylonjs/Engines/engine";
  27658. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27659. import { Observable } from "babylonjs/Misc/observable";
  27660. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27661. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27662. import { Animatable } from "babylonjs/Animations/animatable";
  27663. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27664. import { Animation } from "babylonjs/Animations/animation";
  27665. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27667. /**
  27668. * Defines how a node can be built from a string name.
  27669. */
  27670. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27671. /**
  27672. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27673. */
  27674. export class Node implements IBehaviorAware<Node> {
  27675. /** @hidden */
  27676. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27677. private static _NodeConstructors;
  27678. /**
  27679. * Add a new node constructor
  27680. * @param type defines the type name of the node to construct
  27681. * @param constructorFunc defines the constructor function
  27682. */
  27683. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27684. /**
  27685. * Returns a node constructor based on type name
  27686. * @param type defines the type name
  27687. * @param name defines the new node name
  27688. * @param scene defines the hosting scene
  27689. * @param options defines optional options to transmit to constructors
  27690. * @returns the new constructor or null
  27691. */
  27692. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27693. /**
  27694. * Gets or sets the name of the node
  27695. */
  27696. name: string;
  27697. /**
  27698. * Gets or sets the id of the node
  27699. */
  27700. id: string;
  27701. /**
  27702. * Gets or sets the unique id of the node
  27703. */
  27704. uniqueId: number;
  27705. /**
  27706. * Gets or sets a string used to store user defined state for the node
  27707. */
  27708. state: string;
  27709. /**
  27710. * Gets or sets an object used to store user defined information for the node
  27711. */
  27712. metadata: any;
  27713. /**
  27714. * For internal use only. Please do not use.
  27715. */
  27716. reservedDataStore: any;
  27717. /**
  27718. * List of inspectable custom properties (used by the Inspector)
  27719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27720. */
  27721. inspectableCustomProperties: IInspectable[];
  27722. private _doNotSerialize;
  27723. /**
  27724. * Gets or sets a boolean used to define if the node must be serialized
  27725. */
  27726. doNotSerialize: boolean;
  27727. /** @hidden */
  27728. _isDisposed: boolean;
  27729. /**
  27730. * Gets a list of Animations associated with the node
  27731. */
  27732. animations: import("babylonjs/Animations/animation").Animation[];
  27733. protected _ranges: {
  27734. [name: string]: Nullable<AnimationRange>;
  27735. };
  27736. /**
  27737. * Callback raised when the node is ready to be used
  27738. */
  27739. onReady: Nullable<(node: Node) => void>;
  27740. private _isEnabled;
  27741. private _isParentEnabled;
  27742. private _isReady;
  27743. /** @hidden */
  27744. _currentRenderId: number;
  27745. private _parentUpdateId;
  27746. /** @hidden */
  27747. _childUpdateId: number;
  27748. /** @hidden */
  27749. _waitingParentId: Nullable<string>;
  27750. /** @hidden */
  27751. _scene: Scene;
  27752. /** @hidden */
  27753. _cache: any;
  27754. private _parentNode;
  27755. private _children;
  27756. /** @hidden */
  27757. _worldMatrix: Matrix;
  27758. /** @hidden */
  27759. _worldMatrixDeterminant: number;
  27760. /** @hidden */
  27761. _worldMatrixDeterminantIsDirty: boolean;
  27762. /** @hidden */
  27763. private _sceneRootNodesIndex;
  27764. /**
  27765. * Gets a boolean indicating if the node has been disposed
  27766. * @returns true if the node was disposed
  27767. */
  27768. isDisposed(): boolean;
  27769. /**
  27770. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27771. * @see https://doc.babylonjs.com/how_to/parenting
  27772. */
  27773. parent: Nullable<Node>;
  27774. private addToSceneRootNodes;
  27775. private removeFromSceneRootNodes;
  27776. private _animationPropertiesOverride;
  27777. /**
  27778. * Gets or sets the animation properties override
  27779. */
  27780. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27781. /**
  27782. * Gets a string idenfifying the name of the class
  27783. * @returns "Node" string
  27784. */
  27785. getClassName(): string;
  27786. /** @hidden */
  27787. readonly _isNode: boolean;
  27788. /**
  27789. * An event triggered when the mesh is disposed
  27790. */
  27791. onDisposeObservable: Observable<Node>;
  27792. private _onDisposeObserver;
  27793. /**
  27794. * Sets a callback that will be raised when the node will be disposed
  27795. */
  27796. onDispose: () => void;
  27797. /**
  27798. * Creates a new Node
  27799. * @param name the name and id to be given to this node
  27800. * @param scene the scene this node will be added to
  27801. * @param addToRootNodes the node will be added to scene.rootNodes
  27802. */
  27803. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27804. /**
  27805. * Gets the scene of the node
  27806. * @returns a scene
  27807. */
  27808. getScene(): Scene;
  27809. /**
  27810. * Gets the engine of the node
  27811. * @returns a Engine
  27812. */
  27813. getEngine(): Engine;
  27814. private _behaviors;
  27815. /**
  27816. * Attach a behavior to the node
  27817. * @see http://doc.babylonjs.com/features/behaviour
  27818. * @param behavior defines the behavior to attach
  27819. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27820. * @returns the current Node
  27821. */
  27822. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27823. /**
  27824. * Remove an attached behavior
  27825. * @see http://doc.babylonjs.com/features/behaviour
  27826. * @param behavior defines the behavior to attach
  27827. * @returns the current Node
  27828. */
  27829. removeBehavior(behavior: Behavior<Node>): Node;
  27830. /**
  27831. * Gets the list of attached behaviors
  27832. * @see http://doc.babylonjs.com/features/behaviour
  27833. */
  27834. readonly behaviors: Behavior<Node>[];
  27835. /**
  27836. * Gets an attached behavior by name
  27837. * @param name defines the name of the behavior to look for
  27838. * @see http://doc.babylonjs.com/features/behaviour
  27839. * @returns null if behavior was not found else the requested behavior
  27840. */
  27841. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27842. /**
  27843. * Returns the latest update of the World matrix
  27844. * @returns a Matrix
  27845. */
  27846. getWorldMatrix(): Matrix;
  27847. /** @hidden */
  27848. _getWorldMatrixDeterminant(): number;
  27849. /**
  27850. * Returns directly the latest state of the mesh World matrix.
  27851. * A Matrix is returned.
  27852. */
  27853. readonly worldMatrixFromCache: Matrix;
  27854. /** @hidden */
  27855. _initCache(): void;
  27856. /** @hidden */
  27857. updateCache(force?: boolean): void;
  27858. /** @hidden */
  27859. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27860. /** @hidden */
  27861. _updateCache(ignoreParentClass?: boolean): void;
  27862. /** @hidden */
  27863. _isSynchronized(): boolean;
  27864. /** @hidden */
  27865. _markSyncedWithParent(): void;
  27866. /** @hidden */
  27867. isSynchronizedWithParent(): boolean;
  27868. /** @hidden */
  27869. isSynchronized(): boolean;
  27870. /**
  27871. * Is this node ready to be used/rendered
  27872. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27873. * @return true if the node is ready
  27874. */
  27875. isReady(completeCheck?: boolean): boolean;
  27876. /**
  27877. * Is this node enabled?
  27878. * 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
  27879. * @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
  27880. * @return whether this node (and its parent) is enabled
  27881. */
  27882. isEnabled(checkAncestors?: boolean): boolean;
  27883. /** @hidden */
  27884. protected _syncParentEnabledState(): void;
  27885. /**
  27886. * Set the enabled state of this node
  27887. * @param value defines the new enabled state
  27888. */
  27889. setEnabled(value: boolean): void;
  27890. /**
  27891. * Is this node a descendant of the given node?
  27892. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27893. * @param ancestor defines the parent node to inspect
  27894. * @returns a boolean indicating if this node is a descendant of the given node
  27895. */
  27896. isDescendantOf(ancestor: Node): boolean;
  27897. /** @hidden */
  27898. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27899. /**
  27900. * Will return all nodes that have this node as ascendant
  27901. * @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
  27902. * @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
  27903. * @return all children nodes of all types
  27904. */
  27905. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27906. /**
  27907. * Get all child-meshes of this node
  27908. * @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)
  27909. * @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
  27910. * @returns an array of AbstractMesh
  27911. */
  27912. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27913. /**
  27914. * Get all direct children of this node
  27915. * @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
  27916. * @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)
  27917. * @returns an array of Node
  27918. */
  27919. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27920. /** @hidden */
  27921. _setReady(state: boolean): void;
  27922. /**
  27923. * Get an animation by name
  27924. * @param name defines the name of the animation to look for
  27925. * @returns null if not found else the requested animation
  27926. */
  27927. getAnimationByName(name: string): Nullable<Animation>;
  27928. /**
  27929. * Creates an animation range for this node
  27930. * @param name defines the name of the range
  27931. * @param from defines the starting key
  27932. * @param to defines the end key
  27933. */
  27934. createAnimationRange(name: string, from: number, to: number): void;
  27935. /**
  27936. * Delete a specific animation range
  27937. * @param name defines the name of the range to delete
  27938. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27939. */
  27940. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27941. /**
  27942. * Get an animation range by name
  27943. * @param name defines the name of the animation range to look for
  27944. * @returns null if not found else the requested animation range
  27945. */
  27946. getAnimationRange(name: string): Nullable<AnimationRange>;
  27947. /**
  27948. * Gets the list of all animation ranges defined on this node
  27949. * @returns an array
  27950. */
  27951. getAnimationRanges(): Nullable<AnimationRange>[];
  27952. /**
  27953. * Will start the animation sequence
  27954. * @param name defines the range frames for animation sequence
  27955. * @param loop defines if the animation should loop (false by default)
  27956. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27957. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27958. * @returns the object created for this animation. If range does not exist, it will return null
  27959. */
  27960. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27961. /**
  27962. * Serialize animation ranges into a JSON compatible object
  27963. * @returns serialization object
  27964. */
  27965. serializeAnimationRanges(): any;
  27966. /**
  27967. * Computes the world matrix of the node
  27968. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27969. * @returns the world matrix
  27970. */
  27971. computeWorldMatrix(force?: boolean): Matrix;
  27972. /**
  27973. * Releases resources associated with this node.
  27974. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27975. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27976. */
  27977. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27978. /**
  27979. * Parse animation range data from a serialization object and store them into a given node
  27980. * @param node defines where to store the animation ranges
  27981. * @param parsedNode defines the serialization object to read data from
  27982. * @param scene defines the hosting scene
  27983. */
  27984. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27985. /**
  27986. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27987. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27988. * @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
  27989. * @returns the new bounding vectors
  27990. */
  27991. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27992. min: Vector3;
  27993. max: Vector3;
  27994. };
  27995. }
  27996. }
  27997. declare module "babylonjs/Animations/animation" {
  27998. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27999. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28000. import { Color3 } from "babylonjs/Maths/math.color";
  28001. import { Nullable } from "babylonjs/types";
  28002. import { Scene } from "babylonjs/scene";
  28003. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28004. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28005. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28006. import { Node } from "babylonjs/node";
  28007. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28008. import { Size } from "babylonjs/Maths/math.size";
  28009. import { Animatable } from "babylonjs/Animations/animatable";
  28010. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28011. /**
  28012. * @hidden
  28013. */
  28014. export class _IAnimationState {
  28015. key: number;
  28016. repeatCount: number;
  28017. workValue?: any;
  28018. loopMode?: number;
  28019. offsetValue?: any;
  28020. highLimitValue?: any;
  28021. }
  28022. /**
  28023. * Class used to store any kind of animation
  28024. */
  28025. export class Animation {
  28026. /**Name of the animation */
  28027. name: string;
  28028. /**Property to animate */
  28029. targetProperty: string;
  28030. /**The frames per second of the animation */
  28031. framePerSecond: number;
  28032. /**The data type of the animation */
  28033. dataType: number;
  28034. /**The loop mode of the animation */
  28035. loopMode?: number | undefined;
  28036. /**Specifies if blending should be enabled */
  28037. enableBlending?: boolean | undefined;
  28038. /**
  28039. * Use matrix interpolation instead of using direct key value when animating matrices
  28040. */
  28041. static AllowMatricesInterpolation: boolean;
  28042. /**
  28043. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28044. */
  28045. static AllowMatrixDecomposeForInterpolation: boolean;
  28046. /**
  28047. * Stores the key frames of the animation
  28048. */
  28049. private _keys;
  28050. /**
  28051. * Stores the easing function of the animation
  28052. */
  28053. private _easingFunction;
  28054. /**
  28055. * @hidden Internal use only
  28056. */
  28057. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28058. /**
  28059. * The set of event that will be linked to this animation
  28060. */
  28061. private _events;
  28062. /**
  28063. * Stores an array of target property paths
  28064. */
  28065. targetPropertyPath: string[];
  28066. /**
  28067. * Stores the blending speed of the animation
  28068. */
  28069. blendingSpeed: number;
  28070. /**
  28071. * Stores the animation ranges for the animation
  28072. */
  28073. private _ranges;
  28074. /**
  28075. * @hidden Internal use
  28076. */
  28077. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28078. /**
  28079. * Sets up an animation
  28080. * @param property The property to animate
  28081. * @param animationType The animation type to apply
  28082. * @param framePerSecond The frames per second of the animation
  28083. * @param easingFunction The easing function used in the animation
  28084. * @returns The created animation
  28085. */
  28086. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28087. /**
  28088. * Create and start an animation on a node
  28089. * @param name defines the name of the global animation that will be run on all nodes
  28090. * @param node defines the root node where the animation will take place
  28091. * @param targetProperty defines property to animate
  28092. * @param framePerSecond defines the number of frame per second yo use
  28093. * @param totalFrame defines the number of frames in total
  28094. * @param from defines the initial value
  28095. * @param to defines the final value
  28096. * @param loopMode defines which loop mode you want to use (off by default)
  28097. * @param easingFunction defines the easing function to use (linear by default)
  28098. * @param onAnimationEnd defines the callback to call when animation end
  28099. * @returns the animatable created for this animation
  28100. */
  28101. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28102. /**
  28103. * Create and start an animation on a node and its descendants
  28104. * @param name defines the name of the global animation that will be run on all nodes
  28105. * @param node defines the root node where the animation will take place
  28106. * @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
  28107. * @param targetProperty defines property to animate
  28108. * @param framePerSecond defines the number of frame per second to use
  28109. * @param totalFrame defines the number of frames in total
  28110. * @param from defines the initial value
  28111. * @param to defines the final value
  28112. * @param loopMode defines which loop mode you want to use (off by default)
  28113. * @param easingFunction defines the easing function to use (linear by default)
  28114. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28115. * @returns the list of animatables created for all nodes
  28116. * @example https://www.babylonjs-playground.com/#MH0VLI
  28117. */
  28118. 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[]>;
  28119. /**
  28120. * Creates a new animation, merges it with the existing animations and starts it
  28121. * @param name Name of the animation
  28122. * @param node Node which contains the scene that begins the animations
  28123. * @param targetProperty Specifies which property to animate
  28124. * @param framePerSecond The frames per second of the animation
  28125. * @param totalFrame The total number of frames
  28126. * @param from The frame at the beginning of the animation
  28127. * @param to The frame at the end of the animation
  28128. * @param loopMode Specifies the loop mode of the animation
  28129. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28130. * @param onAnimationEnd Callback to run once the animation is complete
  28131. * @returns Nullable animation
  28132. */
  28133. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28134. /**
  28135. * Transition property of an host to the target Value
  28136. * @param property The property to transition
  28137. * @param targetValue The target Value of the property
  28138. * @param host The object where the property to animate belongs
  28139. * @param scene Scene used to run the animation
  28140. * @param frameRate Framerate (in frame/s) to use
  28141. * @param transition The transition type we want to use
  28142. * @param duration The duration of the animation, in milliseconds
  28143. * @param onAnimationEnd Callback trigger at the end of the animation
  28144. * @returns Nullable animation
  28145. */
  28146. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28147. /**
  28148. * Return the array of runtime animations currently using this animation
  28149. */
  28150. readonly runtimeAnimations: RuntimeAnimation[];
  28151. /**
  28152. * Specifies if any of the runtime animations are currently running
  28153. */
  28154. readonly hasRunningRuntimeAnimations: boolean;
  28155. /**
  28156. * Initializes the animation
  28157. * @param name Name of the animation
  28158. * @param targetProperty Property to animate
  28159. * @param framePerSecond The frames per second of the animation
  28160. * @param dataType The data type of the animation
  28161. * @param loopMode The loop mode of the animation
  28162. * @param enableBlending Specifies if blending should be enabled
  28163. */
  28164. constructor(
  28165. /**Name of the animation */
  28166. name: string,
  28167. /**Property to animate */
  28168. targetProperty: string,
  28169. /**The frames per second of the animation */
  28170. framePerSecond: number,
  28171. /**The data type of the animation */
  28172. dataType: number,
  28173. /**The loop mode of the animation */
  28174. loopMode?: number | undefined,
  28175. /**Specifies if blending should be enabled */
  28176. enableBlending?: boolean | undefined);
  28177. /**
  28178. * Converts the animation to a string
  28179. * @param fullDetails support for multiple levels of logging within scene loading
  28180. * @returns String form of the animation
  28181. */
  28182. toString(fullDetails?: boolean): string;
  28183. /**
  28184. * Add an event to this animation
  28185. * @param event Event to add
  28186. */
  28187. addEvent(event: AnimationEvent): void;
  28188. /**
  28189. * Remove all events found at the given frame
  28190. * @param frame The frame to remove events from
  28191. */
  28192. removeEvents(frame: number): void;
  28193. /**
  28194. * Retrieves all the events from the animation
  28195. * @returns Events from the animation
  28196. */
  28197. getEvents(): AnimationEvent[];
  28198. /**
  28199. * Creates an animation range
  28200. * @param name Name of the animation range
  28201. * @param from Starting frame of the animation range
  28202. * @param to Ending frame of the animation
  28203. */
  28204. createRange(name: string, from: number, to: number): void;
  28205. /**
  28206. * Deletes an animation range by name
  28207. * @param name Name of the animation range to delete
  28208. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28209. */
  28210. deleteRange(name: string, deleteFrames?: boolean): void;
  28211. /**
  28212. * Gets the animation range by name, or null if not defined
  28213. * @param name Name of the animation range
  28214. * @returns Nullable animation range
  28215. */
  28216. getRange(name: string): Nullable<AnimationRange>;
  28217. /**
  28218. * Gets the key frames from the animation
  28219. * @returns The key frames of the animation
  28220. */
  28221. getKeys(): Array<IAnimationKey>;
  28222. /**
  28223. * Gets the highest frame rate of the animation
  28224. * @returns Highest frame rate of the animation
  28225. */
  28226. getHighestFrame(): number;
  28227. /**
  28228. * Gets the easing function of the animation
  28229. * @returns Easing function of the animation
  28230. */
  28231. getEasingFunction(): IEasingFunction;
  28232. /**
  28233. * Sets the easing function of the animation
  28234. * @param easingFunction A custom mathematical formula for animation
  28235. */
  28236. setEasingFunction(easingFunction: EasingFunction): void;
  28237. /**
  28238. * Interpolates a scalar linearly
  28239. * @param startValue Start value of the animation curve
  28240. * @param endValue End value of the animation curve
  28241. * @param gradient Scalar amount to interpolate
  28242. * @returns Interpolated scalar value
  28243. */
  28244. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28245. /**
  28246. * Interpolates a scalar cubically
  28247. * @param startValue Start value of the animation curve
  28248. * @param outTangent End tangent of the animation
  28249. * @param endValue End value of the animation curve
  28250. * @param inTangent Start tangent of the animation curve
  28251. * @param gradient Scalar amount to interpolate
  28252. * @returns Interpolated scalar value
  28253. */
  28254. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28255. /**
  28256. * Interpolates a quaternion using a spherical linear interpolation
  28257. * @param startValue Start value of the animation curve
  28258. * @param endValue End value of the animation curve
  28259. * @param gradient Scalar amount to interpolate
  28260. * @returns Interpolated quaternion value
  28261. */
  28262. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28263. /**
  28264. * Interpolates a quaternion cubically
  28265. * @param startValue Start value of the animation curve
  28266. * @param outTangent End tangent of the animation curve
  28267. * @param endValue End value of the animation curve
  28268. * @param inTangent Start tangent of the animation curve
  28269. * @param gradient Scalar amount to interpolate
  28270. * @returns Interpolated quaternion value
  28271. */
  28272. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28273. /**
  28274. * Interpolates a Vector3 linearl
  28275. * @param startValue Start value of the animation curve
  28276. * @param endValue End value of the animation curve
  28277. * @param gradient Scalar amount to interpolate
  28278. * @returns Interpolated scalar value
  28279. */
  28280. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28281. /**
  28282. * Interpolates a Vector3 cubically
  28283. * @param startValue Start value of the animation curve
  28284. * @param outTangent End tangent of the animation
  28285. * @param endValue End value of the animation curve
  28286. * @param inTangent Start tangent of the animation curve
  28287. * @param gradient Scalar amount to interpolate
  28288. * @returns InterpolatedVector3 value
  28289. */
  28290. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28291. /**
  28292. * Interpolates a Vector2 linearly
  28293. * @param startValue Start value of the animation curve
  28294. * @param endValue End value of the animation curve
  28295. * @param gradient Scalar amount to interpolate
  28296. * @returns Interpolated Vector2 value
  28297. */
  28298. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28299. /**
  28300. * Interpolates a Vector2 cubically
  28301. * @param startValue Start value of the animation curve
  28302. * @param outTangent End tangent of the animation
  28303. * @param endValue End value of the animation curve
  28304. * @param inTangent Start tangent of the animation curve
  28305. * @param gradient Scalar amount to interpolate
  28306. * @returns Interpolated Vector2 value
  28307. */
  28308. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28309. /**
  28310. * Interpolates a size linearly
  28311. * @param startValue Start value of the animation curve
  28312. * @param endValue End value of the animation curve
  28313. * @param gradient Scalar amount to interpolate
  28314. * @returns Interpolated Size value
  28315. */
  28316. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28317. /**
  28318. * Interpolates a Color3 linearly
  28319. * @param startValue Start value of the animation curve
  28320. * @param endValue End value of the animation curve
  28321. * @param gradient Scalar amount to interpolate
  28322. * @returns Interpolated Color3 value
  28323. */
  28324. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28325. /**
  28326. * @hidden Internal use only
  28327. */
  28328. _getKeyValue(value: any): any;
  28329. /**
  28330. * @hidden Internal use only
  28331. */
  28332. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28333. /**
  28334. * Defines the function to use to interpolate matrices
  28335. * @param startValue defines the start matrix
  28336. * @param endValue defines the end matrix
  28337. * @param gradient defines the gradient between both matrices
  28338. * @param result defines an optional target matrix where to store the interpolation
  28339. * @returns the interpolated matrix
  28340. */
  28341. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28342. /**
  28343. * Makes a copy of the animation
  28344. * @returns Cloned animation
  28345. */
  28346. clone(): Animation;
  28347. /**
  28348. * Sets the key frames of the animation
  28349. * @param values The animation key frames to set
  28350. */
  28351. setKeys(values: Array<IAnimationKey>): void;
  28352. /**
  28353. * Serializes the animation to an object
  28354. * @returns Serialized object
  28355. */
  28356. serialize(): any;
  28357. /**
  28358. * Float animation type
  28359. */
  28360. private static _ANIMATIONTYPE_FLOAT;
  28361. /**
  28362. * Vector3 animation type
  28363. */
  28364. private static _ANIMATIONTYPE_VECTOR3;
  28365. /**
  28366. * Quaternion animation type
  28367. */
  28368. private static _ANIMATIONTYPE_QUATERNION;
  28369. /**
  28370. * Matrix animation type
  28371. */
  28372. private static _ANIMATIONTYPE_MATRIX;
  28373. /**
  28374. * Color3 animation type
  28375. */
  28376. private static _ANIMATIONTYPE_COLOR3;
  28377. /**
  28378. * Vector2 animation type
  28379. */
  28380. private static _ANIMATIONTYPE_VECTOR2;
  28381. /**
  28382. * Size animation type
  28383. */
  28384. private static _ANIMATIONTYPE_SIZE;
  28385. /**
  28386. * Relative Loop Mode
  28387. */
  28388. private static _ANIMATIONLOOPMODE_RELATIVE;
  28389. /**
  28390. * Cycle Loop Mode
  28391. */
  28392. private static _ANIMATIONLOOPMODE_CYCLE;
  28393. /**
  28394. * Constant Loop Mode
  28395. */
  28396. private static _ANIMATIONLOOPMODE_CONSTANT;
  28397. /**
  28398. * Get the float animation type
  28399. */
  28400. static readonly ANIMATIONTYPE_FLOAT: number;
  28401. /**
  28402. * Get the Vector3 animation type
  28403. */
  28404. static readonly ANIMATIONTYPE_VECTOR3: number;
  28405. /**
  28406. * Get the Vector2 animation type
  28407. */
  28408. static readonly ANIMATIONTYPE_VECTOR2: number;
  28409. /**
  28410. * Get the Size animation type
  28411. */
  28412. static readonly ANIMATIONTYPE_SIZE: number;
  28413. /**
  28414. * Get the Quaternion animation type
  28415. */
  28416. static readonly ANIMATIONTYPE_QUATERNION: number;
  28417. /**
  28418. * Get the Matrix animation type
  28419. */
  28420. static readonly ANIMATIONTYPE_MATRIX: number;
  28421. /**
  28422. * Get the Color3 animation type
  28423. */
  28424. static readonly ANIMATIONTYPE_COLOR3: number;
  28425. /**
  28426. * Get the Relative Loop Mode
  28427. */
  28428. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28429. /**
  28430. * Get the Cycle Loop Mode
  28431. */
  28432. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28433. /**
  28434. * Get the Constant Loop Mode
  28435. */
  28436. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28437. /** @hidden */
  28438. static _UniversalLerp(left: any, right: any, amount: number): any;
  28439. /**
  28440. * Parses an animation object and creates an animation
  28441. * @param parsedAnimation Parsed animation object
  28442. * @returns Animation object
  28443. */
  28444. static Parse(parsedAnimation: any): Animation;
  28445. /**
  28446. * Appends the serialized animations from the source animations
  28447. * @param source Source containing the animations
  28448. * @param destination Target to store the animations
  28449. */
  28450. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28451. }
  28452. }
  28453. declare module "babylonjs/Animations/animatable.interface" {
  28454. import { Nullable } from "babylonjs/types";
  28455. import { Animation } from "babylonjs/Animations/animation";
  28456. /**
  28457. * Interface containing an array of animations
  28458. */
  28459. export interface IAnimatable {
  28460. /**
  28461. * Array of animations
  28462. */
  28463. animations: Nullable<Array<Animation>>;
  28464. }
  28465. }
  28466. declare module "babylonjs/Materials/fresnelParameters" {
  28467. import { Color3 } from "babylonjs/Maths/math.color";
  28468. /**
  28469. * This represents all the required information to add a fresnel effect on a material:
  28470. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28471. */
  28472. export class FresnelParameters {
  28473. private _isEnabled;
  28474. /**
  28475. * Define if the fresnel effect is enable or not.
  28476. */
  28477. isEnabled: boolean;
  28478. /**
  28479. * Define the color used on edges (grazing angle)
  28480. */
  28481. leftColor: Color3;
  28482. /**
  28483. * Define the color used on center
  28484. */
  28485. rightColor: Color3;
  28486. /**
  28487. * Define bias applied to computed fresnel term
  28488. */
  28489. bias: number;
  28490. /**
  28491. * Defined the power exponent applied to fresnel term
  28492. */
  28493. power: number;
  28494. /**
  28495. * Clones the current fresnel and its valuues
  28496. * @returns a clone fresnel configuration
  28497. */
  28498. clone(): FresnelParameters;
  28499. /**
  28500. * Serializes the current fresnel parameters to a JSON representation.
  28501. * @return the JSON serialization
  28502. */
  28503. serialize(): any;
  28504. /**
  28505. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28506. * @param parsedFresnelParameters Define the JSON representation
  28507. * @returns the parsed parameters
  28508. */
  28509. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28510. }
  28511. }
  28512. declare module "babylonjs/Misc/decorators" {
  28513. import { Nullable } from "babylonjs/types";
  28514. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28515. import { Scene } from "babylonjs/scene";
  28516. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28517. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28518. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28519. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28520. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28521. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28522. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28523. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28524. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28525. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28526. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28527. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28528. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28529. /**
  28530. * Decorator used to define property that can be serialized as reference to a camera
  28531. * @param sourceName defines the name of the property to decorate
  28532. */
  28533. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28534. /**
  28535. * Class used to help serialization objects
  28536. */
  28537. export class SerializationHelper {
  28538. /** @hidden */
  28539. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28540. /** @hidden */
  28541. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28542. /** @hidden */
  28543. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28544. /** @hidden */
  28545. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28546. /**
  28547. * Appends the serialized animations from the source animations
  28548. * @param source Source containing the animations
  28549. * @param destination Target to store the animations
  28550. */
  28551. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28552. /**
  28553. * Static function used to serialized a specific entity
  28554. * @param entity defines the entity to serialize
  28555. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28556. * @returns a JSON compatible object representing the serialization of the entity
  28557. */
  28558. static Serialize<T>(entity: T, serializationObject?: any): any;
  28559. /**
  28560. * Creates a new entity from a serialization data object
  28561. * @param creationFunction defines a function used to instanciated the new entity
  28562. * @param source defines the source serialization data
  28563. * @param scene defines the hosting scene
  28564. * @param rootUrl defines the root url for resources
  28565. * @returns a new entity
  28566. */
  28567. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28568. /**
  28569. * Clones an object
  28570. * @param creationFunction defines the function used to instanciate the new object
  28571. * @param source defines the source object
  28572. * @returns the cloned object
  28573. */
  28574. static Clone<T>(creationFunction: () => T, source: T): T;
  28575. /**
  28576. * Instanciates a new object based on a source one (some data will be shared between both object)
  28577. * @param creationFunction defines the function used to instanciate the new object
  28578. * @param source defines the source object
  28579. * @returns the new object
  28580. */
  28581. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28582. }
  28583. }
  28584. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28585. import { Nullable } from "babylonjs/types";
  28586. /**
  28587. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28588. */
  28589. export interface CubeMapInfo {
  28590. /**
  28591. * The pixel array for the front face.
  28592. * This is stored in format, left to right, up to down format.
  28593. */
  28594. front: Nullable<ArrayBufferView>;
  28595. /**
  28596. * The pixel array for the back face.
  28597. * This is stored in format, left to right, up to down format.
  28598. */
  28599. back: Nullable<ArrayBufferView>;
  28600. /**
  28601. * The pixel array for the left face.
  28602. * This is stored in format, left to right, up to down format.
  28603. */
  28604. left: Nullable<ArrayBufferView>;
  28605. /**
  28606. * The pixel array for the right face.
  28607. * This is stored in format, left to right, up to down format.
  28608. */
  28609. right: Nullable<ArrayBufferView>;
  28610. /**
  28611. * The pixel array for the up face.
  28612. * This is stored in format, left to right, up to down format.
  28613. */
  28614. up: Nullable<ArrayBufferView>;
  28615. /**
  28616. * The pixel array for the down face.
  28617. * This is stored in format, left to right, up to down format.
  28618. */
  28619. down: Nullable<ArrayBufferView>;
  28620. /**
  28621. * The size of the cubemap stored.
  28622. *
  28623. * Each faces will be size * size pixels.
  28624. */
  28625. size: number;
  28626. /**
  28627. * The format of the texture.
  28628. *
  28629. * RGBA, RGB.
  28630. */
  28631. format: number;
  28632. /**
  28633. * The type of the texture data.
  28634. *
  28635. * UNSIGNED_INT, FLOAT.
  28636. */
  28637. type: number;
  28638. /**
  28639. * Specifies whether the texture is in gamma space.
  28640. */
  28641. gammaSpace: boolean;
  28642. }
  28643. /**
  28644. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28645. */
  28646. export class PanoramaToCubeMapTools {
  28647. private static FACE_FRONT;
  28648. private static FACE_BACK;
  28649. private static FACE_RIGHT;
  28650. private static FACE_LEFT;
  28651. private static FACE_DOWN;
  28652. private static FACE_UP;
  28653. /**
  28654. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28655. *
  28656. * @param float32Array The source data.
  28657. * @param inputWidth The width of the input panorama.
  28658. * @param inputHeight The height of the input panorama.
  28659. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28660. * @return The cubemap data
  28661. */
  28662. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28663. private static CreateCubemapTexture;
  28664. private static CalcProjectionSpherical;
  28665. }
  28666. }
  28667. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28668. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28670. import { Nullable } from "babylonjs/types";
  28671. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28672. /**
  28673. * Helper class dealing with the extraction of spherical polynomial dataArray
  28674. * from a cube map.
  28675. */
  28676. export class CubeMapToSphericalPolynomialTools {
  28677. private static FileFaces;
  28678. /**
  28679. * Converts a texture to the according Spherical Polynomial data.
  28680. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28681. *
  28682. * @param texture The texture to extract the information from.
  28683. * @return The Spherical Polynomial data.
  28684. */
  28685. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28686. /**
  28687. * Converts a cubemap to the according Spherical Polynomial data.
  28688. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28689. *
  28690. * @param cubeInfo The Cube map to extract the information from.
  28691. * @return The Spherical Polynomial data.
  28692. */
  28693. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28694. }
  28695. }
  28696. declare module "babylonjs/Misc/guid" {
  28697. /**
  28698. * Class used to manipulate GUIDs
  28699. */
  28700. export class GUID {
  28701. /**
  28702. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28703. * Be aware Math.random() could cause collisions, but:
  28704. * "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"
  28705. * @returns a pseudo random id
  28706. */
  28707. static RandomId(): string;
  28708. }
  28709. }
  28710. declare module "babylonjs/Materials/Textures/baseTexture" {
  28711. import { Observable } from "babylonjs/Misc/observable";
  28712. import { Nullable } from "babylonjs/types";
  28713. import { Scene } from "babylonjs/scene";
  28714. import { Matrix } from "babylonjs/Maths/math.vector";
  28715. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28717. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28718. import { ISize } from "babylonjs/Maths/math.size";
  28719. /**
  28720. * Base class of all the textures in babylon.
  28721. * It groups all the common properties the materials, post process, lights... might need
  28722. * in order to make a correct use of the texture.
  28723. */
  28724. export class BaseTexture implements IAnimatable {
  28725. /**
  28726. * Default anisotropic filtering level for the application.
  28727. * It is set to 4 as a good tradeoff between perf and quality.
  28728. */
  28729. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28730. /**
  28731. * Gets or sets the unique id of the texture
  28732. */
  28733. uniqueId: number;
  28734. /**
  28735. * Define the name of the texture.
  28736. */
  28737. name: string;
  28738. /**
  28739. * Gets or sets an object used to store user defined information.
  28740. */
  28741. metadata: any;
  28742. /**
  28743. * For internal use only. Please do not use.
  28744. */
  28745. reservedDataStore: any;
  28746. private _hasAlpha;
  28747. /**
  28748. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28749. */
  28750. hasAlpha: boolean;
  28751. /**
  28752. * Defines if the alpha value should be determined via the rgb values.
  28753. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28754. */
  28755. getAlphaFromRGB: boolean;
  28756. /**
  28757. * Intensity or strength of the texture.
  28758. * It is commonly used by materials to fine tune the intensity of the texture
  28759. */
  28760. level: number;
  28761. /**
  28762. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28763. * This is part of the texture as textures usually maps to one uv set.
  28764. */
  28765. coordinatesIndex: number;
  28766. private _coordinatesMode;
  28767. /**
  28768. * How a texture is mapped.
  28769. *
  28770. * | Value | Type | Description |
  28771. * | ----- | ----------------------------------- | ----------- |
  28772. * | 0 | EXPLICIT_MODE | |
  28773. * | 1 | SPHERICAL_MODE | |
  28774. * | 2 | PLANAR_MODE | |
  28775. * | 3 | CUBIC_MODE | |
  28776. * | 4 | PROJECTION_MODE | |
  28777. * | 5 | SKYBOX_MODE | |
  28778. * | 6 | INVCUBIC_MODE | |
  28779. * | 7 | EQUIRECTANGULAR_MODE | |
  28780. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28781. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28782. */
  28783. coordinatesMode: number;
  28784. /**
  28785. * | Value | Type | Description |
  28786. * | ----- | ------------------ | ----------- |
  28787. * | 0 | CLAMP_ADDRESSMODE | |
  28788. * | 1 | WRAP_ADDRESSMODE | |
  28789. * | 2 | MIRROR_ADDRESSMODE | |
  28790. */
  28791. wrapU: number;
  28792. /**
  28793. * | Value | Type | Description |
  28794. * | ----- | ------------------ | ----------- |
  28795. * | 0 | CLAMP_ADDRESSMODE | |
  28796. * | 1 | WRAP_ADDRESSMODE | |
  28797. * | 2 | MIRROR_ADDRESSMODE | |
  28798. */
  28799. wrapV: number;
  28800. /**
  28801. * | Value | Type | Description |
  28802. * | ----- | ------------------ | ----------- |
  28803. * | 0 | CLAMP_ADDRESSMODE | |
  28804. * | 1 | WRAP_ADDRESSMODE | |
  28805. * | 2 | MIRROR_ADDRESSMODE | |
  28806. */
  28807. wrapR: number;
  28808. /**
  28809. * With compliant hardware and browser (supporting anisotropic filtering)
  28810. * this defines the level of anisotropic filtering in the texture.
  28811. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28812. */
  28813. anisotropicFilteringLevel: number;
  28814. /**
  28815. * Define if the texture is a cube texture or if false a 2d texture.
  28816. */
  28817. isCube: boolean;
  28818. /**
  28819. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28820. */
  28821. is3D: boolean;
  28822. /**
  28823. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28824. * HDR texture are usually stored in linear space.
  28825. * This only impacts the PBR and Background materials
  28826. */
  28827. gammaSpace: boolean;
  28828. /**
  28829. * Gets or sets whether or not the texture contains RGBD data.
  28830. */
  28831. isRGBD: boolean;
  28832. /**
  28833. * Is Z inverted in the texture (useful in a cube texture).
  28834. */
  28835. invertZ: boolean;
  28836. /**
  28837. * Are mip maps generated for this texture or not.
  28838. */
  28839. readonly noMipmap: boolean;
  28840. /**
  28841. * @hidden
  28842. */
  28843. lodLevelInAlpha: boolean;
  28844. /**
  28845. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28846. */
  28847. lodGenerationOffset: number;
  28848. /**
  28849. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28850. */
  28851. lodGenerationScale: number;
  28852. /**
  28853. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28854. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28855. * average roughness values.
  28856. */
  28857. linearSpecularLOD: boolean;
  28858. /**
  28859. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28860. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28861. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28862. */
  28863. irradianceTexture: Nullable<BaseTexture>;
  28864. /**
  28865. * Define if the texture is a render target.
  28866. */
  28867. isRenderTarget: boolean;
  28868. /**
  28869. * Define the unique id of the texture in the scene.
  28870. */
  28871. readonly uid: string;
  28872. /**
  28873. * Return a string representation of the texture.
  28874. * @returns the texture as a string
  28875. */
  28876. toString(): string;
  28877. /**
  28878. * Get the class name of the texture.
  28879. * @returns "BaseTexture"
  28880. */
  28881. getClassName(): string;
  28882. /**
  28883. * Define the list of animation attached to the texture.
  28884. */
  28885. animations: import("babylonjs/Animations/animation").Animation[];
  28886. /**
  28887. * An event triggered when the texture is disposed.
  28888. */
  28889. onDisposeObservable: Observable<BaseTexture>;
  28890. private _onDisposeObserver;
  28891. /**
  28892. * Callback triggered when the texture has been disposed.
  28893. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28894. */
  28895. onDispose: () => void;
  28896. /**
  28897. * Define the current state of the loading sequence when in delayed load mode.
  28898. */
  28899. delayLoadState: number;
  28900. private _scene;
  28901. /** @hidden */
  28902. _texture: Nullable<InternalTexture>;
  28903. private _uid;
  28904. /**
  28905. * Define if the texture is preventinga material to render or not.
  28906. * If not and the texture is not ready, the engine will use a default black texture instead.
  28907. */
  28908. readonly isBlocking: boolean;
  28909. /**
  28910. * Instantiates a new BaseTexture.
  28911. * Base class of all the textures in babylon.
  28912. * It groups all the common properties the materials, post process, lights... might need
  28913. * in order to make a correct use of the texture.
  28914. * @param scene Define the scene the texture blongs to
  28915. */
  28916. constructor(scene: Nullable<Scene>);
  28917. /**
  28918. * Get the scene the texture belongs to.
  28919. * @returns the scene or null if undefined
  28920. */
  28921. getScene(): Nullable<Scene>;
  28922. /**
  28923. * Get the texture transform matrix used to offset tile the texture for istance.
  28924. * @returns the transformation matrix
  28925. */
  28926. getTextureMatrix(): Matrix;
  28927. /**
  28928. * Get the texture reflection matrix used to rotate/transform the reflection.
  28929. * @returns the reflection matrix
  28930. */
  28931. getReflectionTextureMatrix(): Matrix;
  28932. /**
  28933. * Get the underlying lower level texture from Babylon.
  28934. * @returns the insternal texture
  28935. */
  28936. getInternalTexture(): Nullable<InternalTexture>;
  28937. /**
  28938. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28939. * @returns true if ready or not blocking
  28940. */
  28941. isReadyOrNotBlocking(): boolean;
  28942. /**
  28943. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28944. * @returns true if fully ready
  28945. */
  28946. isReady(): boolean;
  28947. private _cachedSize;
  28948. /**
  28949. * Get the size of the texture.
  28950. * @returns the texture size.
  28951. */
  28952. getSize(): ISize;
  28953. /**
  28954. * Get the base size of the texture.
  28955. * It can be different from the size if the texture has been resized for POT for instance
  28956. * @returns the base size
  28957. */
  28958. getBaseSize(): ISize;
  28959. /**
  28960. * Update the sampling mode of the texture.
  28961. * Default is Trilinear mode.
  28962. *
  28963. * | Value | Type | Description |
  28964. * | ----- | ------------------ | ----------- |
  28965. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28966. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28967. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28968. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28969. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28970. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28971. * | 7 | NEAREST_LINEAR | |
  28972. * | 8 | NEAREST_NEAREST | |
  28973. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28974. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28975. * | 11 | LINEAR_LINEAR | |
  28976. * | 12 | LINEAR_NEAREST | |
  28977. *
  28978. * > _mag_: magnification filter (close to the viewer)
  28979. * > _min_: minification filter (far from the viewer)
  28980. * > _mip_: filter used between mip map levels
  28981. *@param samplingMode Define the new sampling mode of the texture
  28982. */
  28983. updateSamplingMode(samplingMode: number): void;
  28984. /**
  28985. * Scales the texture if is `canRescale()`
  28986. * @param ratio the resize factor we want to use to rescale
  28987. */
  28988. scale(ratio: number): void;
  28989. /**
  28990. * Get if the texture can rescale.
  28991. */
  28992. readonly canRescale: boolean;
  28993. /** @hidden */
  28994. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28995. /** @hidden */
  28996. _rebuild(): void;
  28997. /**
  28998. * Triggers the load sequence in delayed load mode.
  28999. */
  29000. delayLoad(): void;
  29001. /**
  29002. * Clones the texture.
  29003. * @returns the cloned texture
  29004. */
  29005. clone(): Nullable<BaseTexture>;
  29006. /**
  29007. * Get the texture underlying type (INT, FLOAT...)
  29008. */
  29009. readonly textureType: number;
  29010. /**
  29011. * Get the texture underlying format (RGB, RGBA...)
  29012. */
  29013. readonly textureFormat: number;
  29014. /**
  29015. * Indicates that textures need to be re-calculated for all materials
  29016. */
  29017. protected _markAllSubMeshesAsTexturesDirty(): void;
  29018. /**
  29019. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29020. * This will returns an RGBA array buffer containing either in values (0-255) or
  29021. * float values (0-1) depending of the underlying buffer type.
  29022. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29023. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29024. * @param buffer defines a user defined buffer to fill with data (can be null)
  29025. * @returns The Array buffer containing the pixels data.
  29026. */
  29027. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29028. /**
  29029. * Release and destroy the underlying lower level texture aka internalTexture.
  29030. */
  29031. releaseInternalTexture(): void;
  29032. /**
  29033. * Get the polynomial representation of the texture data.
  29034. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  29035. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  29036. */
  29037. sphericalPolynomial: Nullable<SphericalPolynomial>;
  29038. /** @hidden */
  29039. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29040. /** @hidden */
  29041. readonly _lodTextureMid: Nullable<BaseTexture>;
  29042. /** @hidden */
  29043. readonly _lodTextureLow: Nullable<BaseTexture>;
  29044. /**
  29045. * Dispose the texture and release its associated resources.
  29046. */
  29047. dispose(): void;
  29048. /**
  29049. * Serialize the texture into a JSON representation that can be parsed later on.
  29050. * @returns the JSON representation of the texture
  29051. */
  29052. serialize(): any;
  29053. /**
  29054. * Helper function to be called back once a list of texture contains only ready textures.
  29055. * @param textures Define the list of textures to wait for
  29056. * @param callback Define the callback triggered once the entire list will be ready
  29057. */
  29058. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29059. }
  29060. }
  29061. declare module "babylonjs/Materials/effect" {
  29062. import { Observable } from "babylonjs/Misc/observable";
  29063. import { Nullable } from "babylonjs/types";
  29064. import { IDisposable } from "babylonjs/scene";
  29065. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29066. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29067. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29068. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29069. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29070. import { Engine } from "babylonjs/Engines/engine";
  29071. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29072. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29073. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29074. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29075. /**
  29076. * Options to be used when creating an effect.
  29077. */
  29078. export class EffectCreationOptions {
  29079. /**
  29080. * Atrributes that will be used in the shader.
  29081. */
  29082. attributes: string[];
  29083. /**
  29084. * Uniform varible names that will be set in the shader.
  29085. */
  29086. uniformsNames: string[];
  29087. /**
  29088. * Uniform buffer varible names that will be set in the shader.
  29089. */
  29090. uniformBuffersNames: string[];
  29091. /**
  29092. * Sampler texture variable names that will be set in the shader.
  29093. */
  29094. samplers: string[];
  29095. /**
  29096. * Define statements that will be set in the shader.
  29097. */
  29098. defines: any;
  29099. /**
  29100. * Possible fallbacks for this effect to improve performance when needed.
  29101. */
  29102. fallbacks: Nullable<IEffectFallbacks>;
  29103. /**
  29104. * Callback that will be called when the shader is compiled.
  29105. */
  29106. onCompiled: Nullable<(effect: Effect) => void>;
  29107. /**
  29108. * Callback that will be called if an error occurs during shader compilation.
  29109. */
  29110. onError: Nullable<(effect: Effect, errors: string) => void>;
  29111. /**
  29112. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29113. */
  29114. indexParameters?: any;
  29115. /**
  29116. * Max number of lights that can be used in the shader.
  29117. */
  29118. maxSimultaneousLights?: number;
  29119. /**
  29120. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29121. */
  29122. transformFeedbackVaryings?: Nullable<string[]>;
  29123. }
  29124. /**
  29125. * Effect containing vertex and fragment shader that can be executed on an object.
  29126. */
  29127. export class Effect implements IDisposable {
  29128. /**
  29129. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29130. */
  29131. static ShadersRepository: string;
  29132. /**
  29133. * Name of the effect.
  29134. */
  29135. name: any;
  29136. /**
  29137. * String container all the define statements that should be set on the shader.
  29138. */
  29139. defines: string;
  29140. /**
  29141. * Callback that will be called when the shader is compiled.
  29142. */
  29143. onCompiled: Nullable<(effect: Effect) => void>;
  29144. /**
  29145. * Callback that will be called if an error occurs during shader compilation.
  29146. */
  29147. onError: Nullable<(effect: Effect, errors: string) => void>;
  29148. /**
  29149. * Callback that will be called when effect is bound.
  29150. */
  29151. onBind: Nullable<(effect: Effect) => void>;
  29152. /**
  29153. * Unique ID of the effect.
  29154. */
  29155. uniqueId: number;
  29156. /**
  29157. * Observable that will be called when the shader is compiled.
  29158. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29159. */
  29160. onCompileObservable: Observable<Effect>;
  29161. /**
  29162. * Observable that will be called if an error occurs during shader compilation.
  29163. */
  29164. onErrorObservable: Observable<Effect>;
  29165. /** @hidden */
  29166. _onBindObservable: Nullable<Observable<Effect>>;
  29167. /**
  29168. * Observable that will be called when effect is bound.
  29169. */
  29170. readonly onBindObservable: Observable<Effect>;
  29171. /** @hidden */
  29172. _bonesComputationForcedToCPU: boolean;
  29173. private static _uniqueIdSeed;
  29174. private _engine;
  29175. private _uniformBuffersNames;
  29176. private _uniformsNames;
  29177. private _samplerList;
  29178. private _samplers;
  29179. private _isReady;
  29180. private _compilationError;
  29181. private _attributesNames;
  29182. private _attributes;
  29183. private _uniforms;
  29184. /**
  29185. * Key for the effect.
  29186. * @hidden
  29187. */
  29188. _key: string;
  29189. private _indexParameters;
  29190. private _fallbacks;
  29191. private _vertexSourceCode;
  29192. private _fragmentSourceCode;
  29193. private _vertexSourceCodeOverride;
  29194. private _fragmentSourceCodeOverride;
  29195. private _transformFeedbackVaryings;
  29196. /**
  29197. * Compiled shader to webGL program.
  29198. * @hidden
  29199. */
  29200. _pipelineContext: Nullable<IPipelineContext>;
  29201. private _valueCache;
  29202. private static _baseCache;
  29203. /**
  29204. * Instantiates an effect.
  29205. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29206. * @param baseName Name of the effect.
  29207. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29208. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29209. * @param samplers List of sampler variables that will be passed to the shader.
  29210. * @param engine Engine to be used to render the effect
  29211. * @param defines Define statements to be added to the shader.
  29212. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29213. * @param onCompiled Callback that will be called when the shader is compiled.
  29214. * @param onError Callback that will be called if an error occurs during shader compilation.
  29215. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29216. */
  29217. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  29218. private _useFinalCode;
  29219. /**
  29220. * Unique key for this effect
  29221. */
  29222. readonly key: string;
  29223. /**
  29224. * If the effect has been compiled and prepared.
  29225. * @returns if the effect is compiled and prepared.
  29226. */
  29227. isReady(): boolean;
  29228. private _isReadyInternal;
  29229. /**
  29230. * The engine the effect was initialized with.
  29231. * @returns the engine.
  29232. */
  29233. getEngine(): Engine;
  29234. /**
  29235. * The pipeline context for this effect
  29236. * @returns the associated pipeline context
  29237. */
  29238. getPipelineContext(): Nullable<IPipelineContext>;
  29239. /**
  29240. * The set of names of attribute variables for the shader.
  29241. * @returns An array of attribute names.
  29242. */
  29243. getAttributesNames(): string[];
  29244. /**
  29245. * Returns the attribute at the given index.
  29246. * @param index The index of the attribute.
  29247. * @returns The location of the attribute.
  29248. */
  29249. getAttributeLocation(index: number): number;
  29250. /**
  29251. * Returns the attribute based on the name of the variable.
  29252. * @param name of the attribute to look up.
  29253. * @returns the attribute location.
  29254. */
  29255. getAttributeLocationByName(name: string): number;
  29256. /**
  29257. * The number of attributes.
  29258. * @returns the numnber of attributes.
  29259. */
  29260. getAttributesCount(): number;
  29261. /**
  29262. * Gets the index of a uniform variable.
  29263. * @param uniformName of the uniform to look up.
  29264. * @returns the index.
  29265. */
  29266. getUniformIndex(uniformName: string): number;
  29267. /**
  29268. * Returns the attribute based on the name of the variable.
  29269. * @param uniformName of the uniform to look up.
  29270. * @returns the location of the uniform.
  29271. */
  29272. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29273. /**
  29274. * Returns an array of sampler variable names
  29275. * @returns The array of sampler variable neames.
  29276. */
  29277. getSamplers(): string[];
  29278. /**
  29279. * The error from the last compilation.
  29280. * @returns the error string.
  29281. */
  29282. getCompilationError(): string;
  29283. /**
  29284. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29285. * @param func The callback to be used.
  29286. */
  29287. executeWhenCompiled(func: (effect: Effect) => void): void;
  29288. private _checkIsReady;
  29289. /** @hidden */
  29290. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29291. /** @hidden */
  29292. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29293. /** @hidden */
  29294. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29295. /**
  29296. * Recompiles the webGL program
  29297. * @param vertexSourceCode The source code for the vertex shader.
  29298. * @param fragmentSourceCode The source code for the fragment shader.
  29299. * @param onCompiled Callback called when completed.
  29300. * @param onError Callback called on error.
  29301. * @hidden
  29302. */
  29303. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29304. /**
  29305. * Prepares the effect
  29306. * @hidden
  29307. */
  29308. _prepareEffect(): void;
  29309. private _processCompilationErrors;
  29310. /**
  29311. * Checks if the effect is supported. (Must be called after compilation)
  29312. */
  29313. readonly isSupported: boolean;
  29314. /**
  29315. * Binds a texture to the engine to be used as output of the shader.
  29316. * @param channel Name of the output variable.
  29317. * @param texture Texture to bind.
  29318. * @hidden
  29319. */
  29320. _bindTexture(channel: string, texture: InternalTexture): void;
  29321. /**
  29322. * Sets a texture on the engine to be used in the shader.
  29323. * @param channel Name of the sampler variable.
  29324. * @param texture Texture to set.
  29325. */
  29326. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29327. /**
  29328. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29329. * @param channel Name of the sampler variable.
  29330. * @param texture Texture to set.
  29331. */
  29332. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29333. /**
  29334. * Sets an array of textures on the engine to be used in the shader.
  29335. * @param channel Name of the variable.
  29336. * @param textures Textures to set.
  29337. */
  29338. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29339. /**
  29340. * 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)
  29341. * @param channel Name of the sampler variable.
  29342. * @param postProcess Post process to get the input texture from.
  29343. */
  29344. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29345. /**
  29346. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29347. * 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)
  29348. * @param channel Name of the sampler variable.
  29349. * @param postProcess Post process to get the output texture from.
  29350. */
  29351. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29352. /** @hidden */
  29353. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29354. /** @hidden */
  29355. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29356. /** @hidden */
  29357. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29358. /** @hidden */
  29359. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29360. /**
  29361. * Binds a buffer to a uniform.
  29362. * @param buffer Buffer to bind.
  29363. * @param name Name of the uniform variable to bind to.
  29364. */
  29365. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29366. /**
  29367. * Binds block to a uniform.
  29368. * @param blockName Name of the block to bind.
  29369. * @param index Index to bind.
  29370. */
  29371. bindUniformBlock(blockName: string, index: number): void;
  29372. /**
  29373. * Sets an interger value on a uniform variable.
  29374. * @param uniformName Name of the variable.
  29375. * @param value Value to be set.
  29376. * @returns this effect.
  29377. */
  29378. setInt(uniformName: string, value: number): Effect;
  29379. /**
  29380. * Sets an int array on a uniform variable.
  29381. * @param uniformName Name of the variable.
  29382. * @param array array to be set.
  29383. * @returns this effect.
  29384. */
  29385. setIntArray(uniformName: string, array: Int32Array): Effect;
  29386. /**
  29387. * 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)
  29388. * @param uniformName Name of the variable.
  29389. * @param array array to be set.
  29390. * @returns this effect.
  29391. */
  29392. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29393. /**
  29394. * 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)
  29395. * @param uniformName Name of the variable.
  29396. * @param array array to be set.
  29397. * @returns this effect.
  29398. */
  29399. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29400. /**
  29401. * 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)
  29402. * @param uniformName Name of the variable.
  29403. * @param array array to be set.
  29404. * @returns this effect.
  29405. */
  29406. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29407. /**
  29408. * Sets an float array on a uniform variable.
  29409. * @param uniformName Name of the variable.
  29410. * @param array array to be set.
  29411. * @returns this effect.
  29412. */
  29413. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29414. /**
  29415. * 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)
  29416. * @param uniformName Name of the variable.
  29417. * @param array array to be set.
  29418. * @returns this effect.
  29419. */
  29420. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29421. /**
  29422. * 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)
  29423. * @param uniformName Name of the variable.
  29424. * @param array array to be set.
  29425. * @returns this effect.
  29426. */
  29427. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29428. /**
  29429. * 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)
  29430. * @param uniformName Name of the variable.
  29431. * @param array array to be set.
  29432. * @returns this effect.
  29433. */
  29434. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29435. /**
  29436. * Sets an array on a uniform variable.
  29437. * @param uniformName Name of the variable.
  29438. * @param array array to be set.
  29439. * @returns this effect.
  29440. */
  29441. setArray(uniformName: string, array: number[]): Effect;
  29442. /**
  29443. * 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)
  29444. * @param uniformName Name of the variable.
  29445. * @param array array to be set.
  29446. * @returns this effect.
  29447. */
  29448. setArray2(uniformName: string, array: number[]): Effect;
  29449. /**
  29450. * 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)
  29451. * @param uniformName Name of the variable.
  29452. * @param array array to be set.
  29453. * @returns this effect.
  29454. */
  29455. setArray3(uniformName: string, array: number[]): Effect;
  29456. /**
  29457. * 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)
  29458. * @param uniformName Name of the variable.
  29459. * @param array array to be set.
  29460. * @returns this effect.
  29461. */
  29462. setArray4(uniformName: string, array: number[]): Effect;
  29463. /**
  29464. * Sets matrices on a uniform variable.
  29465. * @param uniformName Name of the variable.
  29466. * @param matrices matrices to be set.
  29467. * @returns this effect.
  29468. */
  29469. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29470. /**
  29471. * Sets matrix on a uniform variable.
  29472. * @param uniformName Name of the variable.
  29473. * @param matrix matrix to be set.
  29474. * @returns this effect.
  29475. */
  29476. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29477. /**
  29478. * 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)
  29479. * @param uniformName Name of the variable.
  29480. * @param matrix matrix to be set.
  29481. * @returns this effect.
  29482. */
  29483. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29484. /**
  29485. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29486. * @param uniformName Name of the variable.
  29487. * @param matrix matrix to be set.
  29488. * @returns this effect.
  29489. */
  29490. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29491. /**
  29492. * Sets a float on a uniform variable.
  29493. * @param uniformName Name of the variable.
  29494. * @param value value to be set.
  29495. * @returns this effect.
  29496. */
  29497. setFloat(uniformName: string, value: number): Effect;
  29498. /**
  29499. * Sets a boolean on a uniform variable.
  29500. * @param uniformName Name of the variable.
  29501. * @param bool value to be set.
  29502. * @returns this effect.
  29503. */
  29504. setBool(uniformName: string, bool: boolean): Effect;
  29505. /**
  29506. * Sets a Vector2 on a uniform variable.
  29507. * @param uniformName Name of the variable.
  29508. * @param vector2 vector2 to be set.
  29509. * @returns this effect.
  29510. */
  29511. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29512. /**
  29513. * Sets a float2 on a uniform variable.
  29514. * @param uniformName Name of the variable.
  29515. * @param x First float in float2.
  29516. * @param y Second float in float2.
  29517. * @returns this effect.
  29518. */
  29519. setFloat2(uniformName: string, x: number, y: number): Effect;
  29520. /**
  29521. * Sets a Vector3 on a uniform variable.
  29522. * @param uniformName Name of the variable.
  29523. * @param vector3 Value to be set.
  29524. * @returns this effect.
  29525. */
  29526. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29527. /**
  29528. * Sets a float3 on a uniform variable.
  29529. * @param uniformName Name of the variable.
  29530. * @param x First float in float3.
  29531. * @param y Second float in float3.
  29532. * @param z Third float in float3.
  29533. * @returns this effect.
  29534. */
  29535. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29536. /**
  29537. * Sets a Vector4 on a uniform variable.
  29538. * @param uniformName Name of the variable.
  29539. * @param vector4 Value to be set.
  29540. * @returns this effect.
  29541. */
  29542. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29543. /**
  29544. * Sets a float4 on a uniform variable.
  29545. * @param uniformName Name of the variable.
  29546. * @param x First float in float4.
  29547. * @param y Second float in float4.
  29548. * @param z Third float in float4.
  29549. * @param w Fourth float in float4.
  29550. * @returns this effect.
  29551. */
  29552. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29553. /**
  29554. * Sets a Color3 on a uniform variable.
  29555. * @param uniformName Name of the variable.
  29556. * @param color3 Value to be set.
  29557. * @returns this effect.
  29558. */
  29559. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29560. /**
  29561. * Sets a Color4 on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param color3 Value to be set.
  29564. * @param alpha Alpha value to be set.
  29565. * @returns this effect.
  29566. */
  29567. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29568. /**
  29569. * Sets a Color4 on a uniform variable
  29570. * @param uniformName defines the name of the variable
  29571. * @param color4 defines the value to be set
  29572. * @returns this effect.
  29573. */
  29574. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29575. /** Release all associated resources */
  29576. dispose(): void;
  29577. /**
  29578. * This function will add a new shader to the shader store
  29579. * @param name the name of the shader
  29580. * @param pixelShader optional pixel shader content
  29581. * @param vertexShader optional vertex shader content
  29582. */
  29583. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29584. /**
  29585. * Store of each shader (The can be looked up using effect.key)
  29586. */
  29587. static ShadersStore: {
  29588. [key: string]: string;
  29589. };
  29590. /**
  29591. * Store of each included file for a shader (The can be looked up using effect.key)
  29592. */
  29593. static IncludesShadersStore: {
  29594. [key: string]: string;
  29595. };
  29596. /**
  29597. * Resets the cache of effects.
  29598. */
  29599. static ResetCache(): void;
  29600. }
  29601. }
  29602. declare module "babylonjs/Engines/engineCapabilities" {
  29603. import { Nullable } from "babylonjs/types";
  29604. /**
  29605. * Class used to describe the capabilities of the engine relatively to the current browser
  29606. */
  29607. export class EngineCapabilities {
  29608. /** Maximum textures units per fragment shader */
  29609. maxTexturesImageUnits: number;
  29610. /** Maximum texture units per vertex shader */
  29611. maxVertexTextureImageUnits: number;
  29612. /** Maximum textures units in the entire pipeline */
  29613. maxCombinedTexturesImageUnits: number;
  29614. /** Maximum texture size */
  29615. maxTextureSize: number;
  29616. /** Maximum cube texture size */
  29617. maxCubemapTextureSize: number;
  29618. /** Maximum render texture size */
  29619. maxRenderTextureSize: number;
  29620. /** Maximum number of vertex attributes */
  29621. maxVertexAttribs: number;
  29622. /** Maximum number of varyings */
  29623. maxVaryingVectors: number;
  29624. /** Maximum number of uniforms per vertex shader */
  29625. maxVertexUniformVectors: number;
  29626. /** Maximum number of uniforms per fragment shader */
  29627. maxFragmentUniformVectors: number;
  29628. /** Defines if standard derivates (dx/dy) are supported */
  29629. standardDerivatives: boolean;
  29630. /** Defines if s3tc texture compression is supported */
  29631. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29632. /** Defines if pvrtc texture compression is supported */
  29633. pvrtc: any;
  29634. /** Defines if etc1 texture compression is supported */
  29635. etc1: any;
  29636. /** Defines if etc2 texture compression is supported */
  29637. etc2: any;
  29638. /** Defines if astc texture compression is supported */
  29639. astc: any;
  29640. /** Defines if float textures are supported */
  29641. textureFloat: boolean;
  29642. /** Defines if vertex array objects are supported */
  29643. vertexArrayObject: boolean;
  29644. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29645. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29646. /** Gets the maximum level of anisotropy supported */
  29647. maxAnisotropy: number;
  29648. /** Defines if instancing is supported */
  29649. instancedArrays: boolean;
  29650. /** Defines if 32 bits indices are supported */
  29651. uintIndices: boolean;
  29652. /** Defines if high precision shaders are supported */
  29653. highPrecisionShaderSupported: boolean;
  29654. /** Defines if depth reading in the fragment shader is supported */
  29655. fragmentDepthSupported: boolean;
  29656. /** Defines if float texture linear filtering is supported*/
  29657. textureFloatLinearFiltering: boolean;
  29658. /** Defines if rendering to float textures is supported */
  29659. textureFloatRender: boolean;
  29660. /** Defines if half float textures are supported*/
  29661. textureHalfFloat: boolean;
  29662. /** Defines if half float texture linear filtering is supported*/
  29663. textureHalfFloatLinearFiltering: boolean;
  29664. /** Defines if rendering to half float textures is supported */
  29665. textureHalfFloatRender: boolean;
  29666. /** Defines if textureLOD shader command is supported */
  29667. textureLOD: boolean;
  29668. /** Defines if draw buffers extension is supported */
  29669. drawBuffersExtension: boolean;
  29670. /** Defines if depth textures are supported */
  29671. depthTextureExtension: boolean;
  29672. /** Defines if float color buffer are supported */
  29673. colorBufferFloat: boolean;
  29674. /** Gets disjoint timer query extension (null if not supported) */
  29675. timerQuery: EXT_disjoint_timer_query;
  29676. /** Defines if timestamp can be used with timer query */
  29677. canUseTimestampForTimerQuery: boolean;
  29678. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29679. multiview: any;
  29680. /** Function used to let the system compiles shaders in background */
  29681. parallelShaderCompile: {
  29682. COMPLETION_STATUS_KHR: number;
  29683. };
  29684. /** Max number of texture samples for MSAA */
  29685. maxMSAASamples: number;
  29686. /** Defines if the blend min max extension is supported */
  29687. blendMinMax: boolean;
  29688. }
  29689. }
  29690. declare module "babylonjs/States/depthCullingState" {
  29691. import { Nullable } from "babylonjs/types";
  29692. /**
  29693. * @hidden
  29694. **/
  29695. export class DepthCullingState {
  29696. private _isDepthTestDirty;
  29697. private _isDepthMaskDirty;
  29698. private _isDepthFuncDirty;
  29699. private _isCullFaceDirty;
  29700. private _isCullDirty;
  29701. private _isZOffsetDirty;
  29702. private _isFrontFaceDirty;
  29703. private _depthTest;
  29704. private _depthMask;
  29705. private _depthFunc;
  29706. private _cull;
  29707. private _cullFace;
  29708. private _zOffset;
  29709. private _frontFace;
  29710. /**
  29711. * Initializes the state.
  29712. */
  29713. constructor();
  29714. readonly isDirty: boolean;
  29715. zOffset: number;
  29716. cullFace: Nullable<number>;
  29717. cull: Nullable<boolean>;
  29718. depthFunc: Nullable<number>;
  29719. depthMask: boolean;
  29720. depthTest: boolean;
  29721. frontFace: Nullable<number>;
  29722. reset(): void;
  29723. apply(gl: WebGLRenderingContext): void;
  29724. }
  29725. }
  29726. declare module "babylonjs/States/stencilState" {
  29727. /**
  29728. * @hidden
  29729. **/
  29730. export class StencilState {
  29731. /** 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 */
  29732. static readonly ALWAYS: number;
  29733. /** Passed to stencilOperation to specify that stencil value must be kept */
  29734. static readonly KEEP: number;
  29735. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29736. static readonly REPLACE: number;
  29737. private _isStencilTestDirty;
  29738. private _isStencilMaskDirty;
  29739. private _isStencilFuncDirty;
  29740. private _isStencilOpDirty;
  29741. private _stencilTest;
  29742. private _stencilMask;
  29743. private _stencilFunc;
  29744. private _stencilFuncRef;
  29745. private _stencilFuncMask;
  29746. private _stencilOpStencilFail;
  29747. private _stencilOpDepthFail;
  29748. private _stencilOpStencilDepthPass;
  29749. readonly isDirty: boolean;
  29750. stencilFunc: number;
  29751. stencilFuncRef: number;
  29752. stencilFuncMask: number;
  29753. stencilOpStencilFail: number;
  29754. stencilOpDepthFail: number;
  29755. stencilOpStencilDepthPass: number;
  29756. stencilMask: number;
  29757. stencilTest: boolean;
  29758. constructor();
  29759. reset(): void;
  29760. apply(gl: WebGLRenderingContext): void;
  29761. }
  29762. }
  29763. declare module "babylonjs/States/alphaCullingState" {
  29764. /**
  29765. * @hidden
  29766. **/
  29767. export class AlphaState {
  29768. private _isAlphaBlendDirty;
  29769. private _isBlendFunctionParametersDirty;
  29770. private _isBlendEquationParametersDirty;
  29771. private _isBlendConstantsDirty;
  29772. private _alphaBlend;
  29773. private _blendFunctionParameters;
  29774. private _blendEquationParameters;
  29775. private _blendConstants;
  29776. /**
  29777. * Initializes the state.
  29778. */
  29779. constructor();
  29780. readonly isDirty: boolean;
  29781. alphaBlend: boolean;
  29782. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29783. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29784. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29785. reset(): void;
  29786. apply(gl: WebGLRenderingContext): void;
  29787. }
  29788. }
  29789. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29790. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29791. /** @hidden */
  29792. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29793. attributeProcessor(attribute: string): string;
  29794. varyingProcessor(varying: string, isFragment: boolean): string;
  29795. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29796. }
  29797. }
  29798. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29799. /**
  29800. * Interface for attribute information associated with buffer instanciation
  29801. */
  29802. export class InstancingAttributeInfo {
  29803. /**
  29804. * Index/offset of the attribute in the vertex shader
  29805. */
  29806. index: number;
  29807. /**
  29808. * size of the attribute, 1, 2, 3 or 4
  29809. */
  29810. attributeSize: number;
  29811. /**
  29812. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29813. * default is FLOAT
  29814. */
  29815. attribyteType: number;
  29816. /**
  29817. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29818. */
  29819. normalized: boolean;
  29820. /**
  29821. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29822. */
  29823. offset: number;
  29824. /**
  29825. * Name of the GLSL attribute, for debugging purpose only
  29826. */
  29827. attributeName: string;
  29828. }
  29829. }
  29830. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29831. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29832. import { Nullable } from "babylonjs/types";
  29833. module "babylonjs/Engines/thinEngine" {
  29834. interface ThinEngine {
  29835. /**
  29836. * Update a video texture
  29837. * @param texture defines the texture to update
  29838. * @param video defines the video element to use
  29839. * @param invertY defines if data must be stored with Y axis inverted
  29840. */
  29841. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29842. }
  29843. }
  29844. }
  29845. declare module "babylonjs/Materials/Textures/videoTexture" {
  29846. import { Observable } from "babylonjs/Misc/observable";
  29847. import { Nullable } from "babylonjs/types";
  29848. import { Scene } from "babylonjs/scene";
  29849. import { Texture } from "babylonjs/Materials/Textures/texture";
  29850. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29851. /**
  29852. * Settings for finer control over video usage
  29853. */
  29854. export interface VideoTextureSettings {
  29855. /**
  29856. * Applies `autoplay` to video, if specified
  29857. */
  29858. autoPlay?: boolean;
  29859. /**
  29860. * Applies `loop` to video, if specified
  29861. */
  29862. loop?: boolean;
  29863. /**
  29864. * Automatically updates internal texture from video at every frame in the render loop
  29865. */
  29866. autoUpdateTexture: boolean;
  29867. /**
  29868. * Image src displayed during the video loading or until the user interacts with the video.
  29869. */
  29870. poster?: string;
  29871. }
  29872. /**
  29873. * If you want to display a video in your scene, this is the special texture for that.
  29874. * This special texture works similar to other textures, with the exception of a few parameters.
  29875. * @see https://doc.babylonjs.com/how_to/video_texture
  29876. */
  29877. export class VideoTexture extends Texture {
  29878. /**
  29879. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29880. */
  29881. readonly autoUpdateTexture: boolean;
  29882. /**
  29883. * The video instance used by the texture internally
  29884. */
  29885. readonly video: HTMLVideoElement;
  29886. private _onUserActionRequestedObservable;
  29887. /**
  29888. * Event triggerd when a dom action is required by the user to play the video.
  29889. * This happens due to recent changes in browser policies preventing video to auto start.
  29890. */
  29891. readonly onUserActionRequestedObservable: Observable<Texture>;
  29892. private _generateMipMaps;
  29893. private _engine;
  29894. private _stillImageCaptured;
  29895. private _displayingPosterTexture;
  29896. private _settings;
  29897. private _createInternalTextureOnEvent;
  29898. private _frameId;
  29899. /**
  29900. * Creates a video texture.
  29901. * If you want to display a video in your scene, this is the special texture for that.
  29902. * This special texture works similar to other textures, with the exception of a few parameters.
  29903. * @see https://doc.babylonjs.com/how_to/video_texture
  29904. * @param name optional name, will detect from video source, if not defined
  29905. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29906. * @param scene is obviously the current scene.
  29907. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29908. * @param invertY is false by default but can be used to invert video on Y axis
  29909. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29910. * @param settings allows finer control over video usage
  29911. */
  29912. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29913. private _getName;
  29914. private _getVideo;
  29915. private _createInternalTexture;
  29916. private reset;
  29917. /**
  29918. * @hidden Internal method to initiate `update`.
  29919. */
  29920. _rebuild(): void;
  29921. /**
  29922. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29923. */
  29924. update(): void;
  29925. /**
  29926. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29927. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29928. */
  29929. updateTexture(isVisible: boolean): void;
  29930. protected _updateInternalTexture: () => void;
  29931. /**
  29932. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29933. * @param url New url.
  29934. */
  29935. updateURL(url: string): void;
  29936. /**
  29937. * Dispose the texture and release its associated resources.
  29938. */
  29939. dispose(): void;
  29940. /**
  29941. * Creates a video texture straight from a stream.
  29942. * @param scene Define the scene the texture should be created in
  29943. * @param stream Define the stream the texture should be created from
  29944. * @returns The created video texture as a promise
  29945. */
  29946. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29947. /**
  29948. * Creates a video texture straight from your WebCam video feed.
  29949. * @param scene Define the scene the texture should be created in
  29950. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29951. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29952. * @returns The created video texture as a promise
  29953. */
  29954. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29955. minWidth: number;
  29956. maxWidth: number;
  29957. minHeight: number;
  29958. maxHeight: number;
  29959. deviceId: string;
  29960. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29961. /**
  29962. * Creates a video texture straight from your WebCam video feed.
  29963. * @param scene Define the scene the texture should be created in
  29964. * @param onReady Define a callback to triggered once the texture will be ready
  29965. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29966. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29967. */
  29968. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29969. minWidth: number;
  29970. maxWidth: number;
  29971. minHeight: number;
  29972. maxHeight: number;
  29973. deviceId: string;
  29974. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29975. }
  29976. }
  29977. declare module "babylonjs/Engines/thinEngine" {
  29978. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29979. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  29980. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29981. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29982. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29983. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29984. import { Observable } from "babylonjs/Misc/observable";
  29985. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29986. import { StencilState } from "babylonjs/States/stencilState";
  29987. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29989. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29990. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29991. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29992. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29993. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29994. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29995. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29996. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29998. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29999. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30000. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30001. /**
  30002. * Defines the interface used by objects working like Scene
  30003. * @hidden
  30004. */
  30005. interface ISceneLike {
  30006. _addPendingData(data: any): void;
  30007. _removePendingData(data: any): void;
  30008. offlineProvider: IOfflineProvider;
  30009. }
  30010. /** Interface defining initialization parameters for Engine class */
  30011. export interface EngineOptions extends WebGLContextAttributes {
  30012. /**
  30013. * Defines if the engine should no exceed a specified device ratio
  30014. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30015. */
  30016. limitDeviceRatio?: number;
  30017. /**
  30018. * Defines if webvr should be enabled automatically
  30019. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30020. */
  30021. autoEnableWebVR?: boolean;
  30022. /**
  30023. * Defines if webgl2 should be turned off even if supported
  30024. * @see http://doc.babylonjs.com/features/webgl2
  30025. */
  30026. disableWebGL2Support?: boolean;
  30027. /**
  30028. * Defines if webaudio should be initialized as well
  30029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30030. */
  30031. audioEngine?: boolean;
  30032. /**
  30033. * Defines if animations should run using a deterministic lock step
  30034. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30035. */
  30036. deterministicLockstep?: boolean;
  30037. /** Defines the maximum steps to use with deterministic lock step mode */
  30038. lockstepMaxSteps?: number;
  30039. /**
  30040. * Defines that engine should ignore context lost events
  30041. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30042. */
  30043. doNotHandleContextLost?: boolean;
  30044. /**
  30045. * Defines that engine should ignore modifying touch action attribute and style
  30046. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30047. */
  30048. doNotHandleTouchAction?: boolean;
  30049. /**
  30050. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30051. */
  30052. useHighPrecisionFloats?: boolean;
  30053. }
  30054. /**
  30055. * The base engine class (root of all engines)
  30056. */
  30057. export class ThinEngine {
  30058. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30059. static ExceptionList: ({
  30060. key: string;
  30061. capture: string;
  30062. captureConstraint: number;
  30063. targets: string[];
  30064. } | {
  30065. key: string;
  30066. capture: null;
  30067. captureConstraint: null;
  30068. targets: string[];
  30069. })[];
  30070. /** @hidden */
  30071. static _TextureLoaders: IInternalTextureLoader[];
  30072. /**
  30073. * Returns the current npm package of the sdk
  30074. */
  30075. static readonly NpmPackage: string;
  30076. /**
  30077. * Returns the current version of the framework
  30078. */
  30079. static readonly Version: string;
  30080. /**
  30081. * Returns a string describing the current engine
  30082. */
  30083. readonly description: string;
  30084. /**
  30085. * Gets or sets the epsilon value used by collision engine
  30086. */
  30087. static CollisionsEpsilon: number;
  30088. /**
  30089. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30090. */
  30091. static ShadersRepository: string;
  30092. /** @hidden */
  30093. _shaderProcessor: IShaderProcessor;
  30094. /**
  30095. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30096. */
  30097. forcePOTTextures: boolean;
  30098. /**
  30099. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30100. */
  30101. isFullscreen: boolean;
  30102. /**
  30103. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30104. */
  30105. cullBackFaces: boolean;
  30106. /**
  30107. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30108. */
  30109. renderEvenInBackground: boolean;
  30110. /**
  30111. * Gets or sets a boolean indicating that cache can be kept between frames
  30112. */
  30113. preventCacheWipeBetweenFrames: boolean;
  30114. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30115. validateShaderPrograms: boolean;
  30116. /**
  30117. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30118. */
  30119. disableUniformBuffers: boolean;
  30120. /** @hidden */
  30121. _uniformBuffers: UniformBuffer[];
  30122. /**
  30123. * Gets a boolean indicating that the engine supports uniform buffers
  30124. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30125. */
  30126. readonly supportsUniformBuffers: boolean;
  30127. /** @hidden */
  30128. _gl: WebGLRenderingContext;
  30129. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30130. protected _windowIsBackground: boolean;
  30131. protected _webGLVersion: number;
  30132. protected _highPrecisionShadersAllowed: boolean;
  30133. /** @hidden */
  30134. readonly _shouldUseHighPrecisionShader: boolean;
  30135. /**
  30136. * Gets a boolean indicating that only power of 2 textures are supported
  30137. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30138. */
  30139. readonly needPOTTextures: boolean;
  30140. /** @hidden */
  30141. _badOS: boolean;
  30142. /** @hidden */
  30143. _badDesktopOS: boolean;
  30144. private _hardwareScalingLevel;
  30145. /** @hidden */
  30146. _caps: EngineCapabilities;
  30147. private _isStencilEnable;
  30148. protected _colorWrite: boolean;
  30149. private _glVersion;
  30150. private _glRenderer;
  30151. private _glVendor;
  30152. /** @hidden */
  30153. _videoTextureSupported: boolean;
  30154. protected _renderingQueueLaunched: boolean;
  30155. protected _activeRenderLoops: (() => void)[];
  30156. /**
  30157. * Observable signaled when a context lost event is raised
  30158. */
  30159. onContextLostObservable: Observable<ThinEngine>;
  30160. /**
  30161. * Observable signaled when a context restored event is raised
  30162. */
  30163. onContextRestoredObservable: Observable<ThinEngine>;
  30164. private _onContextLost;
  30165. private _onContextRestored;
  30166. protected _contextWasLost: boolean;
  30167. /** @hidden */
  30168. _doNotHandleContextLost: boolean;
  30169. /**
  30170. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30172. */
  30173. doNotHandleContextLost: boolean;
  30174. /**
  30175. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30176. */
  30177. disableVertexArrayObjects: boolean;
  30178. /** @hidden */
  30179. protected _depthCullingState: DepthCullingState;
  30180. /** @hidden */
  30181. protected _stencilState: StencilState;
  30182. /** @hidden */
  30183. protected _alphaState: AlphaState;
  30184. /** @hidden */
  30185. _internalTexturesCache: InternalTexture[];
  30186. /** @hidden */
  30187. protected _activeChannel: number;
  30188. private _currentTextureChannel;
  30189. /** @hidden */
  30190. protected _boundTexturesCache: {
  30191. [key: string]: Nullable<InternalTexture>;
  30192. };
  30193. /** @hidden */
  30194. protected _currentEffect: Nullable<Effect>;
  30195. /** @hidden */
  30196. protected _currentProgram: Nullable<WebGLProgram>;
  30197. private _compiledEffects;
  30198. private _vertexAttribArraysEnabled;
  30199. /** @hidden */
  30200. protected _cachedViewport: Nullable<IViewportLike>;
  30201. private _cachedVertexArrayObject;
  30202. /** @hidden */
  30203. protected _cachedVertexBuffers: any;
  30204. /** @hidden */
  30205. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30206. /** @hidden */
  30207. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30208. /** @hidden */
  30209. _currentRenderTarget: Nullable<InternalTexture>;
  30210. private _uintIndicesCurrentlySet;
  30211. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30212. /** @hidden */
  30213. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30214. private _currentBufferPointers;
  30215. private _currentInstanceLocations;
  30216. private _currentInstanceBuffers;
  30217. private _textureUnits;
  30218. /** @hidden */
  30219. _workingCanvas: Nullable<HTMLCanvasElement>;
  30220. /** @hidden */
  30221. _workingContext: Nullable<CanvasRenderingContext2D>;
  30222. /** @hidden */
  30223. _bindedRenderFunction: any;
  30224. private _vaoRecordInProgress;
  30225. private _mustWipeVertexAttributes;
  30226. private _emptyTexture;
  30227. private _emptyCubeTexture;
  30228. private _emptyTexture3D;
  30229. /** @hidden */
  30230. _frameHandler: number;
  30231. private _nextFreeTextureSlots;
  30232. private _maxSimultaneousTextures;
  30233. private _activeRequests;
  30234. protected _texturesSupported: string[];
  30235. /** @hidden */
  30236. _textureFormatInUse: Nullable<string>;
  30237. protected readonly _supportsHardwareTextureRescaling: boolean;
  30238. /**
  30239. * Gets the list of texture formats supported
  30240. */
  30241. readonly texturesSupported: Array<string>;
  30242. /**
  30243. * Gets the list of texture formats in use
  30244. */
  30245. readonly textureFormatInUse: Nullable<string>;
  30246. /**
  30247. * Gets the current viewport
  30248. */
  30249. readonly currentViewport: Nullable<IViewportLike>;
  30250. /**
  30251. * Gets the default empty texture
  30252. */
  30253. readonly emptyTexture: InternalTexture;
  30254. /**
  30255. * Gets the default empty 3D texture
  30256. */
  30257. readonly emptyTexture3D: InternalTexture;
  30258. /**
  30259. * Gets the default empty cube texture
  30260. */
  30261. readonly emptyCubeTexture: InternalTexture;
  30262. /**
  30263. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30264. */
  30265. readonly premultipliedAlpha: boolean;
  30266. /**
  30267. * Creates a new engine
  30268. * @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
  30269. * @param antialias defines enable antialiasing (default: false)
  30270. * @param options defines further options to be sent to the getContext() function
  30271. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30272. */
  30273. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30274. private _rebuildInternalTextures;
  30275. private _rebuildEffects;
  30276. /**
  30277. * Gets a boolean indicating if all created effects are ready
  30278. * @returns true if all effects are ready
  30279. */
  30280. areAllEffectsReady(): boolean;
  30281. protected _rebuildBuffers(): void;
  30282. private _initGLContext;
  30283. /**
  30284. * Gets version of the current webGL context
  30285. */
  30286. readonly webGLVersion: number;
  30287. /**
  30288. * Gets a string idenfifying the name of the class
  30289. * @returns "Engine" string
  30290. */
  30291. getClassName(): string;
  30292. /**
  30293. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30294. */
  30295. readonly isStencilEnable: boolean;
  30296. /** @hidden */
  30297. _prepareWorkingCanvas(): void;
  30298. /**
  30299. * Reset the texture cache to empty state
  30300. */
  30301. resetTextureCache(): void;
  30302. /**
  30303. * Gets an object containing information about the current webGL context
  30304. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30305. */
  30306. getGlInfo(): {
  30307. vendor: string;
  30308. renderer: string;
  30309. version: string;
  30310. };
  30311. /**
  30312. * Defines the hardware scaling level.
  30313. * By default the hardware scaling level is computed from the window device ratio.
  30314. * 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.
  30315. * @param level defines the level to use
  30316. */
  30317. setHardwareScalingLevel(level: number): void;
  30318. /**
  30319. * Gets the current hardware scaling level.
  30320. * By default the hardware scaling level is computed from the window device ratio.
  30321. * 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.
  30322. * @returns a number indicating the current hardware scaling level
  30323. */
  30324. getHardwareScalingLevel(): number;
  30325. /**
  30326. * Gets the list of loaded textures
  30327. * @returns an array containing all loaded textures
  30328. */
  30329. getLoadedTexturesCache(): InternalTexture[];
  30330. /**
  30331. * Gets the object containing all engine capabilities
  30332. * @returns the EngineCapabilities object
  30333. */
  30334. getCaps(): EngineCapabilities;
  30335. /**
  30336. * stop executing a render loop function and remove it from the execution array
  30337. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30338. */
  30339. stopRenderLoop(renderFunction?: () => void): void;
  30340. /** @hidden */
  30341. _renderLoop(): void;
  30342. /**
  30343. * Gets the HTML canvas attached with the current webGL context
  30344. * @returns a HTML canvas
  30345. */
  30346. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30347. /**
  30348. * Gets host window
  30349. * @returns the host window object
  30350. */
  30351. getHostWindow(): Window;
  30352. /**
  30353. * Gets the current render width
  30354. * @param useScreen defines if screen size must be used (or the current render target if any)
  30355. * @returns a number defining the current render width
  30356. */
  30357. getRenderWidth(useScreen?: boolean): number;
  30358. /**
  30359. * Gets the current render height
  30360. * @param useScreen defines if screen size must be used (or the current render target if any)
  30361. * @returns a number defining the current render height
  30362. */
  30363. getRenderHeight(useScreen?: boolean): number;
  30364. /**
  30365. * Can be used to override the current requestAnimationFrame requester.
  30366. * @hidden
  30367. */
  30368. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30369. /**
  30370. * Register and execute a render loop. The engine can have more than one render function
  30371. * @param renderFunction defines the function to continuously execute
  30372. */
  30373. runRenderLoop(renderFunction: () => void): void;
  30374. /**
  30375. * Clear the current render buffer or the current render target (if any is set up)
  30376. * @param color defines the color to use
  30377. * @param backBuffer defines if the back buffer must be cleared
  30378. * @param depth defines if the depth buffer must be cleared
  30379. * @param stencil defines if the stencil buffer must be cleared
  30380. */
  30381. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30382. private _viewportCached;
  30383. /** @hidden */
  30384. _viewport(x: number, y: number, width: number, height: number): void;
  30385. /**
  30386. * Set the WebGL's viewport
  30387. * @param viewport defines the viewport element to be used
  30388. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30389. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30390. */
  30391. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30392. /**
  30393. * Begin a new frame
  30394. */
  30395. beginFrame(): void;
  30396. /**
  30397. * Enf the current frame
  30398. */
  30399. endFrame(): void;
  30400. /**
  30401. * Resize the view according to the canvas' size
  30402. */
  30403. resize(): void;
  30404. /**
  30405. * Force a specific size of the canvas
  30406. * @param width defines the new canvas' width
  30407. * @param height defines the new canvas' height
  30408. */
  30409. setSize(width: number, height: number): void;
  30410. /**
  30411. * Binds the frame buffer to the specified texture.
  30412. * @param texture The texture to render to or null for the default canvas
  30413. * @param faceIndex The face of the texture to render to in case of cube texture
  30414. * @param requiredWidth The width of the target to render to
  30415. * @param requiredHeight The height of the target to render to
  30416. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30417. * @param depthStencilTexture The depth stencil texture to use to render
  30418. * @param lodLevel defines le lod level to bind to the frame buffer
  30419. */
  30420. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30421. /** @hidden */
  30422. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30423. /**
  30424. * Unbind the current render target texture from the webGL context
  30425. * @param texture defines the render target texture to unbind
  30426. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30427. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30428. */
  30429. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30430. /**
  30431. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30432. */
  30433. flushFramebuffer(): void;
  30434. /**
  30435. * Unbind the current render target and bind the default framebuffer
  30436. */
  30437. restoreDefaultFramebuffer(): void;
  30438. private _resetVertexBufferBinding;
  30439. /**
  30440. * Creates a vertex buffer
  30441. * @param data the data for the vertex buffer
  30442. * @returns the new WebGL static buffer
  30443. */
  30444. createVertexBuffer(data: DataArray): DataBuffer;
  30445. private _createVertexBuffer;
  30446. /**
  30447. * Creates a dynamic vertex buffer
  30448. * @param data the data for the dynamic vertex buffer
  30449. * @returns the new WebGL dynamic buffer
  30450. */
  30451. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30452. /**
  30453. * Updates a dynamic vertex buffer.
  30454. * @param vertexBuffer the vertex buffer to update
  30455. * @param data the data used to update the vertex buffer
  30456. * @param byteOffset the byte offset of the data
  30457. * @param byteLength the byte length of the data
  30458. */
  30459. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30460. protected _resetIndexBufferBinding(): void;
  30461. /**
  30462. * Creates a new index buffer
  30463. * @param indices defines the content of the index buffer
  30464. * @param updatable defines if the index buffer must be updatable
  30465. * @returns a new webGL buffer
  30466. */
  30467. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30468. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30469. /**
  30470. * Bind a webGL buffer to the webGL context
  30471. * @param buffer defines the buffer to bind
  30472. */
  30473. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30474. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30475. private bindBuffer;
  30476. /**
  30477. * update the bound buffer with the given data
  30478. * @param data defines the data to update
  30479. */
  30480. updateArrayBuffer(data: Float32Array): void;
  30481. private _vertexAttribPointer;
  30482. private _bindIndexBufferWithCache;
  30483. private _bindVertexBuffersAttributes;
  30484. /**
  30485. * Records a vertex array object
  30486. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30487. * @param vertexBuffers defines the list of vertex buffers to store
  30488. * @param indexBuffer defines the index buffer to store
  30489. * @param effect defines the effect to store
  30490. * @returns the new vertex array object
  30491. */
  30492. recordVertexArrayObject(vertexBuffers: {
  30493. [key: string]: VertexBuffer;
  30494. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30495. /**
  30496. * Bind a specific vertex array object
  30497. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30498. * @param vertexArrayObject defines the vertex array object to bind
  30499. * @param indexBuffer defines the index buffer to bind
  30500. */
  30501. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30502. /**
  30503. * Bind webGl buffers directly to the webGL context
  30504. * @param vertexBuffer defines the vertex buffer to bind
  30505. * @param indexBuffer defines the index buffer to bind
  30506. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30507. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30508. * @param effect defines the effect associated with the vertex buffer
  30509. */
  30510. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30511. private _unbindVertexArrayObject;
  30512. /**
  30513. * Bind a list of vertex buffers to the webGL context
  30514. * @param vertexBuffers defines the list of vertex buffers to bind
  30515. * @param indexBuffer defines the index buffer to bind
  30516. * @param effect defines the effect associated with the vertex buffers
  30517. */
  30518. bindBuffers(vertexBuffers: {
  30519. [key: string]: Nullable<VertexBuffer>;
  30520. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30521. /**
  30522. * Unbind all instance attributes
  30523. */
  30524. unbindInstanceAttributes(): void;
  30525. /**
  30526. * Release and free the memory of a vertex array object
  30527. * @param vao defines the vertex array object to delete
  30528. */
  30529. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30530. /** @hidden */
  30531. _releaseBuffer(buffer: DataBuffer): boolean;
  30532. protected _deleteBuffer(buffer: DataBuffer): void;
  30533. /**
  30534. * Creates a webGL buffer to use with instanciation
  30535. * @param capacity defines the size of the buffer
  30536. * @returns the webGL buffer
  30537. */
  30538. createInstancesBuffer(capacity: number): DataBuffer;
  30539. /**
  30540. * Delete a webGL buffer used with instanciation
  30541. * @param buffer defines the webGL buffer to delete
  30542. */
  30543. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30544. /**
  30545. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30546. * @param instancesBuffer defines the webGL buffer to update and bind
  30547. * @param data defines the data to store in the buffer
  30548. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30549. */
  30550. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30551. /**
  30552. * Apply all cached states (depth, culling, stencil and alpha)
  30553. */
  30554. applyStates(): void;
  30555. /**
  30556. * Send a draw order
  30557. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30558. * @param indexStart defines the starting index
  30559. * @param indexCount defines the number of index to draw
  30560. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30561. */
  30562. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30563. /**
  30564. * Draw a list of points
  30565. * @param verticesStart defines the index of first vertex to draw
  30566. * @param verticesCount defines the count of vertices to draw
  30567. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30568. */
  30569. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30570. /**
  30571. * Draw a list of unindexed primitives
  30572. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30573. * @param verticesStart defines the index of first vertex to draw
  30574. * @param verticesCount defines the count of vertices to draw
  30575. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30576. */
  30577. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30578. /**
  30579. * Draw a list of indexed primitives
  30580. * @param fillMode defines the primitive to use
  30581. * @param indexStart defines the starting index
  30582. * @param indexCount defines the number of index to draw
  30583. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30584. */
  30585. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30586. /**
  30587. * Draw a list of unindexed primitives
  30588. * @param fillMode defines the primitive to use
  30589. * @param verticesStart defines the index of first vertex to draw
  30590. * @param verticesCount defines the count of vertices to draw
  30591. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30592. */
  30593. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30594. private _drawMode;
  30595. /** @hidden */
  30596. protected _reportDrawCall(): void;
  30597. /** @hidden */
  30598. _releaseEffect(effect: Effect): void;
  30599. /** @hidden */
  30600. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30601. /**
  30602. * Create a new effect (used to store vertex/fragment shaders)
  30603. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30604. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30605. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30606. * @param samplers defines an array of string used to represent textures
  30607. * @param defines defines the string containing the defines to use to compile the shaders
  30608. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30609. * @param onCompiled defines a function to call when the effect creation is successful
  30610. * @param onError defines a function to call when the effect creation has failed
  30611. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30612. * @returns the new Effect
  30613. */
  30614. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30615. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30616. private _compileShader;
  30617. private _compileRawShader;
  30618. /**
  30619. * Directly creates a webGL program
  30620. * @param pipelineContext defines the pipeline context to attach to
  30621. * @param vertexCode defines the vertex shader code to use
  30622. * @param fragmentCode defines the fragment shader code to use
  30623. * @param context defines the webGL context to use (if not set, the current one will be used)
  30624. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30625. * @returns the new webGL program
  30626. */
  30627. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30628. /**
  30629. * Creates a webGL program
  30630. * @param pipelineContext defines the pipeline context to attach to
  30631. * @param vertexCode defines the vertex shader code to use
  30632. * @param fragmentCode defines the fragment shader code to use
  30633. * @param defines defines the string containing the defines to use to compile the shaders
  30634. * @param context defines the webGL context to use (if not set, the current one will be used)
  30635. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30636. * @returns the new webGL program
  30637. */
  30638. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30639. /**
  30640. * Creates a new pipeline context
  30641. * @returns the new pipeline
  30642. */
  30643. createPipelineContext(): IPipelineContext;
  30644. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30645. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30646. /** @hidden */
  30647. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30648. /** @hidden */
  30649. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30650. /** @hidden */
  30651. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30652. /**
  30653. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30654. * @param pipelineContext defines the pipeline context to use
  30655. * @param uniformsNames defines the list of uniform names
  30656. * @returns an array of webGL uniform locations
  30657. */
  30658. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30659. /**
  30660. * Gets the lsit of active attributes for a given webGL program
  30661. * @param pipelineContext defines the pipeline context to use
  30662. * @param attributesNames defines the list of attribute names to get
  30663. * @returns an array of indices indicating the offset of each attribute
  30664. */
  30665. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30666. /**
  30667. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30668. * @param effect defines the effect to activate
  30669. */
  30670. enableEffect(effect: Nullable<Effect>): void;
  30671. /**
  30672. * Set the value of an uniform to an array of int32
  30673. * @param uniform defines the webGL uniform location where to store the value
  30674. * @param array defines the array of int32 to store
  30675. */
  30676. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30677. /**
  30678. * Set the value of an uniform to an array of int32 (stored as vec2)
  30679. * @param uniform defines the webGL uniform location where to store the value
  30680. * @param array defines the array of int32 to store
  30681. */
  30682. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30683. /**
  30684. * Set the value of an uniform to an array of int32 (stored as vec3)
  30685. * @param uniform defines the webGL uniform location where to store the value
  30686. * @param array defines the array of int32 to store
  30687. */
  30688. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30689. /**
  30690. * Set the value of an uniform to an array of int32 (stored as vec4)
  30691. * @param uniform defines the webGL uniform location where to store the value
  30692. * @param array defines the array of int32 to store
  30693. */
  30694. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30695. /**
  30696. * Set the value of an uniform to an array of float32
  30697. * @param uniform defines the webGL uniform location where to store the value
  30698. * @param array defines the array of float32 to store
  30699. */
  30700. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30701. /**
  30702. * Set the value of an uniform to an array of float32 (stored as vec2)
  30703. * @param uniform defines the webGL uniform location where to store the value
  30704. * @param array defines the array of float32 to store
  30705. */
  30706. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30707. /**
  30708. * Set the value of an uniform to an array of float32 (stored as vec3)
  30709. * @param uniform defines the webGL uniform location where to store the value
  30710. * @param array defines the array of float32 to store
  30711. */
  30712. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30713. /**
  30714. * Set the value of an uniform to an array of float32 (stored as vec4)
  30715. * @param uniform defines the webGL uniform location where to store the value
  30716. * @param array defines the array of float32 to store
  30717. */
  30718. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30719. /**
  30720. * Set the value of an uniform to an array of number
  30721. * @param uniform defines the webGL uniform location where to store the value
  30722. * @param array defines the array of number to store
  30723. */
  30724. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30725. /**
  30726. * Set the value of an uniform to an array of number (stored as vec2)
  30727. * @param uniform defines the webGL uniform location where to store the value
  30728. * @param array defines the array of number to store
  30729. */
  30730. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30731. /**
  30732. * Set the value of an uniform to an array of number (stored as vec3)
  30733. * @param uniform defines the webGL uniform location where to store the value
  30734. * @param array defines the array of number to store
  30735. */
  30736. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30737. /**
  30738. * Set the value of an uniform to an array of number (stored as vec4)
  30739. * @param uniform defines the webGL uniform location where to store the value
  30740. * @param array defines the array of number to store
  30741. */
  30742. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30743. /**
  30744. * Set the value of an uniform to an array of float32 (stored as matrices)
  30745. * @param uniform defines the webGL uniform location where to store the value
  30746. * @param matrices defines the array of float32 to store
  30747. */
  30748. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30749. /**
  30750. * Set the value of an uniform to a matrix (3x3)
  30751. * @param uniform defines the webGL uniform location where to store the value
  30752. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30753. */
  30754. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30755. /**
  30756. * Set the value of an uniform to a matrix (2x2)
  30757. * @param uniform defines the webGL uniform location where to store the value
  30758. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30759. */
  30760. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30761. /**
  30762. * Set the value of an uniform to a number (int)
  30763. * @param uniform defines the webGL uniform location where to store the value
  30764. * @param value defines the int number to store
  30765. */
  30766. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30767. /**
  30768. * Set the value of an uniform to a number (float)
  30769. * @param uniform defines the webGL uniform location where to store the value
  30770. * @param value defines the float number to store
  30771. */
  30772. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30773. /**
  30774. * Set the value of an uniform to a vec2
  30775. * @param uniform defines the webGL uniform location where to store the value
  30776. * @param x defines the 1st component of the value
  30777. * @param y defines the 2nd component of the value
  30778. */
  30779. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30780. /**
  30781. * Set the value of an uniform to a vec3
  30782. * @param uniform defines the webGL uniform location where to store the value
  30783. * @param x defines the 1st component of the value
  30784. * @param y defines the 2nd component of the value
  30785. * @param z defines the 3rd component of the value
  30786. */
  30787. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30788. /**
  30789. * Set the value of an uniform to a boolean
  30790. * @param uniform defines the webGL uniform location where to store the value
  30791. * @param bool defines the boolean to store
  30792. */
  30793. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30794. /**
  30795. * Set the value of an uniform to a vec4
  30796. * @param uniform defines the webGL uniform location where to store the value
  30797. * @param x defines the 1st component of the value
  30798. * @param y defines the 2nd component of the value
  30799. * @param z defines the 3rd component of the value
  30800. * @param w defines the 4th component of the value
  30801. */
  30802. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30803. /**
  30804. * Sets a Color4 on a uniform variable
  30805. * @param uniform defines the uniform location
  30806. * @param color4 defines the value to be set
  30807. */
  30808. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30809. /**
  30810. * Gets the depth culling state manager
  30811. */
  30812. readonly depthCullingState: DepthCullingState;
  30813. /**
  30814. * Gets the alpha state manager
  30815. */
  30816. readonly alphaState: AlphaState;
  30817. /**
  30818. * Gets the stencil state manager
  30819. */
  30820. readonly stencilState: StencilState;
  30821. /**
  30822. * Clears the list of texture accessible through engine.
  30823. * This can help preventing texture load conflict due to name collision.
  30824. */
  30825. clearInternalTexturesCache(): void;
  30826. /**
  30827. * Force the entire cache to be cleared
  30828. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30829. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30830. */
  30831. wipeCaches(bruteForce?: boolean): void;
  30832. /** @hidden */
  30833. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30834. min: number;
  30835. mag: number;
  30836. };
  30837. /** @hidden */
  30838. _createTexture(): WebGLTexture;
  30839. /**
  30840. * Usually called from Texture.ts.
  30841. * Passed information to create a WebGLTexture
  30842. * @param urlArg defines a value which contains one of the following:
  30843. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30844. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30845. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30846. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30847. * @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)
  30848. * @param scene needed for loading to the correct scene
  30849. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30850. * @param onLoad optional callback to be called upon successful completion
  30851. * @param onError optional callback to be called upon failure
  30852. * @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
  30853. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30854. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30855. * @param forcedExtension defines the extension to use to pick the right loader
  30856. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30857. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30858. */
  30859. 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;
  30860. /**
  30861. * @hidden
  30862. */
  30863. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30864. /**
  30865. * Creates a raw texture
  30866. * @param data defines the data to store in the texture
  30867. * @param width defines the width of the texture
  30868. * @param height defines the height of the texture
  30869. * @param format defines the format of the data
  30870. * @param generateMipMaps defines if the engine should generate the mip levels
  30871. * @param invertY defines if data must be stored with Y axis inverted
  30872. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30873. * @param compression defines the compression used (null by default)
  30874. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30875. * @returns the raw texture inside an InternalTexture
  30876. */
  30877. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30878. /**
  30879. * Creates a new raw cube texture
  30880. * @param data defines the array of data to use to create each face
  30881. * @param size defines the size of the textures
  30882. * @param format defines the format of the data
  30883. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30884. * @param generateMipMaps defines if the engine should generate the mip levels
  30885. * @param invertY defines if data must be stored with Y axis inverted
  30886. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30887. * @param compression defines the compression used (null by default)
  30888. * @returns the cube texture as an InternalTexture
  30889. */
  30890. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30891. /**
  30892. * Creates a new raw 3D texture
  30893. * @param data defines the data used to create the texture
  30894. * @param width defines the width of the texture
  30895. * @param height defines the height of the texture
  30896. * @param depth defines the depth of the texture
  30897. * @param format defines the format of the texture
  30898. * @param generateMipMaps defines if the engine must generate mip levels
  30899. * @param invertY defines if data must be stored with Y axis inverted
  30900. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30901. * @param compression defines the compressed used (can be null)
  30902. * @param textureType defines the compressed used (can be null)
  30903. * @returns a new raw 3D texture (stored in an InternalTexture)
  30904. */
  30905. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30906. private _unpackFlipYCached;
  30907. /**
  30908. * In case you are sharing the context with other applications, it might
  30909. * be interested to not cache the unpack flip y state to ensure a consistent
  30910. * value would be set.
  30911. */
  30912. enableUnpackFlipYCached: boolean;
  30913. /** @hidden */
  30914. _unpackFlipY(value: boolean): void;
  30915. /** @hidden */
  30916. _getUnpackAlignement(): number;
  30917. /**
  30918. * Update the sampling mode of a given texture
  30919. * @param samplingMode defines the required sampling mode
  30920. * @param texture defines the texture to update
  30921. */
  30922. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30923. /**
  30924. * Updates a depth texture Comparison Mode and Function.
  30925. * If the comparison Function is equal to 0, the mode will be set to none.
  30926. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30927. * @param texture The texture to set the comparison function for
  30928. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30929. */
  30930. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30931. /** @hidden */
  30932. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30933. width: number;
  30934. height: number;
  30935. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30936. /**
  30937. * Creates a depth stencil texture.
  30938. * This is only available in WebGL 2 or with the depth texture extension available.
  30939. * @param size The size of face edge in the texture.
  30940. * @param options The options defining the texture.
  30941. * @returns The texture
  30942. */
  30943. createDepthStencilTexture(size: number | {
  30944. width: number;
  30945. height: number;
  30946. }, options: DepthTextureCreationOptions): InternalTexture;
  30947. /**
  30948. * Creates a depth stencil texture.
  30949. * This is only available in WebGL 2 or with the depth texture extension available.
  30950. * @param size The size of face edge in the texture.
  30951. * @param options The options defining the texture.
  30952. * @returns The texture
  30953. */
  30954. private _createDepthStencilTexture;
  30955. /** @hidden */
  30956. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30957. /** @hidden */
  30958. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30959. /** @hidden */
  30960. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30961. /** @hidden */
  30962. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30963. /**
  30964. * @hidden
  30965. */
  30966. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30967. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30968. private _prepareWebGLTexture;
  30969. /** @hidden */
  30970. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30971. /** @hidden */
  30972. _releaseFramebufferObjects(texture: InternalTexture): void;
  30973. /** @hidden */
  30974. _releaseTexture(texture: InternalTexture): void;
  30975. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30976. protected _setProgram(program: WebGLProgram): void;
  30977. protected _boundUniforms: {
  30978. [key: number]: WebGLUniformLocation;
  30979. };
  30980. /**
  30981. * Binds an effect to the webGL context
  30982. * @param effect defines the effect to bind
  30983. */
  30984. bindSamplers(effect: Effect): void;
  30985. private _activateCurrentTexture;
  30986. /** @hidden */
  30987. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30988. /** @hidden */
  30989. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30990. /**
  30991. * Unbind all textures from the webGL context
  30992. */
  30993. unbindAllTextures(): void;
  30994. /**
  30995. * Sets a texture to the according uniform.
  30996. * @param channel The texture channel
  30997. * @param uniform The uniform to set
  30998. * @param texture The texture to apply
  30999. */
  31000. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31001. private _bindSamplerUniformToChannel;
  31002. private _getTextureWrapMode;
  31003. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31004. /**
  31005. * Sets an array of texture to the webGL context
  31006. * @param channel defines the channel where the texture array must be set
  31007. * @param uniform defines the associated uniform location
  31008. * @param textures defines the array of textures to bind
  31009. */
  31010. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31011. /** @hidden */
  31012. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31013. private _setTextureParameterFloat;
  31014. private _setTextureParameterInteger;
  31015. /**
  31016. * Unbind all vertex attributes from the webGL context
  31017. */
  31018. unbindAllAttributes(): void;
  31019. /**
  31020. * 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
  31021. */
  31022. releaseEffects(): void;
  31023. /**
  31024. * Dispose and release all associated resources
  31025. */
  31026. dispose(): void;
  31027. /**
  31028. * Attach a new callback raised when context lost event is fired
  31029. * @param callback defines the callback to call
  31030. */
  31031. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31032. /**
  31033. * Attach a new callback raised when context restored event is fired
  31034. * @param callback defines the callback to call
  31035. */
  31036. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31037. /**
  31038. * Get the current error code of the webGL context
  31039. * @returns the error code
  31040. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31041. */
  31042. getError(): number;
  31043. private _canRenderToFloatFramebuffer;
  31044. private _canRenderToHalfFloatFramebuffer;
  31045. private _canRenderToFramebuffer;
  31046. /** @hidden */
  31047. _getWebGLTextureType(type: number): number;
  31048. /** @hidden */
  31049. _getInternalFormat(format: number): number;
  31050. /** @hidden */
  31051. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31052. /** @hidden */
  31053. _getRGBAMultiSampleBufferFormat(type: number): number;
  31054. /** @hidden */
  31055. _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;
  31056. /**
  31057. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31058. * @returns true if the engine can be created
  31059. * @ignorenaming
  31060. */
  31061. static isSupported(): boolean;
  31062. /**
  31063. * Find the next highest power of two.
  31064. * @param x Number to start search from.
  31065. * @return Next highest power of two.
  31066. */
  31067. static CeilingPOT(x: number): number;
  31068. /**
  31069. * Find the next lowest power of two.
  31070. * @param x Number to start search from.
  31071. * @return Next lowest power of two.
  31072. */
  31073. static FloorPOT(x: number): number;
  31074. /**
  31075. * Find the nearest power of two.
  31076. * @param x Number to start search from.
  31077. * @return Next nearest power of two.
  31078. */
  31079. static NearestPOT(x: number): number;
  31080. /**
  31081. * Get the closest exponent of two
  31082. * @param value defines the value to approximate
  31083. * @param max defines the maximum value to return
  31084. * @param mode defines how to define the closest value
  31085. * @returns closest exponent of two of the given value
  31086. */
  31087. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31088. /**
  31089. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31090. * @param func - the function to be called
  31091. * @param requester - the object that will request the next frame. Falls back to window.
  31092. * @returns frame number
  31093. */
  31094. static QueueNewFrame(func: () => void, requester?: any): number;
  31095. }
  31096. }
  31097. declare module "babylonjs/Materials/Textures/internalTexture" {
  31098. import { Observable } from "babylonjs/Misc/observable";
  31099. import { Nullable, int } from "babylonjs/types";
  31100. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31101. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31102. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31103. /**
  31104. * Defines the source of the internal texture
  31105. */
  31106. export enum InternalTextureSource {
  31107. /**
  31108. * The source of the texture data is unknown
  31109. */
  31110. Unknown = 0,
  31111. /**
  31112. * Texture data comes from an URL
  31113. */
  31114. Url = 1,
  31115. /**
  31116. * Texture data is only used for temporary storage
  31117. */
  31118. Temp = 2,
  31119. /**
  31120. * Texture data comes from raw data (ArrayBuffer)
  31121. */
  31122. Raw = 3,
  31123. /**
  31124. * Texture content is dynamic (video or dynamic texture)
  31125. */
  31126. Dynamic = 4,
  31127. /**
  31128. * Texture content is generated by rendering to it
  31129. */
  31130. RenderTarget = 5,
  31131. /**
  31132. * Texture content is part of a multi render target process
  31133. */
  31134. MultiRenderTarget = 6,
  31135. /**
  31136. * Texture data comes from a cube data file
  31137. */
  31138. Cube = 7,
  31139. /**
  31140. * Texture data comes from a raw cube data
  31141. */
  31142. CubeRaw = 8,
  31143. /**
  31144. * Texture data come from a prefiltered cube data file
  31145. */
  31146. CubePrefiltered = 9,
  31147. /**
  31148. * Texture content is raw 3D data
  31149. */
  31150. Raw3D = 10,
  31151. /**
  31152. * Texture content is a depth texture
  31153. */
  31154. Depth = 11,
  31155. /**
  31156. * Texture data comes from a raw cube data encoded with RGBD
  31157. */
  31158. CubeRawRGBD = 12
  31159. }
  31160. /**
  31161. * Class used to store data associated with WebGL texture data for the engine
  31162. * This class should not be used directly
  31163. */
  31164. export class InternalTexture {
  31165. /** @hidden */
  31166. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31167. /**
  31168. * Defines if the texture is ready
  31169. */
  31170. isReady: boolean;
  31171. /**
  31172. * Defines if the texture is a cube texture
  31173. */
  31174. isCube: boolean;
  31175. /**
  31176. * Defines if the texture contains 3D data
  31177. */
  31178. is3D: boolean;
  31179. /**
  31180. * Defines if the texture contains multiview data
  31181. */
  31182. isMultiview: boolean;
  31183. /**
  31184. * Gets the URL used to load this texture
  31185. */
  31186. url: string;
  31187. /**
  31188. * Gets the sampling mode of the texture
  31189. */
  31190. samplingMode: number;
  31191. /**
  31192. * Gets a boolean indicating if the texture needs mipmaps generation
  31193. */
  31194. generateMipMaps: boolean;
  31195. /**
  31196. * Gets the number of samples used by the texture (WebGL2+ only)
  31197. */
  31198. samples: number;
  31199. /**
  31200. * Gets the type of the texture (int, float...)
  31201. */
  31202. type: number;
  31203. /**
  31204. * Gets the format of the texture (RGB, RGBA...)
  31205. */
  31206. format: number;
  31207. /**
  31208. * Observable called when the texture is loaded
  31209. */
  31210. onLoadedObservable: Observable<InternalTexture>;
  31211. /**
  31212. * Gets the width of the texture
  31213. */
  31214. width: number;
  31215. /**
  31216. * Gets the height of the texture
  31217. */
  31218. height: number;
  31219. /**
  31220. * Gets the depth of the texture
  31221. */
  31222. depth: number;
  31223. /**
  31224. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31225. */
  31226. baseWidth: number;
  31227. /**
  31228. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31229. */
  31230. baseHeight: number;
  31231. /**
  31232. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31233. */
  31234. baseDepth: number;
  31235. /**
  31236. * Gets a boolean indicating if the texture is inverted on Y axis
  31237. */
  31238. invertY: boolean;
  31239. /** @hidden */
  31240. _invertVScale: boolean;
  31241. /** @hidden */
  31242. _associatedChannel: number;
  31243. /** @hidden */
  31244. _source: InternalTextureSource;
  31245. /** @hidden */
  31246. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31247. /** @hidden */
  31248. _bufferView: Nullable<ArrayBufferView>;
  31249. /** @hidden */
  31250. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31251. /** @hidden */
  31252. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31253. /** @hidden */
  31254. _size: number;
  31255. /** @hidden */
  31256. _extension: string;
  31257. /** @hidden */
  31258. _files: Nullable<string[]>;
  31259. /** @hidden */
  31260. _workingCanvas: Nullable<HTMLCanvasElement>;
  31261. /** @hidden */
  31262. _workingContext: Nullable<CanvasRenderingContext2D>;
  31263. /** @hidden */
  31264. _framebuffer: Nullable<WebGLFramebuffer>;
  31265. /** @hidden */
  31266. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31267. /** @hidden */
  31268. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31269. /** @hidden */
  31270. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31271. /** @hidden */
  31272. _attachments: Nullable<number[]>;
  31273. /** @hidden */
  31274. _cachedCoordinatesMode: Nullable<number>;
  31275. /** @hidden */
  31276. _cachedWrapU: Nullable<number>;
  31277. /** @hidden */
  31278. _cachedWrapV: Nullable<number>;
  31279. /** @hidden */
  31280. _cachedWrapR: Nullable<number>;
  31281. /** @hidden */
  31282. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31283. /** @hidden */
  31284. _isDisabled: boolean;
  31285. /** @hidden */
  31286. _compression: Nullable<string>;
  31287. /** @hidden */
  31288. _generateStencilBuffer: boolean;
  31289. /** @hidden */
  31290. _generateDepthBuffer: boolean;
  31291. /** @hidden */
  31292. _comparisonFunction: number;
  31293. /** @hidden */
  31294. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31295. /** @hidden */
  31296. _lodGenerationScale: number;
  31297. /** @hidden */
  31298. _lodGenerationOffset: number;
  31299. /** @hidden */
  31300. _colorTextureArray: Nullable<WebGLTexture>;
  31301. /** @hidden */
  31302. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31303. /** @hidden */
  31304. _lodTextureHigh: Nullable<BaseTexture>;
  31305. /** @hidden */
  31306. _lodTextureMid: Nullable<BaseTexture>;
  31307. /** @hidden */
  31308. _lodTextureLow: Nullable<BaseTexture>;
  31309. /** @hidden */
  31310. _isRGBD: boolean;
  31311. /** @hidden */
  31312. _linearSpecularLOD: boolean;
  31313. /** @hidden */
  31314. _irradianceTexture: Nullable<BaseTexture>;
  31315. /** @hidden */
  31316. _webGLTexture: Nullable<WebGLTexture>;
  31317. /** @hidden */
  31318. _references: number;
  31319. private _engine;
  31320. /**
  31321. * Gets the Engine the texture belongs to.
  31322. * @returns The babylon engine
  31323. */
  31324. getEngine(): ThinEngine;
  31325. /**
  31326. * Gets the data source type of the texture
  31327. */
  31328. readonly source: InternalTextureSource;
  31329. /**
  31330. * Creates a new InternalTexture
  31331. * @param engine defines the engine to use
  31332. * @param source defines the type of data that will be used
  31333. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31334. */
  31335. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31336. /**
  31337. * Increments the number of references (ie. the number of Texture that point to it)
  31338. */
  31339. incrementReferences(): void;
  31340. /**
  31341. * Change the size of the texture (not the size of the content)
  31342. * @param width defines the new width
  31343. * @param height defines the new height
  31344. * @param depth defines the new depth (1 by default)
  31345. */
  31346. updateSize(width: int, height: int, depth?: int): void;
  31347. /** @hidden */
  31348. _rebuild(): void;
  31349. /** @hidden */
  31350. _swapAndDie(target: InternalTexture): void;
  31351. /**
  31352. * Dispose the current allocated resources
  31353. */
  31354. dispose(): void;
  31355. }
  31356. }
  31357. declare module "babylonjs/Audio/analyser" {
  31358. import { Scene } from "babylonjs/scene";
  31359. /**
  31360. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31362. */
  31363. export class Analyser {
  31364. /**
  31365. * Gets or sets the smoothing
  31366. * @ignorenaming
  31367. */
  31368. SMOOTHING: number;
  31369. /**
  31370. * Gets or sets the FFT table size
  31371. * @ignorenaming
  31372. */
  31373. FFT_SIZE: number;
  31374. /**
  31375. * Gets or sets the bar graph amplitude
  31376. * @ignorenaming
  31377. */
  31378. BARGRAPHAMPLITUDE: number;
  31379. /**
  31380. * Gets or sets the position of the debug canvas
  31381. * @ignorenaming
  31382. */
  31383. DEBUGCANVASPOS: {
  31384. x: number;
  31385. y: number;
  31386. };
  31387. /**
  31388. * Gets or sets the debug canvas size
  31389. * @ignorenaming
  31390. */
  31391. DEBUGCANVASSIZE: {
  31392. width: number;
  31393. height: number;
  31394. };
  31395. private _byteFreqs;
  31396. private _byteTime;
  31397. private _floatFreqs;
  31398. private _webAudioAnalyser;
  31399. private _debugCanvas;
  31400. private _debugCanvasContext;
  31401. private _scene;
  31402. private _registerFunc;
  31403. private _audioEngine;
  31404. /**
  31405. * Creates a new analyser
  31406. * @param scene defines hosting scene
  31407. */
  31408. constructor(scene: Scene);
  31409. /**
  31410. * Get the number of data values you will have to play with for the visualization
  31411. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31412. * @returns a number
  31413. */
  31414. getFrequencyBinCount(): number;
  31415. /**
  31416. * Gets the current frequency data as a byte array
  31417. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31418. * @returns a Uint8Array
  31419. */
  31420. getByteFrequencyData(): Uint8Array;
  31421. /**
  31422. * Gets the current waveform as a byte array
  31423. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31424. * @returns a Uint8Array
  31425. */
  31426. getByteTimeDomainData(): Uint8Array;
  31427. /**
  31428. * Gets the current frequency data as a float array
  31429. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31430. * @returns a Float32Array
  31431. */
  31432. getFloatFrequencyData(): Float32Array;
  31433. /**
  31434. * Renders the debug canvas
  31435. */
  31436. drawDebugCanvas(): void;
  31437. /**
  31438. * Stops rendering the debug canvas and removes it
  31439. */
  31440. stopDebugCanvas(): void;
  31441. /**
  31442. * Connects two audio nodes
  31443. * @param inputAudioNode defines first node to connect
  31444. * @param outputAudioNode defines second node to connect
  31445. */
  31446. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31447. /**
  31448. * Releases all associated resources
  31449. */
  31450. dispose(): void;
  31451. }
  31452. }
  31453. declare module "babylonjs/Audio/audioEngine" {
  31454. import { IDisposable } from "babylonjs/scene";
  31455. import { Analyser } from "babylonjs/Audio/analyser";
  31456. import { Nullable } from "babylonjs/types";
  31457. import { Observable } from "babylonjs/Misc/observable";
  31458. /**
  31459. * This represents an audio engine and it is responsible
  31460. * to play, synchronize and analyse sounds throughout the application.
  31461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31462. */
  31463. export interface IAudioEngine extends IDisposable {
  31464. /**
  31465. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31466. */
  31467. readonly canUseWebAudio: boolean;
  31468. /**
  31469. * Gets the current AudioContext if available.
  31470. */
  31471. readonly audioContext: Nullable<AudioContext>;
  31472. /**
  31473. * The master gain node defines the global audio volume of your audio engine.
  31474. */
  31475. readonly masterGain: GainNode;
  31476. /**
  31477. * Gets whether or not mp3 are supported by your browser.
  31478. */
  31479. readonly isMP3supported: boolean;
  31480. /**
  31481. * Gets whether or not ogg are supported by your browser.
  31482. */
  31483. readonly isOGGsupported: boolean;
  31484. /**
  31485. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31486. * @ignoreNaming
  31487. */
  31488. WarnedWebAudioUnsupported: boolean;
  31489. /**
  31490. * Defines if the audio engine relies on a custom unlocked button.
  31491. * In this case, the embedded button will not be displayed.
  31492. */
  31493. useCustomUnlockedButton: boolean;
  31494. /**
  31495. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31496. */
  31497. readonly unlocked: boolean;
  31498. /**
  31499. * Event raised when audio has been unlocked on the browser.
  31500. */
  31501. onAudioUnlockedObservable: Observable<AudioEngine>;
  31502. /**
  31503. * Event raised when audio has been locked on the browser.
  31504. */
  31505. onAudioLockedObservable: Observable<AudioEngine>;
  31506. /**
  31507. * Flags the audio engine in Locked state.
  31508. * This happens due to new browser policies preventing audio to autoplay.
  31509. */
  31510. lock(): void;
  31511. /**
  31512. * Unlocks the audio engine once a user action has been done on the dom.
  31513. * This is helpful to resume play once browser policies have been satisfied.
  31514. */
  31515. unlock(): void;
  31516. }
  31517. /**
  31518. * This represents the default audio engine used in babylon.
  31519. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31521. */
  31522. export class AudioEngine implements IAudioEngine {
  31523. private _audioContext;
  31524. private _audioContextInitialized;
  31525. private _muteButton;
  31526. private _hostElement;
  31527. /**
  31528. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31529. */
  31530. canUseWebAudio: boolean;
  31531. /**
  31532. * The master gain node defines the global audio volume of your audio engine.
  31533. */
  31534. masterGain: GainNode;
  31535. /**
  31536. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31537. * @ignoreNaming
  31538. */
  31539. WarnedWebAudioUnsupported: boolean;
  31540. /**
  31541. * Gets whether or not mp3 are supported by your browser.
  31542. */
  31543. isMP3supported: boolean;
  31544. /**
  31545. * Gets whether or not ogg are supported by your browser.
  31546. */
  31547. isOGGsupported: boolean;
  31548. /**
  31549. * Gets whether audio has been unlocked on the device.
  31550. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31551. * a user interaction has happened.
  31552. */
  31553. unlocked: boolean;
  31554. /**
  31555. * Defines if the audio engine relies on a custom unlocked button.
  31556. * In this case, the embedded button will not be displayed.
  31557. */
  31558. useCustomUnlockedButton: boolean;
  31559. /**
  31560. * Event raised when audio has been unlocked on the browser.
  31561. */
  31562. onAudioUnlockedObservable: Observable<AudioEngine>;
  31563. /**
  31564. * Event raised when audio has been locked on the browser.
  31565. */
  31566. onAudioLockedObservable: Observable<AudioEngine>;
  31567. /**
  31568. * Gets the current AudioContext if available.
  31569. */
  31570. readonly audioContext: Nullable<AudioContext>;
  31571. private _connectedAnalyser;
  31572. /**
  31573. * Instantiates a new audio engine.
  31574. *
  31575. * There should be only one per page as some browsers restrict the number
  31576. * of audio contexts you can create.
  31577. * @param hostElement defines the host element where to display the mute icon if necessary
  31578. */
  31579. constructor(hostElement?: Nullable<HTMLElement>);
  31580. /**
  31581. * Flags the audio engine in Locked state.
  31582. * This happens due to new browser policies preventing audio to autoplay.
  31583. */
  31584. lock(): void;
  31585. /**
  31586. * Unlocks the audio engine once a user action has been done on the dom.
  31587. * This is helpful to resume play once browser policies have been satisfied.
  31588. */
  31589. unlock(): void;
  31590. private _resumeAudioContext;
  31591. private _initializeAudioContext;
  31592. private _tryToRun;
  31593. private _triggerRunningState;
  31594. private _triggerSuspendedState;
  31595. private _displayMuteButton;
  31596. private _moveButtonToTopLeft;
  31597. private _onResize;
  31598. private _hideMuteButton;
  31599. /**
  31600. * Destroy and release the resources associated with the audio ccontext.
  31601. */
  31602. dispose(): void;
  31603. /**
  31604. * Gets the global volume sets on the master gain.
  31605. * @returns the global volume if set or -1 otherwise
  31606. */
  31607. getGlobalVolume(): number;
  31608. /**
  31609. * Sets the global volume of your experience (sets on the master gain).
  31610. * @param newVolume Defines the new global volume of the application
  31611. */
  31612. setGlobalVolume(newVolume: number): void;
  31613. /**
  31614. * Connect the audio engine to an audio analyser allowing some amazing
  31615. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31617. * @param analyser The analyser to connect to the engine
  31618. */
  31619. connectToAnalyser(analyser: Analyser): void;
  31620. }
  31621. }
  31622. declare module "babylonjs/Loading/loadingScreen" {
  31623. /**
  31624. * Interface used to present a loading screen while loading a scene
  31625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31626. */
  31627. export interface ILoadingScreen {
  31628. /**
  31629. * Function called to display the loading screen
  31630. */
  31631. displayLoadingUI: () => void;
  31632. /**
  31633. * Function called to hide the loading screen
  31634. */
  31635. hideLoadingUI: () => void;
  31636. /**
  31637. * Gets or sets the color to use for the background
  31638. */
  31639. loadingUIBackgroundColor: string;
  31640. /**
  31641. * Gets or sets the text to display while loading
  31642. */
  31643. loadingUIText: string;
  31644. }
  31645. /**
  31646. * Class used for the default loading screen
  31647. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31648. */
  31649. export class DefaultLoadingScreen implements ILoadingScreen {
  31650. private _renderingCanvas;
  31651. private _loadingText;
  31652. private _loadingDivBackgroundColor;
  31653. private _loadingDiv;
  31654. private _loadingTextDiv;
  31655. /** Gets or sets the logo url to use for the default loading screen */
  31656. static DefaultLogoUrl: string;
  31657. /** Gets or sets the spinner url to use for the default loading screen */
  31658. static DefaultSpinnerUrl: string;
  31659. /**
  31660. * Creates a new default loading screen
  31661. * @param _renderingCanvas defines the canvas used to render the scene
  31662. * @param _loadingText defines the default text to display
  31663. * @param _loadingDivBackgroundColor defines the default background color
  31664. */
  31665. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31666. /**
  31667. * Function called to display the loading screen
  31668. */
  31669. displayLoadingUI(): void;
  31670. /**
  31671. * Function called to hide the loading screen
  31672. */
  31673. hideLoadingUI(): void;
  31674. /**
  31675. * Gets or sets the text to display while loading
  31676. */
  31677. loadingUIText: string;
  31678. /**
  31679. * Gets or sets the color to use for the background
  31680. */
  31681. loadingUIBackgroundColor: string;
  31682. private _resizeLoadingUI;
  31683. }
  31684. }
  31685. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31686. /**
  31687. * Interface for any object that can request an animation frame
  31688. */
  31689. export interface ICustomAnimationFrameRequester {
  31690. /**
  31691. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31692. */
  31693. renderFunction?: Function;
  31694. /**
  31695. * Called to request the next frame to render to
  31696. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31697. */
  31698. requestAnimationFrame: Function;
  31699. /**
  31700. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31701. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31702. */
  31703. requestID?: number;
  31704. }
  31705. }
  31706. declare module "babylonjs/Misc/performanceMonitor" {
  31707. /**
  31708. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31709. */
  31710. export class PerformanceMonitor {
  31711. private _enabled;
  31712. private _rollingFrameTime;
  31713. private _lastFrameTimeMs;
  31714. /**
  31715. * constructor
  31716. * @param frameSampleSize The number of samples required to saturate the sliding window
  31717. */
  31718. constructor(frameSampleSize?: number);
  31719. /**
  31720. * Samples current frame
  31721. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31722. */
  31723. sampleFrame(timeMs?: number): void;
  31724. /**
  31725. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31726. */
  31727. readonly averageFrameTime: number;
  31728. /**
  31729. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31730. */
  31731. readonly averageFrameTimeVariance: number;
  31732. /**
  31733. * Returns the frame time of the most recent frame
  31734. */
  31735. readonly instantaneousFrameTime: number;
  31736. /**
  31737. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31738. */
  31739. readonly averageFPS: number;
  31740. /**
  31741. * Returns the average framerate in frames per second using the most recent frame time
  31742. */
  31743. readonly instantaneousFPS: number;
  31744. /**
  31745. * Returns true if enough samples have been taken to completely fill the sliding window
  31746. */
  31747. readonly isSaturated: boolean;
  31748. /**
  31749. * Enables contributions to the sliding window sample set
  31750. */
  31751. enable(): void;
  31752. /**
  31753. * Disables contributions to the sliding window sample set
  31754. * Samples will not be interpolated over the disabled period
  31755. */
  31756. disable(): void;
  31757. /**
  31758. * Returns true if sampling is enabled
  31759. */
  31760. readonly isEnabled: boolean;
  31761. /**
  31762. * Resets performance monitor
  31763. */
  31764. reset(): void;
  31765. }
  31766. /**
  31767. * RollingAverage
  31768. *
  31769. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31770. */
  31771. export class RollingAverage {
  31772. /**
  31773. * Current average
  31774. */
  31775. average: number;
  31776. /**
  31777. * Current variance
  31778. */
  31779. variance: number;
  31780. protected _samples: Array<number>;
  31781. protected _sampleCount: number;
  31782. protected _pos: number;
  31783. protected _m2: number;
  31784. /**
  31785. * constructor
  31786. * @param length The number of samples required to saturate the sliding window
  31787. */
  31788. constructor(length: number);
  31789. /**
  31790. * Adds a sample to the sample set
  31791. * @param v The sample value
  31792. */
  31793. add(v: number): void;
  31794. /**
  31795. * Returns previously added values or null if outside of history or outside the sliding window domain
  31796. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31797. * @return Value previously recorded with add() or null if outside of range
  31798. */
  31799. history(i: number): number;
  31800. /**
  31801. * Returns true if enough samples have been taken to completely fill the sliding window
  31802. * @return true if sample-set saturated
  31803. */
  31804. isSaturated(): boolean;
  31805. /**
  31806. * Resets the rolling average (equivalent to 0 samples taken so far)
  31807. */
  31808. reset(): void;
  31809. /**
  31810. * Wraps a value around the sample range boundaries
  31811. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31812. * @return Wrapped position in sample range
  31813. */
  31814. protected _wrapPosition(i: number): number;
  31815. }
  31816. }
  31817. declare module "babylonjs/Misc/perfCounter" {
  31818. /**
  31819. * This class is used to track a performance counter which is number based.
  31820. * The user has access to many properties which give statistics of different nature.
  31821. *
  31822. * The implementer can track two kinds of Performance Counter: time and count.
  31823. * 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.
  31824. * 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.
  31825. */
  31826. export class PerfCounter {
  31827. /**
  31828. * Gets or sets a global boolean to turn on and off all the counters
  31829. */
  31830. static Enabled: boolean;
  31831. /**
  31832. * Returns the smallest value ever
  31833. */
  31834. readonly min: number;
  31835. /**
  31836. * Returns the biggest value ever
  31837. */
  31838. readonly max: number;
  31839. /**
  31840. * Returns the average value since the performance counter is running
  31841. */
  31842. readonly average: number;
  31843. /**
  31844. * Returns the average value of the last second the counter was monitored
  31845. */
  31846. readonly lastSecAverage: number;
  31847. /**
  31848. * Returns the current value
  31849. */
  31850. readonly current: number;
  31851. /**
  31852. * Gets the accumulated total
  31853. */
  31854. readonly total: number;
  31855. /**
  31856. * Gets the total value count
  31857. */
  31858. readonly count: number;
  31859. /**
  31860. * Creates a new counter
  31861. */
  31862. constructor();
  31863. /**
  31864. * Call this method to start monitoring a new frame.
  31865. * 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.
  31866. */
  31867. fetchNewFrame(): void;
  31868. /**
  31869. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31870. * @param newCount the count value to add to the monitored count
  31871. * @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.
  31872. */
  31873. addCount(newCount: number, fetchResult: boolean): void;
  31874. /**
  31875. * Start monitoring this performance counter
  31876. */
  31877. beginMonitoring(): void;
  31878. /**
  31879. * Compute the time lapsed since the previous beginMonitoring() call.
  31880. * @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
  31881. */
  31882. endMonitoring(newFrame?: boolean): void;
  31883. private _fetchResult;
  31884. private _startMonitoringTime;
  31885. private _min;
  31886. private _max;
  31887. private _average;
  31888. private _current;
  31889. private _totalValueCount;
  31890. private _totalAccumulated;
  31891. private _lastSecAverage;
  31892. private _lastSecAccumulated;
  31893. private _lastSecTime;
  31894. private _lastSecValueCount;
  31895. }
  31896. }
  31897. declare module "babylonjs/Engines/engine" {
  31898. import { Observable } from "babylonjs/Misc/observable";
  31899. import { Nullable, IndicesArray } from "babylonjs/types";
  31900. import { Scene } from "babylonjs/scene";
  31901. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31902. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31903. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31904. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31905. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31906. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31907. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31908. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31909. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31910. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31911. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31913. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31914. import { Material } from "babylonjs/Materials/material";
  31915. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31916. /**
  31917. * Defines the interface used by display changed events
  31918. */
  31919. export interface IDisplayChangedEventArgs {
  31920. /** Gets the vrDisplay object (if any) */
  31921. vrDisplay: Nullable<any>;
  31922. /** Gets a boolean indicating if webVR is supported */
  31923. vrSupported: boolean;
  31924. }
  31925. /**
  31926. * Defines the interface used by objects containing a viewport (like a camera)
  31927. */
  31928. interface IViewportOwnerLike {
  31929. /**
  31930. * Gets or sets the viewport
  31931. */
  31932. viewport: IViewportLike;
  31933. }
  31934. /**
  31935. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31936. */
  31937. export class Engine extends ThinEngine {
  31938. /** Defines that alpha blending is disabled */
  31939. static readonly ALPHA_DISABLE: number;
  31940. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31941. static readonly ALPHA_ADD: number;
  31942. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31943. static readonly ALPHA_COMBINE: number;
  31944. /** Defines that alpha blending to DEST - SRC * DEST */
  31945. static readonly ALPHA_SUBTRACT: number;
  31946. /** Defines that alpha blending to SRC * DEST */
  31947. static readonly ALPHA_MULTIPLY: number;
  31948. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31949. static readonly ALPHA_MAXIMIZED: number;
  31950. /** Defines that alpha blending to SRC + DEST */
  31951. static readonly ALPHA_ONEONE: number;
  31952. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31953. static readonly ALPHA_PREMULTIPLIED: number;
  31954. /**
  31955. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31956. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31957. */
  31958. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31959. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31960. static readonly ALPHA_INTERPOLATE: number;
  31961. /**
  31962. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31963. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31964. */
  31965. static readonly ALPHA_SCREENMODE: number;
  31966. /** Defines that the ressource is not delayed*/
  31967. static readonly DELAYLOADSTATE_NONE: number;
  31968. /** Defines that the ressource was successfully delay loaded */
  31969. static readonly DELAYLOADSTATE_LOADED: number;
  31970. /** Defines that the ressource is currently delay loading */
  31971. static readonly DELAYLOADSTATE_LOADING: number;
  31972. /** Defines that the ressource is delayed and has not started loading */
  31973. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31974. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31975. static readonly NEVER: number;
  31976. /** 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 */
  31977. static readonly ALWAYS: number;
  31978. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31979. static readonly LESS: number;
  31980. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31981. static readonly EQUAL: number;
  31982. /** 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 */
  31983. static readonly LEQUAL: number;
  31984. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31985. static readonly GREATER: number;
  31986. /** 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 */
  31987. static readonly GEQUAL: number;
  31988. /** 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 */
  31989. static readonly NOTEQUAL: number;
  31990. /** Passed to stencilOperation to specify that stencil value must be kept */
  31991. static readonly KEEP: number;
  31992. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31993. static readonly REPLACE: number;
  31994. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31995. static readonly INCR: number;
  31996. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31997. static readonly DECR: number;
  31998. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31999. static readonly INVERT: number;
  32000. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32001. static readonly INCR_WRAP: number;
  32002. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32003. static readonly DECR_WRAP: number;
  32004. /** Texture is not repeating outside of 0..1 UVs */
  32005. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32006. /** Texture is repeating outside of 0..1 UVs */
  32007. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32008. /** Texture is repeating and mirrored */
  32009. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32010. /** ALPHA */
  32011. static readonly TEXTUREFORMAT_ALPHA: number;
  32012. /** LUMINANCE */
  32013. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32014. /** LUMINANCE_ALPHA */
  32015. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32016. /** RGB */
  32017. static readonly TEXTUREFORMAT_RGB: number;
  32018. /** RGBA */
  32019. static readonly TEXTUREFORMAT_RGBA: number;
  32020. /** RED */
  32021. static readonly TEXTUREFORMAT_RED: number;
  32022. /** RED (2nd reference) */
  32023. static readonly TEXTUREFORMAT_R: number;
  32024. /** RG */
  32025. static readonly TEXTUREFORMAT_RG: number;
  32026. /** RED_INTEGER */
  32027. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32028. /** RED_INTEGER (2nd reference) */
  32029. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32030. /** RG_INTEGER */
  32031. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32032. /** RGB_INTEGER */
  32033. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32034. /** RGBA_INTEGER */
  32035. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32036. /** UNSIGNED_BYTE */
  32037. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32038. /** UNSIGNED_BYTE (2nd reference) */
  32039. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32040. /** FLOAT */
  32041. static readonly TEXTURETYPE_FLOAT: number;
  32042. /** HALF_FLOAT */
  32043. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32044. /** BYTE */
  32045. static readonly TEXTURETYPE_BYTE: number;
  32046. /** SHORT */
  32047. static readonly TEXTURETYPE_SHORT: number;
  32048. /** UNSIGNED_SHORT */
  32049. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32050. /** INT */
  32051. static readonly TEXTURETYPE_INT: number;
  32052. /** UNSIGNED_INT */
  32053. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32054. /** UNSIGNED_SHORT_4_4_4_4 */
  32055. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32056. /** UNSIGNED_SHORT_5_5_5_1 */
  32057. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32058. /** UNSIGNED_SHORT_5_6_5 */
  32059. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32060. /** UNSIGNED_INT_2_10_10_10_REV */
  32061. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32062. /** UNSIGNED_INT_24_8 */
  32063. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32064. /** UNSIGNED_INT_10F_11F_11F_REV */
  32065. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32066. /** UNSIGNED_INT_5_9_9_9_REV */
  32067. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32068. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32069. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32070. /** nearest is mag = nearest and min = nearest and mip = linear */
  32071. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32072. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32073. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32074. /** Trilinear is mag = linear and min = linear and mip = linear */
  32075. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32076. /** nearest is mag = nearest and min = nearest and mip = linear */
  32077. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32078. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32079. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32080. /** Trilinear is mag = linear and min = linear and mip = linear */
  32081. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32082. /** mag = nearest and min = nearest and mip = nearest */
  32083. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32084. /** mag = nearest and min = linear and mip = nearest */
  32085. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32086. /** mag = nearest and min = linear and mip = linear */
  32087. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32088. /** mag = nearest and min = linear and mip = none */
  32089. static readonly TEXTURE_NEAREST_LINEAR: number;
  32090. /** mag = nearest and min = nearest and mip = none */
  32091. static readonly TEXTURE_NEAREST_NEAREST: number;
  32092. /** mag = linear and min = nearest and mip = nearest */
  32093. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32094. /** mag = linear and min = nearest and mip = linear */
  32095. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32096. /** mag = linear and min = linear and mip = none */
  32097. static readonly TEXTURE_LINEAR_LINEAR: number;
  32098. /** mag = linear and min = nearest and mip = none */
  32099. static readonly TEXTURE_LINEAR_NEAREST: number;
  32100. /** Explicit coordinates mode */
  32101. static readonly TEXTURE_EXPLICIT_MODE: number;
  32102. /** Spherical coordinates mode */
  32103. static readonly TEXTURE_SPHERICAL_MODE: number;
  32104. /** Planar coordinates mode */
  32105. static readonly TEXTURE_PLANAR_MODE: number;
  32106. /** Cubic coordinates mode */
  32107. static readonly TEXTURE_CUBIC_MODE: number;
  32108. /** Projection coordinates mode */
  32109. static readonly TEXTURE_PROJECTION_MODE: number;
  32110. /** Skybox coordinates mode */
  32111. static readonly TEXTURE_SKYBOX_MODE: number;
  32112. /** Inverse Cubic coordinates mode */
  32113. static readonly TEXTURE_INVCUBIC_MODE: number;
  32114. /** Equirectangular coordinates mode */
  32115. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32116. /** Equirectangular Fixed coordinates mode */
  32117. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32118. /** Equirectangular Fixed Mirrored coordinates mode */
  32119. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32120. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32121. static readonly SCALEMODE_FLOOR: number;
  32122. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32123. static readonly SCALEMODE_NEAREST: number;
  32124. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32125. static readonly SCALEMODE_CEILING: number;
  32126. /**
  32127. * Returns the current npm package of the sdk
  32128. */
  32129. static readonly NpmPackage: string;
  32130. /**
  32131. * Returns the current version of the framework
  32132. */
  32133. static readonly Version: string;
  32134. /** Gets the list of created engines */
  32135. static readonly Instances: Engine[];
  32136. /**
  32137. * Gets the latest created engine
  32138. */
  32139. static readonly LastCreatedEngine: Nullable<Engine>;
  32140. /**
  32141. * Gets the latest created scene
  32142. */
  32143. static readonly LastCreatedScene: Nullable<Scene>;
  32144. /**
  32145. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32146. * @param flag defines which part of the materials must be marked as dirty
  32147. * @param predicate defines a predicate used to filter which materials should be affected
  32148. */
  32149. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32150. /**
  32151. * Method called to create the default loading screen.
  32152. * This can be overriden in your own app.
  32153. * @param canvas The rendering canvas element
  32154. * @returns The loading screen
  32155. */
  32156. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32157. /**
  32158. * Method called to create the default rescale post process on each engine.
  32159. */
  32160. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32161. /**
  32162. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32163. **/
  32164. enableOfflineSupport: boolean;
  32165. /**
  32166. * 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)
  32167. **/
  32168. disableManifestCheck: boolean;
  32169. /**
  32170. * Gets the list of created scenes
  32171. */
  32172. scenes: Scene[];
  32173. /**
  32174. * Event raised when a new scene is created
  32175. */
  32176. onNewSceneAddedObservable: Observable<Scene>;
  32177. /**
  32178. * Gets the list of created postprocesses
  32179. */
  32180. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32181. /**
  32182. * Gets a boolean indicating if the pointer is currently locked
  32183. */
  32184. isPointerLock: boolean;
  32185. /**
  32186. * Observable event triggered each time the rendering canvas is resized
  32187. */
  32188. onResizeObservable: Observable<Engine>;
  32189. /**
  32190. * Observable event triggered each time the canvas loses focus
  32191. */
  32192. onCanvasBlurObservable: Observable<Engine>;
  32193. /**
  32194. * Observable event triggered each time the canvas gains focus
  32195. */
  32196. onCanvasFocusObservable: Observable<Engine>;
  32197. /**
  32198. * Observable event triggered each time the canvas receives pointerout event
  32199. */
  32200. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32201. /**
  32202. * Observable event triggered before each texture is initialized
  32203. */
  32204. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32205. /**
  32206. * Observable raised when the engine begins a new frame
  32207. */
  32208. onBeginFrameObservable: Observable<Engine>;
  32209. /**
  32210. * If set, will be used to request the next animation frame for the render loop
  32211. */
  32212. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32213. /**
  32214. * Observable raised when the engine ends the current frame
  32215. */
  32216. onEndFrameObservable: Observable<Engine>;
  32217. /**
  32218. * Observable raised when the engine is about to compile a shader
  32219. */
  32220. onBeforeShaderCompilationObservable: Observable<Engine>;
  32221. /**
  32222. * Observable raised when the engine has jsut compiled a shader
  32223. */
  32224. onAfterShaderCompilationObservable: Observable<Engine>;
  32225. /**
  32226. * Gets the audio engine
  32227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32228. * @ignorenaming
  32229. */
  32230. static audioEngine: IAudioEngine;
  32231. /**
  32232. * Default AudioEngine factory responsible of creating the Audio Engine.
  32233. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32234. */
  32235. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32236. /**
  32237. * Default offline support factory responsible of creating a tool used to store data locally.
  32238. * By default, this will create a Database object if the workload has been embedded.
  32239. */
  32240. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32241. private _loadingScreen;
  32242. private _pointerLockRequested;
  32243. private _dummyFramebuffer;
  32244. private _rescalePostProcess;
  32245. /** @hidden */
  32246. protected _alphaMode: number;
  32247. /** @hidden */
  32248. protected _alphaEquation: number;
  32249. private _deterministicLockstep;
  32250. private _lockstepMaxSteps;
  32251. protected readonly _supportsHardwareTextureRescaling: boolean;
  32252. private _fps;
  32253. private _deltaTime;
  32254. /** @hidden */
  32255. _drawCalls: PerfCounter;
  32256. /**
  32257. * Turn this value on if you want to pause FPS computation when in background
  32258. */
  32259. disablePerformanceMonitorInBackground: boolean;
  32260. private _performanceMonitor;
  32261. /**
  32262. * Gets the performance monitor attached to this engine
  32263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32264. */
  32265. readonly performanceMonitor: PerformanceMonitor;
  32266. private _onFocus;
  32267. private _onBlur;
  32268. private _onCanvasPointerOut;
  32269. private _onCanvasBlur;
  32270. private _onCanvasFocus;
  32271. private _onFullscreenChange;
  32272. private _onPointerLockChange;
  32273. /**
  32274. * Creates a new engine
  32275. * @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
  32276. * @param antialias defines enable antialiasing (default: false)
  32277. * @param options defines further options to be sent to the getContext() function
  32278. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32279. */
  32280. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32281. /**
  32282. * Gets current aspect ratio
  32283. * @param viewportOwner defines the camera to use to get the aspect ratio
  32284. * @param useScreen defines if screen size must be used (or the current render target if any)
  32285. * @returns a number defining the aspect ratio
  32286. */
  32287. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32288. /**
  32289. * Gets current screen aspect ratio
  32290. * @returns a number defining the aspect ratio
  32291. */
  32292. getScreenAspectRatio(): number;
  32293. /**
  32294. * Gets host document
  32295. * @returns the host document object
  32296. */
  32297. getHostDocument(): Document;
  32298. /**
  32299. * Gets the client rect of the HTML canvas attached with the current webGL context
  32300. * @returns a client rectanglee
  32301. */
  32302. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32303. /**
  32304. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32306. * @returns true if engine is in deterministic lock step mode
  32307. */
  32308. isDeterministicLockStep(): boolean;
  32309. /**
  32310. * Gets the max steps when engine is running in deterministic lock step
  32311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32312. * @returns the max steps
  32313. */
  32314. getLockstepMaxSteps(): number;
  32315. /**
  32316. * Force the mipmap generation for the given render target texture
  32317. * @param texture defines the render target texture to use
  32318. */
  32319. generateMipMapsForCubemap(texture: InternalTexture): void;
  32320. /** States */
  32321. /**
  32322. * Set various states to the webGL context
  32323. * @param culling defines backface culling state
  32324. * @param zOffset defines the value to apply to zOffset (0 by default)
  32325. * @param force defines if states must be applied even if cache is up to date
  32326. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32327. */
  32328. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32329. /**
  32330. * Set the z offset to apply to current rendering
  32331. * @param value defines the offset to apply
  32332. */
  32333. setZOffset(value: number): void;
  32334. /**
  32335. * Gets the current value of the zOffset
  32336. * @returns the current zOffset state
  32337. */
  32338. getZOffset(): number;
  32339. /**
  32340. * Enable or disable depth buffering
  32341. * @param enable defines the state to set
  32342. */
  32343. setDepthBuffer(enable: boolean): void;
  32344. /**
  32345. * Gets a boolean indicating if depth writing is enabled
  32346. * @returns the current depth writing state
  32347. */
  32348. getDepthWrite(): boolean;
  32349. /**
  32350. * Enable or disable depth writing
  32351. * @param enable defines the state to set
  32352. */
  32353. setDepthWrite(enable: boolean): void;
  32354. /**
  32355. * Enable or disable color writing
  32356. * @param enable defines the state to set
  32357. */
  32358. setColorWrite(enable: boolean): void;
  32359. /**
  32360. * Gets a boolean indicating if color writing is enabled
  32361. * @returns the current color writing state
  32362. */
  32363. getColorWrite(): boolean;
  32364. /**
  32365. * Sets alpha constants used by some alpha blending modes
  32366. * @param r defines the red component
  32367. * @param g defines the green component
  32368. * @param b defines the blue component
  32369. * @param a defines the alpha component
  32370. */
  32371. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32372. /**
  32373. * Sets the current alpha mode
  32374. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32375. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32376. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32377. */
  32378. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32379. /**
  32380. * Gets the current alpha mode
  32381. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32382. * @returns the current alpha mode
  32383. */
  32384. getAlphaMode(): number;
  32385. /**
  32386. * Sets the current alpha equation
  32387. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32388. */
  32389. setAlphaEquation(equation: number): void;
  32390. /**
  32391. * Gets the current alpha equation.
  32392. * @returns the current alpha equation
  32393. */
  32394. getAlphaEquation(): number;
  32395. /**
  32396. * Gets a boolean indicating if stencil buffer is enabled
  32397. * @returns the current stencil buffer state
  32398. */
  32399. getStencilBuffer(): boolean;
  32400. /**
  32401. * Enable or disable the stencil buffer
  32402. * @param enable defines if the stencil buffer must be enabled or disabled
  32403. */
  32404. setStencilBuffer(enable: boolean): void;
  32405. /**
  32406. * Gets the current stencil mask
  32407. * @returns a number defining the new stencil mask to use
  32408. */
  32409. getStencilMask(): number;
  32410. /**
  32411. * Sets the current stencil mask
  32412. * @param mask defines the new stencil mask to use
  32413. */
  32414. setStencilMask(mask: number): void;
  32415. /**
  32416. * Gets the current stencil function
  32417. * @returns a number defining the stencil function to use
  32418. */
  32419. getStencilFunction(): number;
  32420. /**
  32421. * Gets the current stencil reference value
  32422. * @returns a number defining the stencil reference value to use
  32423. */
  32424. getStencilFunctionReference(): number;
  32425. /**
  32426. * Gets the current stencil mask
  32427. * @returns a number defining the stencil mask to use
  32428. */
  32429. getStencilFunctionMask(): number;
  32430. /**
  32431. * Sets the current stencil function
  32432. * @param stencilFunc defines the new stencil function to use
  32433. */
  32434. setStencilFunction(stencilFunc: number): void;
  32435. /**
  32436. * Sets the current stencil reference
  32437. * @param reference defines the new stencil reference to use
  32438. */
  32439. setStencilFunctionReference(reference: number): void;
  32440. /**
  32441. * Sets the current stencil mask
  32442. * @param mask defines the new stencil mask to use
  32443. */
  32444. setStencilFunctionMask(mask: number): void;
  32445. /**
  32446. * Gets the current stencil operation when stencil fails
  32447. * @returns a number defining stencil operation to use when stencil fails
  32448. */
  32449. getStencilOperationFail(): number;
  32450. /**
  32451. * Gets the current stencil operation when depth fails
  32452. * @returns a number defining stencil operation to use when depth fails
  32453. */
  32454. getStencilOperationDepthFail(): number;
  32455. /**
  32456. * Gets the current stencil operation when stencil passes
  32457. * @returns a number defining stencil operation to use when stencil passes
  32458. */
  32459. getStencilOperationPass(): number;
  32460. /**
  32461. * Sets the stencil operation to use when stencil fails
  32462. * @param operation defines the stencil operation to use when stencil fails
  32463. */
  32464. setStencilOperationFail(operation: number): void;
  32465. /**
  32466. * Sets the stencil operation to use when depth fails
  32467. * @param operation defines the stencil operation to use when depth fails
  32468. */
  32469. setStencilOperationDepthFail(operation: number): void;
  32470. /**
  32471. * Sets the stencil operation to use when stencil passes
  32472. * @param operation defines the stencil operation to use when stencil passes
  32473. */
  32474. setStencilOperationPass(operation: number): void;
  32475. /**
  32476. * Sets a boolean indicating if the dithering state is enabled or disabled
  32477. * @param value defines the dithering state
  32478. */
  32479. setDitheringState(value: boolean): void;
  32480. /**
  32481. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32482. * @param value defines the rasterizer state
  32483. */
  32484. setRasterizerState(value: boolean): void;
  32485. /**
  32486. * Gets the current depth function
  32487. * @returns a number defining the depth function
  32488. */
  32489. getDepthFunction(): Nullable<number>;
  32490. /**
  32491. * Sets the current depth function
  32492. * @param depthFunc defines the function to use
  32493. */
  32494. setDepthFunction(depthFunc: number): void;
  32495. /**
  32496. * Sets the current depth function to GREATER
  32497. */
  32498. setDepthFunctionToGreater(): void;
  32499. /**
  32500. * Sets the current depth function to GEQUAL
  32501. */
  32502. setDepthFunctionToGreaterOrEqual(): void;
  32503. /**
  32504. * Sets the current depth function to LESS
  32505. */
  32506. setDepthFunctionToLess(): void;
  32507. /**
  32508. * Sets the current depth function to LEQUAL
  32509. */
  32510. setDepthFunctionToLessOrEqual(): void;
  32511. private _cachedStencilBuffer;
  32512. private _cachedStencilFunction;
  32513. private _cachedStencilMask;
  32514. private _cachedStencilOperationPass;
  32515. private _cachedStencilOperationFail;
  32516. private _cachedStencilOperationDepthFail;
  32517. private _cachedStencilReference;
  32518. /**
  32519. * Caches the the state of the stencil buffer
  32520. */
  32521. cacheStencilState(): void;
  32522. /**
  32523. * Restores the state of the stencil buffer
  32524. */
  32525. restoreStencilState(): void;
  32526. /**
  32527. * Directly set the WebGL Viewport
  32528. * @param x defines the x coordinate of the viewport (in screen space)
  32529. * @param y defines the y coordinate of the viewport (in screen space)
  32530. * @param width defines the width of the viewport (in screen space)
  32531. * @param height defines the height of the viewport (in screen space)
  32532. * @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
  32533. */
  32534. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32535. /**
  32536. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32537. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32538. * @param y defines the y-coordinate of the corner of the clear rectangle
  32539. * @param width defines the width of the clear rectangle
  32540. * @param height defines the height of the clear rectangle
  32541. * @param clearColor defines the clear color
  32542. */
  32543. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32544. /**
  32545. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32546. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32547. * @param y defines the y-coordinate of the corner of the clear rectangle
  32548. * @param width defines the width of the clear rectangle
  32549. * @param height defines the height of the clear rectangle
  32550. */
  32551. enableScissor(x: number, y: number, width: number, height: number): void;
  32552. /**
  32553. * Disable previously set scissor test rectangle
  32554. */
  32555. disableScissor(): void;
  32556. protected _reportDrawCall(): void;
  32557. /**
  32558. * Initializes a webVR display and starts listening to display change events
  32559. * The onVRDisplayChangedObservable will be notified upon these changes
  32560. * @returns The onVRDisplayChangedObservable
  32561. */
  32562. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32563. /** @hidden */
  32564. _prepareVRComponent(): void;
  32565. /** @hidden */
  32566. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32567. /** @hidden */
  32568. _submitVRFrame(): void;
  32569. /**
  32570. * Call this function to leave webVR mode
  32571. * Will do nothing if webVR is not supported or if there is no webVR device
  32572. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32573. */
  32574. disableVR(): void;
  32575. /**
  32576. * Gets a boolean indicating that the system is in VR mode and is presenting
  32577. * @returns true if VR mode is engaged
  32578. */
  32579. isVRPresenting(): boolean;
  32580. /** @hidden */
  32581. _requestVRFrame(): void;
  32582. /** @hidden */
  32583. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32584. /**
  32585. * Gets the source code of the vertex shader associated with a specific webGL program
  32586. * @param program defines the program to use
  32587. * @returns a string containing the source code of the vertex shader associated with the program
  32588. */
  32589. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32590. /**
  32591. * Gets the source code of the fragment shader associated with a specific webGL program
  32592. * @param program defines the program to use
  32593. * @returns a string containing the source code of the fragment shader associated with the program
  32594. */
  32595. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32596. /**
  32597. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32598. * @param x defines the x coordinate of the rectangle where pixels must be read
  32599. * @param y defines the y coordinate of the rectangle where pixels must be read
  32600. * @param width defines the width of the rectangle where pixels must be read
  32601. * @param height defines the height of the rectangle where pixels must be read
  32602. * @returns a Uint8Array containing RGBA colors
  32603. */
  32604. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32605. /**
  32606. * Sets a depth stencil texture from a render target to the according uniform.
  32607. * @param channel The texture channel
  32608. * @param uniform The uniform to set
  32609. * @param texture The render target texture containing the depth stencil texture to apply
  32610. */
  32611. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32612. /**
  32613. * Sets a texture to the webGL context from a postprocess
  32614. * @param channel defines the channel to use
  32615. * @param postProcess defines the source postprocess
  32616. */
  32617. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32618. /**
  32619. * Binds the output of the passed in post process to the texture channel specified
  32620. * @param channel The channel the texture should be bound to
  32621. * @param postProcess The post process which's output should be bound
  32622. */
  32623. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32624. /** @hidden */
  32625. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32626. protected _rebuildBuffers(): void;
  32627. _renderLoop(): void;
  32628. /**
  32629. * Toggle full screen mode
  32630. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32631. */
  32632. switchFullscreen(requestPointerLock: boolean): void;
  32633. /**
  32634. * Enters full screen mode
  32635. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32636. */
  32637. enterFullscreen(requestPointerLock: boolean): void;
  32638. /**
  32639. * Exits full screen mode
  32640. */
  32641. exitFullscreen(): void;
  32642. /**
  32643. * Enters Pointerlock mode
  32644. */
  32645. enterPointerlock(): void;
  32646. /**
  32647. * Exits Pointerlock mode
  32648. */
  32649. exitPointerlock(): void;
  32650. /**
  32651. * Begin a new frame
  32652. */
  32653. beginFrame(): void;
  32654. /**
  32655. * Enf the current frame
  32656. */
  32657. endFrame(): void;
  32658. resize(): void;
  32659. /**
  32660. * Set the compressed texture format to use, based on the formats you have, and the formats
  32661. * supported by the hardware / browser.
  32662. *
  32663. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32664. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32665. * to API arguments needed to compressed textures. This puts the burden on the container
  32666. * generator to house the arcane code for determining these for current & future formats.
  32667. *
  32668. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32669. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32670. *
  32671. * Note: The result of this call is not taken into account when a texture is base64.
  32672. *
  32673. * @param formatsAvailable defines the list of those format families you have created
  32674. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32675. *
  32676. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32677. * @returns The extension selected.
  32678. */
  32679. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32680. /**
  32681. * Force a specific size of the canvas
  32682. * @param width defines the new canvas' width
  32683. * @param height defines the new canvas' height
  32684. */
  32685. setSize(width: number, height: number): void;
  32686. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32687. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32688. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32689. _releaseTexture(texture: InternalTexture): void;
  32690. /**
  32691. * @hidden
  32692. * Rescales a texture
  32693. * @param source input texutre
  32694. * @param destination destination texture
  32695. * @param scene scene to use to render the resize
  32696. * @param internalFormat format to use when resizing
  32697. * @param onComplete callback to be called when resize has completed
  32698. */
  32699. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32700. /**
  32701. * Gets the current framerate
  32702. * @returns a number representing the framerate
  32703. */
  32704. getFps(): number;
  32705. /**
  32706. * Gets the time spent between current and previous frame
  32707. * @returns a number representing the delta time in ms
  32708. */
  32709. getDeltaTime(): number;
  32710. private _measureFps;
  32711. /**
  32712. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32713. * @param renderTarget The render target to set the frame buffer for
  32714. */
  32715. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32716. /**
  32717. * Update a dynamic index buffer
  32718. * @param indexBuffer defines the target index buffer
  32719. * @param indices defines the data to update
  32720. * @param offset defines the offset in the target index buffer where update should start
  32721. */
  32722. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32723. /**
  32724. * Updates the sample count of a render target texture
  32725. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32726. * @param texture defines the texture to update
  32727. * @param samples defines the sample count to set
  32728. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32729. */
  32730. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32731. /** @hidden */
  32732. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32733. dispose(): void;
  32734. private _disableTouchAction;
  32735. /**
  32736. * Display the loading screen
  32737. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32738. */
  32739. displayLoadingUI(): void;
  32740. /**
  32741. * Hide the loading screen
  32742. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32743. */
  32744. hideLoadingUI(): void;
  32745. /**
  32746. * Gets the current loading screen object
  32747. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32748. */
  32749. /**
  32750. * Sets the current loading screen object
  32751. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32752. */
  32753. loadingScreen: ILoadingScreen;
  32754. /**
  32755. * Sets the current loading screen text
  32756. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32757. */
  32758. loadingUIText: string;
  32759. /**
  32760. * Sets the current loading screen background color
  32761. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32762. */
  32763. loadingUIBackgroundColor: string;
  32764. /** Pointerlock and fullscreen */
  32765. /**
  32766. * Ask the browser to promote the current element to pointerlock mode
  32767. * @param element defines the DOM element to promote
  32768. */
  32769. static _RequestPointerlock(element: HTMLElement): void;
  32770. /**
  32771. * Asks the browser to exit pointerlock mode
  32772. */
  32773. static _ExitPointerlock(): void;
  32774. /**
  32775. * Ask the browser to promote the current element to fullscreen rendering mode
  32776. * @param element defines the DOM element to promote
  32777. */
  32778. static _RequestFullscreen(element: HTMLElement): void;
  32779. /**
  32780. * Asks the browser to exit fullscreen mode
  32781. */
  32782. static _ExitFullscreen(): void;
  32783. }
  32784. }
  32785. declare module "babylonjs/Engines/engineStore" {
  32786. import { Nullable } from "babylonjs/types";
  32787. import { Engine } from "babylonjs/Engines/engine";
  32788. import { Scene } from "babylonjs/scene";
  32789. /**
  32790. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32791. * during the life time of the application.
  32792. */
  32793. export class EngineStore {
  32794. /** Gets the list of created engines */
  32795. static Instances: import("babylonjs/Engines/engine").Engine[];
  32796. /** @hidden */
  32797. static _LastCreatedScene: Nullable<Scene>;
  32798. /**
  32799. * Gets the latest created engine
  32800. */
  32801. static readonly LastCreatedEngine: Nullable<Engine>;
  32802. /**
  32803. * Gets the latest created scene
  32804. */
  32805. static readonly LastCreatedScene: Nullable<Scene>;
  32806. /**
  32807. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32808. * @ignorenaming
  32809. */
  32810. static UseFallbackTexture: boolean;
  32811. /**
  32812. * Texture content used if a texture cannot loaded
  32813. * @ignorenaming
  32814. */
  32815. static FallbackTexture: string;
  32816. }
  32817. }
  32818. declare module "babylonjs/Misc/promise" {
  32819. /**
  32820. * Helper class that provides a small promise polyfill
  32821. */
  32822. export class PromisePolyfill {
  32823. /**
  32824. * Static function used to check if the polyfill is required
  32825. * If this is the case then the function will inject the polyfill to window.Promise
  32826. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32827. */
  32828. static Apply(force?: boolean): void;
  32829. }
  32830. }
  32831. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32832. /**
  32833. * Interface for screenshot methods with describe argument called `size` as object with options
  32834. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32835. */
  32836. export interface IScreenshotSize {
  32837. /**
  32838. * number in pixels for canvas height
  32839. */
  32840. height?: number;
  32841. /**
  32842. * multiplier allowing render at a higher or lower resolution
  32843. * If value is defined then height and width will be ignored and taken from camera
  32844. */
  32845. precision?: number;
  32846. /**
  32847. * number in pixels for canvas width
  32848. */
  32849. width?: number;
  32850. }
  32851. }
  32852. declare module "babylonjs/Misc/tools" {
  32853. import { Nullable, float } from "babylonjs/types";
  32854. import { DomManagement } from "babylonjs/Misc/domManagement";
  32855. import { WebRequest } from "babylonjs/Misc/webRequest";
  32856. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32857. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32858. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32859. import { Camera } from "babylonjs/Cameras/camera";
  32860. import { Engine } from "babylonjs/Engines/engine";
  32861. interface IColor4Like {
  32862. r: float;
  32863. g: float;
  32864. b: float;
  32865. a: float;
  32866. }
  32867. /**
  32868. * Class containing a set of static utilities functions
  32869. */
  32870. export class Tools {
  32871. /**
  32872. * Gets or sets the base URL to use to load assets
  32873. */
  32874. static BaseUrl: string;
  32875. /**
  32876. * Enable/Disable Custom HTTP Request Headers globally.
  32877. * default = false
  32878. * @see CustomRequestHeaders
  32879. */
  32880. static UseCustomRequestHeaders: boolean;
  32881. /**
  32882. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32883. * i.e. when loading files, where the server/service expects an Authorization header
  32884. */
  32885. static CustomRequestHeaders: {
  32886. [key: string]: string;
  32887. };
  32888. /**
  32889. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32890. */
  32891. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32892. /**
  32893. * Default behaviour for cors in the application.
  32894. * It can be a string if the expected behavior is identical in the entire app.
  32895. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32896. */
  32897. static CorsBehavior: string | ((url: string | string[]) => string);
  32898. /**
  32899. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32900. * @ignorenaming
  32901. */
  32902. static UseFallbackTexture: boolean;
  32903. /**
  32904. * Use this object to register external classes like custom textures or material
  32905. * to allow the laoders to instantiate them
  32906. */
  32907. static RegisteredExternalClasses: {
  32908. [key: string]: Object;
  32909. };
  32910. /**
  32911. * Texture content used if a texture cannot loaded
  32912. * @ignorenaming
  32913. */
  32914. static fallbackTexture: string;
  32915. /**
  32916. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32917. * @param u defines the coordinate on X axis
  32918. * @param v defines the coordinate on Y axis
  32919. * @param width defines the width of the source data
  32920. * @param height defines the height of the source data
  32921. * @param pixels defines the source byte array
  32922. * @param color defines the output color
  32923. */
  32924. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32925. /**
  32926. * Interpolates between a and b via alpha
  32927. * @param a The lower value (returned when alpha = 0)
  32928. * @param b The upper value (returned when alpha = 1)
  32929. * @param alpha The interpolation-factor
  32930. * @return The mixed value
  32931. */
  32932. static Mix(a: number, b: number, alpha: number): number;
  32933. /**
  32934. * Tries to instantiate a new object from a given class name
  32935. * @param className defines the class name to instantiate
  32936. * @returns the new object or null if the system was not able to do the instantiation
  32937. */
  32938. static Instantiate(className: string): any;
  32939. /**
  32940. * Provides a slice function that will work even on IE
  32941. * @param data defines the array to slice
  32942. * @param start defines the start of the data (optional)
  32943. * @param end defines the end of the data (optional)
  32944. * @returns the new sliced array
  32945. */
  32946. static Slice<T>(data: T, start?: number, end?: number): T;
  32947. /**
  32948. * Polyfill for setImmediate
  32949. * @param action defines the action to execute after the current execution block
  32950. */
  32951. static SetImmediate(action: () => void): void;
  32952. /**
  32953. * Function indicating if a number is an exponent of 2
  32954. * @param value defines the value to test
  32955. * @returns true if the value is an exponent of 2
  32956. */
  32957. static IsExponentOfTwo(value: number): boolean;
  32958. private static _tmpFloatArray;
  32959. /**
  32960. * Returns the nearest 32-bit single precision float representation of a Number
  32961. * @param value A Number. If the parameter is of a different type, it will get converted
  32962. * to a number or to NaN if it cannot be converted
  32963. * @returns number
  32964. */
  32965. static FloatRound(value: number): number;
  32966. /**
  32967. * Extracts the filename from a path
  32968. * @param path defines the path to use
  32969. * @returns the filename
  32970. */
  32971. static GetFilename(path: string): string;
  32972. /**
  32973. * Extracts the "folder" part of a path (everything before the filename).
  32974. * @param uri The URI to extract the info from
  32975. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32976. * @returns The "folder" part of the path
  32977. */
  32978. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32979. /**
  32980. * Extracts text content from a DOM element hierarchy
  32981. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32982. */
  32983. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32984. /**
  32985. * Convert an angle in radians to degrees
  32986. * @param angle defines the angle to convert
  32987. * @returns the angle in degrees
  32988. */
  32989. static ToDegrees(angle: number): number;
  32990. /**
  32991. * Convert an angle in degrees to radians
  32992. * @param angle defines the angle to convert
  32993. * @returns the angle in radians
  32994. */
  32995. static ToRadians(angle: number): number;
  32996. /**
  32997. * Encode a buffer to a base64 string
  32998. * @param buffer defines the buffer to encode
  32999. * @returns the encoded string
  33000. */
  33001. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  33002. /**
  33003. * Returns an array if obj is not an array
  33004. * @param obj defines the object to evaluate as an array
  33005. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33006. * @returns either obj directly if obj is an array or a new array containing obj
  33007. */
  33008. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33009. /**
  33010. * Gets the pointer prefix to use
  33011. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33012. */
  33013. static GetPointerPrefix(): string;
  33014. /**
  33015. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33016. * @param url define the url we are trying
  33017. * @param element define the dom element where to configure the cors policy
  33018. */
  33019. static SetCorsBehavior(url: string | string[], element: {
  33020. crossOrigin: string | null;
  33021. }): void;
  33022. /**
  33023. * Removes unwanted characters from an url
  33024. * @param url defines the url to clean
  33025. * @returns the cleaned url
  33026. */
  33027. static CleanUrl(url: string): string;
  33028. /**
  33029. * Gets or sets a function used to pre-process url before using them to load assets
  33030. */
  33031. static PreprocessUrl: (url: string) => string;
  33032. /**
  33033. * Loads an image as an HTMLImageElement.
  33034. * @param input url string, ArrayBuffer, or Blob to load
  33035. * @param onLoad callback called when the image successfully loads
  33036. * @param onError callback called when the image fails to load
  33037. * @param offlineProvider offline provider for caching
  33038. * @returns the HTMLImageElement of the loaded image
  33039. */
  33040. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  33041. /**
  33042. * Loads a file
  33043. * @param url url string, ArrayBuffer, or Blob to load
  33044. * @param onSuccess callback called when the file successfully loads
  33045. * @param onProgress callback called while file is loading (if the server supports this mode)
  33046. * @param offlineProvider defines the offline provider for caching
  33047. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33048. * @param onError callback called when the file fails to load
  33049. * @returns a file request object
  33050. */
  33051. 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;
  33052. /**
  33053. * Loads a file from a url
  33054. * @param url the file url to load
  33055. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33056. */
  33057. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33058. /**
  33059. * Load a script (identified by an url). When the url returns, the
  33060. * content of this file is added into a new script element, attached to the DOM (body element)
  33061. * @param scriptUrl defines the url of the script to laod
  33062. * @param onSuccess defines the callback called when the script is loaded
  33063. * @param onError defines the callback to call if an error occurs
  33064. * @param scriptId defines the id of the script element
  33065. */
  33066. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33067. /**
  33068. * Load an asynchronous script (identified by an url). When the url returns, the
  33069. * content of this file is added into a new script element, attached to the DOM (body element)
  33070. * @param scriptUrl defines the url of the script to laod
  33071. * @param scriptId defines the id of the script element
  33072. * @returns a promise request object
  33073. */
  33074. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33075. /**
  33076. * Loads a file from a blob
  33077. * @param fileToLoad defines the blob to use
  33078. * @param callback defines the callback to call when data is loaded
  33079. * @param progressCallback defines the callback to call during loading process
  33080. * @returns a file request object
  33081. */
  33082. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33083. /**
  33084. * Loads a file
  33085. * @param fileToLoad defines the file to load
  33086. * @param callback defines the callback to call when data is loaded
  33087. * @param progressCallBack defines the callback to call during loading process
  33088. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33089. * @returns a file request object
  33090. */
  33091. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33092. /**
  33093. * Creates a data url from a given string content
  33094. * @param content defines the content to convert
  33095. * @returns the new data url link
  33096. */
  33097. static FileAsURL(content: string): string;
  33098. /**
  33099. * Format the given number to a specific decimal format
  33100. * @param value defines the number to format
  33101. * @param decimals defines the number of decimals to use
  33102. * @returns the formatted string
  33103. */
  33104. static Format(value: number, decimals?: number): string;
  33105. /**
  33106. * Tries to copy an object by duplicating every property
  33107. * @param source defines the source object
  33108. * @param destination defines the target object
  33109. * @param doNotCopyList defines a list of properties to avoid
  33110. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33111. */
  33112. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33113. /**
  33114. * Gets a boolean indicating if the given object has no own property
  33115. * @param obj defines the object to test
  33116. * @returns true if object has no own property
  33117. */
  33118. static IsEmpty(obj: any): boolean;
  33119. /**
  33120. * Function used to register events at window level
  33121. * @param windowElement defines the Window object to use
  33122. * @param events defines the events to register
  33123. */
  33124. static RegisterTopRootEvents(windowElement: Window, events: {
  33125. name: string;
  33126. handler: Nullable<(e: FocusEvent) => any>;
  33127. }[]): void;
  33128. /**
  33129. * Function used to unregister events from window level
  33130. * @param windowElement defines the Window object to use
  33131. * @param events defines the events to unregister
  33132. */
  33133. static UnregisterTopRootEvents(windowElement: Window, events: {
  33134. name: string;
  33135. handler: Nullable<(e: FocusEvent) => any>;
  33136. }[]): void;
  33137. /**
  33138. * @ignore
  33139. */
  33140. static _ScreenshotCanvas: HTMLCanvasElement;
  33141. /**
  33142. * Dumps the current bound framebuffer
  33143. * @param width defines the rendering width
  33144. * @param height defines the rendering height
  33145. * @param engine defines the hosting engine
  33146. * @param successCallback defines the callback triggered once the data are available
  33147. * @param mimeType defines the mime type of the result
  33148. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33149. */
  33150. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33151. /**
  33152. * Converts the canvas data to blob.
  33153. * This acts as a polyfill for browsers not supporting the to blob function.
  33154. * @param canvas Defines the canvas to extract the data from
  33155. * @param successCallback Defines the callback triggered once the data are available
  33156. * @param mimeType Defines the mime type of the result
  33157. */
  33158. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33159. /**
  33160. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33161. * @param successCallback defines the callback triggered once the data are available
  33162. * @param mimeType defines the mime type of the result
  33163. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33164. */
  33165. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33166. /**
  33167. * Downloads a blob in the browser
  33168. * @param blob defines the blob to download
  33169. * @param fileName defines the name of the downloaded file
  33170. */
  33171. static Download(blob: Blob, fileName: string): void;
  33172. /**
  33173. * Captures a screenshot of the current rendering
  33174. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33175. * @param engine defines the rendering engine
  33176. * @param camera defines the source camera
  33177. * @param size This parameter can be set to a single number or to an object with the
  33178. * following (optional) properties: precision, width, height. If a single number is passed,
  33179. * it will be used for both width and height. If an object is passed, the screenshot size
  33180. * will be derived from the parameters. The precision property is a multiplier allowing
  33181. * rendering at a higher or lower resolution
  33182. * @param successCallback defines the callback receives a single parameter which contains the
  33183. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33184. * src parameter of an <img> to display it
  33185. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33186. * Check your browser for supported MIME types
  33187. */
  33188. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33189. /**
  33190. * Captures a screenshot of the current rendering
  33191. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33192. * @param engine defines the rendering engine
  33193. * @param camera defines the source camera
  33194. * @param size This parameter can be set to a single number or to an object with the
  33195. * following (optional) properties: precision, width, height. If a single number is passed,
  33196. * it will be used for both width and height. If an object is passed, the screenshot size
  33197. * will be derived from the parameters. The precision property is a multiplier allowing
  33198. * rendering at a higher or lower resolution
  33199. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33200. * Check your browser for supported MIME types
  33201. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33202. * to the src parameter of an <img> to display it
  33203. */
  33204. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33205. /**
  33206. * Generates an image screenshot from the specified camera.
  33207. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33208. * @param engine The engine to use for rendering
  33209. * @param camera The camera to use for rendering
  33210. * @param size This parameter can be set to a single number or to an object with the
  33211. * following (optional) properties: precision, width, height. If a single number is passed,
  33212. * it will be used for both width and height. If an object is passed, the screenshot size
  33213. * will be derived from the parameters. The precision property is a multiplier allowing
  33214. * rendering at a higher or lower resolution
  33215. * @param successCallback The callback receives a single parameter which contains the
  33216. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33217. * src parameter of an <img> to display it
  33218. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33219. * Check your browser for supported MIME types
  33220. * @param samples Texture samples (default: 1)
  33221. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33222. * @param fileName A name for for the downloaded file.
  33223. */
  33224. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33225. /**
  33226. * Generates an image screenshot from the specified camera.
  33227. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33228. * @param engine The engine to use for rendering
  33229. * @param camera The camera to use for rendering
  33230. * @param size This parameter can be set to a single number or to an object with the
  33231. * following (optional) properties: precision, width, height. If a single number is passed,
  33232. * it will be used for both width and height. If an object is passed, the screenshot size
  33233. * will be derived from the parameters. The precision property is a multiplier allowing
  33234. * rendering at a higher or lower resolution
  33235. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33236. * Check your browser for supported MIME types
  33237. * @param samples Texture samples (default: 1)
  33238. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33239. * @param fileName A name for for the downloaded file.
  33240. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33241. * to the src parameter of an <img> to display it
  33242. */
  33243. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33244. /**
  33245. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33246. * Be aware Math.random() could cause collisions, but:
  33247. * "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"
  33248. * @returns a pseudo random id
  33249. */
  33250. static RandomId(): string;
  33251. /**
  33252. * Test if the given uri is a base64 string
  33253. * @param uri The uri to test
  33254. * @return True if the uri is a base64 string or false otherwise
  33255. */
  33256. static IsBase64(uri: string): boolean;
  33257. /**
  33258. * Decode the given base64 uri.
  33259. * @param uri The uri to decode
  33260. * @return The decoded base64 data.
  33261. */
  33262. static DecodeBase64(uri: string): ArrayBuffer;
  33263. /**
  33264. * Gets the absolute url.
  33265. * @param url the input url
  33266. * @return the absolute url
  33267. */
  33268. static GetAbsoluteUrl(url: string): string;
  33269. /**
  33270. * No log
  33271. */
  33272. static readonly NoneLogLevel: number;
  33273. /**
  33274. * Only message logs
  33275. */
  33276. static readonly MessageLogLevel: number;
  33277. /**
  33278. * Only warning logs
  33279. */
  33280. static readonly WarningLogLevel: number;
  33281. /**
  33282. * Only error logs
  33283. */
  33284. static readonly ErrorLogLevel: number;
  33285. /**
  33286. * All logs
  33287. */
  33288. static readonly AllLogLevel: number;
  33289. /**
  33290. * Gets a value indicating the number of loading errors
  33291. * @ignorenaming
  33292. */
  33293. static readonly errorsCount: number;
  33294. /**
  33295. * Callback called when a new log is added
  33296. */
  33297. static OnNewCacheEntry: (entry: string) => void;
  33298. /**
  33299. * Log a message to the console
  33300. * @param message defines the message to log
  33301. */
  33302. static Log(message: string): void;
  33303. /**
  33304. * Write a warning message to the console
  33305. * @param message defines the message to log
  33306. */
  33307. static Warn(message: string): void;
  33308. /**
  33309. * Write an error message to the console
  33310. * @param message defines the message to log
  33311. */
  33312. static Error(message: string): void;
  33313. /**
  33314. * Gets current log cache (list of logs)
  33315. */
  33316. static readonly LogCache: string;
  33317. /**
  33318. * Clears the log cache
  33319. */
  33320. static ClearLogCache(): void;
  33321. /**
  33322. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33323. */
  33324. static LogLevels: number;
  33325. /**
  33326. * Checks if the window object exists
  33327. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33328. */
  33329. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33330. /**
  33331. * No performance log
  33332. */
  33333. static readonly PerformanceNoneLogLevel: number;
  33334. /**
  33335. * Use user marks to log performance
  33336. */
  33337. static readonly PerformanceUserMarkLogLevel: number;
  33338. /**
  33339. * Log performance to the console
  33340. */
  33341. static readonly PerformanceConsoleLogLevel: number;
  33342. private static _performance;
  33343. /**
  33344. * Sets the current performance log level
  33345. */
  33346. static PerformanceLogLevel: number;
  33347. private static _StartPerformanceCounterDisabled;
  33348. private static _EndPerformanceCounterDisabled;
  33349. private static _StartUserMark;
  33350. private static _EndUserMark;
  33351. private static _StartPerformanceConsole;
  33352. private static _EndPerformanceConsole;
  33353. /**
  33354. * Starts a performance counter
  33355. */
  33356. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33357. /**
  33358. * Ends a specific performance coutner
  33359. */
  33360. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33361. /**
  33362. * Gets either window.performance.now() if supported or Date.now() else
  33363. */
  33364. static readonly Now: number;
  33365. /**
  33366. * This method will return the name of the class used to create the instance of the given object.
  33367. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33368. * @param object the object to get the class name from
  33369. * @param isType defines if the object is actually a type
  33370. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33371. */
  33372. static GetClassName(object: any, isType?: boolean): string;
  33373. /**
  33374. * Gets the first element of an array satisfying a given predicate
  33375. * @param array defines the array to browse
  33376. * @param predicate defines the predicate to use
  33377. * @returns null if not found or the element
  33378. */
  33379. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33380. /**
  33381. * This method will return the name of the full name of the class, including its owning module (if any).
  33382. * 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).
  33383. * @param object the object to get the class name from
  33384. * @param isType defines if the object is actually a type
  33385. * @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.
  33386. * @ignorenaming
  33387. */
  33388. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33389. /**
  33390. * Returns a promise that resolves after the given amount of time.
  33391. * @param delay Number of milliseconds to delay
  33392. * @returns Promise that resolves after the given amount of time
  33393. */
  33394. static DelayAsync(delay: number): Promise<void>;
  33395. }
  33396. /**
  33397. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33398. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33399. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33400. * @param name The name of the class, case should be preserved
  33401. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33402. */
  33403. export function className(name: string, module?: string): (target: Object) => void;
  33404. /**
  33405. * An implementation of a loop for asynchronous functions.
  33406. */
  33407. export class AsyncLoop {
  33408. /**
  33409. * Defines the number of iterations for the loop
  33410. */
  33411. iterations: number;
  33412. /**
  33413. * Defines the current index of the loop.
  33414. */
  33415. index: number;
  33416. private _done;
  33417. private _fn;
  33418. private _successCallback;
  33419. /**
  33420. * Constructor.
  33421. * @param iterations the number of iterations.
  33422. * @param func the function to run each iteration
  33423. * @param successCallback the callback that will be called upon succesful execution
  33424. * @param offset starting offset.
  33425. */
  33426. constructor(
  33427. /**
  33428. * Defines the number of iterations for the loop
  33429. */
  33430. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33431. /**
  33432. * Execute the next iteration. Must be called after the last iteration was finished.
  33433. */
  33434. executeNext(): void;
  33435. /**
  33436. * Break the loop and run the success callback.
  33437. */
  33438. breakLoop(): void;
  33439. /**
  33440. * Create and run an async loop.
  33441. * @param iterations the number of iterations.
  33442. * @param fn the function to run each iteration
  33443. * @param successCallback the callback that will be called upon succesful execution
  33444. * @param offset starting offset.
  33445. * @returns the created async loop object
  33446. */
  33447. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33448. /**
  33449. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33450. * @param iterations total number of iterations
  33451. * @param syncedIterations number of synchronous iterations in each async iteration.
  33452. * @param fn the function to call each iteration.
  33453. * @param callback a success call back that will be called when iterating stops.
  33454. * @param breakFunction a break condition (optional)
  33455. * @param timeout timeout settings for the setTimeout function. default - 0.
  33456. * @returns the created async loop object
  33457. */
  33458. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33459. }
  33460. }
  33461. declare module "babylonjs/Misc/stringDictionary" {
  33462. import { Nullable } from "babylonjs/types";
  33463. /**
  33464. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33465. * The underlying implementation relies on an associative array to ensure the best performances.
  33466. * The value can be anything including 'null' but except 'undefined'
  33467. */
  33468. export class StringDictionary<T> {
  33469. /**
  33470. * This will clear this dictionary and copy the content from the 'source' one.
  33471. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33472. * @param source the dictionary to take the content from and copy to this dictionary
  33473. */
  33474. copyFrom(source: StringDictionary<T>): void;
  33475. /**
  33476. * Get a value based from its key
  33477. * @param key the given key to get the matching value from
  33478. * @return the value if found, otherwise undefined is returned
  33479. */
  33480. get(key: string): T | undefined;
  33481. /**
  33482. * Get a value from its key or add it if it doesn't exist.
  33483. * This method will ensure you that a given key/data will be present in the dictionary.
  33484. * @param key the given key to get the matching value from
  33485. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33486. * The factory will only be invoked if there's no data for the given key.
  33487. * @return the value corresponding to the key.
  33488. */
  33489. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33490. /**
  33491. * Get a value from its key if present in the dictionary otherwise add it
  33492. * @param key the key to get the value from
  33493. * @param val if there's no such key/value pair in the dictionary add it with this value
  33494. * @return the value corresponding to the key
  33495. */
  33496. getOrAdd(key: string, val: T): T;
  33497. /**
  33498. * Check if there's a given key in the dictionary
  33499. * @param key the key to check for
  33500. * @return true if the key is present, false otherwise
  33501. */
  33502. contains(key: string): boolean;
  33503. /**
  33504. * Add a new key and its corresponding value
  33505. * @param key the key to add
  33506. * @param value the value corresponding to the key
  33507. * @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
  33508. */
  33509. add(key: string, value: T): boolean;
  33510. /**
  33511. * Update a specific value associated to a key
  33512. * @param key defines the key to use
  33513. * @param value defines the value to store
  33514. * @returns true if the value was updated (or false if the key was not found)
  33515. */
  33516. set(key: string, value: T): boolean;
  33517. /**
  33518. * Get the element of the given key and remove it from the dictionary
  33519. * @param key defines the key to search
  33520. * @returns the value associated with the key or null if not found
  33521. */
  33522. getAndRemove(key: string): Nullable<T>;
  33523. /**
  33524. * Remove a key/value from the dictionary.
  33525. * @param key the key to remove
  33526. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33527. */
  33528. remove(key: string): boolean;
  33529. /**
  33530. * Clear the whole content of the dictionary
  33531. */
  33532. clear(): void;
  33533. /**
  33534. * Gets the current count
  33535. */
  33536. readonly count: number;
  33537. /**
  33538. * Execute a callback on each key/val of the dictionary.
  33539. * Note that you can remove any element in this dictionary in the callback implementation
  33540. * @param callback the callback to execute on a given key/value pair
  33541. */
  33542. forEach(callback: (key: string, val: T) => void): void;
  33543. /**
  33544. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33545. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33546. * Note that you can remove any element in this dictionary in the callback implementation
  33547. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33548. * @returns the first item
  33549. */
  33550. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33551. private _count;
  33552. private _data;
  33553. }
  33554. }
  33555. declare module "babylonjs/Collisions/collisionCoordinator" {
  33556. import { Nullable } from "babylonjs/types";
  33557. import { Scene } from "babylonjs/scene";
  33558. import { Vector3 } from "babylonjs/Maths/math.vector";
  33559. import { Collider } from "babylonjs/Collisions/collider";
  33560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33561. /** @hidden */
  33562. export interface ICollisionCoordinator {
  33563. createCollider(): Collider;
  33564. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33565. init(scene: Scene): void;
  33566. }
  33567. /** @hidden */
  33568. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33569. private _scene;
  33570. private _scaledPosition;
  33571. private _scaledVelocity;
  33572. private _finalPosition;
  33573. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33574. createCollider(): Collider;
  33575. init(scene: Scene): void;
  33576. private _collideWithWorld;
  33577. }
  33578. }
  33579. declare module "babylonjs/Inputs/scene.inputManager" {
  33580. import { Nullable } from "babylonjs/types";
  33581. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33582. import { Vector2 } from "babylonjs/Maths/math.vector";
  33583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33584. import { Scene } from "babylonjs/scene";
  33585. /**
  33586. * Class used to manage all inputs for the scene.
  33587. */
  33588. export class InputManager {
  33589. /** The distance in pixel that you have to move to prevent some events */
  33590. static DragMovementThreshold: number;
  33591. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33592. static LongPressDelay: number;
  33593. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33594. static DoubleClickDelay: number;
  33595. /** If you need to check double click without raising a single click at first click, enable this flag */
  33596. static ExclusiveDoubleClickMode: boolean;
  33597. private _wheelEventName;
  33598. private _onPointerMove;
  33599. private _onPointerDown;
  33600. private _onPointerUp;
  33601. private _initClickEvent;
  33602. private _initActionManager;
  33603. private _delayedSimpleClick;
  33604. private _delayedSimpleClickTimeout;
  33605. private _previousDelayedSimpleClickTimeout;
  33606. private _meshPickProceed;
  33607. private _previousButtonPressed;
  33608. private _currentPickResult;
  33609. private _previousPickResult;
  33610. private _totalPointersPressed;
  33611. private _doubleClickOccured;
  33612. private _pointerOverMesh;
  33613. private _pickedDownMesh;
  33614. private _pickedUpMesh;
  33615. private _pointerX;
  33616. private _pointerY;
  33617. private _unTranslatedPointerX;
  33618. private _unTranslatedPointerY;
  33619. private _startingPointerPosition;
  33620. private _previousStartingPointerPosition;
  33621. private _startingPointerTime;
  33622. private _previousStartingPointerTime;
  33623. private _pointerCaptures;
  33624. private _onKeyDown;
  33625. private _onKeyUp;
  33626. private _onCanvasFocusObserver;
  33627. private _onCanvasBlurObserver;
  33628. private _scene;
  33629. /**
  33630. * Creates a new InputManager
  33631. * @param scene defines the hosting scene
  33632. */
  33633. constructor(scene: Scene);
  33634. /**
  33635. * Gets the mesh that is currently under the pointer
  33636. */
  33637. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33638. /**
  33639. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33640. */
  33641. readonly unTranslatedPointer: Vector2;
  33642. /**
  33643. * Gets or sets the current on-screen X position of the pointer
  33644. */
  33645. pointerX: number;
  33646. /**
  33647. * Gets or sets the current on-screen Y position of the pointer
  33648. */
  33649. pointerY: number;
  33650. private _updatePointerPosition;
  33651. private _processPointerMove;
  33652. private _setRayOnPointerInfo;
  33653. private _checkPrePointerObservable;
  33654. /**
  33655. * Use this method to simulate a pointer move on a mesh
  33656. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33657. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33658. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33659. */
  33660. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33661. /**
  33662. * Use this method to simulate a pointer down on a mesh
  33663. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33664. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33665. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33666. */
  33667. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33668. private _processPointerDown;
  33669. /** @hidden */
  33670. _isPointerSwiping(): boolean;
  33671. /**
  33672. * Use this method to simulate a pointer up on a mesh
  33673. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33674. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33675. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33676. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33677. */
  33678. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33679. private _processPointerUp;
  33680. /**
  33681. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33682. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33683. * @returns true if the pointer was captured
  33684. */
  33685. isPointerCaptured(pointerId?: number): boolean;
  33686. /**
  33687. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33688. * @param attachUp defines if you want to attach events to pointerup
  33689. * @param attachDown defines if you want to attach events to pointerdown
  33690. * @param attachMove defines if you want to attach events to pointermove
  33691. */
  33692. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33693. /**
  33694. * Detaches all event handlers
  33695. */
  33696. detachControl(): void;
  33697. /**
  33698. * Force the value of meshUnderPointer
  33699. * @param mesh defines the mesh to use
  33700. */
  33701. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33702. /**
  33703. * Gets the mesh under the pointer
  33704. * @returns a Mesh or null if no mesh is under the pointer
  33705. */
  33706. getPointerOverMesh(): Nullable<AbstractMesh>;
  33707. }
  33708. }
  33709. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33710. /**
  33711. * Helper class used to generate session unique ID
  33712. */
  33713. export class UniqueIdGenerator {
  33714. private static _UniqueIdCounter;
  33715. /**
  33716. * Gets an unique (relatively to the current scene) Id
  33717. */
  33718. static readonly UniqueId: number;
  33719. }
  33720. }
  33721. declare module "babylonjs/Animations/animationGroup" {
  33722. import { Animatable } from "babylonjs/Animations/animatable";
  33723. import { Animation } from "babylonjs/Animations/animation";
  33724. import { Scene, IDisposable } from "babylonjs/scene";
  33725. import { Observable } from "babylonjs/Misc/observable";
  33726. import { Nullable } from "babylonjs/types";
  33727. import "babylonjs/Animations/animatable";
  33728. /**
  33729. * This class defines the direct association between an animation and a target
  33730. */
  33731. export class TargetedAnimation {
  33732. /**
  33733. * Animation to perform
  33734. */
  33735. animation: Animation;
  33736. /**
  33737. * Target to animate
  33738. */
  33739. target: any;
  33740. /**
  33741. * Serialize the object
  33742. * @returns the JSON object representing the current entity
  33743. */
  33744. serialize(): any;
  33745. }
  33746. /**
  33747. * Use this class to create coordinated animations on multiple targets
  33748. */
  33749. export class AnimationGroup implements IDisposable {
  33750. /** The name of the animation group */
  33751. name: string;
  33752. private _scene;
  33753. private _targetedAnimations;
  33754. private _animatables;
  33755. private _from;
  33756. private _to;
  33757. private _isStarted;
  33758. private _isPaused;
  33759. private _speedRatio;
  33760. private _loopAnimation;
  33761. /**
  33762. * Gets or sets the unique id of the node
  33763. */
  33764. uniqueId: number;
  33765. /**
  33766. * This observable will notify when one animation have ended
  33767. */
  33768. onAnimationEndObservable: Observable<TargetedAnimation>;
  33769. /**
  33770. * Observer raised when one animation loops
  33771. */
  33772. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33773. /**
  33774. * This observable will notify when all animations have ended.
  33775. */
  33776. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33777. /**
  33778. * This observable will notify when all animations have paused.
  33779. */
  33780. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33781. /**
  33782. * This observable will notify when all animations are playing.
  33783. */
  33784. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33785. /**
  33786. * Gets the first frame
  33787. */
  33788. readonly from: number;
  33789. /**
  33790. * Gets the last frame
  33791. */
  33792. readonly to: number;
  33793. /**
  33794. * Define if the animations are started
  33795. */
  33796. readonly isStarted: boolean;
  33797. /**
  33798. * Gets a value indicating that the current group is playing
  33799. */
  33800. readonly isPlaying: boolean;
  33801. /**
  33802. * Gets or sets the speed ratio to use for all animations
  33803. */
  33804. /**
  33805. * Gets or sets the speed ratio to use for all animations
  33806. */
  33807. speedRatio: number;
  33808. /**
  33809. * Gets or sets if all animations should loop or not
  33810. */
  33811. loopAnimation: boolean;
  33812. /**
  33813. * Gets the targeted animations for this animation group
  33814. */
  33815. readonly targetedAnimations: Array<TargetedAnimation>;
  33816. /**
  33817. * returning the list of animatables controlled by this animation group.
  33818. */
  33819. readonly animatables: Array<Animatable>;
  33820. /**
  33821. * Instantiates a new Animation Group.
  33822. * This helps managing several animations at once.
  33823. * @see http://doc.babylonjs.com/how_to/group
  33824. * @param name Defines the name of the group
  33825. * @param scene Defines the scene the group belongs to
  33826. */
  33827. constructor(
  33828. /** The name of the animation group */
  33829. name: string, scene?: Nullable<Scene>);
  33830. /**
  33831. * Add an animation (with its target) in the group
  33832. * @param animation defines the animation we want to add
  33833. * @param target defines the target of the animation
  33834. * @returns the TargetedAnimation object
  33835. */
  33836. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33837. /**
  33838. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33839. * It can add constant keys at begin or end
  33840. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33841. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33842. * @returns the animation group
  33843. */
  33844. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33845. /**
  33846. * Start all animations on given targets
  33847. * @param loop defines if animations must loop
  33848. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33849. * @param from defines the from key (optional)
  33850. * @param to defines the to key (optional)
  33851. * @returns the current animation group
  33852. */
  33853. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33854. /**
  33855. * Pause all animations
  33856. * @returns the animation group
  33857. */
  33858. pause(): AnimationGroup;
  33859. /**
  33860. * Play all animations to initial state
  33861. * This function will start() the animations if they were not started or will restart() them if they were paused
  33862. * @param loop defines if animations must loop
  33863. * @returns the animation group
  33864. */
  33865. play(loop?: boolean): AnimationGroup;
  33866. /**
  33867. * Reset all animations to initial state
  33868. * @returns the animation group
  33869. */
  33870. reset(): AnimationGroup;
  33871. /**
  33872. * Restart animations from key 0
  33873. * @returns the animation group
  33874. */
  33875. restart(): AnimationGroup;
  33876. /**
  33877. * Stop all animations
  33878. * @returns the animation group
  33879. */
  33880. stop(): AnimationGroup;
  33881. /**
  33882. * Set animation weight for all animatables
  33883. * @param weight defines the weight to use
  33884. * @return the animationGroup
  33885. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33886. */
  33887. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33888. /**
  33889. * Synchronize and normalize all animatables with a source animatable
  33890. * @param root defines the root animatable to synchronize with
  33891. * @return the animationGroup
  33892. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33893. */
  33894. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33895. /**
  33896. * Goes to a specific frame in this animation group
  33897. * @param frame the frame number to go to
  33898. * @return the animationGroup
  33899. */
  33900. goToFrame(frame: number): AnimationGroup;
  33901. /**
  33902. * Dispose all associated resources
  33903. */
  33904. dispose(): void;
  33905. private _checkAnimationGroupEnded;
  33906. /**
  33907. * Clone the current animation group and returns a copy
  33908. * @param newName defines the name of the new group
  33909. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33910. * @returns the new aniamtion group
  33911. */
  33912. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33913. /**
  33914. * Serializes the animationGroup to an object
  33915. * @returns Serialized object
  33916. */
  33917. serialize(): any;
  33918. /**
  33919. * Returns a new AnimationGroup object parsed from the source provided.
  33920. * @param parsedAnimationGroup defines the source
  33921. * @param scene defines the scene that will receive the animationGroup
  33922. * @returns a new AnimationGroup
  33923. */
  33924. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33925. /**
  33926. * Returns the string "AnimationGroup"
  33927. * @returns "AnimationGroup"
  33928. */
  33929. getClassName(): string;
  33930. /**
  33931. * Creates a detailled string about the object
  33932. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33933. * @returns a string representing the object
  33934. */
  33935. toString(fullDetails?: boolean): string;
  33936. }
  33937. }
  33938. declare module "babylonjs/scene" {
  33939. import { Nullable } from "babylonjs/types";
  33940. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33941. import { Observable } from "babylonjs/Misc/observable";
  33942. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33943. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33944. import { Geometry } from "babylonjs/Meshes/geometry";
  33945. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33946. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33948. import { Mesh } from "babylonjs/Meshes/mesh";
  33949. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33950. import { Bone } from "babylonjs/Bones/bone";
  33951. import { Skeleton } from "babylonjs/Bones/skeleton";
  33952. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33953. import { Camera } from "babylonjs/Cameras/camera";
  33954. import { AbstractScene } from "babylonjs/abstractScene";
  33955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33956. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33957. import { Material } from "babylonjs/Materials/material";
  33958. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33959. import { Effect } from "babylonjs/Materials/effect";
  33960. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33961. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33962. import { Light } from "babylonjs/Lights/light";
  33963. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33964. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33965. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33966. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33968. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33969. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33970. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33971. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33972. import { Engine } from "babylonjs/Engines/engine";
  33973. import { Node } from "babylonjs/node";
  33974. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33975. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33976. import { WebRequest } from "babylonjs/Misc/webRequest";
  33977. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33978. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33979. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33980. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33981. import { Plane } from "babylonjs/Maths/math.plane";
  33982. import { Ray } from "babylonjs/Culling/ray";
  33983. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33984. import { Animation } from "babylonjs/Animations/animation";
  33985. import { Animatable } from "babylonjs/Animations/animatable";
  33986. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33987. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33988. import { Collider } from "babylonjs/Collisions/collider";
  33989. /**
  33990. * Define an interface for all classes that will hold resources
  33991. */
  33992. export interface IDisposable {
  33993. /**
  33994. * Releases all held resources
  33995. */
  33996. dispose(): void;
  33997. }
  33998. /** Interface defining initialization parameters for Scene class */
  33999. export interface SceneOptions {
  34000. /**
  34001. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34002. * It will improve performance when the number of geometries becomes important.
  34003. */
  34004. useGeometryUniqueIdsMap?: boolean;
  34005. /**
  34006. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34007. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34008. */
  34009. useMaterialMeshMap?: boolean;
  34010. /**
  34011. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34012. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34013. */
  34014. useClonedMeshhMap?: boolean;
  34015. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34016. virtual?: boolean;
  34017. }
  34018. /**
  34019. * Represents a scene to be rendered by the engine.
  34020. * @see http://doc.babylonjs.com/features/scene
  34021. */
  34022. export class Scene extends AbstractScene implements IAnimatable {
  34023. /** The fog is deactivated */
  34024. static readonly FOGMODE_NONE: number;
  34025. /** The fog density is following an exponential function */
  34026. static readonly FOGMODE_EXP: number;
  34027. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34028. static readonly FOGMODE_EXP2: number;
  34029. /** The fog density is following a linear function. */
  34030. static readonly FOGMODE_LINEAR: number;
  34031. /**
  34032. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34033. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34034. */
  34035. static MinDeltaTime: number;
  34036. /**
  34037. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34038. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34039. */
  34040. static MaxDeltaTime: number;
  34041. /**
  34042. * Factory used to create the default material.
  34043. * @param name The name of the material to create
  34044. * @param scene The scene to create the material for
  34045. * @returns The default material
  34046. */
  34047. static DefaultMaterialFactory(scene: Scene): Material;
  34048. /**
  34049. * Factory used to create the a collision coordinator.
  34050. * @returns The collision coordinator
  34051. */
  34052. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34053. /** @hidden */
  34054. _inputManager: InputManager;
  34055. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34056. cameraToUseForPointers: Nullable<Camera>;
  34057. /** @hidden */
  34058. readonly _isScene: boolean;
  34059. /**
  34060. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34061. */
  34062. autoClear: boolean;
  34063. /**
  34064. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34065. */
  34066. autoClearDepthAndStencil: boolean;
  34067. /**
  34068. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34069. */
  34070. clearColor: Color4;
  34071. /**
  34072. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34073. */
  34074. ambientColor: Color3;
  34075. /**
  34076. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34077. * It should only be one of the following (if not the default embedded one):
  34078. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34079. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34080. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34081. * The material properties need to be setup according to the type of texture in use.
  34082. */
  34083. environmentBRDFTexture: BaseTexture;
  34084. /** @hidden */
  34085. protected _environmentTexture: Nullable<BaseTexture>;
  34086. /**
  34087. * Texture used in all pbr material as the reflection texture.
  34088. * As in the majority of the scene they are the same (exception for multi room and so on),
  34089. * this is easier to reference from here than from all the materials.
  34090. */
  34091. /**
  34092. * Texture used in all pbr material as the reflection texture.
  34093. * As in the majority of the scene they are the same (exception for multi room and so on),
  34094. * this is easier to set here than in all the materials.
  34095. */
  34096. environmentTexture: Nullable<BaseTexture>;
  34097. /** @hidden */
  34098. protected _environmentIntensity: number;
  34099. /**
  34100. * Intensity of the environment in all pbr material.
  34101. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34102. * As in the majority of the scene they are the same (exception for multi room and so on),
  34103. * this is easier to reference from here than from all the materials.
  34104. */
  34105. /**
  34106. * Intensity of the environment in all pbr material.
  34107. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34108. * As in the majority of the scene they are the same (exception for multi room and so on),
  34109. * this is easier to set here than in all the materials.
  34110. */
  34111. environmentIntensity: number;
  34112. /** @hidden */
  34113. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34114. /**
  34115. * Default image processing configuration used either in the rendering
  34116. * Forward main pass or through the imageProcessingPostProcess if present.
  34117. * As in the majority of the scene they are the same (exception for multi camera),
  34118. * this is easier to reference from here than from all the materials and post process.
  34119. *
  34120. * No setter as we it is a shared configuration, you can set the values instead.
  34121. */
  34122. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34123. private _forceWireframe;
  34124. /**
  34125. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34126. */
  34127. forceWireframe: boolean;
  34128. private _forcePointsCloud;
  34129. /**
  34130. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34131. */
  34132. forcePointsCloud: boolean;
  34133. /**
  34134. * Gets or sets the active clipplane 1
  34135. */
  34136. clipPlane: Nullable<Plane>;
  34137. /**
  34138. * Gets or sets the active clipplane 2
  34139. */
  34140. clipPlane2: Nullable<Plane>;
  34141. /**
  34142. * Gets or sets the active clipplane 3
  34143. */
  34144. clipPlane3: Nullable<Plane>;
  34145. /**
  34146. * Gets or sets the active clipplane 4
  34147. */
  34148. clipPlane4: Nullable<Plane>;
  34149. /**
  34150. * Gets or sets a boolean indicating if animations are enabled
  34151. */
  34152. animationsEnabled: boolean;
  34153. private _animationPropertiesOverride;
  34154. /**
  34155. * Gets or sets the animation properties override
  34156. */
  34157. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34158. /**
  34159. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34160. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34161. */
  34162. useConstantAnimationDeltaTime: boolean;
  34163. /**
  34164. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34165. * Please note that it requires to run a ray cast through the scene on every frame
  34166. */
  34167. constantlyUpdateMeshUnderPointer: boolean;
  34168. /**
  34169. * Defines the HTML cursor to use when hovering over interactive elements
  34170. */
  34171. hoverCursor: string;
  34172. /**
  34173. * Defines the HTML default cursor to use (empty by default)
  34174. */
  34175. defaultCursor: string;
  34176. /**
  34177. * This is used to call preventDefault() on pointer down
  34178. * in order to block unwanted artifacts like system double clicks
  34179. */
  34180. preventDefaultOnPointerDown: boolean;
  34181. /**
  34182. * This is used to call preventDefault() on pointer up
  34183. * in order to block unwanted artifacts like system double clicks
  34184. */
  34185. preventDefaultOnPointerUp: boolean;
  34186. /**
  34187. * Gets or sets user defined metadata
  34188. */
  34189. metadata: any;
  34190. /**
  34191. * For internal use only. Please do not use.
  34192. */
  34193. reservedDataStore: any;
  34194. /**
  34195. * Gets the name of the plugin used to load this scene (null by default)
  34196. */
  34197. loadingPluginName: string;
  34198. /**
  34199. * Use this array to add regular expressions used to disable offline support for specific urls
  34200. */
  34201. disableOfflineSupportExceptionRules: RegExp[];
  34202. /**
  34203. * An event triggered when the scene is disposed.
  34204. */
  34205. onDisposeObservable: Observable<Scene>;
  34206. private _onDisposeObserver;
  34207. /** Sets a function to be executed when this scene is disposed. */
  34208. onDispose: () => void;
  34209. /**
  34210. * An event triggered before rendering the scene (right after animations and physics)
  34211. */
  34212. onBeforeRenderObservable: Observable<Scene>;
  34213. private _onBeforeRenderObserver;
  34214. /** Sets a function to be executed before rendering this scene */
  34215. beforeRender: Nullable<() => void>;
  34216. /**
  34217. * An event triggered after rendering the scene
  34218. */
  34219. onAfterRenderObservable: Observable<Scene>;
  34220. /**
  34221. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34222. */
  34223. onAfterRenderCameraObservable: Observable<Camera>;
  34224. private _onAfterRenderObserver;
  34225. /** Sets a function to be executed after rendering this scene */
  34226. afterRender: Nullable<() => void>;
  34227. /**
  34228. * An event triggered before animating the scene
  34229. */
  34230. onBeforeAnimationsObservable: Observable<Scene>;
  34231. /**
  34232. * An event triggered after animations processing
  34233. */
  34234. onAfterAnimationsObservable: Observable<Scene>;
  34235. /**
  34236. * An event triggered before draw calls are ready to be sent
  34237. */
  34238. onBeforeDrawPhaseObservable: Observable<Scene>;
  34239. /**
  34240. * An event triggered after draw calls have been sent
  34241. */
  34242. onAfterDrawPhaseObservable: Observable<Scene>;
  34243. /**
  34244. * An event triggered when the scene is ready
  34245. */
  34246. onReadyObservable: Observable<Scene>;
  34247. /**
  34248. * An event triggered before rendering a camera
  34249. */
  34250. onBeforeCameraRenderObservable: Observable<Camera>;
  34251. private _onBeforeCameraRenderObserver;
  34252. /** Sets a function to be executed before rendering a camera*/
  34253. beforeCameraRender: () => void;
  34254. /**
  34255. * An event triggered after rendering a camera
  34256. */
  34257. onAfterCameraRenderObservable: Observable<Camera>;
  34258. private _onAfterCameraRenderObserver;
  34259. /** Sets a function to be executed after rendering a camera*/
  34260. afterCameraRender: () => void;
  34261. /**
  34262. * An event triggered when active meshes evaluation is about to start
  34263. */
  34264. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34265. /**
  34266. * An event triggered when active meshes evaluation is done
  34267. */
  34268. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34269. /**
  34270. * An event triggered when particles rendering is about to start
  34271. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34272. */
  34273. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34274. /**
  34275. * An event triggered when particles rendering is done
  34276. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34277. */
  34278. onAfterParticlesRenderingObservable: Observable<Scene>;
  34279. /**
  34280. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34281. */
  34282. onDataLoadedObservable: Observable<Scene>;
  34283. /**
  34284. * An event triggered when a camera is created
  34285. */
  34286. onNewCameraAddedObservable: Observable<Camera>;
  34287. /**
  34288. * An event triggered when a camera is removed
  34289. */
  34290. onCameraRemovedObservable: Observable<Camera>;
  34291. /**
  34292. * An event triggered when a light is created
  34293. */
  34294. onNewLightAddedObservable: Observable<Light>;
  34295. /**
  34296. * An event triggered when a light is removed
  34297. */
  34298. onLightRemovedObservable: Observable<Light>;
  34299. /**
  34300. * An event triggered when a geometry is created
  34301. */
  34302. onNewGeometryAddedObservable: Observable<Geometry>;
  34303. /**
  34304. * An event triggered when a geometry is removed
  34305. */
  34306. onGeometryRemovedObservable: Observable<Geometry>;
  34307. /**
  34308. * An event triggered when a transform node is created
  34309. */
  34310. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34311. /**
  34312. * An event triggered when a transform node is removed
  34313. */
  34314. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34315. /**
  34316. * An event triggered when a mesh is created
  34317. */
  34318. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34319. /**
  34320. * An event triggered when a mesh is removed
  34321. */
  34322. onMeshRemovedObservable: Observable<AbstractMesh>;
  34323. /**
  34324. * An event triggered when a skeleton is created
  34325. */
  34326. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34327. /**
  34328. * An event triggered when a skeleton is removed
  34329. */
  34330. onSkeletonRemovedObservable: Observable<Skeleton>;
  34331. /**
  34332. * An event triggered when a material is created
  34333. */
  34334. onNewMaterialAddedObservable: Observable<Material>;
  34335. /**
  34336. * An event triggered when a material is removed
  34337. */
  34338. onMaterialRemovedObservable: Observable<Material>;
  34339. /**
  34340. * An event triggered when a texture is created
  34341. */
  34342. onNewTextureAddedObservable: Observable<BaseTexture>;
  34343. /**
  34344. * An event triggered when a texture is removed
  34345. */
  34346. onTextureRemovedObservable: Observable<BaseTexture>;
  34347. /**
  34348. * An event triggered when render targets are about to be rendered
  34349. * Can happen multiple times per frame.
  34350. */
  34351. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34352. /**
  34353. * An event triggered when render targets were rendered.
  34354. * Can happen multiple times per frame.
  34355. */
  34356. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34357. /**
  34358. * An event triggered before calculating deterministic simulation step
  34359. */
  34360. onBeforeStepObservable: Observable<Scene>;
  34361. /**
  34362. * An event triggered after calculating deterministic simulation step
  34363. */
  34364. onAfterStepObservable: Observable<Scene>;
  34365. /**
  34366. * An event triggered when the activeCamera property is updated
  34367. */
  34368. onActiveCameraChanged: Observable<Scene>;
  34369. /**
  34370. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34371. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34372. * 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)
  34373. */
  34374. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34375. /**
  34376. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34377. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34378. * 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)
  34379. */
  34380. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34381. /**
  34382. * This Observable will when a mesh has been imported into the scene.
  34383. */
  34384. onMeshImportedObservable: Observable<AbstractMesh>;
  34385. /**
  34386. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34387. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34388. */
  34389. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34390. /** @hidden */
  34391. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34392. /**
  34393. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34394. */
  34395. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34396. /**
  34397. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34398. */
  34399. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34400. /**
  34401. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34402. */
  34403. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34404. /** Callback called when a pointer move is detected */
  34405. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34406. /** Callback called when a pointer down is detected */
  34407. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34408. /** Callback called when a pointer up is detected */
  34409. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34410. /** Callback called when a pointer pick is detected */
  34411. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34412. /**
  34413. * 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).
  34414. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34415. */
  34416. onPrePointerObservable: Observable<PointerInfoPre>;
  34417. /**
  34418. * Observable event triggered each time an input event is received from the rendering canvas
  34419. */
  34420. onPointerObservable: Observable<PointerInfo>;
  34421. /**
  34422. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34423. */
  34424. readonly unTranslatedPointer: Vector2;
  34425. /**
  34426. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34427. */
  34428. static DragMovementThreshold: number;
  34429. /**
  34430. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34431. */
  34432. static LongPressDelay: number;
  34433. /**
  34434. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34435. */
  34436. static DoubleClickDelay: number;
  34437. /** If you need to check double click without raising a single click at first click, enable this flag */
  34438. static ExclusiveDoubleClickMode: boolean;
  34439. /** @hidden */
  34440. _mirroredCameraPosition: Nullable<Vector3>;
  34441. /**
  34442. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34443. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34444. */
  34445. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34446. /**
  34447. * Observable event triggered each time an keyboard event is received from the hosting window
  34448. */
  34449. onKeyboardObservable: Observable<KeyboardInfo>;
  34450. private _useRightHandedSystem;
  34451. /**
  34452. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34453. */
  34454. useRightHandedSystem: boolean;
  34455. private _timeAccumulator;
  34456. private _currentStepId;
  34457. private _currentInternalStep;
  34458. /**
  34459. * Sets the step Id used by deterministic lock step
  34460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34461. * @param newStepId defines the step Id
  34462. */
  34463. setStepId(newStepId: number): void;
  34464. /**
  34465. * Gets the step Id used by deterministic lock step
  34466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34467. * @returns the step Id
  34468. */
  34469. getStepId(): number;
  34470. /**
  34471. * Gets the internal step used by deterministic lock step
  34472. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34473. * @returns the internal step
  34474. */
  34475. getInternalStep(): number;
  34476. private _fogEnabled;
  34477. /**
  34478. * Gets or sets a boolean indicating if fog is enabled on this scene
  34479. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34480. * (Default is true)
  34481. */
  34482. fogEnabled: boolean;
  34483. private _fogMode;
  34484. /**
  34485. * Gets or sets the fog mode to use
  34486. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34487. * | mode | value |
  34488. * | --- | --- |
  34489. * | FOGMODE_NONE | 0 |
  34490. * | FOGMODE_EXP | 1 |
  34491. * | FOGMODE_EXP2 | 2 |
  34492. * | FOGMODE_LINEAR | 3 |
  34493. */
  34494. fogMode: number;
  34495. /**
  34496. * Gets or sets the fog color to use
  34497. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34498. * (Default is Color3(0.2, 0.2, 0.3))
  34499. */
  34500. fogColor: Color3;
  34501. /**
  34502. * Gets or sets the fog density to use
  34503. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34504. * (Default is 0.1)
  34505. */
  34506. fogDensity: number;
  34507. /**
  34508. * Gets or sets the fog start distance to use
  34509. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34510. * (Default is 0)
  34511. */
  34512. fogStart: number;
  34513. /**
  34514. * Gets or sets the fog end distance to use
  34515. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34516. * (Default is 1000)
  34517. */
  34518. fogEnd: number;
  34519. private _shadowsEnabled;
  34520. /**
  34521. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34522. */
  34523. shadowsEnabled: boolean;
  34524. private _lightsEnabled;
  34525. /**
  34526. * Gets or sets a boolean indicating if lights are enabled on this scene
  34527. */
  34528. lightsEnabled: boolean;
  34529. /** All of the active cameras added to this scene. */
  34530. activeCameras: Camera[];
  34531. /** @hidden */
  34532. _activeCamera: Nullable<Camera>;
  34533. /** Gets or sets the current active camera */
  34534. activeCamera: Nullable<Camera>;
  34535. private _defaultMaterial;
  34536. /** The default material used on meshes when no material is affected */
  34537. /** The default material used on meshes when no material is affected */
  34538. defaultMaterial: Material;
  34539. private _texturesEnabled;
  34540. /**
  34541. * Gets or sets a boolean indicating if textures are enabled on this scene
  34542. */
  34543. texturesEnabled: boolean;
  34544. /**
  34545. * Gets or sets a boolean indicating if particles are enabled on this scene
  34546. */
  34547. particlesEnabled: boolean;
  34548. /**
  34549. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34550. */
  34551. spritesEnabled: boolean;
  34552. private _skeletonsEnabled;
  34553. /**
  34554. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34555. */
  34556. skeletonsEnabled: boolean;
  34557. /**
  34558. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34559. */
  34560. lensFlaresEnabled: boolean;
  34561. /**
  34562. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34563. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34564. */
  34565. collisionsEnabled: boolean;
  34566. private _collisionCoordinator;
  34567. /** @hidden */
  34568. readonly collisionCoordinator: ICollisionCoordinator;
  34569. /**
  34570. * Defines the gravity applied to this scene (used only for collisions)
  34571. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34572. */
  34573. gravity: Vector3;
  34574. /**
  34575. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34576. */
  34577. postProcessesEnabled: boolean;
  34578. /**
  34579. * The list of postprocesses added to the scene
  34580. */
  34581. postProcesses: PostProcess[];
  34582. /**
  34583. * Gets the current postprocess manager
  34584. */
  34585. postProcessManager: PostProcessManager;
  34586. /**
  34587. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34588. */
  34589. renderTargetsEnabled: boolean;
  34590. /**
  34591. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34592. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34593. */
  34594. dumpNextRenderTargets: boolean;
  34595. /**
  34596. * The list of user defined render targets added to the scene
  34597. */
  34598. customRenderTargets: RenderTargetTexture[];
  34599. /**
  34600. * Defines if texture loading must be delayed
  34601. * If true, textures will only be loaded when they need to be rendered
  34602. */
  34603. useDelayedTextureLoading: boolean;
  34604. /**
  34605. * Gets the list of meshes imported to the scene through SceneLoader
  34606. */
  34607. importedMeshesFiles: String[];
  34608. /**
  34609. * Gets or sets a boolean indicating if probes are enabled on this scene
  34610. */
  34611. probesEnabled: boolean;
  34612. /**
  34613. * Gets or sets the current offline provider to use to store scene data
  34614. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34615. */
  34616. offlineProvider: IOfflineProvider;
  34617. /**
  34618. * Gets or sets the action manager associated with the scene
  34619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34620. */
  34621. actionManager: AbstractActionManager;
  34622. private _meshesForIntersections;
  34623. /**
  34624. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34625. */
  34626. proceduralTexturesEnabled: boolean;
  34627. private _engine;
  34628. private _totalVertices;
  34629. /** @hidden */
  34630. _activeIndices: PerfCounter;
  34631. /** @hidden */
  34632. _activeParticles: PerfCounter;
  34633. /** @hidden */
  34634. _activeBones: PerfCounter;
  34635. private _animationRatio;
  34636. /** @hidden */
  34637. _animationTimeLast: number;
  34638. /** @hidden */
  34639. _animationTime: number;
  34640. /**
  34641. * Gets or sets a general scale for animation speed
  34642. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34643. */
  34644. animationTimeScale: number;
  34645. /** @hidden */
  34646. _cachedMaterial: Nullable<Material>;
  34647. /** @hidden */
  34648. _cachedEffect: Nullable<Effect>;
  34649. /** @hidden */
  34650. _cachedVisibility: Nullable<number>;
  34651. private _renderId;
  34652. private _frameId;
  34653. private _executeWhenReadyTimeoutId;
  34654. private _intermediateRendering;
  34655. private _viewUpdateFlag;
  34656. private _projectionUpdateFlag;
  34657. /** @hidden */
  34658. _toBeDisposed: Nullable<IDisposable>[];
  34659. private _activeRequests;
  34660. /** @hidden */
  34661. _pendingData: any[];
  34662. private _isDisposed;
  34663. /**
  34664. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34665. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34666. */
  34667. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34668. private _activeMeshes;
  34669. private _processedMaterials;
  34670. private _renderTargets;
  34671. /** @hidden */
  34672. _activeParticleSystems: SmartArray<IParticleSystem>;
  34673. private _activeSkeletons;
  34674. private _softwareSkinnedMeshes;
  34675. private _renderingManager;
  34676. /** @hidden */
  34677. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34678. private _transformMatrix;
  34679. private _sceneUbo;
  34680. /** @hidden */
  34681. _viewMatrix: Matrix;
  34682. private _projectionMatrix;
  34683. /** @hidden */
  34684. _forcedViewPosition: Nullable<Vector3>;
  34685. /** @hidden */
  34686. _frustumPlanes: Plane[];
  34687. /**
  34688. * Gets the list of frustum planes (built from the active camera)
  34689. */
  34690. readonly frustumPlanes: Plane[];
  34691. /**
  34692. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34693. * This is useful if there are more lights that the maximum simulteanous authorized
  34694. */
  34695. requireLightSorting: boolean;
  34696. /** @hidden */
  34697. readonly useMaterialMeshMap: boolean;
  34698. /** @hidden */
  34699. readonly useClonedMeshhMap: boolean;
  34700. private _externalData;
  34701. private _uid;
  34702. /**
  34703. * @hidden
  34704. * Backing store of defined scene components.
  34705. */
  34706. _components: ISceneComponent[];
  34707. /**
  34708. * @hidden
  34709. * Backing store of defined scene components.
  34710. */
  34711. _serializableComponents: ISceneSerializableComponent[];
  34712. /**
  34713. * List of components to register on the next registration step.
  34714. */
  34715. private _transientComponents;
  34716. /**
  34717. * Registers the transient components if needed.
  34718. */
  34719. private _registerTransientComponents;
  34720. /**
  34721. * @hidden
  34722. * Add a component to the scene.
  34723. * Note that the ccomponent could be registered on th next frame if this is called after
  34724. * the register component stage.
  34725. * @param component Defines the component to add to the scene
  34726. */
  34727. _addComponent(component: ISceneComponent): void;
  34728. /**
  34729. * @hidden
  34730. * Gets a component from the scene.
  34731. * @param name defines the name of the component to retrieve
  34732. * @returns the component or null if not present
  34733. */
  34734. _getComponent(name: string): Nullable<ISceneComponent>;
  34735. /**
  34736. * @hidden
  34737. * Defines the actions happening before camera updates.
  34738. */
  34739. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34740. /**
  34741. * @hidden
  34742. * Defines the actions happening before clear the canvas.
  34743. */
  34744. _beforeClearStage: Stage<SimpleStageAction>;
  34745. /**
  34746. * @hidden
  34747. * Defines the actions when collecting render targets for the frame.
  34748. */
  34749. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34750. /**
  34751. * @hidden
  34752. * Defines the actions happening for one camera in the frame.
  34753. */
  34754. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34755. /**
  34756. * @hidden
  34757. * Defines the actions happening during the per mesh ready checks.
  34758. */
  34759. _isReadyForMeshStage: Stage<MeshStageAction>;
  34760. /**
  34761. * @hidden
  34762. * Defines the actions happening before evaluate active mesh checks.
  34763. */
  34764. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34765. /**
  34766. * @hidden
  34767. * Defines the actions happening during the evaluate sub mesh checks.
  34768. */
  34769. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34770. /**
  34771. * @hidden
  34772. * Defines the actions happening during the active mesh stage.
  34773. */
  34774. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34775. /**
  34776. * @hidden
  34777. * Defines the actions happening during the per camera render target step.
  34778. */
  34779. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34780. /**
  34781. * @hidden
  34782. * Defines the actions happening just before the active camera is drawing.
  34783. */
  34784. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34785. /**
  34786. * @hidden
  34787. * Defines the actions happening just before a render target is drawing.
  34788. */
  34789. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34790. /**
  34791. * @hidden
  34792. * Defines the actions happening just before a rendering group is drawing.
  34793. */
  34794. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34795. /**
  34796. * @hidden
  34797. * Defines the actions happening just before a mesh is drawing.
  34798. */
  34799. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34800. /**
  34801. * @hidden
  34802. * Defines the actions happening just after a mesh has been drawn.
  34803. */
  34804. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34805. /**
  34806. * @hidden
  34807. * Defines the actions happening just after a rendering group has been drawn.
  34808. */
  34809. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34810. /**
  34811. * @hidden
  34812. * Defines the actions happening just after the active camera has been drawn.
  34813. */
  34814. _afterCameraDrawStage: Stage<CameraStageAction>;
  34815. /**
  34816. * @hidden
  34817. * Defines the actions happening just after a render target has been drawn.
  34818. */
  34819. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34820. /**
  34821. * @hidden
  34822. * Defines the actions happening just after rendering all cameras and computing intersections.
  34823. */
  34824. _afterRenderStage: Stage<SimpleStageAction>;
  34825. /**
  34826. * @hidden
  34827. * Defines the actions happening when a pointer move event happens.
  34828. */
  34829. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34830. /**
  34831. * @hidden
  34832. * Defines the actions happening when a pointer down event happens.
  34833. */
  34834. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34835. /**
  34836. * @hidden
  34837. * Defines the actions happening when a pointer up event happens.
  34838. */
  34839. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34840. /**
  34841. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34842. */
  34843. private geometriesByUniqueId;
  34844. /**
  34845. * Creates a new Scene
  34846. * @param engine defines the engine to use to render this scene
  34847. * @param options defines the scene options
  34848. */
  34849. constructor(engine: Engine, options?: SceneOptions);
  34850. /**
  34851. * Gets a string idenfifying the name of the class
  34852. * @returns "Scene" string
  34853. */
  34854. getClassName(): string;
  34855. private _defaultMeshCandidates;
  34856. /**
  34857. * @hidden
  34858. */
  34859. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34860. private _defaultSubMeshCandidates;
  34861. /**
  34862. * @hidden
  34863. */
  34864. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34865. /**
  34866. * Sets the default candidate providers for the scene.
  34867. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34868. * and getCollidingSubMeshCandidates to their default function
  34869. */
  34870. setDefaultCandidateProviders(): void;
  34871. /**
  34872. * Gets the mesh that is currently under the pointer
  34873. */
  34874. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34875. /**
  34876. * Gets or sets the current on-screen X position of the pointer
  34877. */
  34878. pointerX: number;
  34879. /**
  34880. * Gets or sets the current on-screen Y position of the pointer
  34881. */
  34882. pointerY: number;
  34883. /**
  34884. * Gets the cached material (ie. the latest rendered one)
  34885. * @returns the cached material
  34886. */
  34887. getCachedMaterial(): Nullable<Material>;
  34888. /**
  34889. * Gets the cached effect (ie. the latest rendered one)
  34890. * @returns the cached effect
  34891. */
  34892. getCachedEffect(): Nullable<Effect>;
  34893. /**
  34894. * Gets the cached visibility state (ie. the latest rendered one)
  34895. * @returns the cached visibility state
  34896. */
  34897. getCachedVisibility(): Nullable<number>;
  34898. /**
  34899. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34900. * @param material defines the current material
  34901. * @param effect defines the current effect
  34902. * @param visibility defines the current visibility state
  34903. * @returns true if one parameter is not cached
  34904. */
  34905. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34906. /**
  34907. * Gets the engine associated with the scene
  34908. * @returns an Engine
  34909. */
  34910. getEngine(): Engine;
  34911. /**
  34912. * Gets the total number of vertices rendered per frame
  34913. * @returns the total number of vertices rendered per frame
  34914. */
  34915. getTotalVertices(): number;
  34916. /**
  34917. * Gets the performance counter for total vertices
  34918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34919. */
  34920. readonly totalVerticesPerfCounter: PerfCounter;
  34921. /**
  34922. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34923. * @returns the total number of active indices rendered per frame
  34924. */
  34925. getActiveIndices(): number;
  34926. /**
  34927. * Gets the performance counter for active indices
  34928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34929. */
  34930. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34931. /**
  34932. * Gets the total number of active particles rendered per frame
  34933. * @returns the total number of active particles rendered per frame
  34934. */
  34935. getActiveParticles(): number;
  34936. /**
  34937. * Gets the performance counter for active particles
  34938. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34939. */
  34940. readonly activeParticlesPerfCounter: PerfCounter;
  34941. /**
  34942. * Gets the total number of active bones rendered per frame
  34943. * @returns the total number of active bones rendered per frame
  34944. */
  34945. getActiveBones(): number;
  34946. /**
  34947. * Gets the performance counter for active bones
  34948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34949. */
  34950. readonly activeBonesPerfCounter: PerfCounter;
  34951. /**
  34952. * Gets the array of active meshes
  34953. * @returns an array of AbstractMesh
  34954. */
  34955. getActiveMeshes(): SmartArray<AbstractMesh>;
  34956. /**
  34957. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34958. * @returns a number
  34959. */
  34960. getAnimationRatio(): number;
  34961. /**
  34962. * Gets an unique Id for the current render phase
  34963. * @returns a number
  34964. */
  34965. getRenderId(): number;
  34966. /**
  34967. * Gets an unique Id for the current frame
  34968. * @returns a number
  34969. */
  34970. getFrameId(): number;
  34971. /** Call this function if you want to manually increment the render Id*/
  34972. incrementRenderId(): void;
  34973. private _createUbo;
  34974. /**
  34975. * Use this method to simulate a pointer move on a mesh
  34976. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34977. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34978. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34979. * @returns the current scene
  34980. */
  34981. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34982. /**
  34983. * Use this method to simulate a pointer down on a mesh
  34984. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34985. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34986. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34987. * @returns the current scene
  34988. */
  34989. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34990. /**
  34991. * Use this method to simulate a pointer up on a mesh
  34992. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34993. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34994. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34995. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34996. * @returns the current scene
  34997. */
  34998. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34999. /**
  35000. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35001. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35002. * @returns true if the pointer was captured
  35003. */
  35004. isPointerCaptured(pointerId?: number): boolean;
  35005. /**
  35006. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35007. * @param attachUp defines if you want to attach events to pointerup
  35008. * @param attachDown defines if you want to attach events to pointerdown
  35009. * @param attachMove defines if you want to attach events to pointermove
  35010. */
  35011. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35012. /** Detaches all event handlers*/
  35013. detachControl(): void;
  35014. /**
  35015. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35016. * Delay loaded resources are not taking in account
  35017. * @return true if all required resources are ready
  35018. */
  35019. isReady(): boolean;
  35020. /** Resets all cached information relative to material (including effect and visibility) */
  35021. resetCachedMaterial(): void;
  35022. /**
  35023. * Registers a function to be called before every frame render
  35024. * @param func defines the function to register
  35025. */
  35026. registerBeforeRender(func: () => void): void;
  35027. /**
  35028. * Unregisters a function called before every frame render
  35029. * @param func defines the function to unregister
  35030. */
  35031. unregisterBeforeRender(func: () => void): void;
  35032. /**
  35033. * Registers a function to be called after every frame render
  35034. * @param func defines the function to register
  35035. */
  35036. registerAfterRender(func: () => void): void;
  35037. /**
  35038. * Unregisters a function called after every frame render
  35039. * @param func defines the function to unregister
  35040. */
  35041. unregisterAfterRender(func: () => void): void;
  35042. private _executeOnceBeforeRender;
  35043. /**
  35044. * The provided function will run before render once and will be disposed afterwards.
  35045. * A timeout delay can be provided so that the function will be executed in N ms.
  35046. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35047. * @param func The function to be executed.
  35048. * @param timeout optional delay in ms
  35049. */
  35050. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35051. /** @hidden */
  35052. _addPendingData(data: any): void;
  35053. /** @hidden */
  35054. _removePendingData(data: any): void;
  35055. /**
  35056. * Returns the number of items waiting to be loaded
  35057. * @returns the number of items waiting to be loaded
  35058. */
  35059. getWaitingItemsCount(): number;
  35060. /**
  35061. * Returns a boolean indicating if the scene is still loading data
  35062. */
  35063. readonly isLoading: boolean;
  35064. /**
  35065. * Registers a function to be executed when the scene is ready
  35066. * @param {Function} func - the function to be executed
  35067. */
  35068. executeWhenReady(func: () => void): void;
  35069. /**
  35070. * Returns a promise that resolves when the scene is ready
  35071. * @returns A promise that resolves when the scene is ready
  35072. */
  35073. whenReadyAsync(): Promise<void>;
  35074. /** @hidden */
  35075. _checkIsReady(): void;
  35076. /**
  35077. * Gets all animatable attached to the scene
  35078. */
  35079. readonly animatables: Animatable[];
  35080. /**
  35081. * Resets the last animation time frame.
  35082. * Useful to override when animations start running when loading a scene for the first time.
  35083. */
  35084. resetLastAnimationTimeFrame(): void;
  35085. /**
  35086. * Gets the current view matrix
  35087. * @returns a Matrix
  35088. */
  35089. getViewMatrix(): Matrix;
  35090. /**
  35091. * Gets the current projection matrix
  35092. * @returns a Matrix
  35093. */
  35094. getProjectionMatrix(): Matrix;
  35095. /**
  35096. * Gets the current transform matrix
  35097. * @returns a Matrix made of View * Projection
  35098. */
  35099. getTransformMatrix(): Matrix;
  35100. /**
  35101. * Sets the current transform matrix
  35102. * @param viewL defines the View matrix to use
  35103. * @param projectionL defines the Projection matrix to use
  35104. * @param viewR defines the right View matrix to use (if provided)
  35105. * @param projectionR defines the right Projection matrix to use (if provided)
  35106. */
  35107. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35108. /**
  35109. * Gets the uniform buffer used to store scene data
  35110. * @returns a UniformBuffer
  35111. */
  35112. getSceneUniformBuffer(): UniformBuffer;
  35113. /**
  35114. * Gets an unique (relatively to the current scene) Id
  35115. * @returns an unique number for the scene
  35116. */
  35117. getUniqueId(): number;
  35118. /**
  35119. * Add a mesh to the list of scene's meshes
  35120. * @param newMesh defines the mesh to add
  35121. * @param recursive if all child meshes should also be added to the scene
  35122. */
  35123. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35124. /**
  35125. * Remove a mesh for the list of scene's meshes
  35126. * @param toRemove defines the mesh to remove
  35127. * @param recursive if all child meshes should also be removed from the scene
  35128. * @returns the index where the mesh was in the mesh list
  35129. */
  35130. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35131. /**
  35132. * Add a transform node to the list of scene's transform nodes
  35133. * @param newTransformNode defines the transform node to add
  35134. */
  35135. addTransformNode(newTransformNode: TransformNode): void;
  35136. /**
  35137. * Remove a transform node for the list of scene's transform nodes
  35138. * @param toRemove defines the transform node to remove
  35139. * @returns the index where the transform node was in the transform node list
  35140. */
  35141. removeTransformNode(toRemove: TransformNode): number;
  35142. /**
  35143. * Remove a skeleton for the list of scene's skeletons
  35144. * @param toRemove defines the skeleton to remove
  35145. * @returns the index where the skeleton was in the skeleton list
  35146. */
  35147. removeSkeleton(toRemove: Skeleton): number;
  35148. /**
  35149. * Remove a morph target for the list of scene's morph targets
  35150. * @param toRemove defines the morph target to remove
  35151. * @returns the index where the morph target was in the morph target list
  35152. */
  35153. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35154. /**
  35155. * Remove a light for the list of scene's lights
  35156. * @param toRemove defines the light to remove
  35157. * @returns the index where the light was in the light list
  35158. */
  35159. removeLight(toRemove: Light): number;
  35160. /**
  35161. * Remove a camera for the list of scene's cameras
  35162. * @param toRemove defines the camera to remove
  35163. * @returns the index where the camera was in the camera list
  35164. */
  35165. removeCamera(toRemove: Camera): number;
  35166. /**
  35167. * Remove a particle system for the list of scene's particle systems
  35168. * @param toRemove defines the particle system to remove
  35169. * @returns the index where the particle system was in the particle system list
  35170. */
  35171. removeParticleSystem(toRemove: IParticleSystem): number;
  35172. /**
  35173. * Remove a animation for the list of scene's animations
  35174. * @param toRemove defines the animation to remove
  35175. * @returns the index where the animation was in the animation list
  35176. */
  35177. removeAnimation(toRemove: Animation): number;
  35178. /**
  35179. * Will stop the animation of the given target
  35180. * @param target - the target
  35181. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35182. * @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)
  35183. */
  35184. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35185. /**
  35186. * Removes the given animation group from this scene.
  35187. * @param toRemove The animation group to remove
  35188. * @returns The index of the removed animation group
  35189. */
  35190. removeAnimationGroup(toRemove: AnimationGroup): number;
  35191. /**
  35192. * Removes the given multi-material from this scene.
  35193. * @param toRemove The multi-material to remove
  35194. * @returns The index of the removed multi-material
  35195. */
  35196. removeMultiMaterial(toRemove: MultiMaterial): number;
  35197. /**
  35198. * Removes the given material from this scene.
  35199. * @param toRemove The material to remove
  35200. * @returns The index of the removed material
  35201. */
  35202. removeMaterial(toRemove: Material): number;
  35203. /**
  35204. * Removes the given action manager from this scene.
  35205. * @param toRemove The action manager to remove
  35206. * @returns The index of the removed action manager
  35207. */
  35208. removeActionManager(toRemove: AbstractActionManager): number;
  35209. /**
  35210. * Removes the given texture from this scene.
  35211. * @param toRemove The texture to remove
  35212. * @returns The index of the removed texture
  35213. */
  35214. removeTexture(toRemove: BaseTexture): number;
  35215. /**
  35216. * Adds the given light to this scene
  35217. * @param newLight The light to add
  35218. */
  35219. addLight(newLight: Light): void;
  35220. /**
  35221. * Sorts the list list based on light priorities
  35222. */
  35223. sortLightsByPriority(): void;
  35224. /**
  35225. * Adds the given camera to this scene
  35226. * @param newCamera The camera to add
  35227. */
  35228. addCamera(newCamera: Camera): void;
  35229. /**
  35230. * Adds the given skeleton to this scene
  35231. * @param newSkeleton The skeleton to add
  35232. */
  35233. addSkeleton(newSkeleton: Skeleton): void;
  35234. /**
  35235. * Adds the given particle system to this scene
  35236. * @param newParticleSystem The particle system to add
  35237. */
  35238. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35239. /**
  35240. * Adds the given animation to this scene
  35241. * @param newAnimation The animation to add
  35242. */
  35243. addAnimation(newAnimation: Animation): void;
  35244. /**
  35245. * Adds the given animation group to this scene.
  35246. * @param newAnimationGroup The animation group to add
  35247. */
  35248. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35249. /**
  35250. * Adds the given multi-material to this scene
  35251. * @param newMultiMaterial The multi-material to add
  35252. */
  35253. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35254. /**
  35255. * Adds the given material to this scene
  35256. * @param newMaterial The material to add
  35257. */
  35258. addMaterial(newMaterial: Material): void;
  35259. /**
  35260. * Adds the given morph target to this scene
  35261. * @param newMorphTargetManager The morph target to add
  35262. */
  35263. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35264. /**
  35265. * Adds the given geometry to this scene
  35266. * @param newGeometry The geometry to add
  35267. */
  35268. addGeometry(newGeometry: Geometry): void;
  35269. /**
  35270. * Adds the given action manager to this scene
  35271. * @param newActionManager The action manager to add
  35272. */
  35273. addActionManager(newActionManager: AbstractActionManager): void;
  35274. /**
  35275. * Adds the given texture to this scene.
  35276. * @param newTexture The texture to add
  35277. */
  35278. addTexture(newTexture: BaseTexture): void;
  35279. /**
  35280. * Switch active camera
  35281. * @param newCamera defines the new active camera
  35282. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35283. */
  35284. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35285. /**
  35286. * sets the active camera of the scene using its ID
  35287. * @param id defines the camera's ID
  35288. * @return the new active camera or null if none found.
  35289. */
  35290. setActiveCameraByID(id: string): Nullable<Camera>;
  35291. /**
  35292. * sets the active camera of the scene using its name
  35293. * @param name defines the camera's name
  35294. * @returns the new active camera or null if none found.
  35295. */
  35296. setActiveCameraByName(name: string): Nullable<Camera>;
  35297. /**
  35298. * get an animation group using its name
  35299. * @param name defines the material's name
  35300. * @return the animation group or null if none found.
  35301. */
  35302. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35303. /**
  35304. * Get a material using its unique id
  35305. * @param uniqueId defines the material's unique id
  35306. * @return the material or null if none found.
  35307. */
  35308. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35309. /**
  35310. * get a material using its id
  35311. * @param id defines the material's ID
  35312. * @return the material or null if none found.
  35313. */
  35314. getMaterialByID(id: string): Nullable<Material>;
  35315. /**
  35316. * Gets a the last added material using a given id
  35317. * @param id defines the material's ID
  35318. * @return the last material with the given id or null if none found.
  35319. */
  35320. getLastMaterialByID(id: string): Nullable<Material>;
  35321. /**
  35322. * Gets a material using its name
  35323. * @param name defines the material's name
  35324. * @return the material or null if none found.
  35325. */
  35326. getMaterialByName(name: string): Nullable<Material>;
  35327. /**
  35328. * Get a texture using its unique id
  35329. * @param uniqueId defines the texture's unique id
  35330. * @return the texture or null if none found.
  35331. */
  35332. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35333. /**
  35334. * Gets a camera using its id
  35335. * @param id defines the id to look for
  35336. * @returns the camera or null if not found
  35337. */
  35338. getCameraByID(id: string): Nullable<Camera>;
  35339. /**
  35340. * Gets a camera using its unique id
  35341. * @param uniqueId defines the unique id to look for
  35342. * @returns the camera or null if not found
  35343. */
  35344. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35345. /**
  35346. * Gets a camera using its name
  35347. * @param name defines the camera's name
  35348. * @return the camera or null if none found.
  35349. */
  35350. getCameraByName(name: string): Nullable<Camera>;
  35351. /**
  35352. * Gets a bone using its id
  35353. * @param id defines the bone's id
  35354. * @return the bone or null if not found
  35355. */
  35356. getBoneByID(id: string): Nullable<Bone>;
  35357. /**
  35358. * Gets a bone using its id
  35359. * @param name defines the bone's name
  35360. * @return the bone or null if not found
  35361. */
  35362. getBoneByName(name: string): Nullable<Bone>;
  35363. /**
  35364. * Gets a light node using its name
  35365. * @param name defines the the light's name
  35366. * @return the light or null if none found.
  35367. */
  35368. getLightByName(name: string): Nullable<Light>;
  35369. /**
  35370. * Gets a light node using its id
  35371. * @param id defines the light's id
  35372. * @return the light or null if none found.
  35373. */
  35374. getLightByID(id: string): Nullable<Light>;
  35375. /**
  35376. * Gets a light node using its scene-generated unique ID
  35377. * @param uniqueId defines the light's unique id
  35378. * @return the light or null if none found.
  35379. */
  35380. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35381. /**
  35382. * Gets a particle system by id
  35383. * @param id defines the particle system id
  35384. * @return the corresponding system or null if none found
  35385. */
  35386. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35387. /**
  35388. * Gets a geometry using its ID
  35389. * @param id defines the geometry's id
  35390. * @return the geometry or null if none found.
  35391. */
  35392. getGeometryByID(id: string): Nullable<Geometry>;
  35393. private _getGeometryByUniqueID;
  35394. /**
  35395. * Add a new geometry to this scene
  35396. * @param geometry defines the geometry to be added to the scene.
  35397. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35398. * @return a boolean defining if the geometry was added or not
  35399. */
  35400. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35401. /**
  35402. * Removes an existing geometry
  35403. * @param geometry defines the geometry to be removed from the scene
  35404. * @return a boolean defining if the geometry was removed or not
  35405. */
  35406. removeGeometry(geometry: Geometry): boolean;
  35407. /**
  35408. * Gets the list of geometries attached to the scene
  35409. * @returns an array of Geometry
  35410. */
  35411. getGeometries(): Geometry[];
  35412. /**
  35413. * Gets the first added mesh found of a given ID
  35414. * @param id defines the id to search for
  35415. * @return the mesh found or null if not found at all
  35416. */
  35417. getMeshByID(id: string): Nullable<AbstractMesh>;
  35418. /**
  35419. * Gets a list of meshes using their id
  35420. * @param id defines the id to search for
  35421. * @returns a list of meshes
  35422. */
  35423. getMeshesByID(id: string): Array<AbstractMesh>;
  35424. /**
  35425. * Gets the first added transform node found of a given ID
  35426. * @param id defines the id to search for
  35427. * @return the found transform node or null if not found at all.
  35428. */
  35429. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35430. /**
  35431. * Gets a transform node with its auto-generated unique id
  35432. * @param uniqueId efines the unique id to search for
  35433. * @return the found transform node or null if not found at all.
  35434. */
  35435. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35436. /**
  35437. * Gets a list of transform nodes using their id
  35438. * @param id defines the id to search for
  35439. * @returns a list of transform nodes
  35440. */
  35441. getTransformNodesByID(id: string): Array<TransformNode>;
  35442. /**
  35443. * Gets a mesh with its auto-generated unique id
  35444. * @param uniqueId defines the unique id to search for
  35445. * @return the found mesh or null if not found at all.
  35446. */
  35447. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35448. /**
  35449. * Gets a the last added mesh using a given id
  35450. * @param id defines the id to search for
  35451. * @return the found mesh or null if not found at all.
  35452. */
  35453. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35454. /**
  35455. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35456. * @param id defines the id to search for
  35457. * @return the found node or null if not found at all
  35458. */
  35459. getLastEntryByID(id: string): Nullable<Node>;
  35460. /**
  35461. * Gets a node (Mesh, Camera, Light) using a given id
  35462. * @param id defines the id to search for
  35463. * @return the found node or null if not found at all
  35464. */
  35465. getNodeByID(id: string): Nullable<Node>;
  35466. /**
  35467. * Gets a node (Mesh, Camera, Light) using a given name
  35468. * @param name defines the name to search for
  35469. * @return the found node or null if not found at all.
  35470. */
  35471. getNodeByName(name: string): Nullable<Node>;
  35472. /**
  35473. * Gets a mesh using a given name
  35474. * @param name defines the name to search for
  35475. * @return the found mesh or null if not found at all.
  35476. */
  35477. getMeshByName(name: string): Nullable<AbstractMesh>;
  35478. /**
  35479. * Gets a transform node using a given name
  35480. * @param name defines the name to search for
  35481. * @return the found transform node or null if not found at all.
  35482. */
  35483. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35484. /**
  35485. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35486. * @param id defines the id to search for
  35487. * @return the found skeleton or null if not found at all.
  35488. */
  35489. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35490. /**
  35491. * Gets a skeleton using a given auto generated unique id
  35492. * @param uniqueId defines the unique id to search for
  35493. * @return the found skeleton or null if not found at all.
  35494. */
  35495. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35496. /**
  35497. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35498. * @param id defines the id to search for
  35499. * @return the found skeleton or null if not found at all.
  35500. */
  35501. getSkeletonById(id: string): Nullable<Skeleton>;
  35502. /**
  35503. * Gets a skeleton using a given name
  35504. * @param name defines the name to search for
  35505. * @return the found skeleton or null if not found at all.
  35506. */
  35507. getSkeletonByName(name: string): Nullable<Skeleton>;
  35508. /**
  35509. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35510. * @param id defines the id to search for
  35511. * @return the found morph target manager or null if not found at all.
  35512. */
  35513. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35514. /**
  35515. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35516. * @param id defines the id to search for
  35517. * @return the found morph target or null if not found at all.
  35518. */
  35519. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35520. /**
  35521. * Gets a boolean indicating if the given mesh is active
  35522. * @param mesh defines the mesh to look for
  35523. * @returns true if the mesh is in the active list
  35524. */
  35525. isActiveMesh(mesh: AbstractMesh): boolean;
  35526. /**
  35527. * Return a unique id as a string which can serve as an identifier for the scene
  35528. */
  35529. readonly uid: string;
  35530. /**
  35531. * Add an externaly attached data from its key.
  35532. * This method call will fail and return false, if such key already exists.
  35533. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35534. * @param key the unique key that identifies the data
  35535. * @param data the data object to associate to the key for this Engine instance
  35536. * @return true if no such key were already present and the data was added successfully, false otherwise
  35537. */
  35538. addExternalData<T>(key: string, data: T): boolean;
  35539. /**
  35540. * Get an externaly attached data from its key
  35541. * @param key the unique key that identifies the data
  35542. * @return the associated data, if present (can be null), or undefined if not present
  35543. */
  35544. getExternalData<T>(key: string): Nullable<T>;
  35545. /**
  35546. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35547. * @param key the unique key that identifies the data
  35548. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35549. * @return the associated data, can be null if the factory returned null.
  35550. */
  35551. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35552. /**
  35553. * Remove an externaly attached data from the Engine instance
  35554. * @param key the unique key that identifies the data
  35555. * @return true if the data was successfully removed, false if it doesn't exist
  35556. */
  35557. removeExternalData(key: string): boolean;
  35558. private _evaluateSubMesh;
  35559. /**
  35560. * Clear the processed materials smart array preventing retention point in material dispose.
  35561. */
  35562. freeProcessedMaterials(): void;
  35563. private _preventFreeActiveMeshesAndRenderingGroups;
  35564. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35565. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35566. * when disposing several meshes in a row or a hierarchy of meshes.
  35567. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35568. */
  35569. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35570. /**
  35571. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35572. */
  35573. freeActiveMeshes(): void;
  35574. /**
  35575. * Clear the info related to rendering groups preventing retention points during dispose.
  35576. */
  35577. freeRenderingGroups(): void;
  35578. /** @hidden */
  35579. _isInIntermediateRendering(): boolean;
  35580. /**
  35581. * Lambda returning the list of potentially active meshes.
  35582. */
  35583. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35584. /**
  35585. * Lambda returning the list of potentially active sub meshes.
  35586. */
  35587. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35588. /**
  35589. * Lambda returning the list of potentially intersecting sub meshes.
  35590. */
  35591. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35592. /**
  35593. * Lambda returning the list of potentially colliding sub meshes.
  35594. */
  35595. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35596. private _activeMeshesFrozen;
  35597. /**
  35598. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35599. * @returns the current scene
  35600. */
  35601. freezeActiveMeshes(): Scene;
  35602. /**
  35603. * Use this function to restart evaluating active meshes on every frame
  35604. * @returns the current scene
  35605. */
  35606. unfreezeActiveMeshes(): Scene;
  35607. private _evaluateActiveMeshes;
  35608. private _activeMesh;
  35609. /**
  35610. * Update the transform matrix to update from the current active camera
  35611. * @param force defines a boolean used to force the update even if cache is up to date
  35612. */
  35613. updateTransformMatrix(force?: boolean): void;
  35614. private _bindFrameBuffer;
  35615. /** @hidden */
  35616. _allowPostProcessClearColor: boolean;
  35617. /** @hidden */
  35618. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35619. private _processSubCameras;
  35620. private _checkIntersections;
  35621. /** @hidden */
  35622. _advancePhysicsEngineStep(step: number): void;
  35623. /**
  35624. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35625. */
  35626. getDeterministicFrameTime: () => number;
  35627. /** @hidden */
  35628. _animate(): void;
  35629. /** Execute all animations (for a frame) */
  35630. animate(): void;
  35631. /**
  35632. * Render the scene
  35633. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35634. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35635. */
  35636. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35637. /**
  35638. * Freeze all materials
  35639. * A frozen material will not be updatable but should be faster to render
  35640. */
  35641. freezeMaterials(): void;
  35642. /**
  35643. * Unfreeze all materials
  35644. * A frozen material will not be updatable but should be faster to render
  35645. */
  35646. unfreezeMaterials(): void;
  35647. /**
  35648. * Releases all held ressources
  35649. */
  35650. dispose(): void;
  35651. /**
  35652. * Gets if the scene is already disposed
  35653. */
  35654. readonly isDisposed: boolean;
  35655. /**
  35656. * Call this function to reduce memory footprint of the scene.
  35657. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35658. */
  35659. clearCachedVertexData(): void;
  35660. /**
  35661. * This function will remove the local cached buffer data from texture.
  35662. * It will save memory but will prevent the texture from being rebuilt
  35663. */
  35664. cleanCachedTextureBuffer(): void;
  35665. /**
  35666. * Get the world extend vectors with an optional filter
  35667. *
  35668. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35669. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35670. */
  35671. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35672. min: Vector3;
  35673. max: Vector3;
  35674. };
  35675. /**
  35676. * Creates a ray that can be used to pick in the scene
  35677. * @param x defines the x coordinate of the origin (on-screen)
  35678. * @param y defines the y coordinate of the origin (on-screen)
  35679. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35680. * @param camera defines the camera to use for the picking
  35681. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35682. * @returns a Ray
  35683. */
  35684. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35685. /**
  35686. * Creates a ray that can be used to pick in the scene
  35687. * @param x defines the x coordinate of the origin (on-screen)
  35688. * @param y defines the y coordinate of the origin (on-screen)
  35689. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35690. * @param result defines the ray where to store the picking ray
  35691. * @param camera defines the camera to use for the picking
  35692. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35693. * @returns the current scene
  35694. */
  35695. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35696. /**
  35697. * Creates a ray that can be used to pick in the scene
  35698. * @param x defines the x coordinate of the origin (on-screen)
  35699. * @param y defines the y coordinate of the origin (on-screen)
  35700. * @param camera defines the camera to use for the picking
  35701. * @returns a Ray
  35702. */
  35703. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35704. /**
  35705. * Creates a ray that can be used to pick in the scene
  35706. * @param x defines the x coordinate of the origin (on-screen)
  35707. * @param y defines the y coordinate of the origin (on-screen)
  35708. * @param result defines the ray where to store the picking ray
  35709. * @param camera defines the camera to use for the picking
  35710. * @returns the current scene
  35711. */
  35712. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35713. /** Launch a ray to try to pick a mesh in the scene
  35714. * @param x position on screen
  35715. * @param y position on screen
  35716. * @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
  35717. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35718. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35719. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35720. * @returns a PickingInfo
  35721. */
  35722. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35723. /** Use the given ray to pick a mesh in the scene
  35724. * @param ray The ray to use to pick meshes
  35725. * @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
  35726. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35728. * @returns a PickingInfo
  35729. */
  35730. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35731. /**
  35732. * Launch a ray to try to pick a mesh in the scene
  35733. * @param x X position on screen
  35734. * @param y Y position on screen
  35735. * @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
  35736. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35737. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35738. * @returns an array of PickingInfo
  35739. */
  35740. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35741. /**
  35742. * Launch a ray to try to pick a mesh in the scene
  35743. * @param ray Ray to use
  35744. * @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
  35745. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35746. * @returns an array of PickingInfo
  35747. */
  35748. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35749. /**
  35750. * Force the value of meshUnderPointer
  35751. * @param mesh defines the mesh to use
  35752. */
  35753. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35754. /**
  35755. * Gets the mesh under the pointer
  35756. * @returns a Mesh or null if no mesh is under the pointer
  35757. */
  35758. getPointerOverMesh(): Nullable<AbstractMesh>;
  35759. /** @hidden */
  35760. _rebuildGeometries(): void;
  35761. /** @hidden */
  35762. _rebuildTextures(): void;
  35763. private _getByTags;
  35764. /**
  35765. * Get a list of meshes by tags
  35766. * @param tagsQuery defines the tags query to use
  35767. * @param forEach defines a predicate used to filter results
  35768. * @returns an array of Mesh
  35769. */
  35770. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35771. /**
  35772. * Get a list of cameras by tags
  35773. * @param tagsQuery defines the tags query to use
  35774. * @param forEach defines a predicate used to filter results
  35775. * @returns an array of Camera
  35776. */
  35777. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35778. /**
  35779. * Get a list of lights by tags
  35780. * @param tagsQuery defines the tags query to use
  35781. * @param forEach defines a predicate used to filter results
  35782. * @returns an array of Light
  35783. */
  35784. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35785. /**
  35786. * Get a list of materials by tags
  35787. * @param tagsQuery defines the tags query to use
  35788. * @param forEach defines a predicate used to filter results
  35789. * @returns an array of Material
  35790. */
  35791. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35792. /**
  35793. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35794. * This allowed control for front to back rendering or reversly depending of the special needs.
  35795. *
  35796. * @param renderingGroupId The rendering group id corresponding to its index
  35797. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35798. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35799. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35800. */
  35801. 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;
  35802. /**
  35803. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35804. *
  35805. * @param renderingGroupId The rendering group id corresponding to its index
  35806. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35807. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35808. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35809. */
  35810. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35811. /**
  35812. * Gets the current auto clear configuration for one rendering group of the rendering
  35813. * manager.
  35814. * @param index the rendering group index to get the information for
  35815. * @returns The auto clear setup for the requested rendering group
  35816. */
  35817. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35818. private _blockMaterialDirtyMechanism;
  35819. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35820. blockMaterialDirtyMechanism: boolean;
  35821. /**
  35822. * Will flag all materials as dirty to trigger new shader compilation
  35823. * @param flag defines the flag used to specify which material part must be marked as dirty
  35824. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35825. */
  35826. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35827. /** @hidden */
  35828. _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;
  35829. /** @hidden */
  35830. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35831. }
  35832. }
  35833. declare module "babylonjs/assetContainer" {
  35834. import { AbstractScene } from "babylonjs/abstractScene";
  35835. import { Scene } from "babylonjs/scene";
  35836. import { Mesh } from "babylonjs/Meshes/mesh";
  35837. /**
  35838. * Set of assets to keep when moving a scene into an asset container.
  35839. */
  35840. export class KeepAssets extends AbstractScene {
  35841. }
  35842. /**
  35843. * Container with a set of assets that can be added or removed from a scene.
  35844. */
  35845. export class AssetContainer extends AbstractScene {
  35846. /**
  35847. * The scene the AssetContainer belongs to.
  35848. */
  35849. scene: Scene;
  35850. /**
  35851. * Instantiates an AssetContainer.
  35852. * @param scene The scene the AssetContainer belongs to.
  35853. */
  35854. constructor(scene: Scene);
  35855. /**
  35856. * Adds all the assets from the container to the scene.
  35857. */
  35858. addAllToScene(): void;
  35859. /**
  35860. * Removes all the assets in the container from the scene
  35861. */
  35862. removeAllFromScene(): void;
  35863. /**
  35864. * Disposes all the assets in the container
  35865. */
  35866. dispose(): void;
  35867. private _moveAssets;
  35868. /**
  35869. * Removes all the assets contained in the scene and adds them to the container.
  35870. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35871. */
  35872. moveAllFromScene(keepAssets?: KeepAssets): void;
  35873. /**
  35874. * 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.
  35875. * @returns the root mesh
  35876. */
  35877. createRootMesh(): Mesh;
  35878. }
  35879. }
  35880. declare module "babylonjs/abstractScene" {
  35881. import { Scene } from "babylonjs/scene";
  35882. import { Nullable } from "babylonjs/types";
  35883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35884. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35885. import { Geometry } from "babylonjs/Meshes/geometry";
  35886. import { Skeleton } from "babylonjs/Bones/skeleton";
  35887. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35888. import { AssetContainer } from "babylonjs/assetContainer";
  35889. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35890. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35892. import { Material } from "babylonjs/Materials/material";
  35893. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35894. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35895. import { Camera } from "babylonjs/Cameras/camera";
  35896. import { Light } from "babylonjs/Lights/light";
  35897. import { Node } from "babylonjs/node";
  35898. import { Animation } from "babylonjs/Animations/animation";
  35899. /**
  35900. * Defines how the parser contract is defined.
  35901. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35902. */
  35903. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35904. /**
  35905. * Defines how the individual parser contract is defined.
  35906. * These parser can parse an individual asset
  35907. */
  35908. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35909. /**
  35910. * Base class of the scene acting as a container for the different elements composing a scene.
  35911. * This class is dynamically extended by the different components of the scene increasing
  35912. * flexibility and reducing coupling
  35913. */
  35914. export abstract class AbstractScene {
  35915. /**
  35916. * Stores the list of available parsers in the application.
  35917. */
  35918. private static _BabylonFileParsers;
  35919. /**
  35920. * Stores the list of available individual parsers in the application.
  35921. */
  35922. private static _IndividualBabylonFileParsers;
  35923. /**
  35924. * Adds a parser in the list of available ones
  35925. * @param name Defines the name of the parser
  35926. * @param parser Defines the parser to add
  35927. */
  35928. static AddParser(name: string, parser: BabylonFileParser): void;
  35929. /**
  35930. * Gets a general parser from the list of avaialble ones
  35931. * @param name Defines the name of the parser
  35932. * @returns the requested parser or null
  35933. */
  35934. static GetParser(name: string): Nullable<BabylonFileParser>;
  35935. /**
  35936. * Adds n individual parser in the list of available ones
  35937. * @param name Defines the name of the parser
  35938. * @param parser Defines the parser to add
  35939. */
  35940. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35941. /**
  35942. * Gets an individual parser from the list of avaialble ones
  35943. * @param name Defines the name of the parser
  35944. * @returns the requested parser or null
  35945. */
  35946. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35947. /**
  35948. * Parser json data and populate both a scene and its associated container object
  35949. * @param jsonData Defines the data to parse
  35950. * @param scene Defines the scene to parse the data for
  35951. * @param container Defines the container attached to the parsing sequence
  35952. * @param rootUrl Defines the root url of the data
  35953. */
  35954. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35955. /**
  35956. * Gets the list of root nodes (ie. nodes with no parent)
  35957. */
  35958. rootNodes: Node[];
  35959. /** All of the cameras added to this scene
  35960. * @see http://doc.babylonjs.com/babylon101/cameras
  35961. */
  35962. cameras: Camera[];
  35963. /**
  35964. * All of the lights added to this scene
  35965. * @see http://doc.babylonjs.com/babylon101/lights
  35966. */
  35967. lights: Light[];
  35968. /**
  35969. * All of the (abstract) meshes added to this scene
  35970. */
  35971. meshes: AbstractMesh[];
  35972. /**
  35973. * The list of skeletons added to the scene
  35974. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35975. */
  35976. skeletons: Skeleton[];
  35977. /**
  35978. * All of the particle systems added to this scene
  35979. * @see http://doc.babylonjs.com/babylon101/particles
  35980. */
  35981. particleSystems: IParticleSystem[];
  35982. /**
  35983. * Gets a list of Animations associated with the scene
  35984. */
  35985. animations: Animation[];
  35986. /**
  35987. * All of the animation groups added to this scene
  35988. * @see http://doc.babylonjs.com/how_to/group
  35989. */
  35990. animationGroups: AnimationGroup[];
  35991. /**
  35992. * All of the multi-materials added to this scene
  35993. * @see http://doc.babylonjs.com/how_to/multi_materials
  35994. */
  35995. multiMaterials: MultiMaterial[];
  35996. /**
  35997. * All of the materials added to this scene
  35998. * In the context of a Scene, it is not supposed to be modified manually.
  35999. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  36000. * Note also that the order of the Material wihin the array is not significant and might change.
  36001. * @see http://doc.babylonjs.com/babylon101/materials
  36002. */
  36003. materials: Material[];
  36004. /**
  36005. * The list of morph target managers added to the scene
  36006. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36007. */
  36008. morphTargetManagers: MorphTargetManager[];
  36009. /**
  36010. * The list of geometries used in the scene.
  36011. */
  36012. geometries: Geometry[];
  36013. /**
  36014. * All of the tranform nodes added to this scene
  36015. * In the context of a Scene, it is not supposed to be modified manually.
  36016. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36017. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36018. * @see http://doc.babylonjs.com/how_to/transformnode
  36019. */
  36020. transformNodes: TransformNode[];
  36021. /**
  36022. * ActionManagers available on the scene.
  36023. */
  36024. actionManagers: AbstractActionManager[];
  36025. /**
  36026. * Textures to keep.
  36027. */
  36028. textures: BaseTexture[];
  36029. /**
  36030. * Environment texture for the scene
  36031. */
  36032. environmentTexture: Nullable<BaseTexture>;
  36033. }
  36034. }
  36035. declare module "babylonjs/Audio/sound" {
  36036. import { Observable } from "babylonjs/Misc/observable";
  36037. import { Vector3 } from "babylonjs/Maths/math.vector";
  36038. import { Nullable } from "babylonjs/types";
  36039. import { Scene } from "babylonjs/scene";
  36040. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36041. /**
  36042. * Interface used to define options for Sound class
  36043. */
  36044. export interface ISoundOptions {
  36045. /**
  36046. * Does the sound autoplay once loaded.
  36047. */
  36048. autoplay?: boolean;
  36049. /**
  36050. * Does the sound loop after it finishes playing once.
  36051. */
  36052. loop?: boolean;
  36053. /**
  36054. * Sound's volume
  36055. */
  36056. volume?: number;
  36057. /**
  36058. * Is it a spatial sound?
  36059. */
  36060. spatialSound?: boolean;
  36061. /**
  36062. * Maximum distance to hear that sound
  36063. */
  36064. maxDistance?: number;
  36065. /**
  36066. * Uses user defined attenuation function
  36067. */
  36068. useCustomAttenuation?: boolean;
  36069. /**
  36070. * Define the roll off factor of spatial sounds.
  36071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36072. */
  36073. rolloffFactor?: number;
  36074. /**
  36075. * Define the reference distance the sound should be heard perfectly.
  36076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36077. */
  36078. refDistance?: number;
  36079. /**
  36080. * Define the distance attenuation model the sound will follow.
  36081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36082. */
  36083. distanceModel?: string;
  36084. /**
  36085. * Defines the playback speed (1 by default)
  36086. */
  36087. playbackRate?: number;
  36088. /**
  36089. * Defines if the sound is from a streaming source
  36090. */
  36091. streaming?: boolean;
  36092. /**
  36093. * Defines an optional length (in seconds) inside the sound file
  36094. */
  36095. length?: number;
  36096. /**
  36097. * Defines an optional offset (in seconds) inside the sound file
  36098. */
  36099. offset?: number;
  36100. /**
  36101. * If true, URLs will not be required to state the audio file codec to use.
  36102. */
  36103. skipCodecCheck?: boolean;
  36104. }
  36105. /**
  36106. * Defines a sound that can be played in the application.
  36107. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36109. */
  36110. export class Sound {
  36111. /**
  36112. * The name of the sound in the scene.
  36113. */
  36114. name: string;
  36115. /**
  36116. * Does the sound autoplay once loaded.
  36117. */
  36118. autoplay: boolean;
  36119. /**
  36120. * Does the sound loop after it finishes playing once.
  36121. */
  36122. loop: boolean;
  36123. /**
  36124. * Does the sound use a custom attenuation curve to simulate the falloff
  36125. * happening when the source gets further away from the camera.
  36126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36127. */
  36128. useCustomAttenuation: boolean;
  36129. /**
  36130. * The sound track id this sound belongs to.
  36131. */
  36132. soundTrackId: number;
  36133. /**
  36134. * Is this sound currently played.
  36135. */
  36136. isPlaying: boolean;
  36137. /**
  36138. * Is this sound currently paused.
  36139. */
  36140. isPaused: boolean;
  36141. /**
  36142. * Does this sound enables spatial sound.
  36143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36144. */
  36145. spatialSound: boolean;
  36146. /**
  36147. * Define the reference distance the sound should be heard perfectly.
  36148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36149. */
  36150. refDistance: number;
  36151. /**
  36152. * Define the roll off factor of spatial sounds.
  36153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36154. */
  36155. rolloffFactor: number;
  36156. /**
  36157. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36159. */
  36160. maxDistance: number;
  36161. /**
  36162. * Define the distance attenuation model the sound will follow.
  36163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36164. */
  36165. distanceModel: string;
  36166. /**
  36167. * @hidden
  36168. * Back Compat
  36169. **/
  36170. onended: () => any;
  36171. /**
  36172. * Observable event when the current playing sound finishes.
  36173. */
  36174. onEndedObservable: Observable<Sound>;
  36175. private _panningModel;
  36176. private _playbackRate;
  36177. private _streaming;
  36178. private _startTime;
  36179. private _startOffset;
  36180. private _position;
  36181. /** @hidden */
  36182. _positionInEmitterSpace: boolean;
  36183. private _localDirection;
  36184. private _volume;
  36185. private _isReadyToPlay;
  36186. private _isDirectional;
  36187. private _readyToPlayCallback;
  36188. private _audioBuffer;
  36189. private _soundSource;
  36190. private _streamingSource;
  36191. private _soundPanner;
  36192. private _soundGain;
  36193. private _inputAudioNode;
  36194. private _outputAudioNode;
  36195. private _coneInnerAngle;
  36196. private _coneOuterAngle;
  36197. private _coneOuterGain;
  36198. private _scene;
  36199. private _connectedTransformNode;
  36200. private _customAttenuationFunction;
  36201. private _registerFunc;
  36202. private _isOutputConnected;
  36203. private _htmlAudioElement;
  36204. private _urlType;
  36205. private _length?;
  36206. private _offset?;
  36207. /** @hidden */
  36208. static _SceneComponentInitialization: (scene: Scene) => void;
  36209. /**
  36210. * Create a sound and attach it to a scene
  36211. * @param name Name of your sound
  36212. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36213. * @param scene defines the scene the sound belongs to
  36214. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36215. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36216. */
  36217. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36218. /**
  36219. * Release the sound and its associated resources
  36220. */
  36221. dispose(): void;
  36222. /**
  36223. * Gets if the sounds is ready to be played or not.
  36224. * @returns true if ready, otherwise false
  36225. */
  36226. isReady(): boolean;
  36227. private _soundLoaded;
  36228. /**
  36229. * Sets the data of the sound from an audiobuffer
  36230. * @param audioBuffer The audioBuffer containing the data
  36231. */
  36232. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36233. /**
  36234. * Updates the current sounds options such as maxdistance, loop...
  36235. * @param options A JSON object containing values named as the object properties
  36236. */
  36237. updateOptions(options: ISoundOptions): void;
  36238. private _createSpatialParameters;
  36239. private _updateSpatialParameters;
  36240. /**
  36241. * Switch the panning model to HRTF:
  36242. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36244. */
  36245. switchPanningModelToHRTF(): void;
  36246. /**
  36247. * Switch the panning model to Equal Power:
  36248. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36250. */
  36251. switchPanningModelToEqualPower(): void;
  36252. private _switchPanningModel;
  36253. /**
  36254. * Connect this sound to a sound track audio node like gain...
  36255. * @param soundTrackAudioNode the sound track audio node to connect to
  36256. */
  36257. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36258. /**
  36259. * Transform this sound into a directional source
  36260. * @param coneInnerAngle Size of the inner cone in degree
  36261. * @param coneOuterAngle Size of the outer cone in degree
  36262. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36263. */
  36264. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36265. /**
  36266. * Gets or sets the inner angle for the directional cone.
  36267. */
  36268. /**
  36269. * Gets or sets the inner angle for the directional cone.
  36270. */
  36271. directionalConeInnerAngle: number;
  36272. /**
  36273. * Gets or sets the outer angle for the directional cone.
  36274. */
  36275. /**
  36276. * Gets or sets the outer angle for the directional cone.
  36277. */
  36278. directionalConeOuterAngle: number;
  36279. /**
  36280. * Sets the position of the emitter if spatial sound is enabled
  36281. * @param newPosition Defines the new posisiton
  36282. */
  36283. setPosition(newPosition: Vector3): void;
  36284. /**
  36285. * Sets the local direction of the emitter if spatial sound is enabled
  36286. * @param newLocalDirection Defines the new local direction
  36287. */
  36288. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36289. private _updateDirection;
  36290. /** @hidden */
  36291. updateDistanceFromListener(): void;
  36292. /**
  36293. * Sets a new custom attenuation function for the sound.
  36294. * @param callback Defines the function used for the attenuation
  36295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36296. */
  36297. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36298. /**
  36299. * Play the sound
  36300. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36301. * @param offset (optional) Start the sound at a specific time in seconds
  36302. * @param length (optional) Sound duration (in seconds)
  36303. */
  36304. play(time?: number, offset?: number, length?: number): void;
  36305. private _onended;
  36306. /**
  36307. * Stop the sound
  36308. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36309. */
  36310. stop(time?: number): void;
  36311. /**
  36312. * Put the sound in pause
  36313. */
  36314. pause(): void;
  36315. /**
  36316. * Sets a dedicated volume for this sounds
  36317. * @param newVolume Define the new volume of the sound
  36318. * @param time Define time for gradual change to new volume
  36319. */
  36320. setVolume(newVolume: number, time?: number): void;
  36321. /**
  36322. * Set the sound play back rate
  36323. * @param newPlaybackRate Define the playback rate the sound should be played at
  36324. */
  36325. setPlaybackRate(newPlaybackRate: number): void;
  36326. /**
  36327. * Gets the volume of the sound.
  36328. * @returns the volume of the sound
  36329. */
  36330. getVolume(): number;
  36331. /**
  36332. * Attach the sound to a dedicated mesh
  36333. * @param transformNode The transform node to connect the sound with
  36334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36335. */
  36336. attachToMesh(transformNode: TransformNode): void;
  36337. /**
  36338. * Detach the sound from the previously attached mesh
  36339. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36340. */
  36341. detachFromMesh(): void;
  36342. private _onRegisterAfterWorldMatrixUpdate;
  36343. /**
  36344. * Clone the current sound in the scene.
  36345. * @returns the new sound clone
  36346. */
  36347. clone(): Nullable<Sound>;
  36348. /**
  36349. * Gets the current underlying audio buffer containing the data
  36350. * @returns the audio buffer
  36351. */
  36352. getAudioBuffer(): Nullable<AudioBuffer>;
  36353. /**
  36354. * Serializes the Sound in a JSON representation
  36355. * @returns the JSON representation of the sound
  36356. */
  36357. serialize(): any;
  36358. /**
  36359. * Parse a JSON representation of a sound to innstantiate in a given scene
  36360. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36361. * @param scene Define the scene the new parsed sound should be created in
  36362. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36363. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36364. * @returns the newly parsed sound
  36365. */
  36366. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36367. }
  36368. }
  36369. declare module "babylonjs/Actions/directAudioActions" {
  36370. import { Action } from "babylonjs/Actions/action";
  36371. import { Condition } from "babylonjs/Actions/condition";
  36372. import { Sound } from "babylonjs/Audio/sound";
  36373. /**
  36374. * This defines an action helpful to play a defined sound on a triggered action.
  36375. */
  36376. export class PlaySoundAction extends Action {
  36377. private _sound;
  36378. /**
  36379. * Instantiate the action
  36380. * @param triggerOptions defines the trigger options
  36381. * @param sound defines the sound to play
  36382. * @param condition defines the trigger related conditions
  36383. */
  36384. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36385. /** @hidden */
  36386. _prepare(): void;
  36387. /**
  36388. * Execute the action and play the sound.
  36389. */
  36390. execute(): void;
  36391. /**
  36392. * Serializes the actions and its related information.
  36393. * @param parent defines the object to serialize in
  36394. * @returns the serialized object
  36395. */
  36396. serialize(parent: any): any;
  36397. }
  36398. /**
  36399. * This defines an action helpful to stop a defined sound on a triggered action.
  36400. */
  36401. export class StopSoundAction extends Action {
  36402. private _sound;
  36403. /**
  36404. * Instantiate the action
  36405. * @param triggerOptions defines the trigger options
  36406. * @param sound defines the sound to stop
  36407. * @param condition defines the trigger related conditions
  36408. */
  36409. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36410. /** @hidden */
  36411. _prepare(): void;
  36412. /**
  36413. * Execute the action and stop the sound.
  36414. */
  36415. execute(): void;
  36416. /**
  36417. * Serializes the actions and its related information.
  36418. * @param parent defines the object to serialize in
  36419. * @returns the serialized object
  36420. */
  36421. serialize(parent: any): any;
  36422. }
  36423. }
  36424. declare module "babylonjs/Actions/interpolateValueAction" {
  36425. import { Action } from "babylonjs/Actions/action";
  36426. import { Condition } from "babylonjs/Actions/condition";
  36427. import { Observable } from "babylonjs/Misc/observable";
  36428. /**
  36429. * This defines an action responsible to change the value of a property
  36430. * by interpolating between its current value and the newly set one once triggered.
  36431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36432. */
  36433. export class InterpolateValueAction extends Action {
  36434. /**
  36435. * Defines the path of the property where the value should be interpolated
  36436. */
  36437. propertyPath: string;
  36438. /**
  36439. * Defines the target value at the end of the interpolation.
  36440. */
  36441. value: any;
  36442. /**
  36443. * Defines the time it will take for the property to interpolate to the value.
  36444. */
  36445. duration: number;
  36446. /**
  36447. * Defines if the other scene animations should be stopped when the action has been triggered
  36448. */
  36449. stopOtherAnimations?: boolean;
  36450. /**
  36451. * Defines a callback raised once the interpolation animation has been done.
  36452. */
  36453. onInterpolationDone?: () => void;
  36454. /**
  36455. * Observable triggered once the interpolation animation has been done.
  36456. */
  36457. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36458. private _target;
  36459. private _effectiveTarget;
  36460. private _property;
  36461. /**
  36462. * Instantiate the action
  36463. * @param triggerOptions defines the trigger options
  36464. * @param target defines the object containing the value to interpolate
  36465. * @param propertyPath defines the path to the property in the target object
  36466. * @param value defines the target value at the end of the interpolation
  36467. * @param duration deines the time it will take for the property to interpolate to the value.
  36468. * @param condition defines the trigger related conditions
  36469. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36470. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36471. */
  36472. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36473. /** @hidden */
  36474. _prepare(): void;
  36475. /**
  36476. * Execute the action starts the value interpolation.
  36477. */
  36478. execute(): void;
  36479. /**
  36480. * Serializes the actions and its related information.
  36481. * @param parent defines the object to serialize in
  36482. * @returns the serialized object
  36483. */
  36484. serialize(parent: any): any;
  36485. }
  36486. }
  36487. declare module "babylonjs/Actions/index" {
  36488. export * from "babylonjs/Actions/abstractActionManager";
  36489. export * from "babylonjs/Actions/action";
  36490. export * from "babylonjs/Actions/actionEvent";
  36491. export * from "babylonjs/Actions/actionManager";
  36492. export * from "babylonjs/Actions/condition";
  36493. export * from "babylonjs/Actions/directActions";
  36494. export * from "babylonjs/Actions/directAudioActions";
  36495. export * from "babylonjs/Actions/interpolateValueAction";
  36496. }
  36497. declare module "babylonjs/Animations/index" {
  36498. export * from "babylonjs/Animations/animatable";
  36499. export * from "babylonjs/Animations/animation";
  36500. export * from "babylonjs/Animations/animationGroup";
  36501. export * from "babylonjs/Animations/animationPropertiesOverride";
  36502. export * from "babylonjs/Animations/easing";
  36503. export * from "babylonjs/Animations/runtimeAnimation";
  36504. export * from "babylonjs/Animations/animationEvent";
  36505. export * from "babylonjs/Animations/animationGroup";
  36506. export * from "babylonjs/Animations/animationKey";
  36507. export * from "babylonjs/Animations/animationRange";
  36508. export * from "babylonjs/Animations/animatable.interface";
  36509. }
  36510. declare module "babylonjs/Audio/soundTrack" {
  36511. import { Sound } from "babylonjs/Audio/sound";
  36512. import { Analyser } from "babylonjs/Audio/analyser";
  36513. import { Scene } from "babylonjs/scene";
  36514. /**
  36515. * Options allowed during the creation of a sound track.
  36516. */
  36517. export interface ISoundTrackOptions {
  36518. /**
  36519. * The volume the sound track should take during creation
  36520. */
  36521. volume?: number;
  36522. /**
  36523. * Define if the sound track is the main sound track of the scene
  36524. */
  36525. mainTrack?: boolean;
  36526. }
  36527. /**
  36528. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36529. * It will be also used in a future release to apply effects on a specific track.
  36530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36531. */
  36532. export class SoundTrack {
  36533. /**
  36534. * The unique identifier of the sound track in the scene.
  36535. */
  36536. id: number;
  36537. /**
  36538. * The list of sounds included in the sound track.
  36539. */
  36540. soundCollection: Array<Sound>;
  36541. private _outputAudioNode;
  36542. private _scene;
  36543. private _isMainTrack;
  36544. private _connectedAnalyser;
  36545. private _options;
  36546. private _isInitialized;
  36547. /**
  36548. * Creates a new sound track.
  36549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36550. * @param scene Define the scene the sound track belongs to
  36551. * @param options
  36552. */
  36553. constructor(scene: Scene, options?: ISoundTrackOptions);
  36554. private _initializeSoundTrackAudioGraph;
  36555. /**
  36556. * Release the sound track and its associated resources
  36557. */
  36558. dispose(): void;
  36559. /**
  36560. * Adds a sound to this sound track
  36561. * @param sound define the cound to add
  36562. * @ignoreNaming
  36563. */
  36564. AddSound(sound: Sound): void;
  36565. /**
  36566. * Removes a sound to this sound track
  36567. * @param sound define the cound to remove
  36568. * @ignoreNaming
  36569. */
  36570. RemoveSound(sound: Sound): void;
  36571. /**
  36572. * Set a global volume for the full sound track.
  36573. * @param newVolume Define the new volume of the sound track
  36574. */
  36575. setVolume(newVolume: number): void;
  36576. /**
  36577. * Switch the panning model to HRTF:
  36578. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36580. */
  36581. switchPanningModelToHRTF(): void;
  36582. /**
  36583. * Switch the panning model to Equal Power:
  36584. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36585. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36586. */
  36587. switchPanningModelToEqualPower(): void;
  36588. /**
  36589. * Connect the sound track to an audio analyser allowing some amazing
  36590. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36592. * @param analyser The analyser to connect to the engine
  36593. */
  36594. connectToAnalyser(analyser: Analyser): void;
  36595. }
  36596. }
  36597. declare module "babylonjs/Audio/audioSceneComponent" {
  36598. import { Sound } from "babylonjs/Audio/sound";
  36599. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36600. import { Nullable } from "babylonjs/types";
  36601. import { Vector3 } from "babylonjs/Maths/math.vector";
  36602. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36603. import { Scene } from "babylonjs/scene";
  36604. import { AbstractScene } from "babylonjs/abstractScene";
  36605. import "babylonjs/Audio/audioEngine";
  36606. module "babylonjs/abstractScene" {
  36607. interface AbstractScene {
  36608. /**
  36609. * The list of sounds used in the scene.
  36610. */
  36611. sounds: Nullable<Array<Sound>>;
  36612. }
  36613. }
  36614. module "babylonjs/scene" {
  36615. interface Scene {
  36616. /**
  36617. * @hidden
  36618. * Backing field
  36619. */
  36620. _mainSoundTrack: SoundTrack;
  36621. /**
  36622. * The main sound track played by the scene.
  36623. * It cotains your primary collection of sounds.
  36624. */
  36625. mainSoundTrack: SoundTrack;
  36626. /**
  36627. * The list of sound tracks added to the scene
  36628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36629. */
  36630. soundTracks: Nullable<Array<SoundTrack>>;
  36631. /**
  36632. * Gets a sound using a given name
  36633. * @param name defines the name to search for
  36634. * @return the found sound or null if not found at all.
  36635. */
  36636. getSoundByName(name: string): Nullable<Sound>;
  36637. /**
  36638. * Gets or sets if audio support is enabled
  36639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36640. */
  36641. audioEnabled: boolean;
  36642. /**
  36643. * Gets or sets if audio will be output to headphones
  36644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36645. */
  36646. headphone: boolean;
  36647. /**
  36648. * Gets or sets custom audio listener position provider
  36649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36650. */
  36651. audioListenerPositionProvider: Nullable<() => Vector3>;
  36652. }
  36653. }
  36654. /**
  36655. * Defines the sound scene component responsible to manage any sounds
  36656. * in a given scene.
  36657. */
  36658. export class AudioSceneComponent implements ISceneSerializableComponent {
  36659. /**
  36660. * The component name helpfull to identify the component in the list of scene components.
  36661. */
  36662. readonly name: string;
  36663. /**
  36664. * The scene the component belongs to.
  36665. */
  36666. scene: Scene;
  36667. private _audioEnabled;
  36668. /**
  36669. * Gets whether audio is enabled or not.
  36670. * Please use related enable/disable method to switch state.
  36671. */
  36672. readonly audioEnabled: boolean;
  36673. private _headphone;
  36674. /**
  36675. * Gets whether audio is outputing to headphone or not.
  36676. * Please use the according Switch methods to change output.
  36677. */
  36678. readonly headphone: boolean;
  36679. private _audioListenerPositionProvider;
  36680. /**
  36681. * Gets the current audio listener position provider
  36682. */
  36683. /**
  36684. * Sets a custom listener position for all sounds in the scene
  36685. * By default, this is the position of the first active camera
  36686. */
  36687. audioListenerPositionProvider: Nullable<() => Vector3>;
  36688. /**
  36689. * Creates a new instance of the component for the given scene
  36690. * @param scene Defines the scene to register the component in
  36691. */
  36692. constructor(scene: Scene);
  36693. /**
  36694. * Registers the component in a given scene
  36695. */
  36696. register(): void;
  36697. /**
  36698. * Rebuilds the elements related to this component in case of
  36699. * context lost for instance.
  36700. */
  36701. rebuild(): void;
  36702. /**
  36703. * Serializes the component data to the specified json object
  36704. * @param serializationObject The object to serialize to
  36705. */
  36706. serialize(serializationObject: any): void;
  36707. /**
  36708. * Adds all the elements from the container to the scene
  36709. * @param container the container holding the elements
  36710. */
  36711. addFromContainer(container: AbstractScene): void;
  36712. /**
  36713. * Removes all the elements in the container from the scene
  36714. * @param container contains the elements to remove
  36715. * @param dispose if the removed element should be disposed (default: false)
  36716. */
  36717. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36718. /**
  36719. * Disposes the component and the associated ressources.
  36720. */
  36721. dispose(): void;
  36722. /**
  36723. * Disables audio in the associated scene.
  36724. */
  36725. disableAudio(): void;
  36726. /**
  36727. * Enables audio in the associated scene.
  36728. */
  36729. enableAudio(): void;
  36730. /**
  36731. * Switch audio to headphone output.
  36732. */
  36733. switchAudioModeForHeadphones(): void;
  36734. /**
  36735. * Switch audio to normal speakers.
  36736. */
  36737. switchAudioModeForNormalSpeakers(): void;
  36738. private _afterRender;
  36739. }
  36740. }
  36741. declare module "babylonjs/Audio/weightedsound" {
  36742. import { Sound } from "babylonjs/Audio/sound";
  36743. /**
  36744. * Wraps one or more Sound objects and selects one with random weight for playback.
  36745. */
  36746. export class WeightedSound {
  36747. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36748. loop: boolean;
  36749. private _coneInnerAngle;
  36750. private _coneOuterAngle;
  36751. private _volume;
  36752. /** A Sound is currently playing. */
  36753. isPlaying: boolean;
  36754. /** A Sound is currently paused. */
  36755. isPaused: boolean;
  36756. private _sounds;
  36757. private _weights;
  36758. private _currentIndex?;
  36759. /**
  36760. * Creates a new WeightedSound from the list of sounds given.
  36761. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36762. * @param sounds Array of Sounds that will be selected from.
  36763. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36764. */
  36765. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36766. /**
  36767. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36768. */
  36769. /**
  36770. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36771. */
  36772. directionalConeInnerAngle: number;
  36773. /**
  36774. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36775. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36776. */
  36777. /**
  36778. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36779. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36780. */
  36781. directionalConeOuterAngle: number;
  36782. /**
  36783. * Playback volume.
  36784. */
  36785. /**
  36786. * Playback volume.
  36787. */
  36788. volume: number;
  36789. private _onended;
  36790. /**
  36791. * Suspend playback
  36792. */
  36793. pause(): void;
  36794. /**
  36795. * Stop playback
  36796. */
  36797. stop(): void;
  36798. /**
  36799. * Start playback.
  36800. * @param startOffset Position the clip head at a specific time in seconds.
  36801. */
  36802. play(startOffset?: number): void;
  36803. }
  36804. }
  36805. declare module "babylonjs/Audio/index" {
  36806. export * from "babylonjs/Audio/analyser";
  36807. export * from "babylonjs/Audio/audioEngine";
  36808. export * from "babylonjs/Audio/audioSceneComponent";
  36809. export * from "babylonjs/Audio/sound";
  36810. export * from "babylonjs/Audio/soundTrack";
  36811. export * from "babylonjs/Audio/weightedsound";
  36812. }
  36813. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36814. import { Behavior } from "babylonjs/Behaviors/behavior";
  36815. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36816. import { BackEase } from "babylonjs/Animations/easing";
  36817. /**
  36818. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36819. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36820. */
  36821. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36822. /**
  36823. * Gets the name of the behavior.
  36824. */
  36825. readonly name: string;
  36826. /**
  36827. * The easing function used by animations
  36828. */
  36829. static EasingFunction: BackEase;
  36830. /**
  36831. * The easing mode used by animations
  36832. */
  36833. static EasingMode: number;
  36834. /**
  36835. * The duration of the animation, in milliseconds
  36836. */
  36837. transitionDuration: number;
  36838. /**
  36839. * Length of the distance animated by the transition when lower radius is reached
  36840. */
  36841. lowerRadiusTransitionRange: number;
  36842. /**
  36843. * Length of the distance animated by the transition when upper radius is reached
  36844. */
  36845. upperRadiusTransitionRange: number;
  36846. private _autoTransitionRange;
  36847. /**
  36848. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36849. */
  36850. /**
  36851. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36852. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36853. */
  36854. autoTransitionRange: boolean;
  36855. private _attachedCamera;
  36856. private _onAfterCheckInputsObserver;
  36857. private _onMeshTargetChangedObserver;
  36858. /**
  36859. * Initializes the behavior.
  36860. */
  36861. init(): void;
  36862. /**
  36863. * Attaches the behavior to its arc rotate camera.
  36864. * @param camera Defines the camera to attach the behavior to
  36865. */
  36866. attach(camera: ArcRotateCamera): void;
  36867. /**
  36868. * Detaches the behavior from its current arc rotate camera.
  36869. */
  36870. detach(): void;
  36871. private _radiusIsAnimating;
  36872. private _radiusBounceTransition;
  36873. private _animatables;
  36874. private _cachedWheelPrecision;
  36875. /**
  36876. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36877. * @param radiusLimit The limit to check against.
  36878. * @return Bool to indicate if at limit.
  36879. */
  36880. private _isRadiusAtLimit;
  36881. /**
  36882. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36883. * @param radiusDelta The delta by which to animate to. Can be negative.
  36884. */
  36885. private _applyBoundRadiusAnimation;
  36886. /**
  36887. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36888. */
  36889. protected _clearAnimationLocks(): void;
  36890. /**
  36891. * Stops and removes all animations that have been applied to the camera
  36892. */
  36893. stopAllAnimations(): void;
  36894. }
  36895. }
  36896. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36897. import { Behavior } from "babylonjs/Behaviors/behavior";
  36898. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36899. import { ExponentialEase } from "babylonjs/Animations/easing";
  36900. import { Nullable } from "babylonjs/types";
  36901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36902. import { Vector3 } from "babylonjs/Maths/math.vector";
  36903. /**
  36904. * 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.
  36905. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36906. */
  36907. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36908. /**
  36909. * Gets the name of the behavior.
  36910. */
  36911. readonly name: string;
  36912. private _mode;
  36913. private _radiusScale;
  36914. private _positionScale;
  36915. private _defaultElevation;
  36916. private _elevationReturnTime;
  36917. private _elevationReturnWaitTime;
  36918. private _zoomStopsAnimation;
  36919. private _framingTime;
  36920. /**
  36921. * The easing function used by animations
  36922. */
  36923. static EasingFunction: ExponentialEase;
  36924. /**
  36925. * The easing mode used by animations
  36926. */
  36927. static EasingMode: number;
  36928. /**
  36929. * Sets the current mode used by the behavior
  36930. */
  36931. /**
  36932. * Gets current mode used by the behavior.
  36933. */
  36934. mode: number;
  36935. /**
  36936. * Sets the scale applied to the radius (1 by default)
  36937. */
  36938. /**
  36939. * Gets the scale applied to the radius
  36940. */
  36941. radiusScale: number;
  36942. /**
  36943. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36944. */
  36945. /**
  36946. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36947. */
  36948. positionScale: number;
  36949. /**
  36950. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36951. * behaviour is triggered, in radians.
  36952. */
  36953. /**
  36954. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36955. * behaviour is triggered, in radians.
  36956. */
  36957. defaultElevation: number;
  36958. /**
  36959. * Sets the time (in milliseconds) taken to return to the default beta position.
  36960. * Negative value indicates camera should not return to default.
  36961. */
  36962. /**
  36963. * Gets the time (in milliseconds) taken to return to the default beta position.
  36964. * Negative value indicates camera should not return to default.
  36965. */
  36966. elevationReturnTime: number;
  36967. /**
  36968. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36969. */
  36970. /**
  36971. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36972. */
  36973. elevationReturnWaitTime: number;
  36974. /**
  36975. * Sets the flag that indicates if user zooming should stop animation.
  36976. */
  36977. /**
  36978. * Gets the flag that indicates if user zooming should stop animation.
  36979. */
  36980. zoomStopsAnimation: boolean;
  36981. /**
  36982. * Sets the transition time when framing the mesh, in milliseconds
  36983. */
  36984. /**
  36985. * Gets the transition time when framing the mesh, in milliseconds
  36986. */
  36987. framingTime: number;
  36988. /**
  36989. * Define if the behavior should automatically change the configured
  36990. * camera limits and sensibilities.
  36991. */
  36992. autoCorrectCameraLimitsAndSensibility: boolean;
  36993. private _onPrePointerObservableObserver;
  36994. private _onAfterCheckInputsObserver;
  36995. private _onMeshTargetChangedObserver;
  36996. private _attachedCamera;
  36997. private _isPointerDown;
  36998. private _lastInteractionTime;
  36999. /**
  37000. * Initializes the behavior.
  37001. */
  37002. init(): void;
  37003. /**
  37004. * Attaches the behavior to its arc rotate camera.
  37005. * @param camera Defines the camera to attach the behavior to
  37006. */
  37007. attach(camera: ArcRotateCamera): void;
  37008. /**
  37009. * Detaches the behavior from its current arc rotate camera.
  37010. */
  37011. detach(): void;
  37012. private _animatables;
  37013. private _betaIsAnimating;
  37014. private _betaTransition;
  37015. private _radiusTransition;
  37016. private _vectorTransition;
  37017. /**
  37018. * Targets the given mesh and updates zoom level accordingly.
  37019. * @param mesh The mesh to target.
  37020. * @param radius Optional. If a cached radius position already exists, overrides default.
  37021. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37022. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37023. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37024. */
  37025. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37026. /**
  37027. * Targets the given mesh with its children and updates zoom level accordingly.
  37028. * @param mesh The mesh to target.
  37029. * @param radius Optional. If a cached radius position already exists, overrides default.
  37030. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37031. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37032. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37033. */
  37034. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37035. /**
  37036. * Targets the given meshes with their children and updates zoom level accordingly.
  37037. * @param meshes The mesh to target.
  37038. * @param radius Optional. If a cached radius position already exists, overrides default.
  37039. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37040. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37041. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37042. */
  37043. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37044. /**
  37045. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37046. * @param minimumWorld Determines the smaller position of the bounding box extend
  37047. * @param maximumWorld Determines the bigger position of the bounding box extend
  37048. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37049. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37050. */
  37051. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37052. /**
  37053. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37054. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37055. * frustum width.
  37056. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37057. * to fully enclose the mesh in the viewing frustum.
  37058. */
  37059. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37060. /**
  37061. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37062. * is automatically returned to its default position (expected to be above ground plane).
  37063. */
  37064. private _maintainCameraAboveGround;
  37065. /**
  37066. * Returns the frustum slope based on the canvas ratio and camera FOV
  37067. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37068. */
  37069. private _getFrustumSlope;
  37070. /**
  37071. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37072. */
  37073. private _clearAnimationLocks;
  37074. /**
  37075. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37076. */
  37077. private _applyUserInteraction;
  37078. /**
  37079. * Stops and removes all animations that have been applied to the camera
  37080. */
  37081. stopAllAnimations(): void;
  37082. /**
  37083. * Gets a value indicating if the user is moving the camera
  37084. */
  37085. readonly isUserIsMoving: boolean;
  37086. /**
  37087. * The camera can move all the way towards the mesh.
  37088. */
  37089. static IgnoreBoundsSizeMode: number;
  37090. /**
  37091. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37092. */
  37093. static FitFrustumSidesMode: number;
  37094. }
  37095. }
  37096. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37097. import { Nullable } from "babylonjs/types";
  37098. import { Camera } from "babylonjs/Cameras/camera";
  37099. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37100. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37101. /**
  37102. * Base class for Camera Pointer Inputs.
  37103. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37104. * for example usage.
  37105. */
  37106. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37107. /**
  37108. * Defines the camera the input is attached to.
  37109. */
  37110. abstract camera: Camera;
  37111. /**
  37112. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37113. */
  37114. protected _altKey: boolean;
  37115. protected _ctrlKey: boolean;
  37116. protected _metaKey: boolean;
  37117. protected _shiftKey: boolean;
  37118. /**
  37119. * Which mouse buttons were pressed at time of last mouse event.
  37120. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37121. */
  37122. protected _buttonsPressed: number;
  37123. /**
  37124. * Defines the buttons associated with the input to handle camera move.
  37125. */
  37126. buttons: number[];
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Gets the class name of the current input.
  37140. * @returns the class name
  37141. */
  37142. getClassName(): string;
  37143. /**
  37144. * Get the friendly name associated with the input class.
  37145. * @returns the input friendly name
  37146. */
  37147. getSimpleName(): string;
  37148. /**
  37149. * Called on pointer POINTERDOUBLETAP event.
  37150. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37151. */
  37152. protected onDoubleTap(type: string): void;
  37153. /**
  37154. * Called on pointer POINTERMOVE event if only a single touch is active.
  37155. * Override this method to provide functionality.
  37156. */
  37157. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37158. /**
  37159. * Called on pointer POINTERMOVE event if multiple touches are active.
  37160. * Override this method to provide functionality.
  37161. */
  37162. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37163. /**
  37164. * Called on JS contextmenu event.
  37165. * Override this method to provide functionality.
  37166. */
  37167. protected onContextMenu(evt: PointerEvent): void;
  37168. /**
  37169. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37170. * press.
  37171. * Override this method to provide functionality.
  37172. */
  37173. protected onButtonDown(evt: PointerEvent): void;
  37174. /**
  37175. * Called each time a new POINTERUP event occurs. Ie, for each button
  37176. * release.
  37177. * Override this method to provide functionality.
  37178. */
  37179. protected onButtonUp(evt: PointerEvent): void;
  37180. /**
  37181. * Called when window becomes inactive.
  37182. * Override this method to provide functionality.
  37183. */
  37184. protected onLostFocus(): void;
  37185. private _pointerInput;
  37186. private _observer;
  37187. private _onLostFocus;
  37188. private pointA;
  37189. private pointB;
  37190. }
  37191. }
  37192. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37193. import { Nullable } from "babylonjs/types";
  37194. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37195. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37196. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37197. /**
  37198. * Manage the pointers inputs to control an arc rotate camera.
  37199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37200. */
  37201. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37202. /**
  37203. * Defines the camera the input is attached to.
  37204. */
  37205. camera: ArcRotateCamera;
  37206. /**
  37207. * Gets the class name of the current input.
  37208. * @returns the class name
  37209. */
  37210. getClassName(): string;
  37211. /**
  37212. * Defines the buttons associated with the input to handle camera move.
  37213. */
  37214. buttons: number[];
  37215. /**
  37216. * Defines the pointer angular sensibility along the X axis or how fast is
  37217. * the camera rotating.
  37218. */
  37219. angularSensibilityX: number;
  37220. /**
  37221. * Defines the pointer angular sensibility along the Y axis or how fast is
  37222. * the camera rotating.
  37223. */
  37224. angularSensibilityY: number;
  37225. /**
  37226. * Defines the pointer pinch precision or how fast is the camera zooming.
  37227. */
  37228. pinchPrecision: number;
  37229. /**
  37230. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37231. * from 0.
  37232. * It defines the percentage of current camera.radius to use as delta when
  37233. * pinch zoom is used.
  37234. */
  37235. pinchDeltaPercentage: number;
  37236. /**
  37237. * Defines the pointer panning sensibility or how fast is the camera moving.
  37238. */
  37239. panningSensibility: number;
  37240. /**
  37241. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37242. */
  37243. multiTouchPanning: boolean;
  37244. /**
  37245. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37246. * zoom (pinch) through multitouch.
  37247. */
  37248. multiTouchPanAndZoom: boolean;
  37249. /**
  37250. * Revers pinch action direction.
  37251. */
  37252. pinchInwards: boolean;
  37253. private _isPanClick;
  37254. private _twoFingerActivityCount;
  37255. private _isPinching;
  37256. /**
  37257. * Called on pointer POINTERMOVE event if only a single touch is active.
  37258. */
  37259. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37260. /**
  37261. * Called on pointer POINTERDOUBLETAP event.
  37262. */
  37263. protected onDoubleTap(type: string): void;
  37264. /**
  37265. * Called on pointer POINTERMOVE event if multiple touches are active.
  37266. */
  37267. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37268. /**
  37269. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37270. * press.
  37271. */
  37272. protected onButtonDown(evt: PointerEvent): void;
  37273. /**
  37274. * Called each time a new POINTERUP event occurs. Ie, for each button
  37275. * release.
  37276. */
  37277. protected onButtonUp(evt: PointerEvent): void;
  37278. /**
  37279. * Called when window becomes inactive.
  37280. */
  37281. protected onLostFocus(): void;
  37282. }
  37283. }
  37284. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37285. import { Nullable } from "babylonjs/types";
  37286. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37287. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37288. /**
  37289. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37291. */
  37292. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37293. /**
  37294. * Defines the camera the input is attached to.
  37295. */
  37296. camera: ArcRotateCamera;
  37297. /**
  37298. * Defines the list of key codes associated with the up action (increase alpha)
  37299. */
  37300. keysUp: number[];
  37301. /**
  37302. * Defines the list of key codes associated with the down action (decrease alpha)
  37303. */
  37304. keysDown: number[];
  37305. /**
  37306. * Defines the list of key codes associated with the left action (increase beta)
  37307. */
  37308. keysLeft: number[];
  37309. /**
  37310. * Defines the list of key codes associated with the right action (decrease beta)
  37311. */
  37312. keysRight: number[];
  37313. /**
  37314. * Defines the list of key codes associated with the reset action.
  37315. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37316. */
  37317. keysReset: number[];
  37318. /**
  37319. * Defines the panning sensibility of the inputs.
  37320. * (How fast is the camera paning)
  37321. */
  37322. panningSensibility: number;
  37323. /**
  37324. * Defines the zooming sensibility of the inputs.
  37325. * (How fast is the camera zooming)
  37326. */
  37327. zoomingSensibility: number;
  37328. /**
  37329. * Defines wether maintaining the alt key down switch the movement mode from
  37330. * orientation to zoom.
  37331. */
  37332. useAltToZoom: boolean;
  37333. /**
  37334. * Rotation speed of the camera
  37335. */
  37336. angularSpeed: number;
  37337. private _keys;
  37338. private _ctrlPressed;
  37339. private _altPressed;
  37340. private _onCanvasBlurObserver;
  37341. private _onKeyboardObserver;
  37342. private _engine;
  37343. private _scene;
  37344. /**
  37345. * Attach the input controls to a specific dom element to get the input from.
  37346. * @param element Defines the element the controls should be listened from
  37347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37348. */
  37349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37350. /**
  37351. * Detach the current controls from the specified dom element.
  37352. * @param element Defines the element to stop listening the inputs from
  37353. */
  37354. detachControl(element: Nullable<HTMLElement>): void;
  37355. /**
  37356. * Update the current camera state depending on the inputs that have been used this frame.
  37357. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37358. */
  37359. checkInputs(): void;
  37360. /**
  37361. * Gets the class name of the current intput.
  37362. * @returns the class name
  37363. */
  37364. getClassName(): string;
  37365. /**
  37366. * Get the friendly name associated with the input class.
  37367. * @returns the input friendly name
  37368. */
  37369. getSimpleName(): string;
  37370. }
  37371. }
  37372. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37373. import { Nullable } from "babylonjs/types";
  37374. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37375. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37376. /**
  37377. * Manage the mouse wheel inputs to control an arc rotate camera.
  37378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37379. */
  37380. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37381. /**
  37382. * Defines the camera the input is attached to.
  37383. */
  37384. camera: ArcRotateCamera;
  37385. /**
  37386. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37387. */
  37388. wheelPrecision: number;
  37389. /**
  37390. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37391. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37392. */
  37393. wheelDeltaPercentage: number;
  37394. private _wheel;
  37395. private _observer;
  37396. private computeDeltaFromMouseWheelLegacyEvent;
  37397. /**
  37398. * Attach the input controls to a specific dom element to get the input from.
  37399. * @param element Defines the element the controls should be listened from
  37400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37401. */
  37402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37403. /**
  37404. * Detach the current controls from the specified dom element.
  37405. * @param element Defines the element to stop listening the inputs from
  37406. */
  37407. detachControl(element: Nullable<HTMLElement>): void;
  37408. /**
  37409. * Gets the class name of the current intput.
  37410. * @returns the class name
  37411. */
  37412. getClassName(): string;
  37413. /**
  37414. * Get the friendly name associated with the input class.
  37415. * @returns the input friendly name
  37416. */
  37417. getSimpleName(): string;
  37418. }
  37419. }
  37420. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37421. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37422. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37423. /**
  37424. * Default Inputs manager for the ArcRotateCamera.
  37425. * It groups all the default supported inputs for ease of use.
  37426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37427. */
  37428. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37429. /**
  37430. * Instantiates a new ArcRotateCameraInputsManager.
  37431. * @param camera Defines the camera the inputs belong to
  37432. */
  37433. constructor(camera: ArcRotateCamera);
  37434. /**
  37435. * Add mouse wheel input support to the input manager.
  37436. * @returns the current input manager
  37437. */
  37438. addMouseWheel(): ArcRotateCameraInputsManager;
  37439. /**
  37440. * Add pointers input support to the input manager.
  37441. * @returns the current input manager
  37442. */
  37443. addPointers(): ArcRotateCameraInputsManager;
  37444. /**
  37445. * Add keyboard input support to the input manager.
  37446. * @returns the current input manager
  37447. */
  37448. addKeyboard(): ArcRotateCameraInputsManager;
  37449. }
  37450. }
  37451. declare module "babylonjs/Cameras/arcRotateCamera" {
  37452. import { Observable } from "babylonjs/Misc/observable";
  37453. import { Nullable } from "babylonjs/types";
  37454. import { Scene } from "babylonjs/scene";
  37455. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37457. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37458. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37459. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37460. import { Camera } from "babylonjs/Cameras/camera";
  37461. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37462. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37463. import { Collider } from "babylonjs/Collisions/collider";
  37464. /**
  37465. * This represents an orbital type of camera.
  37466. *
  37467. * 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.
  37468. * 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.
  37469. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37470. */
  37471. export class ArcRotateCamera extends TargetCamera {
  37472. /**
  37473. * Defines the rotation angle of the camera along the longitudinal axis.
  37474. */
  37475. alpha: number;
  37476. /**
  37477. * Defines the rotation angle of the camera along the latitudinal axis.
  37478. */
  37479. beta: number;
  37480. /**
  37481. * Defines the radius of the camera from it s target point.
  37482. */
  37483. radius: number;
  37484. protected _target: Vector3;
  37485. protected _targetHost: Nullable<AbstractMesh>;
  37486. /**
  37487. * Defines the target point of the camera.
  37488. * The camera looks towards it form the radius distance.
  37489. */
  37490. target: Vector3;
  37491. /**
  37492. * Define the current local position of the camera in the scene
  37493. */
  37494. position: Vector3;
  37495. protected _upVector: Vector3;
  37496. protected _upToYMatrix: Matrix;
  37497. protected _YToUpMatrix: Matrix;
  37498. /**
  37499. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37500. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37501. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37502. */
  37503. upVector: Vector3;
  37504. /**
  37505. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37506. */
  37507. setMatUp(): void;
  37508. /**
  37509. * Current inertia value on the longitudinal axis.
  37510. * The bigger this number the longer it will take for the camera to stop.
  37511. */
  37512. inertialAlphaOffset: number;
  37513. /**
  37514. * Current inertia value on the latitudinal axis.
  37515. * The bigger this number the longer it will take for the camera to stop.
  37516. */
  37517. inertialBetaOffset: number;
  37518. /**
  37519. * Current inertia value on the radius axis.
  37520. * The bigger this number the longer it will take for the camera to stop.
  37521. */
  37522. inertialRadiusOffset: number;
  37523. /**
  37524. * Minimum allowed angle on the longitudinal axis.
  37525. * This can help limiting how the Camera is able to move in the scene.
  37526. */
  37527. lowerAlphaLimit: Nullable<number>;
  37528. /**
  37529. * Maximum allowed angle on the longitudinal axis.
  37530. * This can help limiting how the Camera is able to move in the scene.
  37531. */
  37532. upperAlphaLimit: Nullable<number>;
  37533. /**
  37534. * Minimum allowed angle on the latitudinal axis.
  37535. * This can help limiting how the Camera is able to move in the scene.
  37536. */
  37537. lowerBetaLimit: number;
  37538. /**
  37539. * Maximum allowed angle on the latitudinal axis.
  37540. * This can help limiting how the Camera is able to move in the scene.
  37541. */
  37542. upperBetaLimit: number;
  37543. /**
  37544. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37545. * This can help limiting how the Camera is able to move in the scene.
  37546. */
  37547. lowerRadiusLimit: Nullable<number>;
  37548. /**
  37549. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37550. * This can help limiting how the Camera is able to move in the scene.
  37551. */
  37552. upperRadiusLimit: Nullable<number>;
  37553. /**
  37554. * Defines the current inertia value used during panning of the camera along the X axis.
  37555. */
  37556. inertialPanningX: number;
  37557. /**
  37558. * Defines the current inertia value used during panning of the camera along the Y axis.
  37559. */
  37560. inertialPanningY: number;
  37561. /**
  37562. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37563. * Basically if your fingers moves away from more than this distance you will be considered
  37564. * in pinch mode.
  37565. */
  37566. pinchToPanMaxDistance: number;
  37567. /**
  37568. * Defines the maximum distance the camera can pan.
  37569. * This could help keeping the cammera always in your scene.
  37570. */
  37571. panningDistanceLimit: Nullable<number>;
  37572. /**
  37573. * Defines the target of the camera before paning.
  37574. */
  37575. panningOriginTarget: Vector3;
  37576. /**
  37577. * Defines the value of the inertia used during panning.
  37578. * 0 would mean stop inertia and one would mean no decelleration at all.
  37579. */
  37580. panningInertia: number;
  37581. /**
  37582. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37583. */
  37584. angularSensibilityX: number;
  37585. /**
  37586. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37587. */
  37588. angularSensibilityY: number;
  37589. /**
  37590. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37591. */
  37592. pinchPrecision: number;
  37593. /**
  37594. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37595. * It will be used instead of pinchDeltaPrecision if different from 0.
  37596. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37597. */
  37598. pinchDeltaPercentage: number;
  37599. /**
  37600. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37601. */
  37602. panningSensibility: number;
  37603. /**
  37604. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37605. */
  37606. keysUp: number[];
  37607. /**
  37608. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37609. */
  37610. keysDown: number[];
  37611. /**
  37612. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37613. */
  37614. keysLeft: number[];
  37615. /**
  37616. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37617. */
  37618. keysRight: number[];
  37619. /**
  37620. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37621. */
  37622. wheelPrecision: number;
  37623. /**
  37624. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37625. * It will be used instead of pinchDeltaPrecision if different from 0.
  37626. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37627. */
  37628. wheelDeltaPercentage: number;
  37629. /**
  37630. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37631. */
  37632. zoomOnFactor: number;
  37633. /**
  37634. * Defines a screen offset for the camera position.
  37635. */
  37636. targetScreenOffset: Vector2;
  37637. /**
  37638. * Allows the camera to be completely reversed.
  37639. * If false the camera can not arrive upside down.
  37640. */
  37641. allowUpsideDown: boolean;
  37642. /**
  37643. * Define if double tap/click is used to restore the previously saved state of the camera.
  37644. */
  37645. useInputToRestoreState: boolean;
  37646. /** @hidden */
  37647. _viewMatrix: Matrix;
  37648. /** @hidden */
  37649. _useCtrlForPanning: boolean;
  37650. /** @hidden */
  37651. _panningMouseButton: number;
  37652. /**
  37653. * Defines the input associated to the camera.
  37654. */
  37655. inputs: ArcRotateCameraInputsManager;
  37656. /** @hidden */
  37657. _reset: () => void;
  37658. /**
  37659. * Defines the allowed panning axis.
  37660. */
  37661. panningAxis: Vector3;
  37662. protected _localDirection: Vector3;
  37663. protected _transformedDirection: Vector3;
  37664. private _bouncingBehavior;
  37665. /**
  37666. * Gets the bouncing behavior of the camera if it has been enabled.
  37667. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37668. */
  37669. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37670. /**
  37671. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37672. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37673. */
  37674. useBouncingBehavior: boolean;
  37675. private _framingBehavior;
  37676. /**
  37677. * Gets the framing behavior of the camera if it has been enabled.
  37678. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37679. */
  37680. readonly framingBehavior: Nullable<FramingBehavior>;
  37681. /**
  37682. * Defines if the framing behavior of the camera is enabled on the camera.
  37683. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37684. */
  37685. useFramingBehavior: boolean;
  37686. private _autoRotationBehavior;
  37687. /**
  37688. * Gets the auto rotation behavior of the camera if it has been enabled.
  37689. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37690. */
  37691. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37692. /**
  37693. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37694. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37695. */
  37696. useAutoRotationBehavior: boolean;
  37697. /**
  37698. * Observable triggered when the mesh target has been changed on the camera.
  37699. */
  37700. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37701. /**
  37702. * Event raised when the camera is colliding with a mesh.
  37703. */
  37704. onCollide: (collidedMesh: AbstractMesh) => void;
  37705. /**
  37706. * Defines whether the camera should check collision with the objects oh the scene.
  37707. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37708. */
  37709. checkCollisions: boolean;
  37710. /**
  37711. * Defines the collision radius of the camera.
  37712. * This simulates a sphere around the camera.
  37713. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37714. */
  37715. collisionRadius: Vector3;
  37716. protected _collider: Collider;
  37717. protected _previousPosition: Vector3;
  37718. protected _collisionVelocity: Vector3;
  37719. protected _newPosition: Vector3;
  37720. protected _previousAlpha: number;
  37721. protected _previousBeta: number;
  37722. protected _previousRadius: number;
  37723. protected _collisionTriggered: boolean;
  37724. protected _targetBoundingCenter: Nullable<Vector3>;
  37725. private _computationVector;
  37726. /**
  37727. * Instantiates a new ArcRotateCamera in a given scene
  37728. * @param name Defines the name of the camera
  37729. * @param alpha Defines the camera rotation along the logitudinal axis
  37730. * @param beta Defines the camera rotation along the latitudinal axis
  37731. * @param radius Defines the camera distance from its target
  37732. * @param target Defines the camera target
  37733. * @param scene Defines the scene the camera belongs to
  37734. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37735. */
  37736. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37737. /** @hidden */
  37738. _initCache(): void;
  37739. /** @hidden */
  37740. _updateCache(ignoreParentClass?: boolean): void;
  37741. protected _getTargetPosition(): Vector3;
  37742. private _storedAlpha;
  37743. private _storedBeta;
  37744. private _storedRadius;
  37745. private _storedTarget;
  37746. private _storedTargetScreenOffset;
  37747. /**
  37748. * Stores the current state of the camera (alpha, beta, radius and target)
  37749. * @returns the camera itself
  37750. */
  37751. storeState(): Camera;
  37752. /**
  37753. * @hidden
  37754. * Restored camera state. You must call storeState() first
  37755. */
  37756. _restoreStateValues(): boolean;
  37757. /** @hidden */
  37758. _isSynchronizedViewMatrix(): boolean;
  37759. /**
  37760. * Attached controls to the current camera.
  37761. * @param element Defines the element the controls should be listened from
  37762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37763. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37764. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37765. */
  37766. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37767. /**
  37768. * Detach the current controls from the camera.
  37769. * The camera will stop reacting to inputs.
  37770. * @param element Defines the element to stop listening the inputs from
  37771. */
  37772. detachControl(element: HTMLElement): void;
  37773. /** @hidden */
  37774. _checkInputs(): void;
  37775. protected _checkLimits(): void;
  37776. /**
  37777. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37778. */
  37779. rebuildAnglesAndRadius(): void;
  37780. /**
  37781. * Use a position to define the current camera related information like alpha, beta and radius
  37782. * @param position Defines the position to set the camera at
  37783. */
  37784. setPosition(position: Vector3): void;
  37785. /**
  37786. * Defines the target the camera should look at.
  37787. * This will automatically adapt alpha beta and radius to fit within the new target.
  37788. * @param target Defines the new target as a Vector or a mesh
  37789. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37790. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37791. */
  37792. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37793. /** @hidden */
  37794. _getViewMatrix(): Matrix;
  37795. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37796. /**
  37797. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37798. * @param meshes Defines the mesh to zoom on
  37799. * @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)
  37800. */
  37801. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37802. /**
  37803. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37804. * The target will be changed but the radius
  37805. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37806. * @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)
  37807. */
  37808. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37809. min: Vector3;
  37810. max: Vector3;
  37811. distance: number;
  37812. }, doNotUpdateMaxZ?: boolean): void;
  37813. /**
  37814. * @override
  37815. * Override Camera.createRigCamera
  37816. */
  37817. createRigCamera(name: string, cameraIndex: number): Camera;
  37818. /**
  37819. * @hidden
  37820. * @override
  37821. * Override Camera._updateRigCameras
  37822. */
  37823. _updateRigCameras(): void;
  37824. /**
  37825. * Destroy the camera and release the current resources hold by it.
  37826. */
  37827. dispose(): void;
  37828. /**
  37829. * Gets the current object class name.
  37830. * @return the class name
  37831. */
  37832. getClassName(): string;
  37833. }
  37834. }
  37835. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37836. import { Behavior } from "babylonjs/Behaviors/behavior";
  37837. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37838. /**
  37839. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37840. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37841. */
  37842. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37843. /**
  37844. * Gets the name of the behavior.
  37845. */
  37846. readonly name: string;
  37847. private _zoomStopsAnimation;
  37848. private _idleRotationSpeed;
  37849. private _idleRotationWaitTime;
  37850. private _idleRotationSpinupTime;
  37851. /**
  37852. * Sets the flag that indicates if user zooming should stop animation.
  37853. */
  37854. /**
  37855. * Gets the flag that indicates if user zooming should stop animation.
  37856. */
  37857. zoomStopsAnimation: boolean;
  37858. /**
  37859. * Sets the default speed at which the camera rotates around the model.
  37860. */
  37861. /**
  37862. * Gets the default speed at which the camera rotates around the model.
  37863. */
  37864. idleRotationSpeed: number;
  37865. /**
  37866. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37867. */
  37868. /**
  37869. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37870. */
  37871. idleRotationWaitTime: number;
  37872. /**
  37873. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37874. */
  37875. /**
  37876. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37877. */
  37878. idleRotationSpinupTime: number;
  37879. /**
  37880. * Gets a value indicating if the camera is currently rotating because of this behavior
  37881. */
  37882. readonly rotationInProgress: boolean;
  37883. private _onPrePointerObservableObserver;
  37884. private _onAfterCheckInputsObserver;
  37885. private _attachedCamera;
  37886. private _isPointerDown;
  37887. private _lastFrameTime;
  37888. private _lastInteractionTime;
  37889. private _cameraRotationSpeed;
  37890. /**
  37891. * Initializes the behavior.
  37892. */
  37893. init(): void;
  37894. /**
  37895. * Attaches the behavior to its arc rotate camera.
  37896. * @param camera Defines the camera to attach the behavior to
  37897. */
  37898. attach(camera: ArcRotateCamera): void;
  37899. /**
  37900. * Detaches the behavior from its current arc rotate camera.
  37901. */
  37902. detach(): void;
  37903. /**
  37904. * Returns true if user is scrolling.
  37905. * @return true if user is scrolling.
  37906. */
  37907. private _userIsZooming;
  37908. private _lastFrameRadius;
  37909. private _shouldAnimationStopForInteraction;
  37910. /**
  37911. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37912. */
  37913. private _applyUserInteraction;
  37914. private _userIsMoving;
  37915. }
  37916. }
  37917. declare module "babylonjs/Behaviors/Cameras/index" {
  37918. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37919. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37920. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37921. }
  37922. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37923. import { Mesh } from "babylonjs/Meshes/mesh";
  37924. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37925. import { Behavior } from "babylonjs/Behaviors/behavior";
  37926. /**
  37927. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37928. */
  37929. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37930. private ui;
  37931. /**
  37932. * The name of the behavior
  37933. */
  37934. name: string;
  37935. /**
  37936. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37937. */
  37938. distanceAwayFromFace: number;
  37939. /**
  37940. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37941. */
  37942. distanceAwayFromBottomOfFace: number;
  37943. private _faceVectors;
  37944. private _target;
  37945. private _scene;
  37946. private _onRenderObserver;
  37947. private _tmpMatrix;
  37948. private _tmpVector;
  37949. /**
  37950. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37951. * @param ui The transform node that should be attched to the mesh
  37952. */
  37953. constructor(ui: TransformNode);
  37954. /**
  37955. * Initializes the behavior
  37956. */
  37957. init(): void;
  37958. private _closestFace;
  37959. private _zeroVector;
  37960. private _lookAtTmpMatrix;
  37961. private _lookAtToRef;
  37962. /**
  37963. * Attaches the AttachToBoxBehavior to the passed in mesh
  37964. * @param target The mesh that the specified node will be attached to
  37965. */
  37966. attach(target: Mesh): void;
  37967. /**
  37968. * Detaches the behavior from the mesh
  37969. */
  37970. detach(): void;
  37971. }
  37972. }
  37973. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37974. import { Behavior } from "babylonjs/Behaviors/behavior";
  37975. import { Mesh } from "babylonjs/Meshes/mesh";
  37976. /**
  37977. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37978. */
  37979. export class FadeInOutBehavior implements Behavior<Mesh> {
  37980. /**
  37981. * Time in milliseconds to delay before fading in (Default: 0)
  37982. */
  37983. delay: number;
  37984. /**
  37985. * Time in milliseconds for the mesh to fade in (Default: 300)
  37986. */
  37987. fadeInTime: number;
  37988. private _millisecondsPerFrame;
  37989. private _hovered;
  37990. private _hoverValue;
  37991. private _ownerNode;
  37992. /**
  37993. * Instatiates the FadeInOutBehavior
  37994. */
  37995. constructor();
  37996. /**
  37997. * The name of the behavior
  37998. */
  37999. readonly name: string;
  38000. /**
  38001. * Initializes the behavior
  38002. */
  38003. init(): void;
  38004. /**
  38005. * Attaches the fade behavior on the passed in mesh
  38006. * @param ownerNode The mesh that will be faded in/out once attached
  38007. */
  38008. attach(ownerNode: Mesh): void;
  38009. /**
  38010. * Detaches the behavior from the mesh
  38011. */
  38012. detach(): void;
  38013. /**
  38014. * Triggers the mesh to begin fading in or out
  38015. * @param value if the object should fade in or out (true to fade in)
  38016. */
  38017. fadeIn(value: boolean): void;
  38018. private _update;
  38019. private _setAllVisibility;
  38020. }
  38021. }
  38022. declare module "babylonjs/Misc/pivotTools" {
  38023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38024. /**
  38025. * Class containing a set of static utilities functions for managing Pivots
  38026. * @hidden
  38027. */
  38028. export class PivotTools {
  38029. private static _PivotCached;
  38030. private static _OldPivotPoint;
  38031. private static _PivotTranslation;
  38032. private static _PivotTmpVector;
  38033. /** @hidden */
  38034. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38035. /** @hidden */
  38036. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38037. }
  38038. }
  38039. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38040. import { Scene } from "babylonjs/scene";
  38041. import { Vector4 } from "babylonjs/Maths/math.vector";
  38042. import { Mesh } from "babylonjs/Meshes/mesh";
  38043. import { Nullable } from "babylonjs/types";
  38044. import { Plane } from "babylonjs/Maths/math.plane";
  38045. /**
  38046. * Class containing static functions to help procedurally build meshes
  38047. */
  38048. export class PlaneBuilder {
  38049. /**
  38050. * Creates a plane mesh
  38051. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38052. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38053. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38057. * @param name defines the name of the mesh
  38058. * @param options defines the options used to create the mesh
  38059. * @param scene defines the hosting scene
  38060. * @returns the plane mesh
  38061. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38062. */
  38063. static CreatePlane(name: string, options: {
  38064. size?: number;
  38065. width?: number;
  38066. height?: number;
  38067. sideOrientation?: number;
  38068. frontUVs?: Vector4;
  38069. backUVs?: Vector4;
  38070. updatable?: boolean;
  38071. sourcePlane?: Plane;
  38072. }, scene?: Nullable<Scene>): Mesh;
  38073. }
  38074. }
  38075. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38076. import { Behavior } from "babylonjs/Behaviors/behavior";
  38077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38078. import { Observable } from "babylonjs/Misc/observable";
  38079. import { Vector3 } from "babylonjs/Maths/math.vector";
  38080. import { Ray } from "babylonjs/Culling/ray";
  38081. import "babylonjs/Meshes/Builders/planeBuilder";
  38082. /**
  38083. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38084. */
  38085. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38086. private static _AnyMouseID;
  38087. /**
  38088. * Abstract mesh the behavior is set on
  38089. */
  38090. attachedNode: AbstractMesh;
  38091. private _dragPlane;
  38092. private _scene;
  38093. private _pointerObserver;
  38094. private _beforeRenderObserver;
  38095. private static _planeScene;
  38096. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38097. /**
  38098. * 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)
  38099. */
  38100. maxDragAngle: number;
  38101. /**
  38102. * @hidden
  38103. */
  38104. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38105. /**
  38106. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38107. */
  38108. currentDraggingPointerID: number;
  38109. /**
  38110. * The last position where the pointer hit the drag plane in world space
  38111. */
  38112. lastDragPosition: Vector3;
  38113. /**
  38114. * If the behavior is currently in a dragging state
  38115. */
  38116. dragging: boolean;
  38117. /**
  38118. * 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)
  38119. */
  38120. dragDeltaRatio: number;
  38121. /**
  38122. * If the drag plane orientation should be updated during the dragging (Default: true)
  38123. */
  38124. updateDragPlane: boolean;
  38125. private _debugMode;
  38126. private _moving;
  38127. /**
  38128. * Fires each time the attached mesh is dragged with the pointer
  38129. * * delta between last drag position and current drag position in world space
  38130. * * dragDistance along the drag axis
  38131. * * dragPlaneNormal normal of the current drag plane used during the drag
  38132. * * dragPlanePoint in world space where the drag intersects the drag plane
  38133. */
  38134. onDragObservable: Observable<{
  38135. delta: Vector3;
  38136. dragPlanePoint: Vector3;
  38137. dragPlaneNormal: Vector3;
  38138. dragDistance: number;
  38139. pointerId: number;
  38140. }>;
  38141. /**
  38142. * Fires each time a drag begins (eg. mouse down on mesh)
  38143. */
  38144. onDragStartObservable: Observable<{
  38145. dragPlanePoint: Vector3;
  38146. pointerId: number;
  38147. }>;
  38148. /**
  38149. * Fires each time a drag ends (eg. mouse release after drag)
  38150. */
  38151. onDragEndObservable: Observable<{
  38152. dragPlanePoint: Vector3;
  38153. pointerId: number;
  38154. }>;
  38155. /**
  38156. * If the attached mesh should be moved when dragged
  38157. */
  38158. moveAttached: boolean;
  38159. /**
  38160. * If the drag behavior will react to drag events (Default: true)
  38161. */
  38162. enabled: boolean;
  38163. /**
  38164. * If pointer events should start and release the drag (Default: true)
  38165. */
  38166. startAndReleaseDragOnPointerEvents: boolean;
  38167. /**
  38168. * If camera controls should be detached during the drag
  38169. */
  38170. detachCameraControls: boolean;
  38171. /**
  38172. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38173. */
  38174. useObjectOrienationForDragging: boolean;
  38175. private _options;
  38176. /**
  38177. * Creates a pointer drag behavior that can be attached to a mesh
  38178. * @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)
  38179. */
  38180. constructor(options?: {
  38181. dragAxis?: Vector3;
  38182. dragPlaneNormal?: Vector3;
  38183. });
  38184. /**
  38185. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38186. */
  38187. validateDrag: (targetPosition: Vector3) => boolean;
  38188. /**
  38189. * The name of the behavior
  38190. */
  38191. readonly name: string;
  38192. /**
  38193. * Initializes the behavior
  38194. */
  38195. init(): void;
  38196. private _tmpVector;
  38197. private _alternatePickedPoint;
  38198. private _worldDragAxis;
  38199. private _targetPosition;
  38200. private _attachedElement;
  38201. /**
  38202. * Attaches the drag behavior the passed in mesh
  38203. * @param ownerNode The mesh that will be dragged around once attached
  38204. * @param predicate Predicate to use for pick filtering
  38205. */
  38206. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38207. /**
  38208. * Force relase the drag action by code.
  38209. */
  38210. releaseDrag(): void;
  38211. private _startDragRay;
  38212. private _lastPointerRay;
  38213. /**
  38214. * Simulates the start of a pointer drag event on the behavior
  38215. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38216. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38217. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38218. */
  38219. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38220. private _startDrag;
  38221. private _dragDelta;
  38222. private _moveDrag;
  38223. private _pickWithRayOnDragPlane;
  38224. private _pointA;
  38225. private _pointB;
  38226. private _pointC;
  38227. private _lineA;
  38228. private _lineB;
  38229. private _localAxis;
  38230. private _lookAt;
  38231. private _updateDragPlanePosition;
  38232. /**
  38233. * Detaches the behavior from the mesh
  38234. */
  38235. detach(): void;
  38236. }
  38237. }
  38238. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38239. import { Mesh } from "babylonjs/Meshes/mesh";
  38240. import { Behavior } from "babylonjs/Behaviors/behavior";
  38241. /**
  38242. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38243. */
  38244. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38245. private _dragBehaviorA;
  38246. private _dragBehaviorB;
  38247. private _startDistance;
  38248. private _initialScale;
  38249. private _targetScale;
  38250. private _ownerNode;
  38251. private _sceneRenderObserver;
  38252. /**
  38253. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38254. */
  38255. constructor();
  38256. /**
  38257. * The name of the behavior
  38258. */
  38259. readonly name: string;
  38260. /**
  38261. * Initializes the behavior
  38262. */
  38263. init(): void;
  38264. private _getCurrentDistance;
  38265. /**
  38266. * Attaches the scale behavior the passed in mesh
  38267. * @param ownerNode The mesh that will be scaled around once attached
  38268. */
  38269. attach(ownerNode: Mesh): void;
  38270. /**
  38271. * Detaches the behavior from the mesh
  38272. */
  38273. detach(): void;
  38274. }
  38275. }
  38276. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38277. import { Behavior } from "babylonjs/Behaviors/behavior";
  38278. import { Mesh } from "babylonjs/Meshes/mesh";
  38279. import { Observable } from "babylonjs/Misc/observable";
  38280. /**
  38281. * 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
  38282. */
  38283. export class SixDofDragBehavior implements Behavior<Mesh> {
  38284. private static _virtualScene;
  38285. private _ownerNode;
  38286. private _sceneRenderObserver;
  38287. private _scene;
  38288. private _targetPosition;
  38289. private _virtualOriginMesh;
  38290. private _virtualDragMesh;
  38291. private _pointerObserver;
  38292. private _moving;
  38293. private _startingOrientation;
  38294. /**
  38295. * 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)
  38296. */
  38297. private zDragFactor;
  38298. /**
  38299. * If the object should rotate to face the drag origin
  38300. */
  38301. rotateDraggedObject: boolean;
  38302. /**
  38303. * If the behavior is currently in a dragging state
  38304. */
  38305. dragging: boolean;
  38306. /**
  38307. * 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)
  38308. */
  38309. dragDeltaRatio: number;
  38310. /**
  38311. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38312. */
  38313. currentDraggingPointerID: number;
  38314. /**
  38315. * If camera controls should be detached during the drag
  38316. */
  38317. detachCameraControls: boolean;
  38318. /**
  38319. * Fires each time a drag starts
  38320. */
  38321. onDragStartObservable: Observable<{}>;
  38322. /**
  38323. * Fires each time a drag ends (eg. mouse release after drag)
  38324. */
  38325. onDragEndObservable: Observable<{}>;
  38326. /**
  38327. * 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
  38328. */
  38329. constructor();
  38330. /**
  38331. * The name of the behavior
  38332. */
  38333. readonly name: string;
  38334. /**
  38335. * Initializes the behavior
  38336. */
  38337. init(): void;
  38338. /**
  38339. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38340. */
  38341. private readonly _pointerCamera;
  38342. /**
  38343. * Attaches the scale behavior the passed in mesh
  38344. * @param ownerNode The mesh that will be scaled around once attached
  38345. */
  38346. attach(ownerNode: Mesh): void;
  38347. /**
  38348. * Detaches the behavior from the mesh
  38349. */
  38350. detach(): void;
  38351. }
  38352. }
  38353. declare module "babylonjs/Behaviors/Meshes/index" {
  38354. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38355. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38356. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38357. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38358. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38359. }
  38360. declare module "babylonjs/Behaviors/index" {
  38361. export * from "babylonjs/Behaviors/behavior";
  38362. export * from "babylonjs/Behaviors/Cameras/index";
  38363. export * from "babylonjs/Behaviors/Meshes/index";
  38364. }
  38365. declare module "babylonjs/Bones/boneIKController" {
  38366. import { Bone } from "babylonjs/Bones/bone";
  38367. import { Vector3 } from "babylonjs/Maths/math.vector";
  38368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38369. import { Nullable } from "babylonjs/types";
  38370. /**
  38371. * Class used to apply inverse kinematics to bones
  38372. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38373. */
  38374. export class BoneIKController {
  38375. private static _tmpVecs;
  38376. private static _tmpQuat;
  38377. private static _tmpMats;
  38378. /**
  38379. * Gets or sets the target mesh
  38380. */
  38381. targetMesh: AbstractMesh;
  38382. /** Gets or sets the mesh used as pole */
  38383. poleTargetMesh: AbstractMesh;
  38384. /**
  38385. * Gets or sets the bone used as pole
  38386. */
  38387. poleTargetBone: Nullable<Bone>;
  38388. /**
  38389. * Gets or sets the target position
  38390. */
  38391. targetPosition: Vector3;
  38392. /**
  38393. * Gets or sets the pole target position
  38394. */
  38395. poleTargetPosition: Vector3;
  38396. /**
  38397. * Gets or sets the pole target local offset
  38398. */
  38399. poleTargetLocalOffset: Vector3;
  38400. /**
  38401. * Gets or sets the pole angle
  38402. */
  38403. poleAngle: number;
  38404. /**
  38405. * Gets or sets the mesh associated with the controller
  38406. */
  38407. mesh: AbstractMesh;
  38408. /**
  38409. * 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)
  38410. */
  38411. slerpAmount: number;
  38412. private _bone1Quat;
  38413. private _bone1Mat;
  38414. private _bone2Ang;
  38415. private _bone1;
  38416. private _bone2;
  38417. private _bone1Length;
  38418. private _bone2Length;
  38419. private _maxAngle;
  38420. private _maxReach;
  38421. private _rightHandedSystem;
  38422. private _bendAxis;
  38423. private _slerping;
  38424. private _adjustRoll;
  38425. /**
  38426. * Gets or sets maximum allowed angle
  38427. */
  38428. maxAngle: number;
  38429. /**
  38430. * Creates a new BoneIKController
  38431. * @param mesh defines the mesh to control
  38432. * @param bone defines the bone to control
  38433. * @param options defines options to set up the controller
  38434. */
  38435. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38436. targetMesh?: AbstractMesh;
  38437. poleTargetMesh?: AbstractMesh;
  38438. poleTargetBone?: Bone;
  38439. poleTargetLocalOffset?: Vector3;
  38440. poleAngle?: number;
  38441. bendAxis?: Vector3;
  38442. maxAngle?: number;
  38443. slerpAmount?: number;
  38444. });
  38445. private _setMaxAngle;
  38446. /**
  38447. * Force the controller to update the bones
  38448. */
  38449. update(): void;
  38450. }
  38451. }
  38452. declare module "babylonjs/Bones/boneLookController" {
  38453. import { Vector3 } from "babylonjs/Maths/math.vector";
  38454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38455. import { Bone } from "babylonjs/Bones/bone";
  38456. import { Space } from "babylonjs/Maths/math.axis";
  38457. /**
  38458. * Class used to make a bone look toward a point in space
  38459. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38460. */
  38461. export class BoneLookController {
  38462. private static _tmpVecs;
  38463. private static _tmpQuat;
  38464. private static _tmpMats;
  38465. /**
  38466. * The target Vector3 that the bone will look at
  38467. */
  38468. target: Vector3;
  38469. /**
  38470. * The mesh that the bone is attached to
  38471. */
  38472. mesh: AbstractMesh;
  38473. /**
  38474. * The bone that will be looking to the target
  38475. */
  38476. bone: Bone;
  38477. /**
  38478. * The up axis of the coordinate system that is used when the bone is rotated
  38479. */
  38480. upAxis: Vector3;
  38481. /**
  38482. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38483. */
  38484. upAxisSpace: Space;
  38485. /**
  38486. * Used to make an adjustment to the yaw of the bone
  38487. */
  38488. adjustYaw: number;
  38489. /**
  38490. * Used to make an adjustment to the pitch of the bone
  38491. */
  38492. adjustPitch: number;
  38493. /**
  38494. * Used to make an adjustment to the roll of the bone
  38495. */
  38496. adjustRoll: number;
  38497. /**
  38498. * 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)
  38499. */
  38500. slerpAmount: number;
  38501. private _minYaw;
  38502. private _maxYaw;
  38503. private _minPitch;
  38504. private _maxPitch;
  38505. private _minYawSin;
  38506. private _minYawCos;
  38507. private _maxYawSin;
  38508. private _maxYawCos;
  38509. private _midYawConstraint;
  38510. private _minPitchTan;
  38511. private _maxPitchTan;
  38512. private _boneQuat;
  38513. private _slerping;
  38514. private _transformYawPitch;
  38515. private _transformYawPitchInv;
  38516. private _firstFrameSkipped;
  38517. private _yawRange;
  38518. private _fowardAxis;
  38519. /**
  38520. * Gets or sets the minimum yaw angle that the bone can look to
  38521. */
  38522. minYaw: number;
  38523. /**
  38524. * Gets or sets the maximum yaw angle that the bone can look to
  38525. */
  38526. maxYaw: number;
  38527. /**
  38528. * Gets or sets the minimum pitch angle that the bone can look to
  38529. */
  38530. minPitch: number;
  38531. /**
  38532. * Gets or sets the maximum pitch angle that the bone can look to
  38533. */
  38534. maxPitch: number;
  38535. /**
  38536. * Create a BoneLookController
  38537. * @param mesh the mesh that the bone belongs to
  38538. * @param bone the bone that will be looking to the target
  38539. * @param target the target Vector3 to look at
  38540. * @param options optional settings:
  38541. * * maxYaw: the maximum angle the bone will yaw to
  38542. * * minYaw: the minimum angle the bone will yaw to
  38543. * * maxPitch: the maximum angle the bone will pitch to
  38544. * * minPitch: the minimum angle the bone will yaw to
  38545. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38546. * * upAxis: the up axis of the coordinate system
  38547. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38548. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38549. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38550. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38551. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38552. * * adjustRoll: used to make an adjustment to the roll of the bone
  38553. **/
  38554. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38555. maxYaw?: number;
  38556. minYaw?: number;
  38557. maxPitch?: number;
  38558. minPitch?: number;
  38559. slerpAmount?: number;
  38560. upAxis?: Vector3;
  38561. upAxisSpace?: Space;
  38562. yawAxis?: Vector3;
  38563. pitchAxis?: Vector3;
  38564. adjustYaw?: number;
  38565. adjustPitch?: number;
  38566. adjustRoll?: number;
  38567. });
  38568. /**
  38569. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38570. */
  38571. update(): void;
  38572. private _getAngleDiff;
  38573. private _getAngleBetween;
  38574. private _isAngleBetween;
  38575. }
  38576. }
  38577. declare module "babylonjs/Bones/index" {
  38578. export * from "babylonjs/Bones/bone";
  38579. export * from "babylonjs/Bones/boneIKController";
  38580. export * from "babylonjs/Bones/boneLookController";
  38581. export * from "babylonjs/Bones/skeleton";
  38582. }
  38583. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38584. import { Nullable } from "babylonjs/types";
  38585. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38586. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38587. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38588. /**
  38589. * Manage the gamepad inputs to control an arc rotate camera.
  38590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38591. */
  38592. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38593. /**
  38594. * Defines the camera the input is attached to.
  38595. */
  38596. camera: ArcRotateCamera;
  38597. /**
  38598. * Defines the gamepad the input is gathering event from.
  38599. */
  38600. gamepad: Nullable<Gamepad>;
  38601. /**
  38602. * Defines the gamepad rotation sensiblity.
  38603. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38604. */
  38605. gamepadRotationSensibility: number;
  38606. /**
  38607. * Defines the gamepad move sensiblity.
  38608. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38609. */
  38610. gamepadMoveSensibility: number;
  38611. private _onGamepadConnectedObserver;
  38612. private _onGamepadDisconnectedObserver;
  38613. /**
  38614. * Attach the input controls to a specific dom element to get the input from.
  38615. * @param element Defines the element the controls should be listened from
  38616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38617. */
  38618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38619. /**
  38620. * Detach the current controls from the specified dom element.
  38621. * @param element Defines the element to stop listening the inputs from
  38622. */
  38623. detachControl(element: Nullable<HTMLElement>): void;
  38624. /**
  38625. * Update the current camera state depending on the inputs that have been used this frame.
  38626. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38627. */
  38628. checkInputs(): void;
  38629. /**
  38630. * Gets the class name of the current intput.
  38631. * @returns the class name
  38632. */
  38633. getClassName(): string;
  38634. /**
  38635. * Get the friendly name associated with the input class.
  38636. * @returns the input friendly name
  38637. */
  38638. getSimpleName(): string;
  38639. }
  38640. }
  38641. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38642. import { Nullable } from "babylonjs/types";
  38643. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38645. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38646. interface ArcRotateCameraInputsManager {
  38647. /**
  38648. * Add orientation input support to the input manager.
  38649. * @returns the current input manager
  38650. */
  38651. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38652. }
  38653. }
  38654. /**
  38655. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38657. */
  38658. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38659. /**
  38660. * Defines the camera the input is attached to.
  38661. */
  38662. camera: ArcRotateCamera;
  38663. /**
  38664. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38665. */
  38666. alphaCorrection: number;
  38667. /**
  38668. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38669. */
  38670. gammaCorrection: number;
  38671. private _alpha;
  38672. private _gamma;
  38673. private _dirty;
  38674. private _deviceOrientationHandler;
  38675. /**
  38676. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38677. */
  38678. constructor();
  38679. /**
  38680. * Attach the input controls to a specific dom element to get the input from.
  38681. * @param element Defines the element the controls should be listened from
  38682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38683. */
  38684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38685. /** @hidden */
  38686. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38687. /**
  38688. * Update the current camera state depending on the inputs that have been used this frame.
  38689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38690. */
  38691. checkInputs(): void;
  38692. /**
  38693. * Detach the current controls from the specified dom element.
  38694. * @param element Defines the element to stop listening the inputs from
  38695. */
  38696. detachControl(element: Nullable<HTMLElement>): void;
  38697. /**
  38698. * Gets the class name of the current intput.
  38699. * @returns the class name
  38700. */
  38701. getClassName(): string;
  38702. /**
  38703. * Get the friendly name associated with the input class.
  38704. * @returns the input friendly name
  38705. */
  38706. getSimpleName(): string;
  38707. }
  38708. }
  38709. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38710. import { Nullable } from "babylonjs/types";
  38711. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38712. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38713. /**
  38714. * Listen to mouse events to control the camera.
  38715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38716. */
  38717. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38718. /**
  38719. * Defines the camera the input is attached to.
  38720. */
  38721. camera: FlyCamera;
  38722. /**
  38723. * Defines if touch is enabled. (Default is true.)
  38724. */
  38725. touchEnabled: boolean;
  38726. /**
  38727. * Defines the buttons associated with the input to handle camera rotation.
  38728. */
  38729. buttons: number[];
  38730. /**
  38731. * Assign buttons for Yaw control.
  38732. */
  38733. buttonsYaw: number[];
  38734. /**
  38735. * Assign buttons for Pitch control.
  38736. */
  38737. buttonsPitch: number[];
  38738. /**
  38739. * Assign buttons for Roll control.
  38740. */
  38741. buttonsRoll: number[];
  38742. /**
  38743. * Detect if any button is being pressed while mouse is moved.
  38744. * -1 = Mouse locked.
  38745. * 0 = Left button.
  38746. * 1 = Middle Button.
  38747. * 2 = Right Button.
  38748. */
  38749. activeButton: number;
  38750. /**
  38751. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38752. * Higher values reduce its sensitivity.
  38753. */
  38754. angularSensibility: number;
  38755. private _mousemoveCallback;
  38756. private _observer;
  38757. private _rollObserver;
  38758. private previousPosition;
  38759. private noPreventDefault;
  38760. private element;
  38761. /**
  38762. * Listen to mouse events to control the camera.
  38763. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38764. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38765. */
  38766. constructor(touchEnabled?: boolean);
  38767. /**
  38768. * Attach the mouse control to the HTML DOM element.
  38769. * @param element Defines the element that listens to the input events.
  38770. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38771. */
  38772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38773. /**
  38774. * Detach the current controls from the specified dom element.
  38775. * @param element Defines the element to stop listening the inputs from
  38776. */
  38777. detachControl(element: Nullable<HTMLElement>): void;
  38778. /**
  38779. * Gets the class name of the current input.
  38780. * @returns the class name.
  38781. */
  38782. getClassName(): string;
  38783. /**
  38784. * Get the friendly name associated with the input class.
  38785. * @returns the input's friendly name.
  38786. */
  38787. getSimpleName(): string;
  38788. private _pointerInput;
  38789. private _onMouseMove;
  38790. /**
  38791. * Rotate camera by mouse offset.
  38792. */
  38793. private rotateCamera;
  38794. }
  38795. }
  38796. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38797. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38798. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38799. /**
  38800. * Default Inputs manager for the FlyCamera.
  38801. * It groups all the default supported inputs for ease of use.
  38802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38803. */
  38804. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38805. /**
  38806. * Instantiates a new FlyCameraInputsManager.
  38807. * @param camera Defines the camera the inputs belong to.
  38808. */
  38809. constructor(camera: FlyCamera);
  38810. /**
  38811. * Add keyboard input support to the input manager.
  38812. * @returns the new FlyCameraKeyboardMoveInput().
  38813. */
  38814. addKeyboard(): FlyCameraInputsManager;
  38815. /**
  38816. * Add mouse input support to the input manager.
  38817. * @param touchEnabled Enable touch screen support.
  38818. * @returns the new FlyCameraMouseInput().
  38819. */
  38820. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38821. }
  38822. }
  38823. declare module "babylonjs/Cameras/flyCamera" {
  38824. import { Scene } from "babylonjs/scene";
  38825. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38827. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38828. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38829. /**
  38830. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38831. * such as in a 3D Space Shooter or a Flight Simulator.
  38832. */
  38833. export class FlyCamera extends TargetCamera {
  38834. /**
  38835. * Define the collision ellipsoid of the camera.
  38836. * This is helpful for simulating a camera body, like a player's body.
  38837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38838. */
  38839. ellipsoid: Vector3;
  38840. /**
  38841. * Define an offset for the position of the ellipsoid around the camera.
  38842. * This can be helpful if the camera is attached away from the player's body center,
  38843. * such as at its head.
  38844. */
  38845. ellipsoidOffset: Vector3;
  38846. /**
  38847. * Enable or disable collisions of the camera with the rest of the scene objects.
  38848. */
  38849. checkCollisions: boolean;
  38850. /**
  38851. * Enable or disable gravity on the camera.
  38852. */
  38853. applyGravity: boolean;
  38854. /**
  38855. * Define the current direction the camera is moving to.
  38856. */
  38857. cameraDirection: Vector3;
  38858. /**
  38859. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38860. * This overrides and empties cameraRotation.
  38861. */
  38862. rotationQuaternion: Quaternion;
  38863. /**
  38864. * Track Roll to maintain the wanted Rolling when looking around.
  38865. */
  38866. _trackRoll: number;
  38867. /**
  38868. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38869. */
  38870. rollCorrect: number;
  38871. /**
  38872. * Mimic a banked turn, Rolling the camera when Yawing.
  38873. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38874. */
  38875. bankedTurn: boolean;
  38876. /**
  38877. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38878. */
  38879. bankedTurnLimit: number;
  38880. /**
  38881. * Value of 0 disables the banked Roll.
  38882. * Value of 1 is equal to the Yaw angle in radians.
  38883. */
  38884. bankedTurnMultiplier: number;
  38885. /**
  38886. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38887. */
  38888. inputs: FlyCameraInputsManager;
  38889. /**
  38890. * Gets the input sensibility for mouse input.
  38891. * Higher values reduce sensitivity.
  38892. */
  38893. /**
  38894. * Sets the input sensibility for a mouse input.
  38895. * Higher values reduce sensitivity.
  38896. */
  38897. angularSensibility: number;
  38898. /**
  38899. * Get the keys for camera movement forward.
  38900. */
  38901. /**
  38902. * Set the keys for camera movement forward.
  38903. */
  38904. keysForward: number[];
  38905. /**
  38906. * Get the keys for camera movement backward.
  38907. */
  38908. keysBackward: number[];
  38909. /**
  38910. * Get the keys for camera movement up.
  38911. */
  38912. /**
  38913. * Set the keys for camera movement up.
  38914. */
  38915. keysUp: number[];
  38916. /**
  38917. * Get the keys for camera movement down.
  38918. */
  38919. /**
  38920. * Set the keys for camera movement down.
  38921. */
  38922. keysDown: number[];
  38923. /**
  38924. * Get the keys for camera movement left.
  38925. */
  38926. /**
  38927. * Set the keys for camera movement left.
  38928. */
  38929. keysLeft: number[];
  38930. /**
  38931. * Set the keys for camera movement right.
  38932. */
  38933. /**
  38934. * Set the keys for camera movement right.
  38935. */
  38936. keysRight: number[];
  38937. /**
  38938. * Event raised when the camera collides with a mesh in the scene.
  38939. */
  38940. onCollide: (collidedMesh: AbstractMesh) => void;
  38941. private _collider;
  38942. private _needMoveForGravity;
  38943. private _oldPosition;
  38944. private _diffPosition;
  38945. private _newPosition;
  38946. /** @hidden */
  38947. _localDirection: Vector3;
  38948. /** @hidden */
  38949. _transformedDirection: Vector3;
  38950. /**
  38951. * Instantiates a FlyCamera.
  38952. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38953. * such as in a 3D Space Shooter or a Flight Simulator.
  38954. * @param name Define the name of the camera in the scene.
  38955. * @param position Define the starting position of the camera in the scene.
  38956. * @param scene Define the scene the camera belongs to.
  38957. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38958. */
  38959. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38960. /**
  38961. * Attach a control to the HTML DOM element.
  38962. * @param element Defines the element that listens to the input events.
  38963. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38964. */
  38965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38966. /**
  38967. * Detach a control from the HTML DOM element.
  38968. * The camera will stop reacting to that input.
  38969. * @param element Defines the element that listens to the input events.
  38970. */
  38971. detachControl(element: HTMLElement): void;
  38972. private _collisionMask;
  38973. /**
  38974. * Get the mask that the camera ignores in collision events.
  38975. */
  38976. /**
  38977. * Set the mask that the camera ignores in collision events.
  38978. */
  38979. collisionMask: number;
  38980. /** @hidden */
  38981. _collideWithWorld(displacement: Vector3): void;
  38982. /** @hidden */
  38983. private _onCollisionPositionChange;
  38984. /** @hidden */
  38985. _checkInputs(): void;
  38986. /** @hidden */
  38987. _decideIfNeedsToMove(): boolean;
  38988. /** @hidden */
  38989. _updatePosition(): void;
  38990. /**
  38991. * Restore the Roll to its target value at the rate specified.
  38992. * @param rate - Higher means slower restoring.
  38993. * @hidden
  38994. */
  38995. restoreRoll(rate: number): void;
  38996. /**
  38997. * Destroy the camera and release the current resources held by it.
  38998. */
  38999. dispose(): void;
  39000. /**
  39001. * Get the current object class name.
  39002. * @returns the class name.
  39003. */
  39004. getClassName(): string;
  39005. }
  39006. }
  39007. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39008. import { Nullable } from "babylonjs/types";
  39009. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39010. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39011. /**
  39012. * Listen to keyboard events to control the camera.
  39013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39014. */
  39015. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39016. /**
  39017. * Defines the camera the input is attached to.
  39018. */
  39019. camera: FlyCamera;
  39020. /**
  39021. * The list of keyboard keys used to control the forward move of the camera.
  39022. */
  39023. keysForward: number[];
  39024. /**
  39025. * The list of keyboard keys used to control the backward move of the camera.
  39026. */
  39027. keysBackward: number[];
  39028. /**
  39029. * The list of keyboard keys used to control the forward move of the camera.
  39030. */
  39031. keysUp: number[];
  39032. /**
  39033. * The list of keyboard keys used to control the backward move of the camera.
  39034. */
  39035. keysDown: number[];
  39036. /**
  39037. * The list of keyboard keys used to control the right strafe move of the camera.
  39038. */
  39039. keysRight: number[];
  39040. /**
  39041. * The list of keyboard keys used to control the left strafe move of the camera.
  39042. */
  39043. keysLeft: number[];
  39044. private _keys;
  39045. private _onCanvasBlurObserver;
  39046. private _onKeyboardObserver;
  39047. private _engine;
  39048. private _scene;
  39049. /**
  39050. * Attach the input controls to a specific dom element to get the input from.
  39051. * @param element Defines the element the controls should be listened from
  39052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39053. */
  39054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39055. /**
  39056. * Detach the current controls from the specified dom element.
  39057. * @param element Defines the element to stop listening the inputs from
  39058. */
  39059. detachControl(element: Nullable<HTMLElement>): void;
  39060. /**
  39061. * Gets the class name of the current intput.
  39062. * @returns the class name
  39063. */
  39064. getClassName(): string;
  39065. /** @hidden */
  39066. _onLostFocus(e: FocusEvent): void;
  39067. /**
  39068. * Get the friendly name associated with the input class.
  39069. * @returns the input friendly name
  39070. */
  39071. getSimpleName(): string;
  39072. /**
  39073. * Update the current camera state depending on the inputs that have been used this frame.
  39074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39075. */
  39076. checkInputs(): void;
  39077. }
  39078. }
  39079. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39080. import { Nullable } from "babylonjs/types";
  39081. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39082. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39083. /**
  39084. * Manage the mouse wheel inputs to control a follow camera.
  39085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39086. */
  39087. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39088. /**
  39089. * Defines the camera the input is attached to.
  39090. */
  39091. camera: FollowCamera;
  39092. /**
  39093. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39094. */
  39095. axisControlRadius: boolean;
  39096. /**
  39097. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39098. */
  39099. axisControlHeight: boolean;
  39100. /**
  39101. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39102. */
  39103. axisControlRotation: boolean;
  39104. /**
  39105. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39106. * relation to mouseWheel events.
  39107. */
  39108. wheelPrecision: number;
  39109. /**
  39110. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39111. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39112. */
  39113. wheelDeltaPercentage: number;
  39114. private _wheel;
  39115. private _observer;
  39116. /**
  39117. * Attach the input controls to a specific dom element to get the input from.
  39118. * @param element Defines the element the controls should be listened from
  39119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39120. */
  39121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39122. /**
  39123. * Detach the current controls from the specified dom element.
  39124. * @param element Defines the element to stop listening the inputs from
  39125. */
  39126. detachControl(element: Nullable<HTMLElement>): void;
  39127. /**
  39128. * Gets the class name of the current intput.
  39129. * @returns the class name
  39130. */
  39131. getClassName(): string;
  39132. /**
  39133. * Get the friendly name associated with the input class.
  39134. * @returns the input friendly name
  39135. */
  39136. getSimpleName(): string;
  39137. }
  39138. }
  39139. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39140. import { Nullable } from "babylonjs/types";
  39141. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39142. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39143. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39144. /**
  39145. * Manage the pointers inputs to control an follow camera.
  39146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39147. */
  39148. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39149. /**
  39150. * Defines the camera the input is attached to.
  39151. */
  39152. camera: FollowCamera;
  39153. /**
  39154. * Gets the class name of the current input.
  39155. * @returns the class name
  39156. */
  39157. getClassName(): string;
  39158. /**
  39159. * Defines the pointer angular sensibility along the X axis or how fast is
  39160. * the camera rotating.
  39161. * A negative number will reverse the axis direction.
  39162. */
  39163. angularSensibilityX: number;
  39164. /**
  39165. * Defines the pointer angular sensibility along the Y axis or how fast is
  39166. * the camera rotating.
  39167. * A negative number will reverse the axis direction.
  39168. */
  39169. angularSensibilityY: number;
  39170. /**
  39171. * Defines the pointer pinch precision or how fast is the camera zooming.
  39172. * A negative number will reverse the axis direction.
  39173. */
  39174. pinchPrecision: number;
  39175. /**
  39176. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39177. * from 0.
  39178. * It defines the percentage of current camera.radius to use as delta when
  39179. * pinch zoom is used.
  39180. */
  39181. pinchDeltaPercentage: number;
  39182. /**
  39183. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39184. */
  39185. axisXControlRadius: boolean;
  39186. /**
  39187. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39188. */
  39189. axisXControlHeight: boolean;
  39190. /**
  39191. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39192. */
  39193. axisXControlRotation: boolean;
  39194. /**
  39195. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39196. */
  39197. axisYControlRadius: boolean;
  39198. /**
  39199. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39200. */
  39201. axisYControlHeight: boolean;
  39202. /**
  39203. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39204. */
  39205. axisYControlRotation: boolean;
  39206. /**
  39207. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39208. */
  39209. axisPinchControlRadius: boolean;
  39210. /**
  39211. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39212. */
  39213. axisPinchControlHeight: boolean;
  39214. /**
  39215. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39216. */
  39217. axisPinchControlRotation: boolean;
  39218. /**
  39219. * Log error messages if basic misconfiguration has occurred.
  39220. */
  39221. warningEnable: boolean;
  39222. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39223. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39224. private _warningCounter;
  39225. private _warning;
  39226. }
  39227. }
  39228. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39229. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39230. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39231. /**
  39232. * Default Inputs manager for the FollowCamera.
  39233. * It groups all the default supported inputs for ease of use.
  39234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39235. */
  39236. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39237. /**
  39238. * Instantiates a new FollowCameraInputsManager.
  39239. * @param camera Defines the camera the inputs belong to
  39240. */
  39241. constructor(camera: FollowCamera);
  39242. /**
  39243. * Add keyboard input support to the input manager.
  39244. * @returns the current input manager
  39245. */
  39246. addKeyboard(): FollowCameraInputsManager;
  39247. /**
  39248. * Add mouse wheel input support to the input manager.
  39249. * @returns the current input manager
  39250. */
  39251. addMouseWheel(): FollowCameraInputsManager;
  39252. /**
  39253. * Add pointers input support to the input manager.
  39254. * @returns the current input manager
  39255. */
  39256. addPointers(): FollowCameraInputsManager;
  39257. /**
  39258. * Add orientation input support to the input manager.
  39259. * @returns the current input manager
  39260. */
  39261. addVRDeviceOrientation(): FollowCameraInputsManager;
  39262. }
  39263. }
  39264. declare module "babylonjs/Cameras/followCamera" {
  39265. import { Nullable } from "babylonjs/types";
  39266. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39267. import { Scene } from "babylonjs/scene";
  39268. import { Vector3 } from "babylonjs/Maths/math.vector";
  39269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39270. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39271. /**
  39272. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39273. * an arc rotate version arcFollowCamera are available.
  39274. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39275. */
  39276. export class FollowCamera extends TargetCamera {
  39277. /**
  39278. * Distance the follow camera should follow an object at
  39279. */
  39280. radius: number;
  39281. /**
  39282. * Minimum allowed distance of the camera to the axis of rotation
  39283. * (The camera can not get closer).
  39284. * This can help limiting how the Camera is able to move in the scene.
  39285. */
  39286. lowerRadiusLimit: Nullable<number>;
  39287. /**
  39288. * Maximum allowed distance of the camera to the axis of rotation
  39289. * (The camera can not get further).
  39290. * This can help limiting how the Camera is able to move in the scene.
  39291. */
  39292. upperRadiusLimit: Nullable<number>;
  39293. /**
  39294. * Define a rotation offset between the camera and the object it follows
  39295. */
  39296. rotationOffset: number;
  39297. /**
  39298. * Minimum allowed angle to camera position relative to target object.
  39299. * This can help limiting how the Camera is able to move in the scene.
  39300. */
  39301. lowerRotationOffsetLimit: Nullable<number>;
  39302. /**
  39303. * Maximum allowed angle to camera position relative to target object.
  39304. * This can help limiting how the Camera is able to move in the scene.
  39305. */
  39306. upperRotationOffsetLimit: Nullable<number>;
  39307. /**
  39308. * Define a height offset between the camera and the object it follows.
  39309. * It can help following an object from the top (like a car chaing a plane)
  39310. */
  39311. heightOffset: number;
  39312. /**
  39313. * Minimum allowed height of camera position relative to target object.
  39314. * This can help limiting how the Camera is able to move in the scene.
  39315. */
  39316. lowerHeightOffsetLimit: Nullable<number>;
  39317. /**
  39318. * Maximum allowed height of camera position relative to target object.
  39319. * This can help limiting how the Camera is able to move in the scene.
  39320. */
  39321. upperHeightOffsetLimit: Nullable<number>;
  39322. /**
  39323. * Define how fast the camera can accelerate to follow it s target.
  39324. */
  39325. cameraAcceleration: number;
  39326. /**
  39327. * Define the speed limit of the camera following an object.
  39328. */
  39329. maxCameraSpeed: number;
  39330. /**
  39331. * Define the target of the camera.
  39332. */
  39333. lockedTarget: Nullable<AbstractMesh>;
  39334. /**
  39335. * Defines the input associated with the camera.
  39336. */
  39337. inputs: FollowCameraInputsManager;
  39338. /**
  39339. * Instantiates the follow camera.
  39340. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39341. * @param name Define the name of the camera in the scene
  39342. * @param position Define the position of the camera
  39343. * @param scene Define the scene the camera belong to
  39344. * @param lockedTarget Define the target of the camera
  39345. */
  39346. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39347. private _follow;
  39348. /**
  39349. * Attached controls to the current camera.
  39350. * @param element Defines the element the controls should be listened from
  39351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39352. */
  39353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39354. /**
  39355. * Detach the current controls from the camera.
  39356. * The camera will stop reacting to inputs.
  39357. * @param element Defines the element to stop listening the inputs from
  39358. */
  39359. detachControl(element: HTMLElement): void;
  39360. /** @hidden */
  39361. _checkInputs(): void;
  39362. private _checkLimits;
  39363. /**
  39364. * Gets the camera class name.
  39365. * @returns the class name
  39366. */
  39367. getClassName(): string;
  39368. }
  39369. /**
  39370. * Arc Rotate version of the follow camera.
  39371. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39372. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39373. */
  39374. export class ArcFollowCamera extends TargetCamera {
  39375. /** The longitudinal angle of the camera */
  39376. alpha: number;
  39377. /** The latitudinal angle of the camera */
  39378. beta: number;
  39379. /** The radius of the camera from its target */
  39380. radius: number;
  39381. /** Define the camera target (the messh it should follow) */
  39382. target: Nullable<AbstractMesh>;
  39383. private _cartesianCoordinates;
  39384. /**
  39385. * Instantiates a new ArcFollowCamera
  39386. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39387. * @param name Define the name of the camera
  39388. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39389. * @param beta Define the rotation angle of the camera around the elevation axis
  39390. * @param radius Define the radius of the camera from its target point
  39391. * @param target Define the target of the camera
  39392. * @param scene Define the scene the camera belongs to
  39393. */
  39394. constructor(name: string,
  39395. /** The longitudinal angle of the camera */
  39396. alpha: number,
  39397. /** The latitudinal angle of the camera */
  39398. beta: number,
  39399. /** The radius of the camera from its target */
  39400. radius: number,
  39401. /** Define the camera target (the messh it should follow) */
  39402. target: Nullable<AbstractMesh>, scene: Scene);
  39403. private _follow;
  39404. /** @hidden */
  39405. _checkInputs(): void;
  39406. /**
  39407. * Returns the class name of the object.
  39408. * It is mostly used internally for serialization purposes.
  39409. */
  39410. getClassName(): string;
  39411. }
  39412. }
  39413. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39414. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39415. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39416. import { Nullable } from "babylonjs/types";
  39417. /**
  39418. * Manage the keyboard inputs to control the movement of a follow camera.
  39419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39420. */
  39421. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39422. /**
  39423. * Defines the camera the input is attached to.
  39424. */
  39425. camera: FollowCamera;
  39426. /**
  39427. * Defines the list of key codes associated with the up action (increase heightOffset)
  39428. */
  39429. keysHeightOffsetIncr: number[];
  39430. /**
  39431. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39432. */
  39433. keysHeightOffsetDecr: number[];
  39434. /**
  39435. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39436. */
  39437. keysHeightOffsetModifierAlt: boolean;
  39438. /**
  39439. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39440. */
  39441. keysHeightOffsetModifierCtrl: boolean;
  39442. /**
  39443. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39444. */
  39445. keysHeightOffsetModifierShift: boolean;
  39446. /**
  39447. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39448. */
  39449. keysRotationOffsetIncr: number[];
  39450. /**
  39451. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39452. */
  39453. keysRotationOffsetDecr: number[];
  39454. /**
  39455. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39456. */
  39457. keysRotationOffsetModifierAlt: boolean;
  39458. /**
  39459. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39460. */
  39461. keysRotationOffsetModifierCtrl: boolean;
  39462. /**
  39463. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39464. */
  39465. keysRotationOffsetModifierShift: boolean;
  39466. /**
  39467. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39468. */
  39469. keysRadiusIncr: number[];
  39470. /**
  39471. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39472. */
  39473. keysRadiusDecr: number[];
  39474. /**
  39475. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39476. */
  39477. keysRadiusModifierAlt: boolean;
  39478. /**
  39479. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39480. */
  39481. keysRadiusModifierCtrl: boolean;
  39482. /**
  39483. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39484. */
  39485. keysRadiusModifierShift: boolean;
  39486. /**
  39487. * Defines the rate of change of heightOffset.
  39488. */
  39489. heightSensibility: number;
  39490. /**
  39491. * Defines the rate of change of rotationOffset.
  39492. */
  39493. rotationSensibility: number;
  39494. /**
  39495. * Defines the rate of change of radius.
  39496. */
  39497. radiusSensibility: number;
  39498. private _keys;
  39499. private _ctrlPressed;
  39500. private _altPressed;
  39501. private _shiftPressed;
  39502. private _onCanvasBlurObserver;
  39503. private _onKeyboardObserver;
  39504. private _engine;
  39505. private _scene;
  39506. /**
  39507. * Attach the input controls to a specific dom element to get the input from.
  39508. * @param element Defines the element the controls should be listened from
  39509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39510. */
  39511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39512. /**
  39513. * Detach the current controls from the specified dom element.
  39514. * @param element Defines the element to stop listening the inputs from
  39515. */
  39516. detachControl(element: Nullable<HTMLElement>): void;
  39517. /**
  39518. * Update the current camera state depending on the inputs that have been used this frame.
  39519. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39520. */
  39521. checkInputs(): void;
  39522. /**
  39523. * Gets the class name of the current input.
  39524. * @returns the class name
  39525. */
  39526. getClassName(): string;
  39527. /**
  39528. * Get the friendly name associated with the input class.
  39529. * @returns the input friendly name
  39530. */
  39531. getSimpleName(): string;
  39532. /**
  39533. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39534. * allow modification of the heightOffset value.
  39535. */
  39536. private _modifierHeightOffset;
  39537. /**
  39538. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39539. * allow modification of the rotationOffset value.
  39540. */
  39541. private _modifierRotationOffset;
  39542. /**
  39543. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39544. * allow modification of the radius value.
  39545. */
  39546. private _modifierRadius;
  39547. }
  39548. }
  39549. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39550. import { Nullable } from "babylonjs/types";
  39551. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39553. import { Observable } from "babylonjs/Misc/observable";
  39554. module "babylonjs/Cameras/freeCameraInputsManager" {
  39555. interface FreeCameraInputsManager {
  39556. /**
  39557. * @hidden
  39558. */
  39559. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39560. /**
  39561. * Add orientation input support to the input manager.
  39562. * @returns the current input manager
  39563. */
  39564. addDeviceOrientation(): FreeCameraInputsManager;
  39565. }
  39566. }
  39567. /**
  39568. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39569. * Screen rotation is taken into account.
  39570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39571. */
  39572. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39573. private _camera;
  39574. private _screenOrientationAngle;
  39575. private _constantTranform;
  39576. private _screenQuaternion;
  39577. private _alpha;
  39578. private _beta;
  39579. private _gamma;
  39580. /**
  39581. * Can be used to detect if a device orientation sensor is availible on a device
  39582. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39583. * @returns a promise that will resolve on orientation change
  39584. */
  39585. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39586. /**
  39587. * @hidden
  39588. */
  39589. _onDeviceOrientationChangedObservable: Observable<void>;
  39590. /**
  39591. * Instantiates a new input
  39592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39593. */
  39594. constructor();
  39595. /**
  39596. * Define the camera controlled by the input.
  39597. */
  39598. camera: FreeCamera;
  39599. /**
  39600. * Attach the input controls to a specific dom element to get the input from.
  39601. * @param element Defines the element the controls should be listened from
  39602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39603. */
  39604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39605. private _orientationChanged;
  39606. private _deviceOrientation;
  39607. /**
  39608. * Detach the current controls from the specified dom element.
  39609. * @param element Defines the element to stop listening the inputs from
  39610. */
  39611. detachControl(element: Nullable<HTMLElement>): void;
  39612. /**
  39613. * Update the current camera state depending on the inputs that have been used this frame.
  39614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39615. */
  39616. checkInputs(): void;
  39617. /**
  39618. * Gets the class name of the current intput.
  39619. * @returns the class name
  39620. */
  39621. getClassName(): string;
  39622. /**
  39623. * Get the friendly name associated with the input class.
  39624. * @returns the input friendly name
  39625. */
  39626. getSimpleName(): string;
  39627. }
  39628. }
  39629. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39630. import { Nullable } from "babylonjs/types";
  39631. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39632. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39633. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39634. /**
  39635. * Manage the gamepad inputs to control a free camera.
  39636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39637. */
  39638. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39639. /**
  39640. * Define the camera the input is attached to.
  39641. */
  39642. camera: FreeCamera;
  39643. /**
  39644. * Define the Gamepad controlling the input
  39645. */
  39646. gamepad: Nullable<Gamepad>;
  39647. /**
  39648. * Defines the gamepad rotation sensiblity.
  39649. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39650. */
  39651. gamepadAngularSensibility: number;
  39652. /**
  39653. * Defines the gamepad move sensiblity.
  39654. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39655. */
  39656. gamepadMoveSensibility: number;
  39657. private _onGamepadConnectedObserver;
  39658. private _onGamepadDisconnectedObserver;
  39659. private _cameraTransform;
  39660. private _deltaTransform;
  39661. private _vector3;
  39662. private _vector2;
  39663. /**
  39664. * Attach the input controls to a specific dom element to get the input from.
  39665. * @param element Defines the element the controls should be listened from
  39666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39667. */
  39668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39669. /**
  39670. * Detach the current controls from the specified dom element.
  39671. * @param element Defines the element to stop listening the inputs from
  39672. */
  39673. detachControl(element: Nullable<HTMLElement>): void;
  39674. /**
  39675. * Update the current camera state depending on the inputs that have been used this frame.
  39676. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39677. */
  39678. checkInputs(): void;
  39679. /**
  39680. * Gets the class name of the current intput.
  39681. * @returns the class name
  39682. */
  39683. getClassName(): string;
  39684. /**
  39685. * Get the friendly name associated with the input class.
  39686. * @returns the input friendly name
  39687. */
  39688. getSimpleName(): string;
  39689. }
  39690. }
  39691. declare module "babylonjs/Misc/virtualJoystick" {
  39692. import { Nullable } from "babylonjs/types";
  39693. import { Vector3 } from "babylonjs/Maths/math.vector";
  39694. /**
  39695. * Defines the potential axis of a Joystick
  39696. */
  39697. export enum JoystickAxis {
  39698. /** X axis */
  39699. X = 0,
  39700. /** Y axis */
  39701. Y = 1,
  39702. /** Z axis */
  39703. Z = 2
  39704. }
  39705. /**
  39706. * Class used to define virtual joystick (used in touch mode)
  39707. */
  39708. export class VirtualJoystick {
  39709. /**
  39710. * Gets or sets a boolean indicating that left and right values must be inverted
  39711. */
  39712. reverseLeftRight: boolean;
  39713. /**
  39714. * Gets or sets a boolean indicating that up and down values must be inverted
  39715. */
  39716. reverseUpDown: boolean;
  39717. /**
  39718. * Gets the offset value for the position (ie. the change of the position value)
  39719. */
  39720. deltaPosition: Vector3;
  39721. /**
  39722. * Gets a boolean indicating if the virtual joystick was pressed
  39723. */
  39724. pressed: boolean;
  39725. /**
  39726. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39727. */
  39728. static Canvas: Nullable<HTMLCanvasElement>;
  39729. private static _globalJoystickIndex;
  39730. private static vjCanvasContext;
  39731. private static vjCanvasWidth;
  39732. private static vjCanvasHeight;
  39733. private static halfWidth;
  39734. private _action;
  39735. private _axisTargetedByLeftAndRight;
  39736. private _axisTargetedByUpAndDown;
  39737. private _joystickSensibility;
  39738. private _inversedSensibility;
  39739. private _joystickPointerID;
  39740. private _joystickColor;
  39741. private _joystickPointerPos;
  39742. private _joystickPreviousPointerPos;
  39743. private _joystickPointerStartPos;
  39744. private _deltaJoystickVector;
  39745. private _leftJoystick;
  39746. private _touches;
  39747. private _onPointerDownHandlerRef;
  39748. private _onPointerMoveHandlerRef;
  39749. private _onPointerUpHandlerRef;
  39750. private _onResize;
  39751. /**
  39752. * Creates a new virtual joystick
  39753. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39754. */
  39755. constructor(leftJoystick?: boolean);
  39756. /**
  39757. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39758. * @param newJoystickSensibility defines the new sensibility
  39759. */
  39760. setJoystickSensibility(newJoystickSensibility: number): void;
  39761. private _onPointerDown;
  39762. private _onPointerMove;
  39763. private _onPointerUp;
  39764. /**
  39765. * Change the color of the virtual joystick
  39766. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39767. */
  39768. setJoystickColor(newColor: string): void;
  39769. /**
  39770. * Defines a callback to call when the joystick is touched
  39771. * @param action defines the callback
  39772. */
  39773. setActionOnTouch(action: () => any): void;
  39774. /**
  39775. * Defines which axis you'd like to control for left & right
  39776. * @param axis defines the axis to use
  39777. */
  39778. setAxisForLeftRight(axis: JoystickAxis): void;
  39779. /**
  39780. * Defines which axis you'd like to control for up & down
  39781. * @param axis defines the axis to use
  39782. */
  39783. setAxisForUpDown(axis: JoystickAxis): void;
  39784. private _drawVirtualJoystick;
  39785. /**
  39786. * Release internal HTML canvas
  39787. */
  39788. releaseCanvas(): void;
  39789. }
  39790. }
  39791. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39792. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39793. import { Nullable } from "babylonjs/types";
  39794. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39795. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39796. module "babylonjs/Cameras/freeCameraInputsManager" {
  39797. interface FreeCameraInputsManager {
  39798. /**
  39799. * Add virtual joystick input support to the input manager.
  39800. * @returns the current input manager
  39801. */
  39802. addVirtualJoystick(): FreeCameraInputsManager;
  39803. }
  39804. }
  39805. /**
  39806. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39808. */
  39809. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39810. /**
  39811. * Defines the camera the input is attached to.
  39812. */
  39813. camera: FreeCamera;
  39814. private _leftjoystick;
  39815. private _rightjoystick;
  39816. /**
  39817. * Gets the left stick of the virtual joystick.
  39818. * @returns The virtual Joystick
  39819. */
  39820. getLeftJoystick(): VirtualJoystick;
  39821. /**
  39822. * Gets the right stick of the virtual joystick.
  39823. * @returns The virtual Joystick
  39824. */
  39825. getRightJoystick(): VirtualJoystick;
  39826. /**
  39827. * Update the current camera state depending on the inputs that have been used this frame.
  39828. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39829. */
  39830. checkInputs(): void;
  39831. /**
  39832. * Attach the input controls to a specific dom element to get the input from.
  39833. * @param element Defines the element the controls should be listened from
  39834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39835. */
  39836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39837. /**
  39838. * Detach the current controls from the specified dom element.
  39839. * @param element Defines the element to stop listening the inputs from
  39840. */
  39841. detachControl(element: Nullable<HTMLElement>): void;
  39842. /**
  39843. * Gets the class name of the current intput.
  39844. * @returns the class name
  39845. */
  39846. getClassName(): string;
  39847. /**
  39848. * Get the friendly name associated with the input class.
  39849. * @returns the input friendly name
  39850. */
  39851. getSimpleName(): string;
  39852. }
  39853. }
  39854. declare module "babylonjs/Cameras/Inputs/index" {
  39855. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39856. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39857. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39858. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39859. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39860. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39861. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39862. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39863. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39864. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39865. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39866. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39867. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39868. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39869. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39870. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39871. }
  39872. declare module "babylonjs/Cameras/touchCamera" {
  39873. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39874. import { Scene } from "babylonjs/scene";
  39875. import { Vector3 } from "babylonjs/Maths/math.vector";
  39876. /**
  39877. * This represents a FPS type of camera controlled by touch.
  39878. * This is like a universal camera minus the Gamepad controls.
  39879. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39880. */
  39881. export class TouchCamera extends FreeCamera {
  39882. /**
  39883. * Defines the touch sensibility for rotation.
  39884. * The higher the faster.
  39885. */
  39886. touchAngularSensibility: number;
  39887. /**
  39888. * Defines the touch sensibility for move.
  39889. * The higher the faster.
  39890. */
  39891. touchMoveSensibility: number;
  39892. /**
  39893. * Instantiates a new touch camera.
  39894. * This represents a FPS type of camera controlled by touch.
  39895. * This is like a universal camera minus the Gamepad controls.
  39896. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39897. * @param name Define the name of the camera in the scene
  39898. * @param position Define the start position of the camera in the scene
  39899. * @param scene Define the scene the camera belongs to
  39900. */
  39901. constructor(name: string, position: Vector3, scene: Scene);
  39902. /**
  39903. * Gets the current object class name.
  39904. * @return the class name
  39905. */
  39906. getClassName(): string;
  39907. /** @hidden */
  39908. _setupInputs(): void;
  39909. }
  39910. }
  39911. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39912. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39913. import { Scene } from "babylonjs/scene";
  39914. import { Vector3 } from "babylonjs/Maths/math.vector";
  39915. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39916. import { Axis } from "babylonjs/Maths/math.axis";
  39917. /**
  39918. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39919. * being tilted forward or back and left or right.
  39920. */
  39921. export class DeviceOrientationCamera extends FreeCamera {
  39922. private _initialQuaternion;
  39923. private _quaternionCache;
  39924. private _tmpDragQuaternion;
  39925. private _disablePointerInputWhenUsingDeviceOrientation;
  39926. /**
  39927. * Creates a new device orientation camera
  39928. * @param name The name of the camera
  39929. * @param position The start position camera
  39930. * @param scene The scene the camera belongs to
  39931. */
  39932. constructor(name: string, position: Vector3, scene: Scene);
  39933. /**
  39934. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39935. */
  39936. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39937. private _dragFactor;
  39938. /**
  39939. * Enabled turning on the y axis when the orientation sensor is active
  39940. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39941. */
  39942. enableHorizontalDragging(dragFactor?: number): void;
  39943. /**
  39944. * Gets the current instance class name ("DeviceOrientationCamera").
  39945. * This helps avoiding instanceof at run time.
  39946. * @returns the class name
  39947. */
  39948. getClassName(): string;
  39949. /**
  39950. * @hidden
  39951. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39952. */
  39953. _checkInputs(): void;
  39954. /**
  39955. * Reset the camera to its default orientation on the specified axis only.
  39956. * @param axis The axis to reset
  39957. */
  39958. resetToCurrentRotation(axis?: Axis): void;
  39959. }
  39960. }
  39961. declare module "babylonjs/Gamepads/xboxGamepad" {
  39962. import { Observable } from "babylonjs/Misc/observable";
  39963. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39964. /**
  39965. * Defines supported buttons for XBox360 compatible gamepads
  39966. */
  39967. export enum Xbox360Button {
  39968. /** A */
  39969. A = 0,
  39970. /** B */
  39971. B = 1,
  39972. /** X */
  39973. X = 2,
  39974. /** Y */
  39975. Y = 3,
  39976. /** Start */
  39977. Start = 4,
  39978. /** Back */
  39979. Back = 5,
  39980. /** Left button */
  39981. LB = 6,
  39982. /** Right button */
  39983. RB = 7,
  39984. /** Left stick */
  39985. LeftStick = 8,
  39986. /** Right stick */
  39987. RightStick = 9
  39988. }
  39989. /** Defines values for XBox360 DPad */
  39990. export enum Xbox360Dpad {
  39991. /** Up */
  39992. Up = 0,
  39993. /** Down */
  39994. Down = 1,
  39995. /** Left */
  39996. Left = 2,
  39997. /** Right */
  39998. Right = 3
  39999. }
  40000. /**
  40001. * Defines a XBox360 gamepad
  40002. */
  40003. export class Xbox360Pad extends Gamepad {
  40004. private _leftTrigger;
  40005. private _rightTrigger;
  40006. private _onlefttriggerchanged;
  40007. private _onrighttriggerchanged;
  40008. private _onbuttondown;
  40009. private _onbuttonup;
  40010. private _ondpaddown;
  40011. private _ondpadup;
  40012. /** Observable raised when a button is pressed */
  40013. onButtonDownObservable: Observable<Xbox360Button>;
  40014. /** Observable raised when a button is released */
  40015. onButtonUpObservable: Observable<Xbox360Button>;
  40016. /** Observable raised when a pad is pressed */
  40017. onPadDownObservable: Observable<Xbox360Dpad>;
  40018. /** Observable raised when a pad is released */
  40019. onPadUpObservable: Observable<Xbox360Dpad>;
  40020. private _buttonA;
  40021. private _buttonB;
  40022. private _buttonX;
  40023. private _buttonY;
  40024. private _buttonBack;
  40025. private _buttonStart;
  40026. private _buttonLB;
  40027. private _buttonRB;
  40028. private _buttonLeftStick;
  40029. private _buttonRightStick;
  40030. private _dPadUp;
  40031. private _dPadDown;
  40032. private _dPadLeft;
  40033. private _dPadRight;
  40034. private _isXboxOnePad;
  40035. /**
  40036. * Creates a new XBox360 gamepad object
  40037. * @param id defines the id of this gamepad
  40038. * @param index defines its index
  40039. * @param gamepad defines the internal HTML gamepad object
  40040. * @param xboxOne defines if it is a XBox One gamepad
  40041. */
  40042. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40043. /**
  40044. * Defines the callback to call when left trigger is pressed
  40045. * @param callback defines the callback to use
  40046. */
  40047. onlefttriggerchanged(callback: (value: number) => void): void;
  40048. /**
  40049. * Defines the callback to call when right trigger is pressed
  40050. * @param callback defines the callback to use
  40051. */
  40052. onrighttriggerchanged(callback: (value: number) => void): void;
  40053. /**
  40054. * Gets the left trigger value
  40055. */
  40056. /**
  40057. * Sets the left trigger value
  40058. */
  40059. leftTrigger: number;
  40060. /**
  40061. * Gets the right trigger value
  40062. */
  40063. /**
  40064. * Sets the right trigger value
  40065. */
  40066. rightTrigger: number;
  40067. /**
  40068. * Defines the callback to call when a button is pressed
  40069. * @param callback defines the callback to use
  40070. */
  40071. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40072. /**
  40073. * Defines the callback to call when a button is released
  40074. * @param callback defines the callback to use
  40075. */
  40076. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40077. /**
  40078. * Defines the callback to call when a pad is pressed
  40079. * @param callback defines the callback to use
  40080. */
  40081. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40082. /**
  40083. * Defines the callback to call when a pad is released
  40084. * @param callback defines the callback to use
  40085. */
  40086. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40087. private _setButtonValue;
  40088. private _setDPadValue;
  40089. /**
  40090. * Gets the value of the `A` button
  40091. */
  40092. /**
  40093. * Sets the value of the `A` button
  40094. */
  40095. buttonA: number;
  40096. /**
  40097. * Gets the value of the `B` button
  40098. */
  40099. /**
  40100. * Sets the value of the `B` button
  40101. */
  40102. buttonB: number;
  40103. /**
  40104. * Gets the value of the `X` button
  40105. */
  40106. /**
  40107. * Sets the value of the `X` button
  40108. */
  40109. buttonX: number;
  40110. /**
  40111. * Gets the value of the `Y` button
  40112. */
  40113. /**
  40114. * Sets the value of the `Y` button
  40115. */
  40116. buttonY: number;
  40117. /**
  40118. * Gets the value of the `Start` button
  40119. */
  40120. /**
  40121. * Sets the value of the `Start` button
  40122. */
  40123. buttonStart: number;
  40124. /**
  40125. * Gets the value of the `Back` button
  40126. */
  40127. /**
  40128. * Sets the value of the `Back` button
  40129. */
  40130. buttonBack: number;
  40131. /**
  40132. * Gets the value of the `Left` button
  40133. */
  40134. /**
  40135. * Sets the value of the `Left` button
  40136. */
  40137. buttonLB: number;
  40138. /**
  40139. * Gets the value of the `Right` button
  40140. */
  40141. /**
  40142. * Sets the value of the `Right` button
  40143. */
  40144. buttonRB: number;
  40145. /**
  40146. * Gets the value of the Left joystick
  40147. */
  40148. /**
  40149. * Sets the value of the Left joystick
  40150. */
  40151. buttonLeftStick: number;
  40152. /**
  40153. * Gets the value of the Right joystick
  40154. */
  40155. /**
  40156. * Sets the value of the Right joystick
  40157. */
  40158. buttonRightStick: number;
  40159. /**
  40160. * Gets the value of D-pad up
  40161. */
  40162. /**
  40163. * Sets the value of D-pad up
  40164. */
  40165. dPadUp: number;
  40166. /**
  40167. * Gets the value of D-pad down
  40168. */
  40169. /**
  40170. * Sets the value of D-pad down
  40171. */
  40172. dPadDown: number;
  40173. /**
  40174. * Gets the value of D-pad left
  40175. */
  40176. /**
  40177. * Sets the value of D-pad left
  40178. */
  40179. dPadLeft: number;
  40180. /**
  40181. * Gets the value of D-pad right
  40182. */
  40183. /**
  40184. * Sets the value of D-pad right
  40185. */
  40186. dPadRight: number;
  40187. /**
  40188. * Force the gamepad to synchronize with device values
  40189. */
  40190. update(): void;
  40191. /**
  40192. * Disposes the gamepad
  40193. */
  40194. dispose(): void;
  40195. }
  40196. }
  40197. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40198. import { Observable } from "babylonjs/Misc/observable";
  40199. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40200. /**
  40201. * Defines supported buttons for DualShock compatible gamepads
  40202. */
  40203. export enum DualShockButton {
  40204. /** Cross */
  40205. Cross = 0,
  40206. /** Circle */
  40207. Circle = 1,
  40208. /** Square */
  40209. Square = 2,
  40210. /** Triangle */
  40211. Triangle = 3,
  40212. /** Options */
  40213. Options = 4,
  40214. /** Share */
  40215. Share = 5,
  40216. /** L1 */
  40217. L1 = 6,
  40218. /** R1 */
  40219. R1 = 7,
  40220. /** Left stick */
  40221. LeftStick = 8,
  40222. /** Right stick */
  40223. RightStick = 9
  40224. }
  40225. /** Defines values for DualShock DPad */
  40226. export enum DualShockDpad {
  40227. /** Up */
  40228. Up = 0,
  40229. /** Down */
  40230. Down = 1,
  40231. /** Left */
  40232. Left = 2,
  40233. /** Right */
  40234. Right = 3
  40235. }
  40236. /**
  40237. * Defines a DualShock gamepad
  40238. */
  40239. export class DualShockPad extends Gamepad {
  40240. private _leftTrigger;
  40241. private _rightTrigger;
  40242. private _onlefttriggerchanged;
  40243. private _onrighttriggerchanged;
  40244. private _onbuttondown;
  40245. private _onbuttonup;
  40246. private _ondpaddown;
  40247. private _ondpadup;
  40248. /** Observable raised when a button is pressed */
  40249. onButtonDownObservable: Observable<DualShockButton>;
  40250. /** Observable raised when a button is released */
  40251. onButtonUpObservable: Observable<DualShockButton>;
  40252. /** Observable raised when a pad is pressed */
  40253. onPadDownObservable: Observable<DualShockDpad>;
  40254. /** Observable raised when a pad is released */
  40255. onPadUpObservable: Observable<DualShockDpad>;
  40256. private _buttonCross;
  40257. private _buttonCircle;
  40258. private _buttonSquare;
  40259. private _buttonTriangle;
  40260. private _buttonShare;
  40261. private _buttonOptions;
  40262. private _buttonL1;
  40263. private _buttonR1;
  40264. private _buttonLeftStick;
  40265. private _buttonRightStick;
  40266. private _dPadUp;
  40267. private _dPadDown;
  40268. private _dPadLeft;
  40269. private _dPadRight;
  40270. /**
  40271. * Creates a new DualShock gamepad object
  40272. * @param id defines the id of this gamepad
  40273. * @param index defines its index
  40274. * @param gamepad defines the internal HTML gamepad object
  40275. */
  40276. constructor(id: string, index: number, gamepad: any);
  40277. /**
  40278. * Defines the callback to call when left trigger is pressed
  40279. * @param callback defines the callback to use
  40280. */
  40281. onlefttriggerchanged(callback: (value: number) => void): void;
  40282. /**
  40283. * Defines the callback to call when right trigger is pressed
  40284. * @param callback defines the callback to use
  40285. */
  40286. onrighttriggerchanged(callback: (value: number) => void): void;
  40287. /**
  40288. * Gets the left trigger value
  40289. */
  40290. /**
  40291. * Sets the left trigger value
  40292. */
  40293. leftTrigger: number;
  40294. /**
  40295. * Gets the right trigger value
  40296. */
  40297. /**
  40298. * Sets the right trigger value
  40299. */
  40300. rightTrigger: number;
  40301. /**
  40302. * Defines the callback to call when a button is pressed
  40303. * @param callback defines the callback to use
  40304. */
  40305. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40306. /**
  40307. * Defines the callback to call when a button is released
  40308. * @param callback defines the callback to use
  40309. */
  40310. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40311. /**
  40312. * Defines the callback to call when a pad is pressed
  40313. * @param callback defines the callback to use
  40314. */
  40315. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40316. /**
  40317. * Defines the callback to call when a pad is released
  40318. * @param callback defines the callback to use
  40319. */
  40320. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40321. private _setButtonValue;
  40322. private _setDPadValue;
  40323. /**
  40324. * Gets the value of the `Cross` button
  40325. */
  40326. /**
  40327. * Sets the value of the `Cross` button
  40328. */
  40329. buttonCross: number;
  40330. /**
  40331. * Gets the value of the `Circle` button
  40332. */
  40333. /**
  40334. * Sets the value of the `Circle` button
  40335. */
  40336. buttonCircle: number;
  40337. /**
  40338. * Gets the value of the `Square` button
  40339. */
  40340. /**
  40341. * Sets the value of the `Square` button
  40342. */
  40343. buttonSquare: number;
  40344. /**
  40345. * Gets the value of the `Triangle` button
  40346. */
  40347. /**
  40348. * Sets the value of the `Triangle` button
  40349. */
  40350. buttonTriangle: number;
  40351. /**
  40352. * Gets the value of the `Options` button
  40353. */
  40354. /**
  40355. * Sets the value of the `Options` button
  40356. */
  40357. buttonOptions: number;
  40358. /**
  40359. * Gets the value of the `Share` button
  40360. */
  40361. /**
  40362. * Sets the value of the `Share` button
  40363. */
  40364. buttonShare: number;
  40365. /**
  40366. * Gets the value of the `L1` button
  40367. */
  40368. /**
  40369. * Sets the value of the `L1` button
  40370. */
  40371. buttonL1: number;
  40372. /**
  40373. * Gets the value of the `R1` button
  40374. */
  40375. /**
  40376. * Sets the value of the `R1` button
  40377. */
  40378. buttonR1: number;
  40379. /**
  40380. * Gets the value of the Left joystick
  40381. */
  40382. /**
  40383. * Sets the value of the Left joystick
  40384. */
  40385. buttonLeftStick: number;
  40386. /**
  40387. * Gets the value of the Right joystick
  40388. */
  40389. /**
  40390. * Sets the value of the Right joystick
  40391. */
  40392. buttonRightStick: number;
  40393. /**
  40394. * Gets the value of D-pad up
  40395. */
  40396. /**
  40397. * Sets the value of D-pad up
  40398. */
  40399. dPadUp: number;
  40400. /**
  40401. * Gets the value of D-pad down
  40402. */
  40403. /**
  40404. * Sets the value of D-pad down
  40405. */
  40406. dPadDown: number;
  40407. /**
  40408. * Gets the value of D-pad left
  40409. */
  40410. /**
  40411. * Sets the value of D-pad left
  40412. */
  40413. dPadLeft: number;
  40414. /**
  40415. * Gets the value of D-pad right
  40416. */
  40417. /**
  40418. * Sets the value of D-pad right
  40419. */
  40420. dPadRight: number;
  40421. /**
  40422. * Force the gamepad to synchronize with device values
  40423. */
  40424. update(): void;
  40425. /**
  40426. * Disposes the gamepad
  40427. */
  40428. dispose(): void;
  40429. }
  40430. }
  40431. declare module "babylonjs/Gamepads/gamepadManager" {
  40432. import { Observable } from "babylonjs/Misc/observable";
  40433. import { Nullable } from "babylonjs/types";
  40434. import { Scene } from "babylonjs/scene";
  40435. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40436. /**
  40437. * Manager for handling gamepads
  40438. */
  40439. export class GamepadManager {
  40440. private _scene?;
  40441. private _babylonGamepads;
  40442. private _oneGamepadConnected;
  40443. /** @hidden */
  40444. _isMonitoring: boolean;
  40445. private _gamepadEventSupported;
  40446. private _gamepadSupport;
  40447. /**
  40448. * observable to be triggered when the gamepad controller has been connected
  40449. */
  40450. onGamepadConnectedObservable: Observable<Gamepad>;
  40451. /**
  40452. * observable to be triggered when the gamepad controller has been disconnected
  40453. */
  40454. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40455. private _onGamepadConnectedEvent;
  40456. private _onGamepadDisconnectedEvent;
  40457. /**
  40458. * Initializes the gamepad manager
  40459. * @param _scene BabylonJS scene
  40460. */
  40461. constructor(_scene?: Scene | undefined);
  40462. /**
  40463. * The gamepads in the game pad manager
  40464. */
  40465. readonly gamepads: Gamepad[];
  40466. /**
  40467. * Get the gamepad controllers based on type
  40468. * @param type The type of gamepad controller
  40469. * @returns Nullable gamepad
  40470. */
  40471. getGamepadByType(type?: number): Nullable<Gamepad>;
  40472. /**
  40473. * Disposes the gamepad manager
  40474. */
  40475. dispose(): void;
  40476. private _addNewGamepad;
  40477. private _startMonitoringGamepads;
  40478. private _stopMonitoringGamepads;
  40479. /** @hidden */
  40480. _checkGamepadsStatus(): void;
  40481. private _updateGamepadObjects;
  40482. }
  40483. }
  40484. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40485. import { Nullable } from "babylonjs/types";
  40486. import { Scene } from "babylonjs/scene";
  40487. import { ISceneComponent } from "babylonjs/sceneComponent";
  40488. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40489. module "babylonjs/scene" {
  40490. interface Scene {
  40491. /** @hidden */
  40492. _gamepadManager: Nullable<GamepadManager>;
  40493. /**
  40494. * Gets the gamepad manager associated with the scene
  40495. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40496. */
  40497. gamepadManager: GamepadManager;
  40498. }
  40499. }
  40500. module "babylonjs/Cameras/freeCameraInputsManager" {
  40501. /**
  40502. * Interface representing a free camera inputs manager
  40503. */
  40504. interface FreeCameraInputsManager {
  40505. /**
  40506. * Adds gamepad input support to the FreeCameraInputsManager.
  40507. * @returns the FreeCameraInputsManager
  40508. */
  40509. addGamepad(): FreeCameraInputsManager;
  40510. }
  40511. }
  40512. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40513. /**
  40514. * Interface representing an arc rotate camera inputs manager
  40515. */
  40516. interface ArcRotateCameraInputsManager {
  40517. /**
  40518. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40519. * @returns the camera inputs manager
  40520. */
  40521. addGamepad(): ArcRotateCameraInputsManager;
  40522. }
  40523. }
  40524. /**
  40525. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40526. */
  40527. export class GamepadSystemSceneComponent implements ISceneComponent {
  40528. /**
  40529. * The component name helpfull to identify the component in the list of scene components.
  40530. */
  40531. readonly name: string;
  40532. /**
  40533. * The scene the component belongs to.
  40534. */
  40535. scene: Scene;
  40536. /**
  40537. * Creates a new instance of the component for the given scene
  40538. * @param scene Defines the scene to register the component in
  40539. */
  40540. constructor(scene: Scene);
  40541. /**
  40542. * Registers the component in a given scene
  40543. */
  40544. register(): void;
  40545. /**
  40546. * Rebuilds the elements related to this component in case of
  40547. * context lost for instance.
  40548. */
  40549. rebuild(): void;
  40550. /**
  40551. * Disposes the component and the associated ressources
  40552. */
  40553. dispose(): void;
  40554. private _beforeCameraUpdate;
  40555. }
  40556. }
  40557. declare module "babylonjs/Cameras/universalCamera" {
  40558. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40559. import { Scene } from "babylonjs/scene";
  40560. import { Vector3 } from "babylonjs/Maths/math.vector";
  40561. import "babylonjs/Gamepads/gamepadSceneComponent";
  40562. /**
  40563. * 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,
  40564. * which still works and will still be found in many Playgrounds.
  40565. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40566. */
  40567. export class UniversalCamera extends TouchCamera {
  40568. /**
  40569. * Defines the gamepad rotation sensiblity.
  40570. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40571. */
  40572. gamepadAngularSensibility: number;
  40573. /**
  40574. * Defines the gamepad move sensiblity.
  40575. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40576. */
  40577. gamepadMoveSensibility: number;
  40578. /**
  40579. * 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,
  40580. * which still works and will still be found in many Playgrounds.
  40581. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40582. * @param name Define the name of the camera in the scene
  40583. * @param position Define the start position of the camera in the scene
  40584. * @param scene Define the scene the camera belongs to
  40585. */
  40586. constructor(name: string, position: Vector3, scene: Scene);
  40587. /**
  40588. * Gets the current object class name.
  40589. * @return the class name
  40590. */
  40591. getClassName(): string;
  40592. }
  40593. }
  40594. declare module "babylonjs/Cameras/gamepadCamera" {
  40595. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40596. import { Scene } from "babylonjs/scene";
  40597. import { Vector3 } from "babylonjs/Maths/math.vector";
  40598. /**
  40599. * This represents a FPS type of camera. This is only here for back compat purpose.
  40600. * Please use the UniversalCamera instead as both are identical.
  40601. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40602. */
  40603. export class GamepadCamera extends UniversalCamera {
  40604. /**
  40605. * Instantiates a new Gamepad Camera
  40606. * This represents a FPS type of camera. This is only here for back compat purpose.
  40607. * Please use the UniversalCamera instead as both are identical.
  40608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40609. * @param name Define the name of the camera in the scene
  40610. * @param position Define the start position of the camera in the scene
  40611. * @param scene Define the scene the camera belongs to
  40612. */
  40613. constructor(name: string, position: Vector3, scene: Scene);
  40614. /**
  40615. * Gets the current object class name.
  40616. * @return the class name
  40617. */
  40618. getClassName(): string;
  40619. }
  40620. }
  40621. declare module "babylonjs/Shaders/pass.fragment" {
  40622. /** @hidden */
  40623. export var passPixelShader: {
  40624. name: string;
  40625. shader: string;
  40626. };
  40627. }
  40628. declare module "babylonjs/Shaders/passCube.fragment" {
  40629. /** @hidden */
  40630. export var passCubePixelShader: {
  40631. name: string;
  40632. shader: string;
  40633. };
  40634. }
  40635. declare module "babylonjs/PostProcesses/passPostProcess" {
  40636. import { Nullable } from "babylonjs/types";
  40637. import { Camera } from "babylonjs/Cameras/camera";
  40638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40639. import { Engine } from "babylonjs/Engines/engine";
  40640. import "babylonjs/Shaders/pass.fragment";
  40641. import "babylonjs/Shaders/passCube.fragment";
  40642. /**
  40643. * PassPostProcess which produces an output the same as it's input
  40644. */
  40645. export class PassPostProcess extends PostProcess {
  40646. /**
  40647. * Creates the PassPostProcess
  40648. * @param name The name of the effect.
  40649. * @param options The required width/height ratio to downsize to before computing the render pass.
  40650. * @param camera The camera to apply the render pass to.
  40651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40652. * @param engine The engine which the post process will be applied. (default: current engine)
  40653. * @param reusable If the post process can be reused on the same frame. (default: false)
  40654. * @param textureType The type of texture to be used when performing the post processing.
  40655. * @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)
  40656. */
  40657. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40658. }
  40659. /**
  40660. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40661. */
  40662. export class PassCubePostProcess extends PostProcess {
  40663. private _face;
  40664. /**
  40665. * Gets or sets the cube face to display.
  40666. * * 0 is +X
  40667. * * 1 is -X
  40668. * * 2 is +Y
  40669. * * 3 is -Y
  40670. * * 4 is +Z
  40671. * * 5 is -Z
  40672. */
  40673. face: number;
  40674. /**
  40675. * Creates the PassCubePostProcess
  40676. * @param name The name of the effect.
  40677. * @param options The required width/height ratio to downsize to before computing the render pass.
  40678. * @param camera The camera to apply the render pass to.
  40679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40680. * @param engine The engine which the post process will be applied. (default: current engine)
  40681. * @param reusable If the post process can be reused on the same frame. (default: false)
  40682. * @param textureType The type of texture to be used when performing the post processing.
  40683. * @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)
  40684. */
  40685. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40686. }
  40687. }
  40688. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40689. /** @hidden */
  40690. export var anaglyphPixelShader: {
  40691. name: string;
  40692. shader: string;
  40693. };
  40694. }
  40695. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40696. import { Engine } from "babylonjs/Engines/engine";
  40697. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40698. import { Camera } from "babylonjs/Cameras/camera";
  40699. import "babylonjs/Shaders/anaglyph.fragment";
  40700. /**
  40701. * Postprocess used to generate anaglyphic rendering
  40702. */
  40703. export class AnaglyphPostProcess extends PostProcess {
  40704. private _passedProcess;
  40705. /**
  40706. * Creates a new AnaglyphPostProcess
  40707. * @param name defines postprocess name
  40708. * @param options defines creation options or target ratio scale
  40709. * @param rigCameras defines cameras using this postprocess
  40710. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40711. * @param engine defines hosting engine
  40712. * @param reusable defines if the postprocess will be reused multiple times per frame
  40713. */
  40714. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40715. }
  40716. }
  40717. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40718. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40719. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40720. import { Scene } from "babylonjs/scene";
  40721. import { Vector3 } from "babylonjs/Maths/math.vector";
  40722. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40723. /**
  40724. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40725. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40726. */
  40727. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40728. /**
  40729. * Creates a new AnaglyphArcRotateCamera
  40730. * @param name defines camera name
  40731. * @param alpha defines alpha angle (in radians)
  40732. * @param beta defines beta angle (in radians)
  40733. * @param radius defines radius
  40734. * @param target defines camera target
  40735. * @param interaxialDistance defines distance between each color axis
  40736. * @param scene defines the hosting scene
  40737. */
  40738. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40739. /**
  40740. * Gets camera class name
  40741. * @returns AnaglyphArcRotateCamera
  40742. */
  40743. getClassName(): string;
  40744. }
  40745. }
  40746. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40747. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40748. import { Scene } from "babylonjs/scene";
  40749. import { Vector3 } from "babylonjs/Maths/math.vector";
  40750. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40751. /**
  40752. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40753. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40754. */
  40755. export class AnaglyphFreeCamera extends FreeCamera {
  40756. /**
  40757. * Creates a new AnaglyphFreeCamera
  40758. * @param name defines camera name
  40759. * @param position defines initial position
  40760. * @param interaxialDistance defines distance between each color axis
  40761. * @param scene defines the hosting scene
  40762. */
  40763. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40764. /**
  40765. * Gets camera class name
  40766. * @returns AnaglyphFreeCamera
  40767. */
  40768. getClassName(): string;
  40769. }
  40770. }
  40771. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40772. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40773. import { Scene } from "babylonjs/scene";
  40774. import { Vector3 } from "babylonjs/Maths/math.vector";
  40775. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40776. /**
  40777. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40778. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40779. */
  40780. export class AnaglyphGamepadCamera extends GamepadCamera {
  40781. /**
  40782. * Creates a new AnaglyphGamepadCamera
  40783. * @param name defines camera name
  40784. * @param position defines initial position
  40785. * @param interaxialDistance defines distance between each color axis
  40786. * @param scene defines the hosting scene
  40787. */
  40788. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40789. /**
  40790. * Gets camera class name
  40791. * @returns AnaglyphGamepadCamera
  40792. */
  40793. getClassName(): string;
  40794. }
  40795. }
  40796. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40797. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40798. import { Scene } from "babylonjs/scene";
  40799. import { Vector3 } from "babylonjs/Maths/math.vector";
  40800. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40801. /**
  40802. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40803. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40804. */
  40805. export class AnaglyphUniversalCamera extends UniversalCamera {
  40806. /**
  40807. * Creates a new AnaglyphUniversalCamera
  40808. * @param name defines camera name
  40809. * @param position defines initial position
  40810. * @param interaxialDistance defines distance between each color axis
  40811. * @param scene defines the hosting scene
  40812. */
  40813. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40814. /**
  40815. * Gets camera class name
  40816. * @returns AnaglyphUniversalCamera
  40817. */
  40818. getClassName(): string;
  40819. }
  40820. }
  40821. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40822. /** @hidden */
  40823. export var stereoscopicInterlacePixelShader: {
  40824. name: string;
  40825. shader: string;
  40826. };
  40827. }
  40828. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40829. import { Camera } from "babylonjs/Cameras/camera";
  40830. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40831. import { Engine } from "babylonjs/Engines/engine";
  40832. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40833. /**
  40834. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40835. */
  40836. export class StereoscopicInterlacePostProcess extends PostProcess {
  40837. private _stepSize;
  40838. private _passedProcess;
  40839. /**
  40840. * Initializes a StereoscopicInterlacePostProcess
  40841. * @param name The name of the effect.
  40842. * @param rigCameras The rig cameras to be appled to the post process
  40843. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40845. * @param engine The engine which the post process will be applied. (default: current engine)
  40846. * @param reusable If the post process can be reused on the same frame. (default: false)
  40847. */
  40848. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40849. }
  40850. }
  40851. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40852. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40853. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40854. import { Scene } from "babylonjs/scene";
  40855. import { Vector3 } from "babylonjs/Maths/math.vector";
  40856. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40857. /**
  40858. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40859. * @see http://doc.babylonjs.com/features/cameras
  40860. */
  40861. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40862. /**
  40863. * Creates a new StereoscopicArcRotateCamera
  40864. * @param name defines camera name
  40865. * @param alpha defines alpha angle (in radians)
  40866. * @param beta defines beta angle (in radians)
  40867. * @param radius defines radius
  40868. * @param target defines camera target
  40869. * @param interaxialDistance defines distance between each color axis
  40870. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40871. * @param scene defines the hosting scene
  40872. */
  40873. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40874. /**
  40875. * Gets camera class name
  40876. * @returns StereoscopicArcRotateCamera
  40877. */
  40878. getClassName(): string;
  40879. }
  40880. }
  40881. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40882. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40883. import { Scene } from "babylonjs/scene";
  40884. import { Vector3 } from "babylonjs/Maths/math.vector";
  40885. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40886. /**
  40887. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40888. * @see http://doc.babylonjs.com/features/cameras
  40889. */
  40890. export class StereoscopicFreeCamera extends FreeCamera {
  40891. /**
  40892. * Creates a new StereoscopicFreeCamera
  40893. * @param name defines camera name
  40894. * @param position defines initial position
  40895. * @param interaxialDistance defines distance between each color axis
  40896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40897. * @param scene defines the hosting scene
  40898. */
  40899. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40900. /**
  40901. * Gets camera class name
  40902. * @returns StereoscopicFreeCamera
  40903. */
  40904. getClassName(): string;
  40905. }
  40906. }
  40907. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40908. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40909. import { Scene } from "babylonjs/scene";
  40910. import { Vector3 } from "babylonjs/Maths/math.vector";
  40911. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40912. /**
  40913. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40914. * @see http://doc.babylonjs.com/features/cameras
  40915. */
  40916. export class StereoscopicGamepadCamera extends GamepadCamera {
  40917. /**
  40918. * Creates a new StereoscopicGamepadCamera
  40919. * @param name defines camera name
  40920. * @param position defines initial position
  40921. * @param interaxialDistance defines distance between each color axis
  40922. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40923. * @param scene defines the hosting scene
  40924. */
  40925. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40926. /**
  40927. * Gets camera class name
  40928. * @returns StereoscopicGamepadCamera
  40929. */
  40930. getClassName(): string;
  40931. }
  40932. }
  40933. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40934. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40935. import { Scene } from "babylonjs/scene";
  40936. import { Vector3 } from "babylonjs/Maths/math.vector";
  40937. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40938. /**
  40939. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40940. * @see http://doc.babylonjs.com/features/cameras
  40941. */
  40942. export class StereoscopicUniversalCamera extends UniversalCamera {
  40943. /**
  40944. * Creates a new StereoscopicUniversalCamera
  40945. * @param name defines camera name
  40946. * @param position defines initial position
  40947. * @param interaxialDistance defines distance between each color axis
  40948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40949. * @param scene defines the hosting scene
  40950. */
  40951. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40952. /**
  40953. * Gets camera class name
  40954. * @returns StereoscopicUniversalCamera
  40955. */
  40956. getClassName(): string;
  40957. }
  40958. }
  40959. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40960. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40961. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40962. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40963. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40964. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40965. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40966. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40967. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40968. }
  40969. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40970. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40971. import { Scene } from "babylonjs/scene";
  40972. import { Vector3 } from "babylonjs/Maths/math.vector";
  40973. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40974. /**
  40975. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40976. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40977. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40978. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40979. */
  40980. export class VirtualJoysticksCamera extends FreeCamera {
  40981. /**
  40982. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40985. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40986. * @param name Define the name of the camera in the scene
  40987. * @param position Define the start position of the camera in the scene
  40988. * @param scene Define the scene the camera belongs to
  40989. */
  40990. constructor(name: string, position: Vector3, scene: Scene);
  40991. /**
  40992. * Gets the current object class name.
  40993. * @return the class name
  40994. */
  40995. getClassName(): string;
  40996. }
  40997. }
  40998. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40999. import { Matrix } from "babylonjs/Maths/math.vector";
  41000. /**
  41001. * This represents all the required metrics to create a VR camera.
  41002. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41003. */
  41004. export class VRCameraMetrics {
  41005. /**
  41006. * Define the horizontal resolution off the screen.
  41007. */
  41008. hResolution: number;
  41009. /**
  41010. * Define the vertical resolution off the screen.
  41011. */
  41012. vResolution: number;
  41013. /**
  41014. * Define the horizontal screen size.
  41015. */
  41016. hScreenSize: number;
  41017. /**
  41018. * Define the vertical screen size.
  41019. */
  41020. vScreenSize: number;
  41021. /**
  41022. * Define the vertical screen center position.
  41023. */
  41024. vScreenCenter: number;
  41025. /**
  41026. * Define the distance of the eyes to the screen.
  41027. */
  41028. eyeToScreenDistance: number;
  41029. /**
  41030. * Define the distance between both lenses
  41031. */
  41032. lensSeparationDistance: number;
  41033. /**
  41034. * Define the distance between both viewer's eyes.
  41035. */
  41036. interpupillaryDistance: number;
  41037. /**
  41038. * Define the distortion factor of the VR postprocess.
  41039. * Please, touch with care.
  41040. */
  41041. distortionK: number[];
  41042. /**
  41043. * Define the chromatic aberration correction factors for the VR post process.
  41044. */
  41045. chromaAbCorrection: number[];
  41046. /**
  41047. * Define the scale factor of the post process.
  41048. * The smaller the better but the slower.
  41049. */
  41050. postProcessScaleFactor: number;
  41051. /**
  41052. * Define an offset for the lens center.
  41053. */
  41054. lensCenterOffset: number;
  41055. /**
  41056. * Define if the current vr camera should compensate the distortion of the lense or not.
  41057. */
  41058. compensateDistortion: boolean;
  41059. /**
  41060. * Defines if multiview should be enabled when rendering (Default: false)
  41061. */
  41062. multiviewEnabled: boolean;
  41063. /**
  41064. * Gets the rendering aspect ratio based on the provided resolutions.
  41065. */
  41066. readonly aspectRatio: number;
  41067. /**
  41068. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41069. */
  41070. readonly aspectRatioFov: number;
  41071. /**
  41072. * @hidden
  41073. */
  41074. readonly leftHMatrix: Matrix;
  41075. /**
  41076. * @hidden
  41077. */
  41078. readonly rightHMatrix: Matrix;
  41079. /**
  41080. * @hidden
  41081. */
  41082. readonly leftPreViewMatrix: Matrix;
  41083. /**
  41084. * @hidden
  41085. */
  41086. readonly rightPreViewMatrix: Matrix;
  41087. /**
  41088. * Get the default VRMetrics based on the most generic setup.
  41089. * @returns the default vr metrics
  41090. */
  41091. static GetDefault(): VRCameraMetrics;
  41092. }
  41093. }
  41094. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41095. /** @hidden */
  41096. export var vrDistortionCorrectionPixelShader: {
  41097. name: string;
  41098. shader: string;
  41099. };
  41100. }
  41101. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41102. import { Camera } from "babylonjs/Cameras/camera";
  41103. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41104. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41105. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41106. /**
  41107. * VRDistortionCorrectionPostProcess used for mobile VR
  41108. */
  41109. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41110. private _isRightEye;
  41111. private _distortionFactors;
  41112. private _postProcessScaleFactor;
  41113. private _lensCenterOffset;
  41114. private _scaleIn;
  41115. private _scaleFactor;
  41116. private _lensCenter;
  41117. /**
  41118. * Initializes the VRDistortionCorrectionPostProcess
  41119. * @param name The name of the effect.
  41120. * @param camera The camera to apply the render pass to.
  41121. * @param isRightEye If this is for the right eye distortion
  41122. * @param vrMetrics All the required metrics for the VR camera
  41123. */
  41124. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41125. }
  41126. }
  41127. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41128. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41129. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41130. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41131. import { Scene } from "babylonjs/scene";
  41132. import { Vector3 } from "babylonjs/Maths/math.vector";
  41133. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41134. import "babylonjs/Cameras/RigModes/vrRigMode";
  41135. /**
  41136. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41137. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41138. */
  41139. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41140. /**
  41141. * Creates a new VRDeviceOrientationArcRotateCamera
  41142. * @param name defines camera name
  41143. * @param alpha defines the camera rotation along the logitudinal axis
  41144. * @param beta defines the camera rotation along the latitudinal axis
  41145. * @param radius defines the camera distance from its target
  41146. * @param target defines the camera target
  41147. * @param scene defines the scene the camera belongs to
  41148. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41149. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41150. */
  41151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41152. /**
  41153. * Gets camera class name
  41154. * @returns VRDeviceOrientationArcRotateCamera
  41155. */
  41156. getClassName(): string;
  41157. }
  41158. }
  41159. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41160. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41161. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41162. import { Scene } from "babylonjs/scene";
  41163. import { Vector3 } from "babylonjs/Maths/math.vector";
  41164. import "babylonjs/Cameras/RigModes/vrRigMode";
  41165. /**
  41166. * Camera used to simulate VR rendering (based on FreeCamera)
  41167. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41168. */
  41169. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41170. /**
  41171. * Creates a new VRDeviceOrientationFreeCamera
  41172. * @param name defines camera name
  41173. * @param position defines the start position of the camera
  41174. * @param scene defines the scene the camera belongs to
  41175. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41176. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41177. */
  41178. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41179. /**
  41180. * Gets camera class name
  41181. * @returns VRDeviceOrientationFreeCamera
  41182. */
  41183. getClassName(): string;
  41184. }
  41185. }
  41186. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41187. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41188. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41189. import { Scene } from "babylonjs/scene";
  41190. import { Vector3 } from "babylonjs/Maths/math.vector";
  41191. import "babylonjs/Gamepads/gamepadSceneComponent";
  41192. /**
  41193. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41194. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41195. */
  41196. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41197. /**
  41198. * Creates a new VRDeviceOrientationGamepadCamera
  41199. * @param name defines camera name
  41200. * @param position defines the start position of the camera
  41201. * @param scene defines the scene the camera belongs to
  41202. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41203. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41204. */
  41205. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41206. /**
  41207. * Gets camera class name
  41208. * @returns VRDeviceOrientationGamepadCamera
  41209. */
  41210. getClassName(): string;
  41211. }
  41212. }
  41213. declare module "babylonjs/Materials/pushMaterial" {
  41214. import { Nullable } from "babylonjs/types";
  41215. import { Scene } from "babylonjs/scene";
  41216. import { Matrix } from "babylonjs/Maths/math.vector";
  41217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41218. import { Mesh } from "babylonjs/Meshes/mesh";
  41219. import { Material } from "babylonjs/Materials/material";
  41220. import { Effect } from "babylonjs/Materials/effect";
  41221. /**
  41222. * Base class of materials working in push mode in babylon JS
  41223. * @hidden
  41224. */
  41225. export class PushMaterial extends Material {
  41226. protected _activeEffect: Effect;
  41227. protected _normalMatrix: Matrix;
  41228. /**
  41229. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41230. * This means that the material can keep using a previous shader while a new one is being compiled.
  41231. * This is mostly used when shader parallel compilation is supported (true by default)
  41232. */
  41233. allowShaderHotSwapping: boolean;
  41234. constructor(name: string, scene: Scene);
  41235. getEffect(): Effect;
  41236. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41237. /**
  41238. * Binds the given world matrix to the active effect
  41239. *
  41240. * @param world the matrix to bind
  41241. */
  41242. bindOnlyWorldMatrix(world: Matrix): void;
  41243. /**
  41244. * Binds the given normal matrix to the active effect
  41245. *
  41246. * @param normalMatrix the matrix to bind
  41247. */
  41248. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41249. bind(world: Matrix, mesh?: Mesh): void;
  41250. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41251. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41252. }
  41253. }
  41254. declare module "babylonjs/Materials/materialFlags" {
  41255. /**
  41256. * This groups all the flags used to control the materials channel.
  41257. */
  41258. export class MaterialFlags {
  41259. private static _DiffuseTextureEnabled;
  41260. /**
  41261. * Are diffuse textures enabled in the application.
  41262. */
  41263. static DiffuseTextureEnabled: boolean;
  41264. private static _AmbientTextureEnabled;
  41265. /**
  41266. * Are ambient textures enabled in the application.
  41267. */
  41268. static AmbientTextureEnabled: boolean;
  41269. private static _OpacityTextureEnabled;
  41270. /**
  41271. * Are opacity textures enabled in the application.
  41272. */
  41273. static OpacityTextureEnabled: boolean;
  41274. private static _ReflectionTextureEnabled;
  41275. /**
  41276. * Are reflection textures enabled in the application.
  41277. */
  41278. static ReflectionTextureEnabled: boolean;
  41279. private static _EmissiveTextureEnabled;
  41280. /**
  41281. * Are emissive textures enabled in the application.
  41282. */
  41283. static EmissiveTextureEnabled: boolean;
  41284. private static _SpecularTextureEnabled;
  41285. /**
  41286. * Are specular textures enabled in the application.
  41287. */
  41288. static SpecularTextureEnabled: boolean;
  41289. private static _BumpTextureEnabled;
  41290. /**
  41291. * Are bump textures enabled in the application.
  41292. */
  41293. static BumpTextureEnabled: boolean;
  41294. private static _LightmapTextureEnabled;
  41295. /**
  41296. * Are lightmap textures enabled in the application.
  41297. */
  41298. static LightmapTextureEnabled: boolean;
  41299. private static _RefractionTextureEnabled;
  41300. /**
  41301. * Are refraction textures enabled in the application.
  41302. */
  41303. static RefractionTextureEnabled: boolean;
  41304. private static _ColorGradingTextureEnabled;
  41305. /**
  41306. * Are color grading textures enabled in the application.
  41307. */
  41308. static ColorGradingTextureEnabled: boolean;
  41309. private static _FresnelEnabled;
  41310. /**
  41311. * Are fresnels enabled in the application.
  41312. */
  41313. static FresnelEnabled: boolean;
  41314. private static _ClearCoatTextureEnabled;
  41315. /**
  41316. * Are clear coat textures enabled in the application.
  41317. */
  41318. static ClearCoatTextureEnabled: boolean;
  41319. private static _ClearCoatBumpTextureEnabled;
  41320. /**
  41321. * Are clear coat bump textures enabled in the application.
  41322. */
  41323. static ClearCoatBumpTextureEnabled: boolean;
  41324. private static _ClearCoatTintTextureEnabled;
  41325. /**
  41326. * Are clear coat tint textures enabled in the application.
  41327. */
  41328. static ClearCoatTintTextureEnabled: boolean;
  41329. private static _SheenTextureEnabled;
  41330. /**
  41331. * Are sheen textures enabled in the application.
  41332. */
  41333. static SheenTextureEnabled: boolean;
  41334. private static _AnisotropicTextureEnabled;
  41335. /**
  41336. * Are anisotropic textures enabled in the application.
  41337. */
  41338. static AnisotropicTextureEnabled: boolean;
  41339. private static _ThicknessTextureEnabled;
  41340. /**
  41341. * Are thickness textures enabled in the application.
  41342. */
  41343. static ThicknessTextureEnabled: boolean;
  41344. }
  41345. }
  41346. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41347. /** @hidden */
  41348. export var defaultFragmentDeclaration: {
  41349. name: string;
  41350. shader: string;
  41351. };
  41352. }
  41353. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41354. /** @hidden */
  41355. export var defaultUboDeclaration: {
  41356. name: string;
  41357. shader: string;
  41358. };
  41359. }
  41360. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41361. /** @hidden */
  41362. export var lightFragmentDeclaration: {
  41363. name: string;
  41364. shader: string;
  41365. };
  41366. }
  41367. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41368. /** @hidden */
  41369. export var lightUboDeclaration: {
  41370. name: string;
  41371. shader: string;
  41372. };
  41373. }
  41374. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41375. /** @hidden */
  41376. export var lightsFragmentFunctions: {
  41377. name: string;
  41378. shader: string;
  41379. };
  41380. }
  41381. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41382. /** @hidden */
  41383. export var shadowsFragmentFunctions: {
  41384. name: string;
  41385. shader: string;
  41386. };
  41387. }
  41388. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41389. /** @hidden */
  41390. export var fresnelFunction: {
  41391. name: string;
  41392. shader: string;
  41393. };
  41394. }
  41395. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41396. /** @hidden */
  41397. export var reflectionFunction: {
  41398. name: string;
  41399. shader: string;
  41400. };
  41401. }
  41402. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41403. /** @hidden */
  41404. export var bumpFragmentFunctions: {
  41405. name: string;
  41406. shader: string;
  41407. };
  41408. }
  41409. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41410. /** @hidden */
  41411. export var logDepthDeclaration: {
  41412. name: string;
  41413. shader: string;
  41414. };
  41415. }
  41416. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41417. /** @hidden */
  41418. export var bumpFragment: {
  41419. name: string;
  41420. shader: string;
  41421. };
  41422. }
  41423. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41424. /** @hidden */
  41425. export var depthPrePass: {
  41426. name: string;
  41427. shader: string;
  41428. };
  41429. }
  41430. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41431. /** @hidden */
  41432. export var lightFragment: {
  41433. name: string;
  41434. shader: string;
  41435. };
  41436. }
  41437. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41438. /** @hidden */
  41439. export var logDepthFragment: {
  41440. name: string;
  41441. shader: string;
  41442. };
  41443. }
  41444. declare module "babylonjs/Shaders/default.fragment" {
  41445. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41446. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41447. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41448. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41449. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41450. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41451. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41452. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41453. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41454. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41455. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41456. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41457. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41458. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41459. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41460. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41461. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41462. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41463. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41464. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41465. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41466. /** @hidden */
  41467. export var defaultPixelShader: {
  41468. name: string;
  41469. shader: string;
  41470. };
  41471. }
  41472. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41473. /** @hidden */
  41474. export var defaultVertexDeclaration: {
  41475. name: string;
  41476. shader: string;
  41477. };
  41478. }
  41479. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41480. /** @hidden */
  41481. export var bumpVertexDeclaration: {
  41482. name: string;
  41483. shader: string;
  41484. };
  41485. }
  41486. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41487. /** @hidden */
  41488. export var bumpVertex: {
  41489. name: string;
  41490. shader: string;
  41491. };
  41492. }
  41493. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41494. /** @hidden */
  41495. export var fogVertex: {
  41496. name: string;
  41497. shader: string;
  41498. };
  41499. }
  41500. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41501. /** @hidden */
  41502. export var shadowsVertex: {
  41503. name: string;
  41504. shader: string;
  41505. };
  41506. }
  41507. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41508. /** @hidden */
  41509. export var pointCloudVertex: {
  41510. name: string;
  41511. shader: string;
  41512. };
  41513. }
  41514. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41515. /** @hidden */
  41516. export var logDepthVertex: {
  41517. name: string;
  41518. shader: string;
  41519. };
  41520. }
  41521. declare module "babylonjs/Shaders/default.vertex" {
  41522. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41523. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41524. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41526. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41527. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41528. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41529. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41530. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41531. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41533. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41534. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41535. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41536. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41537. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41538. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41539. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41540. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41541. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41542. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41543. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41544. /** @hidden */
  41545. export var defaultVertexShader: {
  41546. name: string;
  41547. shader: string;
  41548. };
  41549. }
  41550. declare module "babylonjs/Materials/standardMaterial" {
  41551. import { SmartArray } from "babylonjs/Misc/smartArray";
  41552. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41553. import { Nullable } from "babylonjs/types";
  41554. import { Scene } from "babylonjs/scene";
  41555. import { Matrix } from "babylonjs/Maths/math.vector";
  41556. import { Color3 } from "babylonjs/Maths/math.color";
  41557. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41559. import { Mesh } from "babylonjs/Meshes/mesh";
  41560. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41561. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41562. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41563. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41564. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41567. import "babylonjs/Shaders/default.fragment";
  41568. import "babylonjs/Shaders/default.vertex";
  41569. /** @hidden */
  41570. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41571. MAINUV1: boolean;
  41572. MAINUV2: boolean;
  41573. DIFFUSE: boolean;
  41574. DIFFUSEDIRECTUV: number;
  41575. AMBIENT: boolean;
  41576. AMBIENTDIRECTUV: number;
  41577. OPACITY: boolean;
  41578. OPACITYDIRECTUV: number;
  41579. OPACITYRGB: boolean;
  41580. REFLECTION: boolean;
  41581. EMISSIVE: boolean;
  41582. EMISSIVEDIRECTUV: number;
  41583. SPECULAR: boolean;
  41584. SPECULARDIRECTUV: number;
  41585. BUMP: boolean;
  41586. BUMPDIRECTUV: number;
  41587. PARALLAX: boolean;
  41588. PARALLAXOCCLUSION: boolean;
  41589. SPECULAROVERALPHA: boolean;
  41590. CLIPPLANE: boolean;
  41591. CLIPPLANE2: boolean;
  41592. CLIPPLANE3: boolean;
  41593. CLIPPLANE4: boolean;
  41594. ALPHATEST: boolean;
  41595. DEPTHPREPASS: boolean;
  41596. ALPHAFROMDIFFUSE: boolean;
  41597. POINTSIZE: boolean;
  41598. FOG: boolean;
  41599. SPECULARTERM: boolean;
  41600. DIFFUSEFRESNEL: boolean;
  41601. OPACITYFRESNEL: boolean;
  41602. REFLECTIONFRESNEL: boolean;
  41603. REFRACTIONFRESNEL: boolean;
  41604. EMISSIVEFRESNEL: boolean;
  41605. FRESNEL: boolean;
  41606. NORMAL: boolean;
  41607. UV1: boolean;
  41608. UV2: boolean;
  41609. VERTEXCOLOR: boolean;
  41610. VERTEXALPHA: boolean;
  41611. NUM_BONE_INFLUENCERS: number;
  41612. BonesPerMesh: number;
  41613. BONETEXTURE: boolean;
  41614. INSTANCES: boolean;
  41615. GLOSSINESS: boolean;
  41616. ROUGHNESS: boolean;
  41617. EMISSIVEASILLUMINATION: boolean;
  41618. LINKEMISSIVEWITHDIFFUSE: boolean;
  41619. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41620. LIGHTMAP: boolean;
  41621. LIGHTMAPDIRECTUV: number;
  41622. OBJECTSPACE_NORMALMAP: boolean;
  41623. USELIGHTMAPASSHADOWMAP: boolean;
  41624. REFLECTIONMAP_3D: boolean;
  41625. REFLECTIONMAP_SPHERICAL: boolean;
  41626. REFLECTIONMAP_PLANAR: boolean;
  41627. REFLECTIONMAP_CUBIC: boolean;
  41628. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41629. REFLECTIONMAP_PROJECTION: boolean;
  41630. REFLECTIONMAP_SKYBOX: boolean;
  41631. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41632. REFLECTIONMAP_EXPLICIT: boolean;
  41633. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41634. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41635. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41636. INVERTCUBICMAP: boolean;
  41637. LOGARITHMICDEPTH: boolean;
  41638. REFRACTION: boolean;
  41639. REFRACTIONMAP_3D: boolean;
  41640. REFLECTIONOVERALPHA: boolean;
  41641. TWOSIDEDLIGHTING: boolean;
  41642. SHADOWFLOAT: boolean;
  41643. MORPHTARGETS: boolean;
  41644. MORPHTARGETS_NORMAL: boolean;
  41645. MORPHTARGETS_TANGENT: boolean;
  41646. MORPHTARGETS_UV: boolean;
  41647. NUM_MORPH_INFLUENCERS: number;
  41648. NONUNIFORMSCALING: boolean;
  41649. PREMULTIPLYALPHA: boolean;
  41650. IMAGEPROCESSING: boolean;
  41651. VIGNETTE: boolean;
  41652. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41653. VIGNETTEBLENDMODEOPAQUE: boolean;
  41654. TONEMAPPING: boolean;
  41655. TONEMAPPING_ACES: boolean;
  41656. CONTRAST: boolean;
  41657. COLORCURVES: boolean;
  41658. COLORGRADING: boolean;
  41659. COLORGRADING3D: boolean;
  41660. SAMPLER3DGREENDEPTH: boolean;
  41661. SAMPLER3DBGRMAP: boolean;
  41662. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41663. MULTIVIEW: boolean;
  41664. /**
  41665. * If the reflection texture on this material is in linear color space
  41666. * @hidden
  41667. */
  41668. IS_REFLECTION_LINEAR: boolean;
  41669. /**
  41670. * If the refraction texture on this material is in linear color space
  41671. * @hidden
  41672. */
  41673. IS_REFRACTION_LINEAR: boolean;
  41674. EXPOSURE: boolean;
  41675. constructor();
  41676. setReflectionMode(modeToEnable: string): void;
  41677. }
  41678. /**
  41679. * This is the default material used in Babylon. It is the best trade off between quality
  41680. * and performances.
  41681. * @see http://doc.babylonjs.com/babylon101/materials
  41682. */
  41683. export class StandardMaterial extends PushMaterial {
  41684. private _diffuseTexture;
  41685. /**
  41686. * The basic texture of the material as viewed under a light.
  41687. */
  41688. diffuseTexture: Nullable<BaseTexture>;
  41689. private _ambientTexture;
  41690. /**
  41691. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41692. */
  41693. ambientTexture: Nullable<BaseTexture>;
  41694. private _opacityTexture;
  41695. /**
  41696. * Define the transparency of the material from a texture.
  41697. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41698. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41699. */
  41700. opacityTexture: Nullable<BaseTexture>;
  41701. private _reflectionTexture;
  41702. /**
  41703. * Define the texture used to display the reflection.
  41704. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41705. */
  41706. reflectionTexture: Nullable<BaseTexture>;
  41707. private _emissiveTexture;
  41708. /**
  41709. * Define texture of the material as if self lit.
  41710. * This will be mixed in the final result even in the absence of light.
  41711. */
  41712. emissiveTexture: Nullable<BaseTexture>;
  41713. private _specularTexture;
  41714. /**
  41715. * Define how the color and intensity of the highlight given by the light in the material.
  41716. */
  41717. specularTexture: Nullable<BaseTexture>;
  41718. private _bumpTexture;
  41719. /**
  41720. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41721. * 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.
  41722. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41723. */
  41724. bumpTexture: Nullable<BaseTexture>;
  41725. private _lightmapTexture;
  41726. /**
  41727. * Complex lighting can be computationally expensive to compute at runtime.
  41728. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41729. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41730. */
  41731. lightmapTexture: Nullable<BaseTexture>;
  41732. private _refractionTexture;
  41733. /**
  41734. * Define the texture used to display the refraction.
  41735. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41736. */
  41737. refractionTexture: Nullable<BaseTexture>;
  41738. /**
  41739. * The color of the material lit by the environmental background lighting.
  41740. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41741. */
  41742. ambientColor: Color3;
  41743. /**
  41744. * The basic color of the material as viewed under a light.
  41745. */
  41746. diffuseColor: Color3;
  41747. /**
  41748. * Define how the color and intensity of the highlight given by the light in the material.
  41749. */
  41750. specularColor: Color3;
  41751. /**
  41752. * Define the color of the material as if self lit.
  41753. * This will be mixed in the final result even in the absence of light.
  41754. */
  41755. emissiveColor: Color3;
  41756. /**
  41757. * Defines how sharp are the highlights in the material.
  41758. * The bigger the value the sharper giving a more glossy feeling to the result.
  41759. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41760. */
  41761. specularPower: number;
  41762. private _useAlphaFromDiffuseTexture;
  41763. /**
  41764. * Does the transparency come from the diffuse texture alpha channel.
  41765. */
  41766. useAlphaFromDiffuseTexture: boolean;
  41767. private _useEmissiveAsIllumination;
  41768. /**
  41769. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41770. */
  41771. useEmissiveAsIllumination: boolean;
  41772. private _linkEmissiveWithDiffuse;
  41773. /**
  41774. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41775. * the emissive level when the final color is close to one.
  41776. */
  41777. linkEmissiveWithDiffuse: boolean;
  41778. private _useSpecularOverAlpha;
  41779. /**
  41780. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41781. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41782. */
  41783. useSpecularOverAlpha: boolean;
  41784. private _useReflectionOverAlpha;
  41785. /**
  41786. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41787. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41788. */
  41789. useReflectionOverAlpha: boolean;
  41790. private _disableLighting;
  41791. /**
  41792. * Does lights from the scene impacts this material.
  41793. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41794. */
  41795. disableLighting: boolean;
  41796. private _useObjectSpaceNormalMap;
  41797. /**
  41798. * Allows using an object space normal map (instead of tangent space).
  41799. */
  41800. useObjectSpaceNormalMap: boolean;
  41801. private _useParallax;
  41802. /**
  41803. * Is parallax enabled or not.
  41804. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41805. */
  41806. useParallax: boolean;
  41807. private _useParallaxOcclusion;
  41808. /**
  41809. * Is parallax occlusion enabled or not.
  41810. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41811. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41812. */
  41813. useParallaxOcclusion: boolean;
  41814. /**
  41815. * 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.
  41816. */
  41817. parallaxScaleBias: number;
  41818. private _roughness;
  41819. /**
  41820. * Helps to define how blurry the reflections should appears in the material.
  41821. */
  41822. roughness: number;
  41823. /**
  41824. * In case of refraction, define the value of the index of refraction.
  41825. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41826. */
  41827. indexOfRefraction: number;
  41828. /**
  41829. * Invert the refraction texture alongside the y axis.
  41830. * It can be useful with procedural textures or probe for instance.
  41831. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41832. */
  41833. invertRefractionY: boolean;
  41834. /**
  41835. * Defines the alpha limits in alpha test mode.
  41836. */
  41837. alphaCutOff: number;
  41838. private _useLightmapAsShadowmap;
  41839. /**
  41840. * In case of light mapping, define whether the map contains light or shadow informations.
  41841. */
  41842. useLightmapAsShadowmap: boolean;
  41843. private _diffuseFresnelParameters;
  41844. /**
  41845. * Define the diffuse fresnel parameters of the material.
  41846. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41847. */
  41848. diffuseFresnelParameters: FresnelParameters;
  41849. private _opacityFresnelParameters;
  41850. /**
  41851. * Define the opacity fresnel parameters of the material.
  41852. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41853. */
  41854. opacityFresnelParameters: FresnelParameters;
  41855. private _reflectionFresnelParameters;
  41856. /**
  41857. * Define the reflection fresnel parameters of the material.
  41858. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41859. */
  41860. reflectionFresnelParameters: FresnelParameters;
  41861. private _refractionFresnelParameters;
  41862. /**
  41863. * Define the refraction fresnel parameters of the material.
  41864. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41865. */
  41866. refractionFresnelParameters: FresnelParameters;
  41867. private _emissiveFresnelParameters;
  41868. /**
  41869. * Define the emissive fresnel parameters of the material.
  41870. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41871. */
  41872. emissiveFresnelParameters: FresnelParameters;
  41873. private _useReflectionFresnelFromSpecular;
  41874. /**
  41875. * If true automatically deducts the fresnels values from the material specularity.
  41876. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41877. */
  41878. useReflectionFresnelFromSpecular: boolean;
  41879. private _useGlossinessFromSpecularMapAlpha;
  41880. /**
  41881. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41882. */
  41883. useGlossinessFromSpecularMapAlpha: boolean;
  41884. private _maxSimultaneousLights;
  41885. /**
  41886. * Defines the maximum number of lights that can be used in the material
  41887. */
  41888. maxSimultaneousLights: number;
  41889. private _invertNormalMapX;
  41890. /**
  41891. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41892. */
  41893. invertNormalMapX: boolean;
  41894. private _invertNormalMapY;
  41895. /**
  41896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41897. */
  41898. invertNormalMapY: boolean;
  41899. private _twoSidedLighting;
  41900. /**
  41901. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41902. */
  41903. twoSidedLighting: boolean;
  41904. /**
  41905. * Default configuration related to image processing available in the standard Material.
  41906. */
  41907. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41908. /**
  41909. * Gets the image processing configuration used either in this material.
  41910. */
  41911. /**
  41912. * Sets the Default image processing configuration used either in the this material.
  41913. *
  41914. * If sets to null, the scene one is in use.
  41915. */
  41916. imageProcessingConfiguration: ImageProcessingConfiguration;
  41917. /**
  41918. * Keep track of the image processing observer to allow dispose and replace.
  41919. */
  41920. private _imageProcessingObserver;
  41921. /**
  41922. * Attaches a new image processing configuration to the Standard Material.
  41923. * @param configuration
  41924. */
  41925. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41926. /**
  41927. * Gets wether the color curves effect is enabled.
  41928. */
  41929. /**
  41930. * Sets wether the color curves effect is enabled.
  41931. */
  41932. cameraColorCurvesEnabled: boolean;
  41933. /**
  41934. * Gets wether the color grading effect is enabled.
  41935. */
  41936. /**
  41937. * Gets wether the color grading effect is enabled.
  41938. */
  41939. cameraColorGradingEnabled: boolean;
  41940. /**
  41941. * Gets wether tonemapping is enabled or not.
  41942. */
  41943. /**
  41944. * Sets wether tonemapping is enabled or not
  41945. */
  41946. cameraToneMappingEnabled: boolean;
  41947. /**
  41948. * The camera exposure used on this material.
  41949. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41950. * This corresponds to a photographic exposure.
  41951. */
  41952. /**
  41953. * The camera exposure used on this material.
  41954. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41955. * This corresponds to a photographic exposure.
  41956. */
  41957. cameraExposure: number;
  41958. /**
  41959. * Gets The camera contrast used on this material.
  41960. */
  41961. /**
  41962. * Sets The camera contrast used on this material.
  41963. */
  41964. cameraContrast: number;
  41965. /**
  41966. * Gets the Color Grading 2D Lookup Texture.
  41967. */
  41968. /**
  41969. * Sets the Color Grading 2D Lookup Texture.
  41970. */
  41971. cameraColorGradingTexture: Nullable<BaseTexture>;
  41972. /**
  41973. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41974. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41975. * 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;
  41976. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41977. */
  41978. /**
  41979. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41980. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41981. * 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;
  41982. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41983. */
  41984. cameraColorCurves: Nullable<ColorCurves>;
  41985. /**
  41986. * Custom callback helping to override the default shader used in the material.
  41987. */
  41988. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41989. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41990. protected _worldViewProjectionMatrix: Matrix;
  41991. protected _globalAmbientColor: Color3;
  41992. protected _useLogarithmicDepth: boolean;
  41993. protected _rebuildInParallel: boolean;
  41994. /**
  41995. * Instantiates a new standard material.
  41996. * This is the default material used in Babylon. It is the best trade off between quality
  41997. * and performances.
  41998. * @see http://doc.babylonjs.com/babylon101/materials
  41999. * @param name Define the name of the material in the scene
  42000. * @param scene Define the scene the material belong to
  42001. */
  42002. constructor(name: string, scene: Scene);
  42003. /**
  42004. * Gets a boolean indicating that current material needs to register RTT
  42005. */
  42006. readonly hasRenderTargetTextures: boolean;
  42007. /**
  42008. * Gets the current class name of the material e.g. "StandardMaterial"
  42009. * Mainly use in serialization.
  42010. * @returns the class name
  42011. */
  42012. getClassName(): string;
  42013. /**
  42014. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42015. * You can try switching to logarithmic depth.
  42016. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42017. */
  42018. useLogarithmicDepth: boolean;
  42019. /**
  42020. * Specifies if the material will require alpha blending
  42021. * @returns a boolean specifying if alpha blending is needed
  42022. */
  42023. needAlphaBlending(): boolean;
  42024. /**
  42025. * Specifies if this material should be rendered in alpha test mode
  42026. * @returns a boolean specifying if an alpha test is needed.
  42027. */
  42028. needAlphaTesting(): boolean;
  42029. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42030. /**
  42031. * Get the texture used for alpha test purpose.
  42032. * @returns the diffuse texture in case of the standard material.
  42033. */
  42034. getAlphaTestTexture(): Nullable<BaseTexture>;
  42035. /**
  42036. * Get if the submesh is ready to be used and all its information available.
  42037. * Child classes can use it to update shaders
  42038. * @param mesh defines the mesh to check
  42039. * @param subMesh defines which submesh to check
  42040. * @param useInstances specifies that instances should be used
  42041. * @returns a boolean indicating that the submesh is ready or not
  42042. */
  42043. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42044. /**
  42045. * Builds the material UBO layouts.
  42046. * Used internally during the effect preparation.
  42047. */
  42048. buildUniformLayout(): void;
  42049. /**
  42050. * Unbinds the material from the mesh
  42051. */
  42052. unbind(): void;
  42053. /**
  42054. * Binds the submesh to this material by preparing the effect and shader to draw
  42055. * @param world defines the world transformation matrix
  42056. * @param mesh defines the mesh containing the submesh
  42057. * @param subMesh defines the submesh to bind the material to
  42058. */
  42059. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42060. /**
  42061. * Get the list of animatables in the material.
  42062. * @returns the list of animatables object used in the material
  42063. */
  42064. getAnimatables(): IAnimatable[];
  42065. /**
  42066. * Gets the active textures from the material
  42067. * @returns an array of textures
  42068. */
  42069. getActiveTextures(): BaseTexture[];
  42070. /**
  42071. * Specifies if the material uses a texture
  42072. * @param texture defines the texture to check against the material
  42073. * @returns a boolean specifying if the material uses the texture
  42074. */
  42075. hasTexture(texture: BaseTexture): boolean;
  42076. /**
  42077. * Disposes the material
  42078. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42079. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42080. */
  42081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42082. /**
  42083. * Makes a duplicate of the material, and gives it a new name
  42084. * @param name defines the new name for the duplicated material
  42085. * @returns the cloned material
  42086. */
  42087. clone(name: string): StandardMaterial;
  42088. /**
  42089. * Serializes this material in a JSON representation
  42090. * @returns the serialized material object
  42091. */
  42092. serialize(): any;
  42093. /**
  42094. * Creates a standard material from parsed material data
  42095. * @param source defines the JSON representation of the material
  42096. * @param scene defines the hosting scene
  42097. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42098. * @returns a new standard material
  42099. */
  42100. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42101. /**
  42102. * Are diffuse textures enabled in the application.
  42103. */
  42104. static DiffuseTextureEnabled: boolean;
  42105. /**
  42106. * Are ambient textures enabled in the application.
  42107. */
  42108. static AmbientTextureEnabled: boolean;
  42109. /**
  42110. * Are opacity textures enabled in the application.
  42111. */
  42112. static OpacityTextureEnabled: boolean;
  42113. /**
  42114. * Are reflection textures enabled in the application.
  42115. */
  42116. static ReflectionTextureEnabled: boolean;
  42117. /**
  42118. * Are emissive textures enabled in the application.
  42119. */
  42120. static EmissiveTextureEnabled: boolean;
  42121. /**
  42122. * Are specular textures enabled in the application.
  42123. */
  42124. static SpecularTextureEnabled: boolean;
  42125. /**
  42126. * Are bump textures enabled in the application.
  42127. */
  42128. static BumpTextureEnabled: boolean;
  42129. /**
  42130. * Are lightmap textures enabled in the application.
  42131. */
  42132. static LightmapTextureEnabled: boolean;
  42133. /**
  42134. * Are refraction textures enabled in the application.
  42135. */
  42136. static RefractionTextureEnabled: boolean;
  42137. /**
  42138. * Are color grading textures enabled in the application.
  42139. */
  42140. static ColorGradingTextureEnabled: boolean;
  42141. /**
  42142. * Are fresnels enabled in the application.
  42143. */
  42144. static FresnelEnabled: boolean;
  42145. }
  42146. }
  42147. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42148. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42149. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42150. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42151. /** @hidden */
  42152. export var imageProcessingPixelShader: {
  42153. name: string;
  42154. shader: string;
  42155. };
  42156. }
  42157. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42158. import { Nullable } from "babylonjs/types";
  42159. import { Color4 } from "babylonjs/Maths/math.color";
  42160. import { Camera } from "babylonjs/Cameras/camera";
  42161. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42162. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42163. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42164. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42165. import { Engine } from "babylonjs/Engines/engine";
  42166. import "babylonjs/Shaders/imageProcessing.fragment";
  42167. import "babylonjs/Shaders/postprocess.vertex";
  42168. /**
  42169. * ImageProcessingPostProcess
  42170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42171. */
  42172. export class ImageProcessingPostProcess extends PostProcess {
  42173. /**
  42174. * Default configuration related to image processing available in the PBR Material.
  42175. */
  42176. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42177. /**
  42178. * Gets the image processing configuration used either in this material.
  42179. */
  42180. /**
  42181. * Sets the Default image processing configuration used either in the this material.
  42182. *
  42183. * If sets to null, the scene one is in use.
  42184. */
  42185. imageProcessingConfiguration: ImageProcessingConfiguration;
  42186. /**
  42187. * Keep track of the image processing observer to allow dispose and replace.
  42188. */
  42189. private _imageProcessingObserver;
  42190. /**
  42191. * Attaches a new image processing configuration to the PBR Material.
  42192. * @param configuration
  42193. */
  42194. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42195. /**
  42196. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42197. */
  42198. /**
  42199. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42200. */
  42201. colorCurves: Nullable<ColorCurves>;
  42202. /**
  42203. * Gets wether the color curves effect is enabled.
  42204. */
  42205. /**
  42206. * Sets wether the color curves effect is enabled.
  42207. */
  42208. colorCurvesEnabled: boolean;
  42209. /**
  42210. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42211. */
  42212. /**
  42213. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42214. */
  42215. colorGradingTexture: Nullable<BaseTexture>;
  42216. /**
  42217. * Gets wether the color grading effect is enabled.
  42218. */
  42219. /**
  42220. * Gets wether the color grading effect is enabled.
  42221. */
  42222. colorGradingEnabled: boolean;
  42223. /**
  42224. * Gets exposure used in the effect.
  42225. */
  42226. /**
  42227. * Sets exposure used in the effect.
  42228. */
  42229. exposure: number;
  42230. /**
  42231. * Gets wether tonemapping is enabled or not.
  42232. */
  42233. /**
  42234. * Sets wether tonemapping is enabled or not
  42235. */
  42236. toneMappingEnabled: boolean;
  42237. /**
  42238. * Gets the type of tone mapping effect.
  42239. */
  42240. /**
  42241. * Sets the type of tone mapping effect.
  42242. */
  42243. toneMappingType: number;
  42244. /**
  42245. * Gets contrast used in the effect.
  42246. */
  42247. /**
  42248. * Sets contrast used in the effect.
  42249. */
  42250. contrast: number;
  42251. /**
  42252. * Gets Vignette stretch size.
  42253. */
  42254. /**
  42255. * Sets Vignette stretch size.
  42256. */
  42257. vignetteStretch: number;
  42258. /**
  42259. * Gets Vignette centre X Offset.
  42260. */
  42261. /**
  42262. * Sets Vignette centre X Offset.
  42263. */
  42264. vignetteCentreX: number;
  42265. /**
  42266. * Gets Vignette centre Y Offset.
  42267. */
  42268. /**
  42269. * Sets Vignette centre Y Offset.
  42270. */
  42271. vignetteCentreY: number;
  42272. /**
  42273. * Gets Vignette weight or intensity of the vignette effect.
  42274. */
  42275. /**
  42276. * Sets Vignette weight or intensity of the vignette effect.
  42277. */
  42278. vignetteWeight: number;
  42279. /**
  42280. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42281. * if vignetteEnabled is set to true.
  42282. */
  42283. /**
  42284. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42285. * if vignetteEnabled is set to true.
  42286. */
  42287. vignetteColor: Color4;
  42288. /**
  42289. * Gets Camera field of view used by the Vignette effect.
  42290. */
  42291. /**
  42292. * Sets Camera field of view used by the Vignette effect.
  42293. */
  42294. vignetteCameraFov: number;
  42295. /**
  42296. * Gets the vignette blend mode allowing different kind of effect.
  42297. */
  42298. /**
  42299. * Sets the vignette blend mode allowing different kind of effect.
  42300. */
  42301. vignetteBlendMode: number;
  42302. /**
  42303. * Gets wether the vignette effect is enabled.
  42304. */
  42305. /**
  42306. * Sets wether the vignette effect is enabled.
  42307. */
  42308. vignetteEnabled: boolean;
  42309. private _fromLinearSpace;
  42310. /**
  42311. * Gets wether the input of the processing is in Gamma or Linear Space.
  42312. */
  42313. /**
  42314. * Sets wether the input of the processing is in Gamma or Linear Space.
  42315. */
  42316. fromLinearSpace: boolean;
  42317. /**
  42318. * Defines cache preventing GC.
  42319. */
  42320. private _defines;
  42321. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42322. /**
  42323. * "ImageProcessingPostProcess"
  42324. * @returns "ImageProcessingPostProcess"
  42325. */
  42326. getClassName(): string;
  42327. protected _updateParameters(): void;
  42328. dispose(camera?: Camera): void;
  42329. }
  42330. }
  42331. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42332. import { Scene } from "babylonjs/scene";
  42333. import { Color3 } from "babylonjs/Maths/math.color";
  42334. import { Mesh } from "babylonjs/Meshes/mesh";
  42335. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42336. import { Nullable } from "babylonjs/types";
  42337. /**
  42338. * Class containing static functions to help procedurally build meshes
  42339. */
  42340. export class GroundBuilder {
  42341. /**
  42342. * Creates a ground mesh
  42343. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42344. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42346. * @param name defines the name of the mesh
  42347. * @param options defines the options used to create the mesh
  42348. * @param scene defines the hosting scene
  42349. * @returns the ground mesh
  42350. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42351. */
  42352. static CreateGround(name: string, options: {
  42353. width?: number;
  42354. height?: number;
  42355. subdivisions?: number;
  42356. subdivisionsX?: number;
  42357. subdivisionsY?: number;
  42358. updatable?: boolean;
  42359. }, scene: any): Mesh;
  42360. /**
  42361. * Creates a tiled ground mesh
  42362. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42363. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42364. * * 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
  42365. * * 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
  42366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42367. * @param name defines the name of the mesh
  42368. * @param options defines the options used to create the mesh
  42369. * @param scene defines the hosting scene
  42370. * @returns the tiled ground mesh
  42371. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42372. */
  42373. static CreateTiledGround(name: string, options: {
  42374. xmin: number;
  42375. zmin: number;
  42376. xmax: number;
  42377. zmax: number;
  42378. subdivisions?: {
  42379. w: number;
  42380. h: number;
  42381. };
  42382. precision?: {
  42383. w: number;
  42384. h: number;
  42385. };
  42386. updatable?: boolean;
  42387. }, scene?: Nullable<Scene>): Mesh;
  42388. /**
  42389. * Creates a ground mesh from a height map
  42390. * * The parameter `url` sets the URL of the height map image resource.
  42391. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42392. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42393. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42394. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42395. * * 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.
  42396. * * 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).
  42397. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42399. * @param name defines the name of the mesh
  42400. * @param url defines the url to the height map
  42401. * @param options defines the options used to create the mesh
  42402. * @param scene defines the hosting scene
  42403. * @returns the ground mesh
  42404. * @see https://doc.babylonjs.com/babylon101/height_map
  42405. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42406. */
  42407. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42408. width?: number;
  42409. height?: number;
  42410. subdivisions?: number;
  42411. minHeight?: number;
  42412. maxHeight?: number;
  42413. colorFilter?: Color3;
  42414. alphaFilter?: number;
  42415. updatable?: boolean;
  42416. onReady?: (mesh: GroundMesh) => void;
  42417. }, scene?: Nullable<Scene>): GroundMesh;
  42418. }
  42419. }
  42420. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42421. import { Vector4 } from "babylonjs/Maths/math.vector";
  42422. import { Mesh } from "babylonjs/Meshes/mesh";
  42423. /**
  42424. * Class containing static functions to help procedurally build meshes
  42425. */
  42426. export class TorusBuilder {
  42427. /**
  42428. * Creates a torus mesh
  42429. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42430. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42431. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42435. * @param name defines the name of the mesh
  42436. * @param options defines the options used to create the mesh
  42437. * @param scene defines the hosting scene
  42438. * @returns the torus mesh
  42439. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42440. */
  42441. static CreateTorus(name: string, options: {
  42442. diameter?: number;
  42443. thickness?: number;
  42444. tessellation?: number;
  42445. updatable?: boolean;
  42446. sideOrientation?: number;
  42447. frontUVs?: Vector4;
  42448. backUVs?: Vector4;
  42449. }, scene: any): Mesh;
  42450. }
  42451. }
  42452. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42453. import { Vector4 } from "babylonjs/Maths/math.vector";
  42454. import { Color4 } from "babylonjs/Maths/math.color";
  42455. import { Mesh } from "babylonjs/Meshes/mesh";
  42456. /**
  42457. * Class containing static functions to help procedurally build meshes
  42458. */
  42459. export class CylinderBuilder {
  42460. /**
  42461. * Creates a cylinder or a cone mesh
  42462. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42463. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42464. * * 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.
  42465. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42466. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42467. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42468. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42469. * * 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).
  42470. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42471. * * 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).
  42472. * * 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
  42473. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42474. * * 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
  42475. * * 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.
  42476. * * If `enclose` is false, a ring surface is one element.
  42477. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42478. * * 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
  42479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42482. * @param name defines the name of the mesh
  42483. * @param options defines the options used to create the mesh
  42484. * @param scene defines the hosting scene
  42485. * @returns the cylinder mesh
  42486. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42487. */
  42488. static CreateCylinder(name: string, options: {
  42489. height?: number;
  42490. diameterTop?: number;
  42491. diameterBottom?: number;
  42492. diameter?: number;
  42493. tessellation?: number;
  42494. subdivisions?: number;
  42495. arc?: number;
  42496. faceColors?: Color4[];
  42497. faceUV?: Vector4[];
  42498. updatable?: boolean;
  42499. hasRings?: boolean;
  42500. enclose?: boolean;
  42501. cap?: number;
  42502. sideOrientation?: number;
  42503. frontUVs?: Vector4;
  42504. backUVs?: Vector4;
  42505. }, scene: any): Mesh;
  42506. }
  42507. }
  42508. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42509. import { Observable } from "babylonjs/Misc/observable";
  42510. import { Nullable } from "babylonjs/types";
  42511. import { Camera } from "babylonjs/Cameras/camera";
  42512. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42513. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42514. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42515. import { Scene } from "babylonjs/scene";
  42516. import { Vector3 } from "babylonjs/Maths/math.vector";
  42517. import { Color3 } from "babylonjs/Maths/math.color";
  42518. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42520. import { Mesh } from "babylonjs/Meshes/mesh";
  42521. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42522. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42523. import "babylonjs/Meshes/Builders/groundBuilder";
  42524. import "babylonjs/Meshes/Builders/torusBuilder";
  42525. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42526. import "babylonjs/Gamepads/gamepadSceneComponent";
  42527. import "babylonjs/Animations/animatable";
  42528. /**
  42529. * Options to modify the vr teleportation behavior.
  42530. */
  42531. export interface VRTeleportationOptions {
  42532. /**
  42533. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42534. */
  42535. floorMeshName?: string;
  42536. /**
  42537. * A list of meshes to be used as the teleportation floor. (default: empty)
  42538. */
  42539. floorMeshes?: Mesh[];
  42540. }
  42541. /**
  42542. * Options to modify the vr experience helper's behavior.
  42543. */
  42544. export interface VRExperienceHelperOptions extends WebVROptions {
  42545. /**
  42546. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42547. */
  42548. createDeviceOrientationCamera?: boolean;
  42549. /**
  42550. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42551. */
  42552. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42553. /**
  42554. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42555. */
  42556. laserToggle?: boolean;
  42557. /**
  42558. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42559. */
  42560. floorMeshes?: Mesh[];
  42561. /**
  42562. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42563. */
  42564. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42565. }
  42566. /**
  42567. * Event containing information after VR has been entered
  42568. */
  42569. export class OnAfterEnteringVRObservableEvent {
  42570. /**
  42571. * If entering vr was successful
  42572. */
  42573. success: boolean;
  42574. }
  42575. /**
  42576. * Helps to quickly add VR support to an existing scene.
  42577. * See http://doc.babylonjs.com/how_to/webvr_helper
  42578. */
  42579. export class VRExperienceHelper {
  42580. /** Options to modify the vr experience helper's behavior. */
  42581. webVROptions: VRExperienceHelperOptions;
  42582. private _scene;
  42583. private _position;
  42584. private _btnVR;
  42585. private _btnVRDisplayed;
  42586. private _webVRsupported;
  42587. private _webVRready;
  42588. private _webVRrequesting;
  42589. private _webVRpresenting;
  42590. private _hasEnteredVR;
  42591. private _fullscreenVRpresenting;
  42592. private _canvas;
  42593. private _webVRCamera;
  42594. private _vrDeviceOrientationCamera;
  42595. private _deviceOrientationCamera;
  42596. private _existingCamera;
  42597. private _onKeyDown;
  42598. private _onVrDisplayPresentChange;
  42599. private _onVRDisplayChanged;
  42600. private _onVRRequestPresentStart;
  42601. private _onVRRequestPresentComplete;
  42602. /**
  42603. * 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)
  42604. */
  42605. enableGazeEvenWhenNoPointerLock: boolean;
  42606. /**
  42607. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42608. */
  42609. exitVROnDoubleTap: boolean;
  42610. /**
  42611. * Observable raised right before entering VR.
  42612. */
  42613. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42614. /**
  42615. * Observable raised when entering VR has completed.
  42616. */
  42617. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42618. /**
  42619. * Observable raised when exiting VR.
  42620. */
  42621. onExitingVRObservable: Observable<VRExperienceHelper>;
  42622. /**
  42623. * Observable raised when controller mesh is loaded.
  42624. */
  42625. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42626. /** Return this.onEnteringVRObservable
  42627. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42628. */
  42629. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42630. /** Return this.onExitingVRObservable
  42631. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42632. */
  42633. readonly onExitingVR: Observable<VRExperienceHelper>;
  42634. /** Return this.onControllerMeshLoadedObservable
  42635. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42636. */
  42637. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42638. private _rayLength;
  42639. private _useCustomVRButton;
  42640. private _teleportationRequested;
  42641. private _teleportActive;
  42642. private _floorMeshName;
  42643. private _floorMeshesCollection;
  42644. private _rotationAllowed;
  42645. private _teleportBackwardsVector;
  42646. private _teleportationTarget;
  42647. private _isDefaultTeleportationTarget;
  42648. private _postProcessMove;
  42649. private _teleportationFillColor;
  42650. private _teleportationBorderColor;
  42651. private _rotationAngle;
  42652. private _haloCenter;
  42653. private _cameraGazer;
  42654. private _padSensibilityUp;
  42655. private _padSensibilityDown;
  42656. private _leftController;
  42657. private _rightController;
  42658. /**
  42659. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42660. */
  42661. onNewMeshSelected: Observable<AbstractMesh>;
  42662. /**
  42663. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42664. * This observable will provide the mesh and the controller used to select the mesh
  42665. */
  42666. onMeshSelectedWithController: Observable<{
  42667. mesh: AbstractMesh;
  42668. controller: WebVRController;
  42669. }>;
  42670. /**
  42671. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42672. */
  42673. onNewMeshPicked: Observable<PickingInfo>;
  42674. private _circleEase;
  42675. /**
  42676. * Observable raised before camera teleportation
  42677. */
  42678. onBeforeCameraTeleport: Observable<Vector3>;
  42679. /**
  42680. * Observable raised after camera teleportation
  42681. */
  42682. onAfterCameraTeleport: Observable<Vector3>;
  42683. /**
  42684. * Observable raised when current selected mesh gets unselected
  42685. */
  42686. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42687. private _raySelectionPredicate;
  42688. /**
  42689. * To be optionaly changed by user to define custom ray selection
  42690. */
  42691. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42692. /**
  42693. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42694. */
  42695. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42696. /**
  42697. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42698. */
  42699. teleportationEnabled: boolean;
  42700. private _defaultHeight;
  42701. private _teleportationInitialized;
  42702. private _interactionsEnabled;
  42703. private _interactionsRequested;
  42704. private _displayGaze;
  42705. private _displayLaserPointer;
  42706. /**
  42707. * The mesh used to display where the user is going to teleport.
  42708. */
  42709. /**
  42710. * Sets the mesh to be used to display where the user is going to teleport.
  42711. */
  42712. teleportationTarget: Mesh;
  42713. /**
  42714. * 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
  42715. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42716. * See http://doc.babylonjs.com/resources/baking_transformations
  42717. */
  42718. gazeTrackerMesh: Mesh;
  42719. /**
  42720. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42721. */
  42722. updateGazeTrackerScale: boolean;
  42723. /**
  42724. * If the gaze trackers color should be updated when selecting meshes
  42725. */
  42726. updateGazeTrackerColor: boolean;
  42727. /**
  42728. * If the controller laser color should be updated when selecting meshes
  42729. */
  42730. updateControllerLaserColor: boolean;
  42731. /**
  42732. * The gaze tracking mesh corresponding to the left controller
  42733. */
  42734. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42735. /**
  42736. * The gaze tracking mesh corresponding to the right controller
  42737. */
  42738. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42739. /**
  42740. * If the ray of the gaze should be displayed.
  42741. */
  42742. /**
  42743. * Sets if the ray of the gaze should be displayed.
  42744. */
  42745. displayGaze: boolean;
  42746. /**
  42747. * If the ray of the LaserPointer should be displayed.
  42748. */
  42749. /**
  42750. * Sets if the ray of the LaserPointer should be displayed.
  42751. */
  42752. displayLaserPointer: boolean;
  42753. /**
  42754. * The deviceOrientationCamera used as the camera when not in VR.
  42755. */
  42756. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42757. /**
  42758. * Based on the current WebVR support, returns the current VR camera used.
  42759. */
  42760. readonly currentVRCamera: Nullable<Camera>;
  42761. /**
  42762. * The webVRCamera which is used when in VR.
  42763. */
  42764. readonly webVRCamera: WebVRFreeCamera;
  42765. /**
  42766. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42767. */
  42768. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42769. /**
  42770. * The html button that is used to trigger entering into VR.
  42771. */
  42772. readonly vrButton: Nullable<HTMLButtonElement>;
  42773. private readonly _teleportationRequestInitiated;
  42774. /**
  42775. * Defines wether or not Pointer lock should be requested when switching to
  42776. * full screen.
  42777. */
  42778. requestPointerLockOnFullScreen: boolean;
  42779. /**
  42780. * Instantiates a VRExperienceHelper.
  42781. * Helps to quickly add VR support to an existing scene.
  42782. * @param scene The scene the VRExperienceHelper belongs to.
  42783. * @param webVROptions Options to modify the vr experience helper's behavior.
  42784. */
  42785. constructor(scene: Scene,
  42786. /** Options to modify the vr experience helper's behavior. */
  42787. webVROptions?: VRExperienceHelperOptions);
  42788. private _onDefaultMeshLoaded;
  42789. private _onResize;
  42790. private _onFullscreenChange;
  42791. /**
  42792. * Gets a value indicating if we are currently in VR mode.
  42793. */
  42794. readonly isInVRMode: boolean;
  42795. private onVrDisplayPresentChange;
  42796. private onVRDisplayChanged;
  42797. private moveButtonToBottomRight;
  42798. private displayVRButton;
  42799. private updateButtonVisibility;
  42800. private _cachedAngularSensibility;
  42801. /**
  42802. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42803. * Otherwise, will use the fullscreen API.
  42804. */
  42805. enterVR(): void;
  42806. /**
  42807. * Attempt to exit VR, or fullscreen.
  42808. */
  42809. exitVR(): void;
  42810. /**
  42811. * The position of the vr experience helper.
  42812. */
  42813. /**
  42814. * Sets the position of the vr experience helper.
  42815. */
  42816. position: Vector3;
  42817. /**
  42818. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42819. */
  42820. enableInteractions(): void;
  42821. private readonly _noControllerIsActive;
  42822. private beforeRender;
  42823. private _isTeleportationFloor;
  42824. /**
  42825. * Adds a floor mesh to be used for teleportation.
  42826. * @param floorMesh the mesh to be used for teleportation.
  42827. */
  42828. addFloorMesh(floorMesh: Mesh): void;
  42829. /**
  42830. * Removes a floor mesh from being used for teleportation.
  42831. * @param floorMesh the mesh to be removed.
  42832. */
  42833. removeFloorMesh(floorMesh: Mesh): void;
  42834. /**
  42835. * Enables interactions and teleportation using the VR controllers and gaze.
  42836. * @param vrTeleportationOptions options to modify teleportation behavior.
  42837. */
  42838. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42839. private _onNewGamepadConnected;
  42840. private _tryEnableInteractionOnController;
  42841. private _onNewGamepadDisconnected;
  42842. private _enableInteractionOnController;
  42843. private _checkTeleportWithRay;
  42844. private _checkRotate;
  42845. private _checkTeleportBackwards;
  42846. private _enableTeleportationOnController;
  42847. private _createTeleportationCircles;
  42848. private _displayTeleportationTarget;
  42849. private _hideTeleportationTarget;
  42850. private _rotateCamera;
  42851. private _moveTeleportationSelectorTo;
  42852. private _workingVector;
  42853. private _workingQuaternion;
  42854. private _workingMatrix;
  42855. /**
  42856. * Teleports the users feet to the desired location
  42857. * @param location The location where the user's feet should be placed
  42858. */
  42859. teleportCamera(location: Vector3): void;
  42860. private _convertNormalToDirectionOfRay;
  42861. private _castRayAndSelectObject;
  42862. private _notifySelectedMeshUnselected;
  42863. /**
  42864. * Sets the color of the laser ray from the vr controllers.
  42865. * @param color new color for the ray.
  42866. */
  42867. changeLaserColor(color: Color3): void;
  42868. /**
  42869. * Sets the color of the ray from the vr headsets gaze.
  42870. * @param color new color for the ray.
  42871. */
  42872. changeGazeColor(color: Color3): void;
  42873. /**
  42874. * Exits VR and disposes of the vr experience helper
  42875. */
  42876. dispose(): void;
  42877. /**
  42878. * Gets the name of the VRExperienceHelper class
  42879. * @returns "VRExperienceHelper"
  42880. */
  42881. getClassName(): string;
  42882. }
  42883. }
  42884. declare module "babylonjs/Cameras/VR/index" {
  42885. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42886. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42887. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42888. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42889. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42890. export * from "babylonjs/Cameras/VR/webVRCamera";
  42891. }
  42892. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42893. import { Observable } from "babylonjs/Misc/observable";
  42894. import { Nullable } from "babylonjs/types";
  42895. import { IDisposable, Scene } from "babylonjs/scene";
  42896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42897. /**
  42898. * Manages an XRSession to work with Babylon's engine
  42899. * @see https://doc.babylonjs.com/how_to/webxr
  42900. */
  42901. export class WebXRSessionManager implements IDisposable {
  42902. private scene;
  42903. /**
  42904. * Fires every time a new xrFrame arrives which can be used to update the camera
  42905. */
  42906. onXRFrameObservable: Observable<any>;
  42907. /**
  42908. * Fires when the xr session is ended either by the device or manually done
  42909. */
  42910. onXRSessionEnded: Observable<any>;
  42911. /**
  42912. * Underlying xr session
  42913. */
  42914. session: XRSession;
  42915. /**
  42916. * Type of reference space used when creating the session
  42917. */
  42918. referenceSpace: XRReferenceSpace;
  42919. /** @hidden */
  42920. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42921. /**
  42922. * Current XR frame
  42923. */
  42924. currentFrame: Nullable<XRFrame>;
  42925. private _xrNavigator;
  42926. private baseLayer;
  42927. /**
  42928. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42929. * @param scene The scene which the session should be created for
  42930. */
  42931. constructor(scene: Scene);
  42932. /**
  42933. * Initializes the manager
  42934. * After initialization enterXR can be called to start an XR session
  42935. * @returns Promise which resolves after it is initialized
  42936. */
  42937. initializeAsync(): Promise<void>;
  42938. /**
  42939. * Initializes an xr session
  42940. * @param xrSessionMode mode to initialize
  42941. * @returns a promise which will resolve once the session has been initialized
  42942. */
  42943. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42944. /**
  42945. * Sets the reference space on the xr session
  42946. * @param referenceSpace space to set
  42947. * @returns a promise that will resolve once the reference space has been set
  42948. */
  42949. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42950. /**
  42951. * Updates the render state of the session
  42952. * @param state state to set
  42953. * @returns a promise that resolves once the render state has been updated
  42954. */
  42955. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42956. /**
  42957. * Starts rendering to the xr layer
  42958. * @returns a promise that will resolve once rendering has started
  42959. */
  42960. startRenderingToXRAsync(): Promise<void>;
  42961. /**
  42962. * Stops the xrSession and restores the renderloop
  42963. * @returns Promise which resolves after it exits XR
  42964. */
  42965. exitXRAsync(): Promise<unknown>;
  42966. /**
  42967. * Checks if a session would be supported for the creation options specified
  42968. * @param sessionMode session mode to check if supported eg. immersive-vr
  42969. * @returns true if supported
  42970. */
  42971. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42972. /**
  42973. * @hidden
  42974. * Converts the render layer of xrSession to a render target
  42975. * @param session session to create render target for
  42976. * @param scene scene the new render target should be created for
  42977. */
  42978. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42979. /**
  42980. * Disposes of the session manager
  42981. */
  42982. dispose(): void;
  42983. }
  42984. }
  42985. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42986. import { Scene } from "babylonjs/scene";
  42987. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42988. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42989. /**
  42990. * WebXR Camera which holds the views for the xrSession
  42991. * @see https://doc.babylonjs.com/how_to/webxr
  42992. */
  42993. export class WebXRCamera extends FreeCamera {
  42994. private static _TmpMatrix;
  42995. /**
  42996. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42997. * @param name the name of the camera
  42998. * @param scene the scene to add the camera to
  42999. */
  43000. constructor(name: string, scene: Scene);
  43001. private _updateNumberOfRigCameras;
  43002. /** @hidden */
  43003. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43004. /**
  43005. * Updates the cameras position from the current pose information of the XR session
  43006. * @param xrSessionManager the session containing pose information
  43007. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43008. */
  43009. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43010. }
  43011. }
  43012. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43013. import { Nullable } from "babylonjs/types";
  43014. import { IDisposable } from "babylonjs/scene";
  43015. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43016. /**
  43017. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43018. */
  43019. export class WebXRManagedOutputCanvas implements IDisposable {
  43020. private helper;
  43021. private _canvas;
  43022. /**
  43023. * xrpresent context of the canvas which can be used to display/mirror xr content
  43024. */
  43025. canvasContext: WebGLRenderingContext;
  43026. /**
  43027. * xr layer for the canvas
  43028. */
  43029. xrLayer: Nullable<XRWebGLLayer>;
  43030. /**
  43031. * Initializes the xr layer for the session
  43032. * @param xrSession xr session
  43033. * @returns a promise that will resolve once the XR Layer has been created
  43034. */
  43035. initializeXRLayerAsync(xrSession: any): any;
  43036. /**
  43037. * Initializes the canvas to be added/removed upon entering/exiting xr
  43038. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43039. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43040. */
  43041. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43042. /**
  43043. * Disposes of the object
  43044. */
  43045. dispose(): void;
  43046. private _setManagedOutputCanvas;
  43047. private _addCanvas;
  43048. private _removeCanvas;
  43049. }
  43050. }
  43051. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43052. import { Observable } from "babylonjs/Misc/observable";
  43053. import { IDisposable, Scene } from "babylonjs/scene";
  43054. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43056. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43057. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43058. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43059. /**
  43060. * States of the webXR experience
  43061. */
  43062. export enum WebXRState {
  43063. /**
  43064. * Transitioning to being in XR mode
  43065. */
  43066. ENTERING_XR = 0,
  43067. /**
  43068. * Transitioning to non XR mode
  43069. */
  43070. EXITING_XR = 1,
  43071. /**
  43072. * In XR mode and presenting
  43073. */
  43074. IN_XR = 2,
  43075. /**
  43076. * Not entered XR mode
  43077. */
  43078. NOT_IN_XR = 3
  43079. }
  43080. /**
  43081. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43082. * @see https://doc.babylonjs.com/how_to/webxr
  43083. */
  43084. export class WebXRExperienceHelper implements IDisposable {
  43085. private scene;
  43086. /**
  43087. * 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
  43088. */
  43089. container: AbstractMesh;
  43090. /**
  43091. * Camera used to render xr content
  43092. */
  43093. camera: WebXRCamera;
  43094. /**
  43095. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43096. */
  43097. state: WebXRState;
  43098. private _setState;
  43099. private static _TmpVector;
  43100. /**
  43101. * Fires when the state of the experience helper has changed
  43102. */
  43103. onStateChangedObservable: Observable<WebXRState>;
  43104. /** Session manager used to keep track of xr session */
  43105. sessionManager: WebXRSessionManager;
  43106. private _nonVRCamera;
  43107. private _originalSceneAutoClear;
  43108. private _supported;
  43109. /**
  43110. * Creates the experience helper
  43111. * @param scene the scene to attach the experience helper to
  43112. * @returns a promise for the experience helper
  43113. */
  43114. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43115. /**
  43116. * Creates a WebXRExperienceHelper
  43117. * @param scene The scene the helper should be created in
  43118. */
  43119. private constructor();
  43120. /**
  43121. * Exits XR mode and returns the scene to its original state
  43122. * @returns promise that resolves after xr mode has exited
  43123. */
  43124. exitXRAsync(): Promise<unknown>;
  43125. /**
  43126. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43127. * @param sessionCreationOptions options for the XR session
  43128. * @param referenceSpaceType frame of reference of the XR session
  43129. * @param outputCanvas the output canvas that will be used to enter XR mode
  43130. * @returns promise that resolves after xr mode has entered
  43131. */
  43132. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43133. /**
  43134. * Updates the global position of the camera by moving the camera's container
  43135. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43136. * @param position The desired global position of the camera
  43137. */
  43138. setPositionOfCameraUsingContainer(position: Vector3): void;
  43139. /**
  43140. * Rotates the xr camera by rotating the camera's container around the camera's position
  43141. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43142. * @param rotation the desired quaternion rotation to apply to the camera
  43143. */
  43144. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43145. /**
  43146. * Disposes of the experience helper
  43147. */
  43148. dispose(): void;
  43149. }
  43150. }
  43151. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43152. import { Nullable } from "babylonjs/types";
  43153. import { Observable } from "babylonjs/Misc/observable";
  43154. import { IDisposable, Scene } from "babylonjs/scene";
  43155. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43156. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43157. /**
  43158. * Button which can be used to enter a different mode of XR
  43159. */
  43160. export class WebXREnterExitUIButton {
  43161. /** button element */
  43162. element: HTMLElement;
  43163. /** XR initialization options for the button */
  43164. sessionMode: XRSessionMode;
  43165. /** Reference space type */
  43166. referenceSpaceType: XRReferenceSpaceType;
  43167. /**
  43168. * Creates a WebXREnterExitUIButton
  43169. * @param element button element
  43170. * @param sessionMode XR initialization session mode
  43171. * @param referenceSpaceType the type of reference space to be used
  43172. */
  43173. constructor(
  43174. /** button element */
  43175. element: HTMLElement,
  43176. /** XR initialization options for the button */
  43177. sessionMode: XRSessionMode,
  43178. /** Reference space type */
  43179. referenceSpaceType: XRReferenceSpaceType);
  43180. /**
  43181. * Overwritable function which can be used to update the button's visuals when the state changes
  43182. * @param activeButton the current active button in the UI
  43183. */
  43184. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43185. }
  43186. /**
  43187. * Options to create the webXR UI
  43188. */
  43189. export class WebXREnterExitUIOptions {
  43190. /**
  43191. * Context to enter xr with
  43192. */
  43193. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43194. /**
  43195. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43196. */
  43197. customButtons?: Array<WebXREnterExitUIButton>;
  43198. }
  43199. /**
  43200. * UI to allow the user to enter/exit XR mode
  43201. */
  43202. export class WebXREnterExitUI implements IDisposable {
  43203. private scene;
  43204. private _overlay;
  43205. private _buttons;
  43206. private _activeButton;
  43207. /**
  43208. * Fired every time the active button is changed.
  43209. *
  43210. * When xr is entered via a button that launches xr that button will be the callback parameter
  43211. *
  43212. * When exiting xr the callback parameter will be null)
  43213. */
  43214. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43215. /**
  43216. * Creates UI to allow the user to enter/exit XR mode
  43217. * @param scene the scene to add the ui to
  43218. * @param helper the xr experience helper to enter/exit xr with
  43219. * @param options options to configure the UI
  43220. * @returns the created ui
  43221. */
  43222. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43223. private constructor();
  43224. private _updateButtons;
  43225. /**
  43226. * Disposes of the object
  43227. */
  43228. dispose(): void;
  43229. }
  43230. }
  43231. declare module "babylonjs/Cameras/XR/webXRController" {
  43232. import { Nullable } from "babylonjs/types";
  43233. import { Observable } from "babylonjs/Misc/observable";
  43234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43235. import { Ray } from "babylonjs/Culling/ray";
  43236. import { Scene } from "babylonjs/scene";
  43237. /**
  43238. * Represents an XR input
  43239. */
  43240. export class WebXRController {
  43241. private scene;
  43242. /** The underlying input source for the controller */
  43243. inputSource: XRInputSource;
  43244. private parentContainer;
  43245. /**
  43246. * 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
  43247. */
  43248. grip?: AbstractMesh;
  43249. /**
  43250. * Pointer which can be used to select objects or attach a visible laser to
  43251. */
  43252. pointer: AbstractMesh;
  43253. /**
  43254. * Event that fires when the controller is removed/disposed
  43255. */
  43256. onDisposeObservable: Observable<{}>;
  43257. private _tmpMatrix;
  43258. private _tmpQuaternion;
  43259. private _tmpVector;
  43260. /**
  43261. * Creates the controller
  43262. * @see https://doc.babylonjs.com/how_to/webxr
  43263. * @param scene the scene which the controller should be associated to
  43264. * @param inputSource the underlying input source for the controller
  43265. * @param parentContainer parent that the controller meshes should be children of
  43266. */
  43267. constructor(scene: Scene,
  43268. /** The underlying input source for the controller */
  43269. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43270. /**
  43271. * Updates the controller pose based on the given XRFrame
  43272. * @param xrFrame xr frame to update the pose with
  43273. * @param referenceSpace reference space to use
  43274. */
  43275. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43276. /**
  43277. * Gets a world space ray coming from the controller
  43278. * @param result the resulting ray
  43279. */
  43280. getWorldPointerRayToRef(result: Ray): void;
  43281. /**
  43282. * Disposes of the object
  43283. */
  43284. dispose(): void;
  43285. }
  43286. }
  43287. declare module "babylonjs/Cameras/XR/webXRInput" {
  43288. import { Observable } from "babylonjs/Misc/observable";
  43289. import { IDisposable } from "babylonjs/scene";
  43290. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43291. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43292. /**
  43293. * XR input used to track XR inputs such as controllers/rays
  43294. */
  43295. export class WebXRInput implements IDisposable {
  43296. /**
  43297. * Base experience the input listens to
  43298. */
  43299. baseExperience: WebXRExperienceHelper;
  43300. /**
  43301. * XR controllers being tracked
  43302. */
  43303. controllers: Array<WebXRController>;
  43304. private _frameObserver;
  43305. private _stateObserver;
  43306. /**
  43307. * Event when a controller has been connected/added
  43308. */
  43309. onControllerAddedObservable: Observable<WebXRController>;
  43310. /**
  43311. * Event when a controller has been removed/disconnected
  43312. */
  43313. onControllerRemovedObservable: Observable<WebXRController>;
  43314. /**
  43315. * Initializes the WebXRInput
  43316. * @param baseExperience experience helper which the input should be created for
  43317. */
  43318. constructor(
  43319. /**
  43320. * Base experience the input listens to
  43321. */
  43322. baseExperience: WebXRExperienceHelper);
  43323. private _onInputSourcesChange;
  43324. private _addAndRemoveControllers;
  43325. /**
  43326. * Disposes of the object
  43327. */
  43328. dispose(): void;
  43329. }
  43330. }
  43331. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43333. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43334. /**
  43335. * Enables teleportation
  43336. */
  43337. export class WebXRControllerTeleportation {
  43338. private _teleportationFillColor;
  43339. private _teleportationBorderColor;
  43340. private _tmpRay;
  43341. private _tmpVector;
  43342. /**
  43343. * Creates a WebXRControllerTeleportation
  43344. * @param input input manager to add teleportation to
  43345. * @param floorMeshes floormeshes which can be teleported to
  43346. */
  43347. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43348. }
  43349. }
  43350. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43351. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43352. /**
  43353. * Handles pointer input automatically for the pointer of XR controllers
  43354. */
  43355. export class WebXRControllerPointerSelection {
  43356. private static _idCounter;
  43357. private _tmpRay;
  43358. /**
  43359. * Creates a WebXRControllerPointerSelection
  43360. * @param input input manager to setup pointer selection
  43361. */
  43362. constructor(input: WebXRInput);
  43363. private _convertNormalToDirectionOfRay;
  43364. private _updatePointerDistance;
  43365. }
  43366. }
  43367. declare module "babylonjs/Loading/sceneLoader" {
  43368. import { Observable } from "babylonjs/Misc/observable";
  43369. import { Nullable } from "babylonjs/types";
  43370. import { Scene } from "babylonjs/scene";
  43371. import { Engine } from "babylonjs/Engines/engine";
  43372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43373. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43374. import { AssetContainer } from "babylonjs/assetContainer";
  43375. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43376. import { Skeleton } from "babylonjs/Bones/skeleton";
  43377. /**
  43378. * Class used to represent data loading progression
  43379. */
  43380. export class SceneLoaderProgressEvent {
  43381. /** defines if data length to load can be evaluated */
  43382. readonly lengthComputable: boolean;
  43383. /** defines the loaded data length */
  43384. readonly loaded: number;
  43385. /** defines the data length to load */
  43386. readonly total: number;
  43387. /**
  43388. * Create a new progress event
  43389. * @param lengthComputable defines if data length to load can be evaluated
  43390. * @param loaded defines the loaded data length
  43391. * @param total defines the data length to load
  43392. */
  43393. constructor(
  43394. /** defines if data length to load can be evaluated */
  43395. lengthComputable: boolean,
  43396. /** defines the loaded data length */
  43397. loaded: number,
  43398. /** defines the data length to load */
  43399. total: number);
  43400. /**
  43401. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43402. * @param event defines the source event
  43403. * @returns a new SceneLoaderProgressEvent
  43404. */
  43405. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43406. }
  43407. /**
  43408. * Interface used by SceneLoader plugins to define supported file extensions
  43409. */
  43410. export interface ISceneLoaderPluginExtensions {
  43411. /**
  43412. * Defines the list of supported extensions
  43413. */
  43414. [extension: string]: {
  43415. isBinary: boolean;
  43416. };
  43417. }
  43418. /**
  43419. * Interface used by SceneLoader plugin factory
  43420. */
  43421. export interface ISceneLoaderPluginFactory {
  43422. /**
  43423. * Defines the name of the factory
  43424. */
  43425. name: string;
  43426. /**
  43427. * Function called to create a new plugin
  43428. * @return the new plugin
  43429. */
  43430. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43431. /**
  43432. * Boolean indicating if the plugin can direct load specific data
  43433. */
  43434. canDirectLoad?: (data: string) => boolean;
  43435. }
  43436. /**
  43437. * Interface used to define a SceneLoader plugin
  43438. */
  43439. export interface ISceneLoaderPlugin {
  43440. /**
  43441. * The friendly name of this plugin.
  43442. */
  43443. name: string;
  43444. /**
  43445. * The file extensions supported by this plugin.
  43446. */
  43447. extensions: string | ISceneLoaderPluginExtensions;
  43448. /**
  43449. * Import meshes into a scene.
  43450. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43451. * @param scene The scene to import into
  43452. * @param data The data to import
  43453. * @param rootUrl The root url for scene and resources
  43454. * @param meshes The meshes array to import into
  43455. * @param particleSystems The particle systems array to import into
  43456. * @param skeletons The skeletons array to import into
  43457. * @param onError The callback when import fails
  43458. * @returns True if successful or false otherwise
  43459. */
  43460. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43461. /**
  43462. * Load into a scene.
  43463. * @param scene The scene to load into
  43464. * @param data The data to import
  43465. * @param rootUrl The root url for scene and resources
  43466. * @param onError The callback when import fails
  43467. * @returns true if successful or false otherwise
  43468. */
  43469. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43470. /**
  43471. * The callback that returns true if the data can be directly loaded.
  43472. */
  43473. canDirectLoad?: (data: string) => boolean;
  43474. /**
  43475. * The callback that allows custom handling of the root url based on the response url.
  43476. */
  43477. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43478. /**
  43479. * Load into an asset container.
  43480. * @param scene The scene to load into
  43481. * @param data The data to import
  43482. * @param rootUrl The root url for scene and resources
  43483. * @param onError The callback when import fails
  43484. * @returns The loaded asset container
  43485. */
  43486. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43487. }
  43488. /**
  43489. * Interface used to define an async SceneLoader plugin
  43490. */
  43491. export interface ISceneLoaderPluginAsync {
  43492. /**
  43493. * The friendly name of this plugin.
  43494. */
  43495. name: string;
  43496. /**
  43497. * The file extensions supported by this plugin.
  43498. */
  43499. extensions: string | ISceneLoaderPluginExtensions;
  43500. /**
  43501. * Import meshes into a scene.
  43502. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43503. * @param scene The scene to import into
  43504. * @param data The data to import
  43505. * @param rootUrl The root url for scene and resources
  43506. * @param onProgress The callback when the load progresses
  43507. * @param fileName Defines the name of the file to load
  43508. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43509. */
  43510. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43511. meshes: AbstractMesh[];
  43512. particleSystems: IParticleSystem[];
  43513. skeletons: Skeleton[];
  43514. animationGroups: AnimationGroup[];
  43515. }>;
  43516. /**
  43517. * Load into a scene.
  43518. * @param scene The scene to load into
  43519. * @param data The data to import
  43520. * @param rootUrl The root url for scene and resources
  43521. * @param onProgress The callback when the load progresses
  43522. * @param fileName Defines the name of the file to load
  43523. * @returns Nothing
  43524. */
  43525. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43526. /**
  43527. * The callback that returns true if the data can be directly loaded.
  43528. */
  43529. canDirectLoad?: (data: string) => boolean;
  43530. /**
  43531. * The callback that allows custom handling of the root url based on the response url.
  43532. */
  43533. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43534. /**
  43535. * Load into an asset container.
  43536. * @param scene The scene to load into
  43537. * @param data The data to import
  43538. * @param rootUrl The root url for scene and resources
  43539. * @param onProgress The callback when the load progresses
  43540. * @param fileName Defines the name of the file to load
  43541. * @returns The loaded asset container
  43542. */
  43543. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43544. }
  43545. /**
  43546. * Class used to load scene from various file formats using registered plugins
  43547. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43548. */
  43549. export class SceneLoader {
  43550. /**
  43551. * No logging while loading
  43552. */
  43553. static readonly NO_LOGGING: number;
  43554. /**
  43555. * Minimal logging while loading
  43556. */
  43557. static readonly MINIMAL_LOGGING: number;
  43558. /**
  43559. * Summary logging while loading
  43560. */
  43561. static readonly SUMMARY_LOGGING: number;
  43562. /**
  43563. * Detailled logging while loading
  43564. */
  43565. static readonly DETAILED_LOGGING: number;
  43566. /**
  43567. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43568. */
  43569. static ForceFullSceneLoadingForIncremental: boolean;
  43570. /**
  43571. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43572. */
  43573. static ShowLoadingScreen: boolean;
  43574. /**
  43575. * Defines the current logging level (while loading the scene)
  43576. * @ignorenaming
  43577. */
  43578. static loggingLevel: number;
  43579. /**
  43580. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43581. */
  43582. static CleanBoneMatrixWeights: boolean;
  43583. /**
  43584. * Event raised when a plugin is used to load a scene
  43585. */
  43586. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43587. private static _registeredPlugins;
  43588. private static _getDefaultPlugin;
  43589. private static _getPluginForExtension;
  43590. private static _getPluginForDirectLoad;
  43591. private static _getPluginForFilename;
  43592. private static _getDirectLoad;
  43593. private static _loadData;
  43594. private static _getFileInfo;
  43595. /**
  43596. * Gets a plugin that can load the given extension
  43597. * @param extension defines the extension to load
  43598. * @returns a plugin or null if none works
  43599. */
  43600. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43601. /**
  43602. * Gets a boolean indicating that the given extension can be loaded
  43603. * @param extension defines the extension to load
  43604. * @returns true if the extension is supported
  43605. */
  43606. static IsPluginForExtensionAvailable(extension: string): boolean;
  43607. /**
  43608. * Adds a new plugin to the list of registered plugins
  43609. * @param plugin defines the plugin to add
  43610. */
  43611. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43612. /**
  43613. * Import meshes into a scene
  43614. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43615. * @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)
  43616. * @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)
  43617. * @param scene the instance of BABYLON.Scene to append to
  43618. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43619. * @param onProgress a callback with a progress event for each file being loaded
  43620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43621. * @param pluginExtension the extension used to determine the plugin
  43622. * @returns The loaded plugin
  43623. */
  43624. 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>;
  43625. /**
  43626. * Import meshes into a scene
  43627. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43628. * @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)
  43629. * @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)
  43630. * @param scene the instance of BABYLON.Scene to append to
  43631. * @param onProgress a callback with a progress event for each file being loaded
  43632. * @param pluginExtension the extension used to determine the plugin
  43633. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43634. */
  43635. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43636. meshes: AbstractMesh[];
  43637. particleSystems: IParticleSystem[];
  43638. skeletons: Skeleton[];
  43639. animationGroups: AnimationGroup[];
  43640. }>;
  43641. /**
  43642. * Load a scene
  43643. * @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)
  43644. * @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)
  43645. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43646. * @param onSuccess a callback with the scene when import succeeds
  43647. * @param onProgress a callback with a progress event for each file being loaded
  43648. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43649. * @param pluginExtension the extension used to determine the plugin
  43650. * @returns The loaded plugin
  43651. */
  43652. 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>;
  43653. /**
  43654. * Load a scene
  43655. * @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)
  43656. * @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)
  43657. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43658. * @param onProgress a callback with a progress event for each file being loaded
  43659. * @param pluginExtension the extension used to determine the plugin
  43660. * @returns The loaded scene
  43661. */
  43662. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43663. /**
  43664. * Append a scene
  43665. * @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)
  43666. * @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)
  43667. * @param scene is the instance of BABYLON.Scene to append to
  43668. * @param onSuccess a callback with the scene when import succeeds
  43669. * @param onProgress a callback with a progress event for each file being loaded
  43670. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43671. * @param pluginExtension the extension used to determine the plugin
  43672. * @returns The loaded plugin
  43673. */
  43674. 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>;
  43675. /**
  43676. * Append a scene
  43677. * @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)
  43678. * @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)
  43679. * @param scene is the instance of BABYLON.Scene to append to
  43680. * @param onProgress a callback with a progress event for each file being loaded
  43681. * @param pluginExtension the extension used to determine the plugin
  43682. * @returns The given scene
  43683. */
  43684. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43685. /**
  43686. * Load a scene into an asset container
  43687. * @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)
  43688. * @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)
  43689. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43690. * @param onSuccess a callback with the scene when import succeeds
  43691. * @param onProgress a callback with a progress event for each file being loaded
  43692. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43693. * @param pluginExtension the extension used to determine the plugin
  43694. * @returns The loaded plugin
  43695. */
  43696. 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>;
  43697. /**
  43698. * Load a scene into an asset container
  43699. * @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)
  43700. * @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)
  43701. * @param scene is the instance of Scene to append to
  43702. * @param onProgress a callback with a progress event for each file being loaded
  43703. * @param pluginExtension the extension used to determine the plugin
  43704. * @returns The loaded asset container
  43705. */
  43706. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43707. }
  43708. }
  43709. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43710. import { Scene } from "babylonjs/scene";
  43711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43712. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43713. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43714. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43715. /**
  43716. * Generic Controller
  43717. */
  43718. export class GenericController extends WebVRController {
  43719. /**
  43720. * Base Url for the controller model.
  43721. */
  43722. static readonly MODEL_BASE_URL: string;
  43723. /**
  43724. * File name for the controller model.
  43725. */
  43726. static readonly MODEL_FILENAME: string;
  43727. /**
  43728. * Creates a new GenericController from a gamepad
  43729. * @param vrGamepad the gamepad that the controller should be created from
  43730. */
  43731. constructor(vrGamepad: any);
  43732. /**
  43733. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43734. * @param scene scene in which to add meshes
  43735. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43736. */
  43737. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43738. /**
  43739. * Called once for each button that changed state since the last frame
  43740. * @param buttonIdx Which button index changed
  43741. * @param state New state of the button
  43742. * @param changes Which properties on the state changed since last frame
  43743. */
  43744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43745. }
  43746. }
  43747. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43748. import { Observable } from "babylonjs/Misc/observable";
  43749. import { Scene } from "babylonjs/scene";
  43750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43751. import { Ray } from "babylonjs/Culling/ray";
  43752. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43753. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43754. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43755. /**
  43756. * Defines the WindowsMotionController object that the state of the windows motion controller
  43757. */
  43758. export class WindowsMotionController extends WebVRController {
  43759. /**
  43760. * The base url used to load the left and right controller models
  43761. */
  43762. static MODEL_BASE_URL: string;
  43763. /**
  43764. * The name of the left controller model file
  43765. */
  43766. static MODEL_LEFT_FILENAME: string;
  43767. /**
  43768. * The name of the right controller model file
  43769. */
  43770. static MODEL_RIGHT_FILENAME: string;
  43771. /**
  43772. * The controller name prefix for this controller type
  43773. */
  43774. static readonly GAMEPAD_ID_PREFIX: string;
  43775. /**
  43776. * The controller id pattern for this controller type
  43777. */
  43778. private static readonly GAMEPAD_ID_PATTERN;
  43779. private _loadedMeshInfo;
  43780. private readonly _mapping;
  43781. /**
  43782. * Fired when the trackpad on this controller is clicked
  43783. */
  43784. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43785. /**
  43786. * Fired when the trackpad on this controller is modified
  43787. */
  43788. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43789. /**
  43790. * The current x and y values of this controller's trackpad
  43791. */
  43792. trackpad: StickValues;
  43793. /**
  43794. * Creates a new WindowsMotionController from a gamepad
  43795. * @param vrGamepad the gamepad that the controller should be created from
  43796. */
  43797. constructor(vrGamepad: any);
  43798. /**
  43799. * Fired when the trigger on this controller is modified
  43800. */
  43801. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43802. /**
  43803. * Fired when the menu button on this controller is modified
  43804. */
  43805. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43806. /**
  43807. * Fired when the grip button on this controller is modified
  43808. */
  43809. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43810. /**
  43811. * Fired when the thumbstick button on this controller is modified
  43812. */
  43813. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43814. /**
  43815. * Fired when the touchpad button on this controller is modified
  43816. */
  43817. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43818. /**
  43819. * Fired when the touchpad values on this controller are modified
  43820. */
  43821. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43822. private _updateTrackpad;
  43823. /**
  43824. * Called once per frame by the engine.
  43825. */
  43826. update(): void;
  43827. /**
  43828. * Called once for each button that changed state since the last frame
  43829. * @param buttonIdx Which button index changed
  43830. * @param state New state of the button
  43831. * @param changes Which properties on the state changed since last frame
  43832. */
  43833. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43834. /**
  43835. * Moves the buttons on the controller mesh based on their current state
  43836. * @param buttonName the name of the button to move
  43837. * @param buttonValue the value of the button which determines the buttons new position
  43838. */
  43839. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43840. /**
  43841. * Moves the axis on the controller mesh based on its current state
  43842. * @param axis the index of the axis
  43843. * @param axisValue the value of the axis which determines the meshes new position
  43844. * @hidden
  43845. */
  43846. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43847. /**
  43848. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43849. * @param scene scene in which to add meshes
  43850. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43851. */
  43852. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43853. /**
  43854. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43855. * can be transformed by button presses and axes values, based on this._mapping.
  43856. *
  43857. * @param scene scene in which the meshes exist
  43858. * @param meshes list of meshes that make up the controller model to process
  43859. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43860. */
  43861. private processModel;
  43862. private createMeshInfo;
  43863. /**
  43864. * Gets the ray of the controller in the direction the controller is pointing
  43865. * @param length the length the resulting ray should be
  43866. * @returns a ray in the direction the controller is pointing
  43867. */
  43868. getForwardRay(length?: number): Ray;
  43869. /**
  43870. * Disposes of the controller
  43871. */
  43872. dispose(): void;
  43873. }
  43874. }
  43875. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43876. import { Observable } from "babylonjs/Misc/observable";
  43877. import { Scene } from "babylonjs/scene";
  43878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43879. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43880. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43881. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43882. /**
  43883. * Oculus Touch Controller
  43884. */
  43885. export class OculusTouchController extends WebVRController {
  43886. /**
  43887. * Base Url for the controller model.
  43888. */
  43889. static MODEL_BASE_URL: string;
  43890. /**
  43891. * File name for the left controller model.
  43892. */
  43893. static MODEL_LEFT_FILENAME: string;
  43894. /**
  43895. * File name for the right controller model.
  43896. */
  43897. static MODEL_RIGHT_FILENAME: string;
  43898. /**
  43899. * Base Url for the Quest controller model.
  43900. */
  43901. static QUEST_MODEL_BASE_URL: string;
  43902. /**
  43903. * @hidden
  43904. * If the controllers are running on a device that needs the updated Quest controller models
  43905. */
  43906. static _IsQuest: boolean;
  43907. /**
  43908. * Fired when the secondary trigger on this controller is modified
  43909. */
  43910. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43911. /**
  43912. * Fired when the thumb rest on this controller is modified
  43913. */
  43914. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43915. /**
  43916. * Creates a new OculusTouchController from a gamepad
  43917. * @param vrGamepad the gamepad that the controller should be created from
  43918. */
  43919. constructor(vrGamepad: any);
  43920. /**
  43921. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43922. * @param scene scene in which to add meshes
  43923. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43924. */
  43925. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43926. /**
  43927. * Fired when the A button on this controller is modified
  43928. */
  43929. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43930. /**
  43931. * Fired when the B button on this controller is modified
  43932. */
  43933. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43934. /**
  43935. * Fired when the X button on this controller is modified
  43936. */
  43937. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43938. /**
  43939. * Fired when the Y button on this controller is modified
  43940. */
  43941. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43942. /**
  43943. * Called once for each button that changed state since the last frame
  43944. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43945. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43946. * 2) secondary trigger (same)
  43947. * 3) A (right) X (left), touch, pressed = value
  43948. * 4) B / Y
  43949. * 5) thumb rest
  43950. * @param buttonIdx Which button index changed
  43951. * @param state New state of the button
  43952. * @param changes Which properties on the state changed since last frame
  43953. */
  43954. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43955. }
  43956. }
  43957. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43958. import { Scene } from "babylonjs/scene";
  43959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43960. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43961. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43962. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43963. import { Observable } from "babylonjs/Misc/observable";
  43964. /**
  43965. * Vive Controller
  43966. */
  43967. export class ViveController extends WebVRController {
  43968. /**
  43969. * Base Url for the controller model.
  43970. */
  43971. static MODEL_BASE_URL: string;
  43972. /**
  43973. * File name for the controller model.
  43974. */
  43975. static MODEL_FILENAME: string;
  43976. /**
  43977. * Creates a new ViveController from a gamepad
  43978. * @param vrGamepad the gamepad that the controller should be created from
  43979. */
  43980. constructor(vrGamepad: any);
  43981. /**
  43982. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43983. * @param scene scene in which to add meshes
  43984. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43985. */
  43986. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43987. /**
  43988. * Fired when the left button on this controller is modified
  43989. */
  43990. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43991. /**
  43992. * Fired when the right button on this controller is modified
  43993. */
  43994. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43995. /**
  43996. * Fired when the menu button on this controller is modified
  43997. */
  43998. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43999. /**
  44000. * Called once for each button that changed state since the last frame
  44001. * Vive mapping:
  44002. * 0: touchpad
  44003. * 1: trigger
  44004. * 2: left AND right buttons
  44005. * 3: menu button
  44006. * @param buttonIdx Which button index changed
  44007. * @param state New state of the button
  44008. * @param changes Which properties on the state changed since last frame
  44009. */
  44010. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44011. }
  44012. }
  44013. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44014. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44015. /**
  44016. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44017. */
  44018. export class WebXRControllerModelLoader {
  44019. /**
  44020. * Creates the WebXRControllerModelLoader
  44021. * @param input xr input that creates the controllers
  44022. */
  44023. constructor(input: WebXRInput);
  44024. }
  44025. }
  44026. declare module "babylonjs/Cameras/XR/index" {
  44027. export * from "babylonjs/Cameras/XR/webXRCamera";
  44028. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44029. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44030. export * from "babylonjs/Cameras/XR/webXRInput";
  44031. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44032. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44033. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44034. export * from "babylonjs/Cameras/XR/webXRController";
  44035. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44036. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44037. }
  44038. declare module "babylonjs/Cameras/RigModes/index" {
  44039. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44040. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44041. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44042. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44043. }
  44044. declare module "babylonjs/Cameras/index" {
  44045. export * from "babylonjs/Cameras/Inputs/index";
  44046. export * from "babylonjs/Cameras/cameraInputsManager";
  44047. export * from "babylonjs/Cameras/camera";
  44048. export * from "babylonjs/Cameras/targetCamera";
  44049. export * from "babylonjs/Cameras/freeCamera";
  44050. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44051. export * from "babylonjs/Cameras/touchCamera";
  44052. export * from "babylonjs/Cameras/arcRotateCamera";
  44053. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44054. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44055. export * from "babylonjs/Cameras/flyCamera";
  44056. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44057. export * from "babylonjs/Cameras/followCamera";
  44058. export * from "babylonjs/Cameras/followCameraInputsManager";
  44059. export * from "babylonjs/Cameras/gamepadCamera";
  44060. export * from "babylonjs/Cameras/Stereoscopic/index";
  44061. export * from "babylonjs/Cameras/universalCamera";
  44062. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44063. export * from "babylonjs/Cameras/VR/index";
  44064. export * from "babylonjs/Cameras/XR/index";
  44065. export * from "babylonjs/Cameras/RigModes/index";
  44066. }
  44067. declare module "babylonjs/Collisions/index" {
  44068. export * from "babylonjs/Collisions/collider";
  44069. export * from "babylonjs/Collisions/collisionCoordinator";
  44070. export * from "babylonjs/Collisions/pickingInfo";
  44071. export * from "babylonjs/Collisions/intersectionInfo";
  44072. export * from "babylonjs/Collisions/meshCollisionData";
  44073. }
  44074. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44075. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44076. import { Vector3 } from "babylonjs/Maths/math.vector";
  44077. import { Ray } from "babylonjs/Culling/ray";
  44078. import { Plane } from "babylonjs/Maths/math.plane";
  44079. /**
  44080. * Contains an array of blocks representing the octree
  44081. */
  44082. export interface IOctreeContainer<T> {
  44083. /**
  44084. * Blocks within the octree
  44085. */
  44086. blocks: Array<OctreeBlock<T>>;
  44087. }
  44088. /**
  44089. * Class used to store a cell in an octree
  44090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44091. */
  44092. export class OctreeBlock<T> {
  44093. /**
  44094. * Gets the content of the current block
  44095. */
  44096. entries: T[];
  44097. /**
  44098. * Gets the list of block children
  44099. */
  44100. blocks: Array<OctreeBlock<T>>;
  44101. private _depth;
  44102. private _maxDepth;
  44103. private _capacity;
  44104. private _minPoint;
  44105. private _maxPoint;
  44106. private _boundingVectors;
  44107. private _creationFunc;
  44108. /**
  44109. * Creates a new block
  44110. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44111. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44112. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44113. * @param depth defines the current depth of this block in the octree
  44114. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44115. * @param creationFunc defines a callback to call when an element is added to the block
  44116. */
  44117. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44118. /**
  44119. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44120. */
  44121. readonly capacity: number;
  44122. /**
  44123. * Gets the minimum vector (in world space) of the block's bounding box
  44124. */
  44125. readonly minPoint: Vector3;
  44126. /**
  44127. * Gets the maximum vector (in world space) of the block's bounding box
  44128. */
  44129. readonly maxPoint: Vector3;
  44130. /**
  44131. * Add a new element to this block
  44132. * @param entry defines the element to add
  44133. */
  44134. addEntry(entry: T): void;
  44135. /**
  44136. * Remove an element from this block
  44137. * @param entry defines the element to remove
  44138. */
  44139. removeEntry(entry: T): void;
  44140. /**
  44141. * Add an array of elements to this block
  44142. * @param entries defines the array of elements to add
  44143. */
  44144. addEntries(entries: T[]): void;
  44145. /**
  44146. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44147. * @param frustumPlanes defines the frustum planes to test
  44148. * @param selection defines the array to store current content if selection is positive
  44149. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44150. */
  44151. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44152. /**
  44153. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44154. * @param sphereCenter defines the bounding sphere center
  44155. * @param sphereRadius defines the bounding sphere radius
  44156. * @param selection defines the array to store current content if selection is positive
  44157. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44158. */
  44159. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44160. /**
  44161. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44162. * @param ray defines the ray to test with
  44163. * @param selection defines the array to store current content if selection is positive
  44164. */
  44165. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44166. /**
  44167. * Subdivide the content into child blocks (this block will then be empty)
  44168. */
  44169. createInnerBlocks(): void;
  44170. /**
  44171. * @hidden
  44172. */
  44173. 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;
  44174. }
  44175. }
  44176. declare module "babylonjs/Culling/Octrees/octree" {
  44177. import { SmartArray } from "babylonjs/Misc/smartArray";
  44178. import { Vector3 } from "babylonjs/Maths/math.vector";
  44179. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44181. import { Ray } from "babylonjs/Culling/ray";
  44182. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44183. import { Plane } from "babylonjs/Maths/math.plane";
  44184. /**
  44185. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44186. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44187. */
  44188. export class Octree<T> {
  44189. /** 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.) */
  44190. maxDepth: number;
  44191. /**
  44192. * Blocks within the octree containing objects
  44193. */
  44194. blocks: Array<OctreeBlock<T>>;
  44195. /**
  44196. * Content stored in the octree
  44197. */
  44198. dynamicContent: T[];
  44199. private _maxBlockCapacity;
  44200. private _selectionContent;
  44201. private _creationFunc;
  44202. /**
  44203. * Creates a octree
  44204. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44205. * @param creationFunc function to be used to instatiate the octree
  44206. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44207. * @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.)
  44208. */
  44209. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44210. /** 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.) */
  44211. maxDepth?: number);
  44212. /**
  44213. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44214. * @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);
  44215. * @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);
  44216. * @param entries meshes to be added to the octree blocks
  44217. */
  44218. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44219. /**
  44220. * Adds a mesh to the octree
  44221. * @param entry Mesh to add to the octree
  44222. */
  44223. addMesh(entry: T): void;
  44224. /**
  44225. * Remove an element from the octree
  44226. * @param entry defines the element to remove
  44227. */
  44228. removeMesh(entry: T): void;
  44229. /**
  44230. * Selects an array of meshes within the frustum
  44231. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44232. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44233. * @returns array of meshes within the frustum
  44234. */
  44235. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44236. /**
  44237. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44238. * @param sphereCenter defines the bounding sphere center
  44239. * @param sphereRadius defines the bounding sphere radius
  44240. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44241. * @returns an array of objects that intersect the sphere
  44242. */
  44243. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44244. /**
  44245. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44246. * @param ray defines the ray to test with
  44247. * @returns array of intersected objects
  44248. */
  44249. intersectsRay(ray: Ray): SmartArray<T>;
  44250. /**
  44251. * Adds a mesh into the octree block if it intersects the block
  44252. */
  44253. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44254. /**
  44255. * Adds a submesh into the octree block if it intersects the block
  44256. */
  44257. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44258. }
  44259. }
  44260. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44261. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44262. import { Scene } from "babylonjs/scene";
  44263. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44265. import { Ray } from "babylonjs/Culling/ray";
  44266. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44267. import { Collider } from "babylonjs/Collisions/collider";
  44268. module "babylonjs/scene" {
  44269. interface Scene {
  44270. /**
  44271. * @hidden
  44272. * Backing Filed
  44273. */
  44274. _selectionOctree: Octree<AbstractMesh>;
  44275. /**
  44276. * Gets the octree used to boost mesh selection (picking)
  44277. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44278. */
  44279. selectionOctree: Octree<AbstractMesh>;
  44280. /**
  44281. * Creates or updates the octree used to boost selection (picking)
  44282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44283. * @param maxCapacity defines the maximum capacity per leaf
  44284. * @param maxDepth defines the maximum depth of the octree
  44285. * @returns an octree of AbstractMesh
  44286. */
  44287. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44288. }
  44289. }
  44290. module "babylonjs/Meshes/abstractMesh" {
  44291. interface AbstractMesh {
  44292. /**
  44293. * @hidden
  44294. * Backing Field
  44295. */
  44296. _submeshesOctree: Octree<SubMesh>;
  44297. /**
  44298. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44299. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44300. * @param maxCapacity defines the maximum size of each block (64 by default)
  44301. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44302. * @returns the new octree
  44303. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44304. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44305. */
  44306. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44307. }
  44308. }
  44309. /**
  44310. * Defines the octree scene component responsible to manage any octrees
  44311. * in a given scene.
  44312. */
  44313. export class OctreeSceneComponent {
  44314. /**
  44315. * The component name help to identify the component in the list of scene components.
  44316. */
  44317. readonly name: string;
  44318. /**
  44319. * The scene the component belongs to.
  44320. */
  44321. scene: Scene;
  44322. /**
  44323. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44324. */
  44325. readonly checksIsEnabled: boolean;
  44326. /**
  44327. * Creates a new instance of the component for the given scene
  44328. * @param scene Defines the scene to register the component in
  44329. */
  44330. constructor(scene: Scene);
  44331. /**
  44332. * Registers the component in a given scene
  44333. */
  44334. register(): void;
  44335. /**
  44336. * Return the list of active meshes
  44337. * @returns the list of active meshes
  44338. */
  44339. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44340. /**
  44341. * Return the list of active sub meshes
  44342. * @param mesh The mesh to get the candidates sub meshes from
  44343. * @returns the list of active sub meshes
  44344. */
  44345. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44346. private _tempRay;
  44347. /**
  44348. * Return the list of sub meshes intersecting with a given local ray
  44349. * @param mesh defines the mesh to find the submesh for
  44350. * @param localRay defines the ray in local space
  44351. * @returns the list of intersecting sub meshes
  44352. */
  44353. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44354. /**
  44355. * Return the list of sub meshes colliding with a collider
  44356. * @param mesh defines the mesh to find the submesh for
  44357. * @param collider defines the collider to evaluate the collision against
  44358. * @returns the list of colliding sub meshes
  44359. */
  44360. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44361. /**
  44362. * Rebuilds the elements related to this component in case of
  44363. * context lost for instance.
  44364. */
  44365. rebuild(): void;
  44366. /**
  44367. * Disposes the component and the associated ressources.
  44368. */
  44369. dispose(): void;
  44370. }
  44371. }
  44372. declare module "babylonjs/Culling/Octrees/index" {
  44373. export * from "babylonjs/Culling/Octrees/octree";
  44374. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44375. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44376. }
  44377. declare module "babylonjs/Culling/index" {
  44378. export * from "babylonjs/Culling/boundingBox";
  44379. export * from "babylonjs/Culling/boundingInfo";
  44380. export * from "babylonjs/Culling/boundingSphere";
  44381. export * from "babylonjs/Culling/Octrees/index";
  44382. export * from "babylonjs/Culling/ray";
  44383. }
  44384. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44385. import { IDisposable, Scene } from "babylonjs/scene";
  44386. import { Nullable } from "babylonjs/types";
  44387. import { Observable } from "babylonjs/Misc/observable";
  44388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44389. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44390. import { Camera } from "babylonjs/Cameras/camera";
  44391. /**
  44392. * Renders a layer on top of an existing scene
  44393. */
  44394. export class UtilityLayerRenderer implements IDisposable {
  44395. /** the original scene that will be rendered on top of */
  44396. originalScene: Scene;
  44397. private _pointerCaptures;
  44398. private _lastPointerEvents;
  44399. private static _DefaultUtilityLayer;
  44400. private static _DefaultKeepDepthUtilityLayer;
  44401. private _sharedGizmoLight;
  44402. private _renderCamera;
  44403. /**
  44404. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44405. * @returns the camera that is used when rendering the utility layer
  44406. */
  44407. getRenderCamera(): Nullable<Camera>;
  44408. /**
  44409. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44410. * @param cam the camera that should be used when rendering the utility layer
  44411. */
  44412. setRenderCamera(cam: Nullable<Camera>): void;
  44413. /**
  44414. * @hidden
  44415. * Light which used by gizmos to get light shading
  44416. */
  44417. _getSharedGizmoLight(): HemisphericLight;
  44418. /**
  44419. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44420. */
  44421. pickUtilitySceneFirst: boolean;
  44422. /**
  44423. * 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)
  44424. */
  44425. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44426. /**
  44427. * 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)
  44428. */
  44429. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44430. /**
  44431. * The scene that is rendered on top of the original scene
  44432. */
  44433. utilityLayerScene: Scene;
  44434. /**
  44435. * If the utility layer should automatically be rendered on top of existing scene
  44436. */
  44437. shouldRender: boolean;
  44438. /**
  44439. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44440. */
  44441. onlyCheckPointerDownEvents: boolean;
  44442. /**
  44443. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44444. */
  44445. processAllEvents: boolean;
  44446. /**
  44447. * Observable raised when the pointer move from the utility layer scene to the main scene
  44448. */
  44449. onPointerOutObservable: Observable<number>;
  44450. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44451. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44452. private _afterRenderObserver;
  44453. private _sceneDisposeObserver;
  44454. private _originalPointerObserver;
  44455. /**
  44456. * Instantiates a UtilityLayerRenderer
  44457. * @param originalScene the original scene that will be rendered on top of
  44458. * @param handleEvents boolean indicating if the utility layer should handle events
  44459. */
  44460. constructor(
  44461. /** the original scene that will be rendered on top of */
  44462. originalScene: Scene, handleEvents?: boolean);
  44463. private _notifyObservers;
  44464. /**
  44465. * Renders the utility layers scene on top of the original scene
  44466. */
  44467. render(): void;
  44468. /**
  44469. * Disposes of the renderer
  44470. */
  44471. dispose(): void;
  44472. private _updateCamera;
  44473. }
  44474. }
  44475. declare module "babylonjs/Gizmos/gizmo" {
  44476. import { Nullable } from "babylonjs/types";
  44477. import { IDisposable } from "babylonjs/scene";
  44478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44479. import { Mesh } from "babylonjs/Meshes/mesh";
  44480. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44481. /**
  44482. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44483. */
  44484. export class Gizmo implements IDisposable {
  44485. /** The utility layer the gizmo will be added to */
  44486. gizmoLayer: UtilityLayerRenderer;
  44487. /**
  44488. * The root mesh of the gizmo
  44489. */
  44490. _rootMesh: Mesh;
  44491. private _attachedMesh;
  44492. /**
  44493. * Ratio for the scale of the gizmo (Default: 1)
  44494. */
  44495. scaleRatio: number;
  44496. /**
  44497. * If a custom mesh has been set (Default: false)
  44498. */
  44499. protected _customMeshSet: boolean;
  44500. /**
  44501. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44502. * * When set, interactions will be enabled
  44503. */
  44504. attachedMesh: Nullable<AbstractMesh>;
  44505. /**
  44506. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44507. * @param mesh The mesh to replace the default mesh of the gizmo
  44508. */
  44509. setCustomMesh(mesh: Mesh): void;
  44510. /**
  44511. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44512. */
  44513. updateGizmoRotationToMatchAttachedMesh: boolean;
  44514. /**
  44515. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44516. */
  44517. updateGizmoPositionToMatchAttachedMesh: boolean;
  44518. /**
  44519. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44520. */
  44521. updateScale: boolean;
  44522. protected _interactionsEnabled: boolean;
  44523. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44524. private _beforeRenderObserver;
  44525. private _tempVector;
  44526. /**
  44527. * Creates a gizmo
  44528. * @param gizmoLayer The utility layer the gizmo will be added to
  44529. */
  44530. constructor(
  44531. /** The utility layer the gizmo will be added to */
  44532. gizmoLayer?: UtilityLayerRenderer);
  44533. /**
  44534. * Updates the gizmo to match the attached mesh's position/rotation
  44535. */
  44536. protected _update(): void;
  44537. /**
  44538. * Disposes of the gizmo
  44539. */
  44540. dispose(): void;
  44541. }
  44542. }
  44543. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44544. import { Observable } from "babylonjs/Misc/observable";
  44545. import { Nullable } from "babylonjs/types";
  44546. import { Vector3 } from "babylonjs/Maths/math.vector";
  44547. import { Color3 } from "babylonjs/Maths/math.color";
  44548. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44550. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44551. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44552. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44553. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44554. import { Scene } from "babylonjs/scene";
  44555. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44556. /**
  44557. * Single plane drag gizmo
  44558. */
  44559. export class PlaneDragGizmo extends Gizmo {
  44560. /**
  44561. * Drag behavior responsible for the gizmos dragging interactions
  44562. */
  44563. dragBehavior: PointerDragBehavior;
  44564. private _pointerObserver;
  44565. /**
  44566. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44567. */
  44568. snapDistance: number;
  44569. /**
  44570. * Event that fires each time the gizmo snaps to a new location.
  44571. * * snapDistance is the the change in distance
  44572. */
  44573. onSnapObservable: Observable<{
  44574. snapDistance: number;
  44575. }>;
  44576. private _plane;
  44577. private _coloredMaterial;
  44578. private _hoverMaterial;
  44579. private _isEnabled;
  44580. private _parent;
  44581. /** @hidden */
  44582. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44583. /** @hidden */
  44584. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44585. /**
  44586. * Creates a PlaneDragGizmo
  44587. * @param gizmoLayer The utility layer the gizmo will be added to
  44588. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44589. * @param color The color of the gizmo
  44590. */
  44591. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44592. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44593. /**
  44594. * If the gizmo is enabled
  44595. */
  44596. isEnabled: boolean;
  44597. /**
  44598. * Disposes of the gizmo
  44599. */
  44600. dispose(): void;
  44601. }
  44602. }
  44603. declare module "babylonjs/Gizmos/positionGizmo" {
  44604. import { Observable } from "babylonjs/Misc/observable";
  44605. import { Nullable } from "babylonjs/types";
  44606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44607. import { Mesh } from "babylonjs/Meshes/mesh";
  44608. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44609. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44610. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44611. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44612. /**
  44613. * Gizmo that enables dragging a mesh along 3 axis
  44614. */
  44615. export class PositionGizmo extends Gizmo {
  44616. /**
  44617. * Internal gizmo used for interactions on the x axis
  44618. */
  44619. xGizmo: AxisDragGizmo;
  44620. /**
  44621. * Internal gizmo used for interactions on the y axis
  44622. */
  44623. yGizmo: AxisDragGizmo;
  44624. /**
  44625. * Internal gizmo used for interactions on the z axis
  44626. */
  44627. zGizmo: AxisDragGizmo;
  44628. /**
  44629. * Internal gizmo used for interactions on the yz plane
  44630. */
  44631. xPlaneGizmo: PlaneDragGizmo;
  44632. /**
  44633. * Internal gizmo used for interactions on the xz plane
  44634. */
  44635. yPlaneGizmo: PlaneDragGizmo;
  44636. /**
  44637. * Internal gizmo used for interactions on the xy plane
  44638. */
  44639. zPlaneGizmo: PlaneDragGizmo;
  44640. /**
  44641. * private variables
  44642. */
  44643. private _meshAttached;
  44644. private _updateGizmoRotationToMatchAttachedMesh;
  44645. private _snapDistance;
  44646. private _scaleRatio;
  44647. /** Fires an event when any of it's sub gizmos are dragged */
  44648. onDragStartObservable: Observable<unknown>;
  44649. /** Fires an event when any of it's sub gizmos are released from dragging */
  44650. onDragEndObservable: Observable<unknown>;
  44651. /**
  44652. * If set to true, planar drag is enabled
  44653. */
  44654. private _planarGizmoEnabled;
  44655. attachedMesh: Nullable<AbstractMesh>;
  44656. /**
  44657. * Creates a PositionGizmo
  44658. * @param gizmoLayer The utility layer the gizmo will be added to
  44659. */
  44660. constructor(gizmoLayer?: UtilityLayerRenderer);
  44661. /**
  44662. * If the planar drag gizmo is enabled
  44663. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44664. */
  44665. planarGizmoEnabled: boolean;
  44666. updateGizmoRotationToMatchAttachedMesh: boolean;
  44667. /**
  44668. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44669. */
  44670. snapDistance: number;
  44671. /**
  44672. * Ratio for the scale of the gizmo (Default: 1)
  44673. */
  44674. scaleRatio: number;
  44675. /**
  44676. * Disposes of the gizmo
  44677. */
  44678. dispose(): void;
  44679. /**
  44680. * CustomMeshes are not supported by this gizmo
  44681. * @param mesh The mesh to replace the default mesh of the gizmo
  44682. */
  44683. setCustomMesh(mesh: Mesh): void;
  44684. }
  44685. }
  44686. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44687. import { Observable } from "babylonjs/Misc/observable";
  44688. import { Nullable } from "babylonjs/types";
  44689. import { Vector3 } from "babylonjs/Maths/math.vector";
  44690. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44692. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44693. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44694. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44695. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44696. import { Scene } from "babylonjs/scene";
  44697. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44698. import { Color3 } from "babylonjs/Maths/math.color";
  44699. /**
  44700. * Single axis drag gizmo
  44701. */
  44702. export class AxisDragGizmo extends Gizmo {
  44703. /**
  44704. * Drag behavior responsible for the gizmos dragging interactions
  44705. */
  44706. dragBehavior: PointerDragBehavior;
  44707. private _pointerObserver;
  44708. /**
  44709. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44710. */
  44711. snapDistance: number;
  44712. /**
  44713. * Event that fires each time the gizmo snaps to a new location.
  44714. * * snapDistance is the the change in distance
  44715. */
  44716. onSnapObservable: Observable<{
  44717. snapDistance: number;
  44718. }>;
  44719. private _isEnabled;
  44720. private _parent;
  44721. private _arrow;
  44722. private _coloredMaterial;
  44723. private _hoverMaterial;
  44724. /** @hidden */
  44725. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44726. /** @hidden */
  44727. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44728. /**
  44729. * Creates an AxisDragGizmo
  44730. * @param gizmoLayer The utility layer the gizmo will be added to
  44731. * @param dragAxis The axis which the gizmo will be able to drag on
  44732. * @param color The color of the gizmo
  44733. */
  44734. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44735. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44736. /**
  44737. * If the gizmo is enabled
  44738. */
  44739. isEnabled: boolean;
  44740. /**
  44741. * Disposes of the gizmo
  44742. */
  44743. dispose(): void;
  44744. }
  44745. }
  44746. declare module "babylonjs/Debug/axesViewer" {
  44747. import { Vector3 } from "babylonjs/Maths/math.vector";
  44748. import { Nullable } from "babylonjs/types";
  44749. import { Scene } from "babylonjs/scene";
  44750. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44751. /**
  44752. * The Axes viewer will show 3 axes in a specific point in space
  44753. */
  44754. export class AxesViewer {
  44755. private _xAxis;
  44756. private _yAxis;
  44757. private _zAxis;
  44758. private _scaleLinesFactor;
  44759. private _instanced;
  44760. /**
  44761. * Gets the hosting scene
  44762. */
  44763. scene: Scene;
  44764. /**
  44765. * Gets or sets a number used to scale line length
  44766. */
  44767. scaleLines: number;
  44768. /** Gets the node hierarchy used to render x-axis */
  44769. readonly xAxis: TransformNode;
  44770. /** Gets the node hierarchy used to render y-axis */
  44771. readonly yAxis: TransformNode;
  44772. /** Gets the node hierarchy used to render z-axis */
  44773. readonly zAxis: TransformNode;
  44774. /**
  44775. * Creates a new AxesViewer
  44776. * @param scene defines the hosting scene
  44777. * @param scaleLines defines a number used to scale line length (1 by default)
  44778. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44779. * @param xAxis defines the node hierarchy used to render the x-axis
  44780. * @param yAxis defines the node hierarchy used to render the y-axis
  44781. * @param zAxis defines the node hierarchy used to render the z-axis
  44782. */
  44783. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44784. /**
  44785. * Force the viewer to update
  44786. * @param position defines the position of the viewer
  44787. * @param xaxis defines the x axis of the viewer
  44788. * @param yaxis defines the y axis of the viewer
  44789. * @param zaxis defines the z axis of the viewer
  44790. */
  44791. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44792. /**
  44793. * Creates an instance of this axes viewer.
  44794. * @returns a new axes viewer with instanced meshes
  44795. */
  44796. createInstance(): AxesViewer;
  44797. /** Releases resources */
  44798. dispose(): void;
  44799. private static _SetRenderingGroupId;
  44800. }
  44801. }
  44802. declare module "babylonjs/Debug/boneAxesViewer" {
  44803. import { Nullable } from "babylonjs/types";
  44804. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44805. import { Vector3 } from "babylonjs/Maths/math.vector";
  44806. import { Mesh } from "babylonjs/Meshes/mesh";
  44807. import { Bone } from "babylonjs/Bones/bone";
  44808. import { Scene } from "babylonjs/scene";
  44809. /**
  44810. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44811. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44812. */
  44813. export class BoneAxesViewer extends AxesViewer {
  44814. /**
  44815. * Gets or sets the target mesh where to display the axes viewer
  44816. */
  44817. mesh: Nullable<Mesh>;
  44818. /**
  44819. * Gets or sets the target bone where to display the axes viewer
  44820. */
  44821. bone: Nullable<Bone>;
  44822. /** Gets current position */
  44823. pos: Vector3;
  44824. /** Gets direction of X axis */
  44825. xaxis: Vector3;
  44826. /** Gets direction of Y axis */
  44827. yaxis: Vector3;
  44828. /** Gets direction of Z axis */
  44829. zaxis: Vector3;
  44830. /**
  44831. * Creates a new BoneAxesViewer
  44832. * @param scene defines the hosting scene
  44833. * @param bone defines the target bone
  44834. * @param mesh defines the target mesh
  44835. * @param scaleLines defines a scaling factor for line length (1 by default)
  44836. */
  44837. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44838. /**
  44839. * Force the viewer to update
  44840. */
  44841. update(): void;
  44842. /** Releases resources */
  44843. dispose(): void;
  44844. }
  44845. }
  44846. declare module "babylonjs/Debug/debugLayer" {
  44847. import { Scene } from "babylonjs/scene";
  44848. /**
  44849. * Interface used to define scene explorer extensibility option
  44850. */
  44851. export interface IExplorerExtensibilityOption {
  44852. /**
  44853. * Define the option label
  44854. */
  44855. label: string;
  44856. /**
  44857. * Defines the action to execute on click
  44858. */
  44859. action: (entity: any) => void;
  44860. }
  44861. /**
  44862. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44863. */
  44864. export interface IExplorerExtensibilityGroup {
  44865. /**
  44866. * Defines a predicate to test if a given type mut be extended
  44867. */
  44868. predicate: (entity: any) => boolean;
  44869. /**
  44870. * Gets the list of options added to a type
  44871. */
  44872. entries: IExplorerExtensibilityOption[];
  44873. }
  44874. /**
  44875. * Interface used to define the options to use to create the Inspector
  44876. */
  44877. export interface IInspectorOptions {
  44878. /**
  44879. * Display in overlay mode (default: false)
  44880. */
  44881. overlay?: boolean;
  44882. /**
  44883. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44884. */
  44885. globalRoot?: HTMLElement;
  44886. /**
  44887. * Display the Scene explorer
  44888. */
  44889. showExplorer?: boolean;
  44890. /**
  44891. * Display the property inspector
  44892. */
  44893. showInspector?: boolean;
  44894. /**
  44895. * Display in embed mode (both panes on the right)
  44896. */
  44897. embedMode?: boolean;
  44898. /**
  44899. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44900. */
  44901. handleResize?: boolean;
  44902. /**
  44903. * Allow the panes to popup (default: true)
  44904. */
  44905. enablePopup?: boolean;
  44906. /**
  44907. * Allow the panes to be closed by users (default: true)
  44908. */
  44909. enableClose?: boolean;
  44910. /**
  44911. * Optional list of extensibility entries
  44912. */
  44913. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44914. /**
  44915. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44916. */
  44917. inspectorURL?: string;
  44918. }
  44919. module "babylonjs/scene" {
  44920. interface Scene {
  44921. /**
  44922. * @hidden
  44923. * Backing field
  44924. */
  44925. _debugLayer: DebugLayer;
  44926. /**
  44927. * Gets the debug layer (aka Inspector) associated with the scene
  44928. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44929. */
  44930. debugLayer: DebugLayer;
  44931. }
  44932. }
  44933. /**
  44934. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44935. * what is happening in your scene
  44936. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44937. */
  44938. export class DebugLayer {
  44939. /**
  44940. * Define the url to get the inspector script from.
  44941. * By default it uses the babylonjs CDN.
  44942. * @ignoreNaming
  44943. */
  44944. static InspectorURL: string;
  44945. private _scene;
  44946. private BJSINSPECTOR;
  44947. private _onPropertyChangedObservable?;
  44948. /**
  44949. * Observable triggered when a property is changed through the inspector.
  44950. */
  44951. readonly onPropertyChangedObservable: any;
  44952. /**
  44953. * Instantiates a new debug layer.
  44954. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44955. * what is happening in your scene
  44956. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44957. * @param scene Defines the scene to inspect
  44958. */
  44959. constructor(scene: Scene);
  44960. /** Creates the inspector window. */
  44961. private _createInspector;
  44962. /**
  44963. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44964. * @param entity defines the entity to select
  44965. * @param lineContainerTitle defines the specific block to highlight
  44966. */
  44967. select(entity: any, lineContainerTitle?: string): void;
  44968. /** Get the inspector from bundle or global */
  44969. private _getGlobalInspector;
  44970. /**
  44971. * Get if the inspector is visible or not.
  44972. * @returns true if visible otherwise, false
  44973. */
  44974. isVisible(): boolean;
  44975. /**
  44976. * Hide the inspector and close its window.
  44977. */
  44978. hide(): void;
  44979. /**
  44980. * Launch the debugLayer.
  44981. * @param config Define the configuration of the inspector
  44982. * @return a promise fulfilled when the debug layer is visible
  44983. */
  44984. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44985. }
  44986. }
  44987. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44988. import { Nullable } from "babylonjs/types";
  44989. import { Scene } from "babylonjs/scene";
  44990. import { Vector4 } from "babylonjs/Maths/math.vector";
  44991. import { Color4 } from "babylonjs/Maths/math.color";
  44992. import { Mesh } from "babylonjs/Meshes/mesh";
  44993. /**
  44994. * Class containing static functions to help procedurally build meshes
  44995. */
  44996. export class BoxBuilder {
  44997. /**
  44998. * Creates a box mesh
  44999. * * The parameter `size` sets the size (float) of each box side (default 1)
  45000. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45001. * * 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)
  45002. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45006. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45007. * @param name defines the name of the mesh
  45008. * @param options defines the options used to create the mesh
  45009. * @param scene defines the hosting scene
  45010. * @returns the box mesh
  45011. */
  45012. static CreateBox(name: string, options: {
  45013. size?: number;
  45014. width?: number;
  45015. height?: number;
  45016. depth?: number;
  45017. faceUV?: Vector4[];
  45018. faceColors?: Color4[];
  45019. sideOrientation?: number;
  45020. frontUVs?: Vector4;
  45021. backUVs?: Vector4;
  45022. wrap?: boolean;
  45023. topBaseAt?: number;
  45024. bottomBaseAt?: number;
  45025. updatable?: boolean;
  45026. }, scene?: Nullable<Scene>): Mesh;
  45027. }
  45028. }
  45029. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45030. import { Vector4 } from "babylonjs/Maths/math.vector";
  45031. import { Mesh } from "babylonjs/Meshes/mesh";
  45032. import { Scene } from "babylonjs/scene";
  45033. import { Nullable } from "babylonjs/types";
  45034. /**
  45035. * Class containing static functions to help procedurally build meshes
  45036. */
  45037. export class SphereBuilder {
  45038. /**
  45039. * Creates a sphere mesh
  45040. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45041. * * 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`)
  45042. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45043. * * 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
  45044. * * 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)
  45045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @param name defines the name of the mesh
  45049. * @param options defines the options used to create the mesh
  45050. * @param scene defines the hosting scene
  45051. * @returns the sphere mesh
  45052. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45053. */
  45054. static CreateSphere(name: string, options: {
  45055. segments?: number;
  45056. diameter?: number;
  45057. diameterX?: number;
  45058. diameterY?: number;
  45059. diameterZ?: number;
  45060. arc?: number;
  45061. slice?: number;
  45062. sideOrientation?: number;
  45063. frontUVs?: Vector4;
  45064. backUVs?: Vector4;
  45065. updatable?: boolean;
  45066. }, scene?: Nullable<Scene>): Mesh;
  45067. }
  45068. }
  45069. declare module "babylonjs/Debug/physicsViewer" {
  45070. import { Nullable } from "babylonjs/types";
  45071. import { Scene } from "babylonjs/scene";
  45072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45073. import { Mesh } from "babylonjs/Meshes/mesh";
  45074. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45075. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45076. /**
  45077. * Used to show the physics impostor around the specific mesh
  45078. */
  45079. export class PhysicsViewer {
  45080. /** @hidden */
  45081. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45082. /** @hidden */
  45083. protected _meshes: Array<Nullable<AbstractMesh>>;
  45084. /** @hidden */
  45085. protected _scene: Nullable<Scene>;
  45086. /** @hidden */
  45087. protected _numMeshes: number;
  45088. /** @hidden */
  45089. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45090. private _renderFunction;
  45091. private _utilityLayer;
  45092. private _debugBoxMesh;
  45093. private _debugSphereMesh;
  45094. private _debugCylinderMesh;
  45095. private _debugMaterial;
  45096. private _debugMeshMeshes;
  45097. /**
  45098. * Creates a new PhysicsViewer
  45099. * @param scene defines the hosting scene
  45100. */
  45101. constructor(scene: Scene);
  45102. /** @hidden */
  45103. protected _updateDebugMeshes(): void;
  45104. /**
  45105. * Renders a specified physic impostor
  45106. * @param impostor defines the impostor to render
  45107. * @param targetMesh defines the mesh represented by the impostor
  45108. * @returns the new debug mesh used to render the impostor
  45109. */
  45110. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45111. /**
  45112. * Hides a specified physic impostor
  45113. * @param impostor defines the impostor to hide
  45114. */
  45115. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45116. private _getDebugMaterial;
  45117. private _getDebugBoxMesh;
  45118. private _getDebugSphereMesh;
  45119. private _getDebugCylinderMesh;
  45120. private _getDebugMeshMesh;
  45121. private _getDebugMesh;
  45122. /** Releases all resources */
  45123. dispose(): void;
  45124. }
  45125. }
  45126. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45127. import { Vector3 } from "babylonjs/Maths/math.vector";
  45128. import { Color4 } from "babylonjs/Maths/math.color";
  45129. import { Nullable } from "babylonjs/types";
  45130. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45131. import { Scene } from "babylonjs/scene";
  45132. /**
  45133. * Class containing static functions to help procedurally build meshes
  45134. */
  45135. export class LinesBuilder {
  45136. /**
  45137. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45138. * * 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
  45139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45140. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45141. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45142. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45143. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45144. * * 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
  45145. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45148. * @param name defines the name of the new line system
  45149. * @param options defines the options used to create the line system
  45150. * @param scene defines the hosting scene
  45151. * @returns a new line system mesh
  45152. */
  45153. static CreateLineSystem(name: string, options: {
  45154. lines: Vector3[][];
  45155. updatable?: boolean;
  45156. instance?: Nullable<LinesMesh>;
  45157. colors?: Nullable<Color4[][]>;
  45158. useVertexAlpha?: boolean;
  45159. }, scene: Nullable<Scene>): LinesMesh;
  45160. /**
  45161. * Creates a line mesh
  45162. * 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
  45163. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45164. * * The parameter `points` is an array successive Vector3
  45165. * * 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
  45166. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45167. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45168. * * When updating an instance, remember that only point positions can change, not the number of points
  45169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45171. * @param name defines the name of the new line system
  45172. * @param options defines the options used to create the line system
  45173. * @param scene defines the hosting scene
  45174. * @returns a new line mesh
  45175. */
  45176. static CreateLines(name: string, options: {
  45177. points: Vector3[];
  45178. updatable?: boolean;
  45179. instance?: Nullable<LinesMesh>;
  45180. colors?: Color4[];
  45181. useVertexAlpha?: boolean;
  45182. }, scene?: Nullable<Scene>): LinesMesh;
  45183. /**
  45184. * Creates a dashed line mesh
  45185. * * 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
  45186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45187. * * The parameter `points` is an array successive Vector3
  45188. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45189. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45190. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45191. * * 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
  45192. * * When updating an instance, remember that only point positions can change, not the number of points
  45193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45194. * @param name defines the name of the mesh
  45195. * @param options defines the options used to create the mesh
  45196. * @param scene defines the hosting scene
  45197. * @returns the dashed line mesh
  45198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45199. */
  45200. static CreateDashedLines(name: string, options: {
  45201. points: Vector3[];
  45202. dashSize?: number;
  45203. gapSize?: number;
  45204. dashNb?: number;
  45205. updatable?: boolean;
  45206. instance?: LinesMesh;
  45207. }, scene?: Nullable<Scene>): LinesMesh;
  45208. }
  45209. }
  45210. declare module "babylonjs/Debug/rayHelper" {
  45211. import { Nullable } from "babylonjs/types";
  45212. import { Ray } from "babylonjs/Culling/ray";
  45213. import { Vector3 } from "babylonjs/Maths/math.vector";
  45214. import { Color3 } from "babylonjs/Maths/math.color";
  45215. import { Scene } from "babylonjs/scene";
  45216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45217. import "babylonjs/Meshes/Builders/linesBuilder";
  45218. /**
  45219. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45220. * in order to better appreciate the issue one might have.
  45221. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45222. */
  45223. export class RayHelper {
  45224. /**
  45225. * Defines the ray we are currently tryin to visualize.
  45226. */
  45227. ray: Nullable<Ray>;
  45228. private _renderPoints;
  45229. private _renderLine;
  45230. private _renderFunction;
  45231. private _scene;
  45232. private _updateToMeshFunction;
  45233. private _attachedToMesh;
  45234. private _meshSpaceDirection;
  45235. private _meshSpaceOrigin;
  45236. /**
  45237. * Helper function to create a colored helper in a scene in one line.
  45238. * @param ray Defines the ray we are currently tryin to visualize
  45239. * @param scene Defines the scene the ray is used in
  45240. * @param color Defines the color we want to see the ray in
  45241. * @returns The newly created ray helper.
  45242. */
  45243. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45244. /**
  45245. * Instantiate a new ray helper.
  45246. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45247. * in order to better appreciate the issue one might have.
  45248. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45249. * @param ray Defines the ray we are currently tryin to visualize
  45250. */
  45251. constructor(ray: Ray);
  45252. /**
  45253. * Shows the ray we are willing to debug.
  45254. * @param scene Defines the scene the ray needs to be rendered in
  45255. * @param color Defines the color the ray needs to be rendered in
  45256. */
  45257. show(scene: Scene, color?: Color3): void;
  45258. /**
  45259. * Hides the ray we are debugging.
  45260. */
  45261. hide(): void;
  45262. private _render;
  45263. /**
  45264. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45265. * @param mesh Defines the mesh we want the helper attached to
  45266. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45267. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45268. * @param length Defines the length of the ray
  45269. */
  45270. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45271. /**
  45272. * Detach the ray helper from the mesh it has previously been attached to.
  45273. */
  45274. detachFromMesh(): void;
  45275. private _updateToMesh;
  45276. /**
  45277. * Dispose the helper and release its associated resources.
  45278. */
  45279. dispose(): void;
  45280. }
  45281. }
  45282. declare module "babylonjs/Debug/skeletonViewer" {
  45283. import { Color3 } from "babylonjs/Maths/math.color";
  45284. import { Scene } from "babylonjs/scene";
  45285. import { Nullable } from "babylonjs/types";
  45286. import { Skeleton } from "babylonjs/Bones/skeleton";
  45287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45288. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45289. /**
  45290. * Class used to render a debug view of a given skeleton
  45291. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45292. */
  45293. export class SkeletonViewer {
  45294. /** defines the skeleton to render */
  45295. skeleton: Skeleton;
  45296. /** defines the mesh attached to the skeleton */
  45297. mesh: AbstractMesh;
  45298. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45299. autoUpdateBonesMatrices: boolean;
  45300. /** defines the rendering group id to use with the viewer */
  45301. renderingGroupId: number;
  45302. /** Gets or sets the color used to render the skeleton */
  45303. color: Color3;
  45304. private _scene;
  45305. private _debugLines;
  45306. private _debugMesh;
  45307. private _isEnabled;
  45308. private _renderFunction;
  45309. private _utilityLayer;
  45310. /**
  45311. * Returns the mesh used to render the bones
  45312. */
  45313. readonly debugMesh: Nullable<LinesMesh>;
  45314. /**
  45315. * Creates a new SkeletonViewer
  45316. * @param skeleton defines the skeleton to render
  45317. * @param mesh defines the mesh attached to the skeleton
  45318. * @param scene defines the hosting scene
  45319. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45320. * @param renderingGroupId defines the rendering group id to use with the viewer
  45321. */
  45322. constructor(
  45323. /** defines the skeleton to render */
  45324. skeleton: Skeleton,
  45325. /** defines the mesh attached to the skeleton */
  45326. mesh: AbstractMesh, scene: Scene,
  45327. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45328. autoUpdateBonesMatrices?: boolean,
  45329. /** defines the rendering group id to use with the viewer */
  45330. renderingGroupId?: number);
  45331. /** Gets or sets a boolean indicating if the viewer is enabled */
  45332. isEnabled: boolean;
  45333. private _getBonePosition;
  45334. private _getLinesForBonesWithLength;
  45335. private _getLinesForBonesNoLength;
  45336. /** Update the viewer to sync with current skeleton state */
  45337. update(): void;
  45338. /** Release associated resources */
  45339. dispose(): void;
  45340. }
  45341. }
  45342. declare module "babylonjs/Debug/index" {
  45343. export * from "babylonjs/Debug/axesViewer";
  45344. export * from "babylonjs/Debug/boneAxesViewer";
  45345. export * from "babylonjs/Debug/debugLayer";
  45346. export * from "babylonjs/Debug/physicsViewer";
  45347. export * from "babylonjs/Debug/rayHelper";
  45348. export * from "babylonjs/Debug/skeletonViewer";
  45349. }
  45350. declare module "babylonjs/Engines/nullEngine" {
  45351. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45352. import { Scene } from "babylonjs/scene";
  45353. import { Engine } from "babylonjs/Engines/engine";
  45354. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45355. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45356. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45357. import { Effect } from "babylonjs/Materials/effect";
  45358. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45359. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45360. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45361. /**
  45362. * Options to create the null engine
  45363. */
  45364. export class NullEngineOptions {
  45365. /**
  45366. * Render width (Default: 512)
  45367. */
  45368. renderWidth: number;
  45369. /**
  45370. * Render height (Default: 256)
  45371. */
  45372. renderHeight: number;
  45373. /**
  45374. * Texture size (Default: 512)
  45375. */
  45376. textureSize: number;
  45377. /**
  45378. * If delta time between frames should be constant
  45379. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45380. */
  45381. deterministicLockstep: boolean;
  45382. /**
  45383. * Maximum about of steps between frames (Default: 4)
  45384. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45385. */
  45386. lockstepMaxSteps: number;
  45387. }
  45388. /**
  45389. * The null engine class provides support for headless version of babylon.js.
  45390. * This can be used in server side scenario or for testing purposes
  45391. */
  45392. export class NullEngine extends Engine {
  45393. private _options;
  45394. /**
  45395. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45396. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45397. * @returns true if engine is in deterministic lock step mode
  45398. */
  45399. isDeterministicLockStep(): boolean;
  45400. /**
  45401. * Gets the max steps when engine is running in deterministic lock step
  45402. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45403. * @returns the max steps
  45404. */
  45405. getLockstepMaxSteps(): number;
  45406. /**
  45407. * Gets the current hardware scaling level.
  45408. * By default the hardware scaling level is computed from the window device ratio.
  45409. * 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.
  45410. * @returns a number indicating the current hardware scaling level
  45411. */
  45412. getHardwareScalingLevel(): number;
  45413. constructor(options?: NullEngineOptions);
  45414. /**
  45415. * Creates a vertex buffer
  45416. * @param vertices the data for the vertex buffer
  45417. * @returns the new WebGL static buffer
  45418. */
  45419. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45420. /**
  45421. * Creates a new index buffer
  45422. * @param indices defines the content of the index buffer
  45423. * @param updatable defines if the index buffer must be updatable
  45424. * @returns a new webGL buffer
  45425. */
  45426. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45427. /**
  45428. * Clear the current render buffer or the current render target (if any is set up)
  45429. * @param color defines the color to use
  45430. * @param backBuffer defines if the back buffer must be cleared
  45431. * @param depth defines if the depth buffer must be cleared
  45432. * @param stencil defines if the stencil buffer must be cleared
  45433. */
  45434. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45435. /**
  45436. * Gets the current render width
  45437. * @param useScreen defines if screen size must be used (or the current render target if any)
  45438. * @returns a number defining the current render width
  45439. */
  45440. getRenderWidth(useScreen?: boolean): number;
  45441. /**
  45442. * Gets the current render height
  45443. * @param useScreen defines if screen size must be used (or the current render target if any)
  45444. * @returns a number defining the current render height
  45445. */
  45446. getRenderHeight(useScreen?: boolean): number;
  45447. /**
  45448. * Set the WebGL's viewport
  45449. * @param viewport defines the viewport element to be used
  45450. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45451. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45452. */
  45453. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45454. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45455. /**
  45456. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45457. * @param pipelineContext defines the pipeline context to use
  45458. * @param uniformsNames defines the list of uniform names
  45459. * @returns an array of webGL uniform locations
  45460. */
  45461. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45462. /**
  45463. * Gets the lsit of active attributes for a given webGL program
  45464. * @param pipelineContext defines the pipeline context to use
  45465. * @param attributesNames defines the list of attribute names to get
  45466. * @returns an array of indices indicating the offset of each attribute
  45467. */
  45468. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45469. /**
  45470. * Binds an effect to the webGL context
  45471. * @param effect defines the effect to bind
  45472. */
  45473. bindSamplers(effect: Effect): void;
  45474. /**
  45475. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45476. * @param effect defines the effect to activate
  45477. */
  45478. enableEffect(effect: Effect): void;
  45479. /**
  45480. * Set various states to the webGL context
  45481. * @param culling defines backface culling state
  45482. * @param zOffset defines the value to apply to zOffset (0 by default)
  45483. * @param force defines if states must be applied even if cache is up to date
  45484. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45485. */
  45486. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45487. /**
  45488. * Set the value of an uniform to an array of int32
  45489. * @param uniform defines the webGL uniform location where to store the value
  45490. * @param array defines the array of int32 to store
  45491. */
  45492. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45493. /**
  45494. * Set the value of an uniform to an array of int32 (stored as vec2)
  45495. * @param uniform defines the webGL uniform location where to store the value
  45496. * @param array defines the array of int32 to store
  45497. */
  45498. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45499. /**
  45500. * Set the value of an uniform to an array of int32 (stored as vec3)
  45501. * @param uniform defines the webGL uniform location where to store the value
  45502. * @param array defines the array of int32 to store
  45503. */
  45504. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45505. /**
  45506. * Set the value of an uniform to an array of int32 (stored as vec4)
  45507. * @param uniform defines the webGL uniform location where to store the value
  45508. * @param array defines the array of int32 to store
  45509. */
  45510. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45511. /**
  45512. * Set the value of an uniform to an array of float32
  45513. * @param uniform defines the webGL uniform location where to store the value
  45514. * @param array defines the array of float32 to store
  45515. */
  45516. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45517. /**
  45518. * Set the value of an uniform to an array of float32 (stored as vec2)
  45519. * @param uniform defines the webGL uniform location where to store the value
  45520. * @param array defines the array of float32 to store
  45521. */
  45522. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45523. /**
  45524. * Set the value of an uniform to an array of float32 (stored as vec3)
  45525. * @param uniform defines the webGL uniform location where to store the value
  45526. * @param array defines the array of float32 to store
  45527. */
  45528. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45529. /**
  45530. * Set the value of an uniform to an array of float32 (stored as vec4)
  45531. * @param uniform defines the webGL uniform location where to store the value
  45532. * @param array defines the array of float32 to store
  45533. */
  45534. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45535. /**
  45536. * Set the value of an uniform to an array of number
  45537. * @param uniform defines the webGL uniform location where to store the value
  45538. * @param array defines the array of number to store
  45539. */
  45540. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45541. /**
  45542. * Set the value of an uniform to an array of number (stored as vec2)
  45543. * @param uniform defines the webGL uniform location where to store the value
  45544. * @param array defines the array of number to store
  45545. */
  45546. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45547. /**
  45548. * Set the value of an uniform to an array of number (stored as vec3)
  45549. * @param uniform defines the webGL uniform location where to store the value
  45550. * @param array defines the array of number to store
  45551. */
  45552. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45553. /**
  45554. * Set the value of an uniform to an array of number (stored as vec4)
  45555. * @param uniform defines the webGL uniform location where to store the value
  45556. * @param array defines the array of number to store
  45557. */
  45558. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45559. /**
  45560. * Set the value of an uniform to an array of float32 (stored as matrices)
  45561. * @param uniform defines the webGL uniform location where to store the value
  45562. * @param matrices defines the array of float32 to store
  45563. */
  45564. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45565. /**
  45566. * Set the value of an uniform to a matrix (3x3)
  45567. * @param uniform defines the webGL uniform location where to store the value
  45568. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45569. */
  45570. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45571. /**
  45572. * Set the value of an uniform to a matrix (2x2)
  45573. * @param uniform defines the webGL uniform location where to store the value
  45574. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45575. */
  45576. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45577. /**
  45578. * Set the value of an uniform to a number (float)
  45579. * @param uniform defines the webGL uniform location where to store the value
  45580. * @param value defines the float number to store
  45581. */
  45582. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45583. /**
  45584. * Set the value of an uniform to a vec2
  45585. * @param uniform defines the webGL uniform location where to store the value
  45586. * @param x defines the 1st component of the value
  45587. * @param y defines the 2nd component of the value
  45588. */
  45589. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45590. /**
  45591. * Set the value of an uniform to a vec3
  45592. * @param uniform defines the webGL uniform location where to store the value
  45593. * @param x defines the 1st component of the value
  45594. * @param y defines the 2nd component of the value
  45595. * @param z defines the 3rd component of the value
  45596. */
  45597. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45598. /**
  45599. * Set the value of an uniform to a boolean
  45600. * @param uniform defines the webGL uniform location where to store the value
  45601. * @param bool defines the boolean to store
  45602. */
  45603. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45604. /**
  45605. * Set the value of an uniform to a vec4
  45606. * @param uniform defines the webGL uniform location where to store the value
  45607. * @param x defines the 1st component of the value
  45608. * @param y defines the 2nd component of the value
  45609. * @param z defines the 3rd component of the value
  45610. * @param w defines the 4th component of the value
  45611. */
  45612. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45613. /**
  45614. * Sets the current alpha mode
  45615. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45616. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45617. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45618. */
  45619. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45620. /**
  45621. * Bind webGl buffers directly to the webGL context
  45622. * @param vertexBuffers defines the vertex buffer to bind
  45623. * @param indexBuffer defines the index buffer to bind
  45624. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45625. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45626. * @param effect defines the effect associated with the vertex buffer
  45627. */
  45628. bindBuffers(vertexBuffers: {
  45629. [key: string]: VertexBuffer;
  45630. }, indexBuffer: DataBuffer, effect: Effect): void;
  45631. /**
  45632. * Force the entire cache to be cleared
  45633. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45634. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45635. */
  45636. wipeCaches(bruteForce?: boolean): void;
  45637. /**
  45638. * Send a draw order
  45639. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45640. * @param indexStart defines the starting index
  45641. * @param indexCount defines the number of index to draw
  45642. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45643. */
  45644. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45645. /**
  45646. * Draw a list of indexed primitives
  45647. * @param fillMode defines the primitive to use
  45648. * @param indexStart defines the starting index
  45649. * @param indexCount defines the number of index to draw
  45650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45651. */
  45652. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45653. /**
  45654. * Draw a list of unindexed primitives
  45655. * @param fillMode defines the primitive to use
  45656. * @param verticesStart defines the index of first vertex to draw
  45657. * @param verticesCount defines the count of vertices to draw
  45658. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45659. */
  45660. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45661. /** @hidden */
  45662. _createTexture(): WebGLTexture;
  45663. /** @hidden */
  45664. _releaseTexture(texture: InternalTexture): void;
  45665. /**
  45666. * Usually called from Texture.ts.
  45667. * Passed information to create a WebGLTexture
  45668. * @param urlArg defines a value which contains one of the following:
  45669. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45670. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45671. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45673. * @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)
  45674. * @param scene needed for loading to the correct scene
  45675. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45676. * @param onLoad optional callback to be called upon successful completion
  45677. * @param onError optional callback to be called upon failure
  45678. * @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
  45679. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45680. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45681. * @param forcedExtension defines the extension to use to pick the right loader
  45682. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45683. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45684. */
  45685. 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;
  45686. /**
  45687. * Creates a new render target texture
  45688. * @param size defines the size of the texture
  45689. * @param options defines the options used to create the texture
  45690. * @returns a new render target texture stored in an InternalTexture
  45691. */
  45692. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45693. /**
  45694. * Update the sampling mode of a given texture
  45695. * @param samplingMode defines the required sampling mode
  45696. * @param texture defines the texture to update
  45697. */
  45698. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45699. /**
  45700. * Binds the frame buffer to the specified texture.
  45701. * @param texture The texture to render to or null for the default canvas
  45702. * @param faceIndex The face of the texture to render to in case of cube texture
  45703. * @param requiredWidth The width of the target to render to
  45704. * @param requiredHeight The height of the target to render to
  45705. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45706. * @param depthStencilTexture The depth stencil texture to use to render
  45707. * @param lodLevel defines le lod level to bind to the frame buffer
  45708. */
  45709. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45710. /**
  45711. * Unbind the current render target texture from the webGL context
  45712. * @param texture defines the render target texture to unbind
  45713. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45714. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45715. */
  45716. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45717. /**
  45718. * Creates a dynamic vertex buffer
  45719. * @param vertices the data for the dynamic vertex buffer
  45720. * @returns the new WebGL dynamic buffer
  45721. */
  45722. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45723. /**
  45724. * Update the content of a dynamic texture
  45725. * @param texture defines the texture to update
  45726. * @param canvas defines the canvas containing the source
  45727. * @param invertY defines if data must be stored with Y axis inverted
  45728. * @param premulAlpha defines if alpha is stored as premultiplied
  45729. * @param format defines the format of the data
  45730. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45731. */
  45732. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45733. /**
  45734. * Gets a boolean indicating if all created effects are ready
  45735. * @returns true if all effects are ready
  45736. */
  45737. areAllEffectsReady(): boolean;
  45738. /**
  45739. * @hidden
  45740. * Get the current error code of the webGL context
  45741. * @returns the error code
  45742. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45743. */
  45744. getError(): number;
  45745. /** @hidden */
  45746. _getUnpackAlignement(): number;
  45747. /** @hidden */
  45748. _unpackFlipY(value: boolean): void;
  45749. /**
  45750. * Update a dynamic index buffer
  45751. * @param indexBuffer defines the target index buffer
  45752. * @param indices defines the data to update
  45753. * @param offset defines the offset in the target index buffer where update should start
  45754. */
  45755. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45756. /**
  45757. * Updates a dynamic vertex buffer.
  45758. * @param vertexBuffer the vertex buffer to update
  45759. * @param vertices the data used to update the vertex buffer
  45760. * @param byteOffset the byte offset of the data (optional)
  45761. * @param byteLength the byte length of the data (optional)
  45762. */
  45763. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45764. /** @hidden */
  45765. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45766. /** @hidden */
  45767. _bindTexture(channel: number, texture: InternalTexture): void;
  45768. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45769. /**
  45770. * 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
  45771. */
  45772. releaseEffects(): void;
  45773. displayLoadingUI(): void;
  45774. hideLoadingUI(): void;
  45775. /** @hidden */
  45776. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45777. /** @hidden */
  45778. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45779. /** @hidden */
  45780. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45781. /** @hidden */
  45782. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45783. }
  45784. }
  45785. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45786. import { Nullable, int } from "babylonjs/types";
  45787. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45788. /** @hidden */
  45789. export class _OcclusionDataStorage {
  45790. /** @hidden */
  45791. occlusionInternalRetryCounter: number;
  45792. /** @hidden */
  45793. isOcclusionQueryInProgress: boolean;
  45794. /** @hidden */
  45795. isOccluded: boolean;
  45796. /** @hidden */
  45797. occlusionRetryCount: number;
  45798. /** @hidden */
  45799. occlusionType: number;
  45800. /** @hidden */
  45801. occlusionQueryAlgorithmType: number;
  45802. }
  45803. module "babylonjs/Engines/engine" {
  45804. interface Engine {
  45805. /**
  45806. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45807. * @return the new query
  45808. */
  45809. createQuery(): WebGLQuery;
  45810. /**
  45811. * Delete and release a webGL query
  45812. * @param query defines the query to delete
  45813. * @return the current engine
  45814. */
  45815. deleteQuery(query: WebGLQuery): Engine;
  45816. /**
  45817. * Check if a given query has resolved and got its value
  45818. * @param query defines the query to check
  45819. * @returns true if the query got its value
  45820. */
  45821. isQueryResultAvailable(query: WebGLQuery): boolean;
  45822. /**
  45823. * Gets the value of a given query
  45824. * @param query defines the query to check
  45825. * @returns the value of the query
  45826. */
  45827. getQueryResult(query: WebGLQuery): number;
  45828. /**
  45829. * Initiates an occlusion query
  45830. * @param algorithmType defines the algorithm to use
  45831. * @param query defines the query to use
  45832. * @returns the current engine
  45833. * @see http://doc.babylonjs.com/features/occlusionquery
  45834. */
  45835. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45836. /**
  45837. * Ends an occlusion query
  45838. * @see http://doc.babylonjs.com/features/occlusionquery
  45839. * @param algorithmType defines the algorithm to use
  45840. * @returns the current engine
  45841. */
  45842. endOcclusionQuery(algorithmType: number): Engine;
  45843. /**
  45844. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45845. * Please note that only one query can be issued at a time
  45846. * @returns a time token used to track the time span
  45847. */
  45848. startTimeQuery(): Nullable<_TimeToken>;
  45849. /**
  45850. * Ends a time query
  45851. * @param token defines the token used to measure the time span
  45852. * @returns the time spent (in ns)
  45853. */
  45854. endTimeQuery(token: _TimeToken): int;
  45855. /** @hidden */
  45856. _currentNonTimestampToken: Nullable<_TimeToken>;
  45857. /** @hidden */
  45858. _createTimeQuery(): WebGLQuery;
  45859. /** @hidden */
  45860. _deleteTimeQuery(query: WebGLQuery): void;
  45861. /** @hidden */
  45862. _getGlAlgorithmType(algorithmType: number): number;
  45863. /** @hidden */
  45864. _getTimeQueryResult(query: WebGLQuery): any;
  45865. /** @hidden */
  45866. _getTimeQueryAvailability(query: WebGLQuery): any;
  45867. }
  45868. }
  45869. module "babylonjs/Meshes/abstractMesh" {
  45870. interface AbstractMesh {
  45871. /**
  45872. * Backing filed
  45873. * @hidden
  45874. */
  45875. __occlusionDataStorage: _OcclusionDataStorage;
  45876. /**
  45877. * Access property
  45878. * @hidden
  45879. */
  45880. _occlusionDataStorage: _OcclusionDataStorage;
  45881. /**
  45882. * 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.
  45883. * The default value is -1 which means don't break the query and wait till the result
  45884. * @see http://doc.babylonjs.com/features/occlusionquery
  45885. */
  45886. occlusionRetryCount: number;
  45887. /**
  45888. * 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:
  45889. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45890. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45891. * * 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.
  45892. * @see http://doc.babylonjs.com/features/occlusionquery
  45893. */
  45894. occlusionType: number;
  45895. /**
  45896. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45897. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45898. * * 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.
  45899. * @see http://doc.babylonjs.com/features/occlusionquery
  45900. */
  45901. occlusionQueryAlgorithmType: number;
  45902. /**
  45903. * 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
  45904. * @see http://doc.babylonjs.com/features/occlusionquery
  45905. */
  45906. isOccluded: boolean;
  45907. /**
  45908. * Flag to check the progress status of the query
  45909. * @see http://doc.babylonjs.com/features/occlusionquery
  45910. */
  45911. isOcclusionQueryInProgress: boolean;
  45912. }
  45913. }
  45914. }
  45915. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45916. import { Nullable } from "babylonjs/types";
  45917. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45918. /** @hidden */
  45919. export var _forceTransformFeedbackToBundle: boolean;
  45920. module "babylonjs/Engines/engine" {
  45921. interface Engine {
  45922. /**
  45923. * Creates a webGL transform feedback object
  45924. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45925. * @returns the webGL transform feedback object
  45926. */
  45927. createTransformFeedback(): WebGLTransformFeedback;
  45928. /**
  45929. * Delete a webGL transform feedback object
  45930. * @param value defines the webGL transform feedback object to delete
  45931. */
  45932. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45933. /**
  45934. * Bind a webGL transform feedback object to the webgl context
  45935. * @param value defines the webGL transform feedback object to bind
  45936. */
  45937. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45938. /**
  45939. * Begins a transform feedback operation
  45940. * @param usePoints defines if points or triangles must be used
  45941. */
  45942. beginTransformFeedback(usePoints: boolean): void;
  45943. /**
  45944. * Ends a transform feedback operation
  45945. */
  45946. endTransformFeedback(): void;
  45947. /**
  45948. * Specify the varyings to use with transform feedback
  45949. * @param program defines the associated webGL program
  45950. * @param value defines the list of strings representing the varying names
  45951. */
  45952. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45953. /**
  45954. * Bind a webGL buffer for a transform feedback operation
  45955. * @param value defines the webGL buffer to bind
  45956. */
  45957. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45958. }
  45959. }
  45960. }
  45961. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45962. import { Scene } from "babylonjs/scene";
  45963. import { Engine } from "babylonjs/Engines/engine";
  45964. import { Texture } from "babylonjs/Materials/Textures/texture";
  45965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45966. import "babylonjs/Engines/Extensions/engine.multiRender";
  45967. /**
  45968. * Creation options of the multi render target texture.
  45969. */
  45970. export interface IMultiRenderTargetOptions {
  45971. /**
  45972. * Define if the texture needs to create mip maps after render.
  45973. */
  45974. generateMipMaps?: boolean;
  45975. /**
  45976. * Define the types of all the draw buffers we want to create
  45977. */
  45978. types?: number[];
  45979. /**
  45980. * Define the sampling modes of all the draw buffers we want to create
  45981. */
  45982. samplingModes?: number[];
  45983. /**
  45984. * Define if a depth buffer is required
  45985. */
  45986. generateDepthBuffer?: boolean;
  45987. /**
  45988. * Define if a stencil buffer is required
  45989. */
  45990. generateStencilBuffer?: boolean;
  45991. /**
  45992. * Define if a depth texture is required instead of a depth buffer
  45993. */
  45994. generateDepthTexture?: boolean;
  45995. /**
  45996. * Define the number of desired draw buffers
  45997. */
  45998. textureCount?: number;
  45999. /**
  46000. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46001. */
  46002. doNotChangeAspectRatio?: boolean;
  46003. /**
  46004. * Define the default type of the buffers we are creating
  46005. */
  46006. defaultType?: number;
  46007. }
  46008. /**
  46009. * A multi render target, like a render target provides the ability to render to a texture.
  46010. * Unlike the render target, it can render to several draw buffers in one draw.
  46011. * This is specially interesting in deferred rendering or for any effects requiring more than
  46012. * just one color from a single pass.
  46013. */
  46014. export class MultiRenderTarget extends RenderTargetTexture {
  46015. private _internalTextures;
  46016. private _textures;
  46017. private _multiRenderTargetOptions;
  46018. /**
  46019. * Get if draw buffers are currently supported by the used hardware and browser.
  46020. */
  46021. readonly isSupported: boolean;
  46022. /**
  46023. * Get the list of textures generated by the multi render target.
  46024. */
  46025. readonly textures: Texture[];
  46026. /**
  46027. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46028. */
  46029. readonly depthTexture: Texture;
  46030. /**
  46031. * Set the wrapping mode on U of all the textures we are rendering to.
  46032. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46033. */
  46034. wrapU: number;
  46035. /**
  46036. * Set the wrapping mode on V of all the textures we are rendering to.
  46037. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46038. */
  46039. wrapV: number;
  46040. /**
  46041. * Instantiate a new multi render target texture.
  46042. * A multi render target, like a render target provides the ability to render to a texture.
  46043. * Unlike the render target, it can render to several draw buffers in one draw.
  46044. * This is specially interesting in deferred rendering or for any effects requiring more than
  46045. * just one color from a single pass.
  46046. * @param name Define the name of the texture
  46047. * @param size Define the size of the buffers to render to
  46048. * @param count Define the number of target we are rendering into
  46049. * @param scene Define the scene the texture belongs to
  46050. * @param options Define the options used to create the multi render target
  46051. */
  46052. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46053. /** @hidden */
  46054. _rebuild(): void;
  46055. private _createInternalTextures;
  46056. private _createTextures;
  46057. /**
  46058. * Define the number of samples used if MSAA is enabled.
  46059. */
  46060. samples: number;
  46061. /**
  46062. * Resize all the textures in the multi render target.
  46063. * Be carrefull as it will recreate all the data in the new texture.
  46064. * @param size Define the new size
  46065. */
  46066. resize(size: any): void;
  46067. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46068. /**
  46069. * Dispose the render targets and their associated resources
  46070. */
  46071. dispose(): void;
  46072. /**
  46073. * Release all the underlying texture used as draw buffers.
  46074. */
  46075. releaseInternalTextures(): void;
  46076. }
  46077. }
  46078. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46079. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46080. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46081. import { Nullable } from "babylonjs/types";
  46082. module "babylonjs/Engines/thinEngine" {
  46083. interface ThinEngine {
  46084. /**
  46085. * Unbind a list of render target textures from the webGL context
  46086. * This is used only when drawBuffer extension or webGL2 are active
  46087. * @param textures defines the render target textures to unbind
  46088. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46089. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46090. */
  46091. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46092. /**
  46093. * Create a multi render target texture
  46094. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46095. * @param size defines the size of the texture
  46096. * @param options defines the creation options
  46097. * @returns the cube texture as an InternalTexture
  46098. */
  46099. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46100. /**
  46101. * Update the sample count for a given multiple render target texture
  46102. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46103. * @param textures defines the textures to update
  46104. * @param samples defines the sample count to set
  46105. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46106. */
  46107. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46108. }
  46109. }
  46110. }
  46111. declare module "babylonjs/Engines/Extensions/index" {
  46112. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46113. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46114. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46115. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46116. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46117. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46118. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46119. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46120. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46121. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46122. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46123. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46124. }
  46125. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46126. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46127. /** @hidden */
  46128. export var rgbdEncodePixelShader: {
  46129. name: string;
  46130. shader: string;
  46131. };
  46132. }
  46133. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46134. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46135. /** @hidden */
  46136. export var rgbdDecodePixelShader: {
  46137. name: string;
  46138. shader: string;
  46139. };
  46140. }
  46141. declare module "babylonjs/Misc/environmentTextureTools" {
  46142. import { Nullable } from "babylonjs/types";
  46143. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46144. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46145. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46146. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46147. import "babylonjs/Shaders/rgbdEncode.fragment";
  46148. import "babylonjs/Shaders/rgbdDecode.fragment";
  46149. /**
  46150. * Raw texture data and descriptor sufficient for WebGL texture upload
  46151. */
  46152. export interface EnvironmentTextureInfo {
  46153. /**
  46154. * Version of the environment map
  46155. */
  46156. version: number;
  46157. /**
  46158. * Width of image
  46159. */
  46160. width: number;
  46161. /**
  46162. * Irradiance information stored in the file.
  46163. */
  46164. irradiance: any;
  46165. /**
  46166. * Specular information stored in the file.
  46167. */
  46168. specular: any;
  46169. }
  46170. /**
  46171. * Defines One Image in the file. It requires only the position in the file
  46172. * as well as the length.
  46173. */
  46174. interface BufferImageData {
  46175. /**
  46176. * Length of the image data.
  46177. */
  46178. length: number;
  46179. /**
  46180. * Position of the data from the null terminator delimiting the end of the JSON.
  46181. */
  46182. position: number;
  46183. }
  46184. /**
  46185. * Defines the specular data enclosed in the file.
  46186. * This corresponds to the version 1 of the data.
  46187. */
  46188. export interface EnvironmentTextureSpecularInfoV1 {
  46189. /**
  46190. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46191. */
  46192. specularDataPosition?: number;
  46193. /**
  46194. * This contains all the images data needed to reconstruct the cubemap.
  46195. */
  46196. mipmaps: Array<BufferImageData>;
  46197. /**
  46198. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46199. */
  46200. lodGenerationScale: number;
  46201. }
  46202. /**
  46203. * Sets of helpers addressing the serialization and deserialization of environment texture
  46204. * stored in a BabylonJS env file.
  46205. * Those files are usually stored as .env files.
  46206. */
  46207. export class EnvironmentTextureTools {
  46208. /**
  46209. * Magic number identifying the env file.
  46210. */
  46211. private static _MagicBytes;
  46212. /**
  46213. * Gets the environment info from an env file.
  46214. * @param data The array buffer containing the .env bytes.
  46215. * @returns the environment file info (the json header) if successfully parsed.
  46216. */
  46217. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46218. /**
  46219. * Creates an environment texture from a loaded cube texture.
  46220. * @param texture defines the cube texture to convert in env file
  46221. * @return a promise containing the environment data if succesfull.
  46222. */
  46223. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46224. /**
  46225. * Creates a JSON representation of the spherical data.
  46226. * @param texture defines the texture containing the polynomials
  46227. * @return the JSON representation of the spherical info
  46228. */
  46229. private static _CreateEnvTextureIrradiance;
  46230. /**
  46231. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46232. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46233. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46234. * @return the views described by info providing access to the underlying buffer
  46235. */
  46236. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46237. /**
  46238. * Uploads the texture info contained in the env file to the GPU.
  46239. * @param texture defines the internal texture to upload to
  46240. * @param arrayBuffer defines the buffer cotaining the data to load
  46241. * @param info defines the texture info retrieved through the GetEnvInfo method
  46242. * @returns a promise
  46243. */
  46244. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46245. /**
  46246. * Uploads the levels of image data to the GPU.
  46247. * @param texture defines the internal texture to upload to
  46248. * @param imageData defines the array buffer views of image data [mipmap][face]
  46249. * @returns a promise
  46250. */
  46251. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46252. /**
  46253. * Uploads spherical polynomials information to the texture.
  46254. * @param texture defines the texture we are trying to upload the information to
  46255. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46256. */
  46257. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46258. /** @hidden */
  46259. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46260. }
  46261. }
  46262. declare module "babylonjs/Maths/math.vertexFormat" {
  46263. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46264. /**
  46265. * Contains position and normal vectors for a vertex
  46266. */
  46267. export class PositionNormalVertex {
  46268. /** the position of the vertex (defaut: 0,0,0) */
  46269. position: Vector3;
  46270. /** the normal of the vertex (defaut: 0,1,0) */
  46271. normal: Vector3;
  46272. /**
  46273. * Creates a PositionNormalVertex
  46274. * @param position the position of the vertex (defaut: 0,0,0)
  46275. * @param normal the normal of the vertex (defaut: 0,1,0)
  46276. */
  46277. constructor(
  46278. /** the position of the vertex (defaut: 0,0,0) */
  46279. position?: Vector3,
  46280. /** the normal of the vertex (defaut: 0,1,0) */
  46281. normal?: Vector3);
  46282. /**
  46283. * Clones the PositionNormalVertex
  46284. * @returns the cloned PositionNormalVertex
  46285. */
  46286. clone(): PositionNormalVertex;
  46287. }
  46288. /**
  46289. * Contains position, normal and uv vectors for a vertex
  46290. */
  46291. export class PositionNormalTextureVertex {
  46292. /** the position of the vertex (defaut: 0,0,0) */
  46293. position: Vector3;
  46294. /** the normal of the vertex (defaut: 0,1,0) */
  46295. normal: Vector3;
  46296. /** the uv of the vertex (default: 0,0) */
  46297. uv: Vector2;
  46298. /**
  46299. * Creates a PositionNormalTextureVertex
  46300. * @param position the position of the vertex (defaut: 0,0,0)
  46301. * @param normal the normal of the vertex (defaut: 0,1,0)
  46302. * @param uv the uv of the vertex (default: 0,0)
  46303. */
  46304. constructor(
  46305. /** the position of the vertex (defaut: 0,0,0) */
  46306. position?: Vector3,
  46307. /** the normal of the vertex (defaut: 0,1,0) */
  46308. normal?: Vector3,
  46309. /** the uv of the vertex (default: 0,0) */
  46310. uv?: Vector2);
  46311. /**
  46312. * Clones the PositionNormalTextureVertex
  46313. * @returns the cloned PositionNormalTextureVertex
  46314. */
  46315. clone(): PositionNormalTextureVertex;
  46316. }
  46317. }
  46318. declare module "babylonjs/Maths/math" {
  46319. export * from "babylonjs/Maths/math.axis";
  46320. export * from "babylonjs/Maths/math.color";
  46321. export * from "babylonjs/Maths/math.constants";
  46322. export * from "babylonjs/Maths/math.frustum";
  46323. export * from "babylonjs/Maths/math.path";
  46324. export * from "babylonjs/Maths/math.plane";
  46325. export * from "babylonjs/Maths/math.size";
  46326. export * from "babylonjs/Maths/math.vector";
  46327. export * from "babylonjs/Maths/math.vertexFormat";
  46328. export * from "babylonjs/Maths/math.viewport";
  46329. }
  46330. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46331. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46332. /** @hidden */
  46333. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46334. private _genericAttributeLocation;
  46335. private _varyingLocationCount;
  46336. private _varyingLocationMap;
  46337. private _replacements;
  46338. private _textureCount;
  46339. private _uniforms;
  46340. lineProcessor(line: string): string;
  46341. attributeProcessor(attribute: string): string;
  46342. varyingProcessor(varying: string, isFragment: boolean): string;
  46343. uniformProcessor(uniform: string): string;
  46344. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46345. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46346. }
  46347. }
  46348. declare module "babylonjs/Engines/nativeEngine" {
  46349. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46350. import { Engine } from "babylonjs/Engines/engine";
  46351. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46353. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46354. import { Effect } from "babylonjs/Materials/effect";
  46355. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46356. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46357. import { Scene } from "babylonjs/scene";
  46358. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46359. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46360. /**
  46361. * Container for accessors for natively-stored mesh data buffers.
  46362. */
  46363. class NativeDataBuffer extends DataBuffer {
  46364. /**
  46365. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46366. */
  46367. nativeIndexBuffer?: any;
  46368. /**
  46369. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46370. */
  46371. nativeVertexBuffer?: any;
  46372. }
  46373. /** @hidden */
  46374. export class NativeEngine extends Engine {
  46375. private readonly _native;
  46376. getHardwareScalingLevel(): number;
  46377. constructor();
  46378. /**
  46379. * Can be used to override the current requestAnimationFrame requester.
  46380. * @hidden
  46381. */
  46382. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46383. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46384. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46385. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46386. recordVertexArrayObject(vertexBuffers: {
  46387. [key: string]: VertexBuffer;
  46388. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46389. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46390. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46391. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46392. /**
  46393. * Draw a list of indexed primitives
  46394. * @param fillMode defines the primitive to use
  46395. * @param indexStart defines the starting index
  46396. * @param indexCount defines the number of index to draw
  46397. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46398. */
  46399. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46400. /**
  46401. * Draw a list of unindexed primitives
  46402. * @param fillMode defines the primitive to use
  46403. * @param verticesStart defines the index of first vertex to draw
  46404. * @param verticesCount defines the count of vertices to draw
  46405. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46406. */
  46407. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46408. createPipelineContext(): IPipelineContext;
  46409. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46410. /** @hidden */
  46411. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46412. /** @hidden */
  46413. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46414. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46415. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46416. protected _setProgram(program: WebGLProgram): void;
  46417. _releaseEffect(effect: Effect): void;
  46418. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46419. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46420. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46421. bindSamplers(effect: Effect): void;
  46422. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46423. getRenderWidth(useScreen?: boolean): number;
  46424. getRenderHeight(useScreen?: boolean): number;
  46425. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46426. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46427. /**
  46428. * Set the z offset to apply to current rendering
  46429. * @param value defines the offset to apply
  46430. */
  46431. setZOffset(value: number): void;
  46432. /**
  46433. * Gets the current value of the zOffset
  46434. * @returns the current zOffset state
  46435. */
  46436. getZOffset(): number;
  46437. /**
  46438. * Enable or disable depth buffering
  46439. * @param enable defines the state to set
  46440. */
  46441. setDepthBuffer(enable: boolean): void;
  46442. /**
  46443. * Gets a boolean indicating if depth writing is enabled
  46444. * @returns the current depth writing state
  46445. */
  46446. getDepthWrite(): boolean;
  46447. /**
  46448. * Enable or disable depth writing
  46449. * @param enable defines the state to set
  46450. */
  46451. setDepthWrite(enable: boolean): void;
  46452. /**
  46453. * Enable or disable color writing
  46454. * @param enable defines the state to set
  46455. */
  46456. setColorWrite(enable: boolean): void;
  46457. /**
  46458. * Gets a boolean indicating if color writing is enabled
  46459. * @returns the current color writing state
  46460. */
  46461. getColorWrite(): boolean;
  46462. /**
  46463. * Sets alpha constants used by some alpha blending modes
  46464. * @param r defines the red component
  46465. * @param g defines the green component
  46466. * @param b defines the blue component
  46467. * @param a defines the alpha component
  46468. */
  46469. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46470. /**
  46471. * Sets the current alpha mode
  46472. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46473. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46474. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46475. */
  46476. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46477. /**
  46478. * Gets the current alpha mode
  46479. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46480. * @returns the current alpha mode
  46481. */
  46482. getAlphaMode(): number;
  46483. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46484. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46485. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46486. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46487. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46488. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46489. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46490. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46491. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46492. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46493. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46494. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46495. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46496. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46497. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46498. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46499. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46500. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46501. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46502. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46503. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46504. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46505. wipeCaches(bruteForce?: boolean): void;
  46506. _createTexture(): WebGLTexture;
  46507. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46508. /**
  46509. * Usually called from BABYLON.Texture.ts.
  46510. * Passed information to create a WebGLTexture
  46511. * @param urlArg defines a value which contains one of the following:
  46512. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46513. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46514. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46515. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46516. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46517. * @param scene needed for loading to the correct scene
  46518. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46519. * @param onLoad optional callback to be called upon successful completion
  46520. * @param onError optional callback to be called upon failure
  46521. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46522. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46523. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46524. * @param forcedExtension defines the extension to use to pick the right loader
  46525. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46526. */
  46527. 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;
  46528. /**
  46529. * Creates a cube texture
  46530. * @param rootUrl defines the url where the files to load is located
  46531. * @param scene defines the current scene
  46532. * @param files defines the list of files to load (1 per face)
  46533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46534. * @param onLoad defines an optional callback raised when the texture is loaded
  46535. * @param onError defines an optional callback raised if there is an issue to load the texture
  46536. * @param format defines the format of the data
  46537. * @param forcedExtension defines the extension to use to pick the right loader
  46538. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46539. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46540. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46541. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46542. * @returns the cube texture as an InternalTexture
  46543. */
  46544. 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;
  46545. private _getSamplingFilter;
  46546. private static _GetNativeTextureFormat;
  46547. createRenderTargetTexture(size: number | {
  46548. width: number;
  46549. height: number;
  46550. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46551. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46552. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46553. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46554. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46555. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46556. /**
  46557. * Updates a dynamic vertex buffer.
  46558. * @param vertexBuffer the vertex buffer to update
  46559. * @param data the data used to update the vertex buffer
  46560. * @param byteOffset the byte offset of the data (optional)
  46561. * @param byteLength the byte length of the data (optional)
  46562. */
  46563. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46564. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46565. private _updateAnisotropicLevel;
  46566. private _getAddressMode;
  46567. /** @hidden */
  46568. _bindTexture(channel: number, texture: InternalTexture): void;
  46569. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46570. releaseEffects(): void;
  46571. /** @hidden */
  46572. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46573. /** @hidden */
  46574. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46575. /** @hidden */
  46576. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46577. /** @hidden */
  46578. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46579. }
  46580. }
  46581. declare module "babylonjs/Engines/index" {
  46582. export * from "babylonjs/Engines/constants";
  46583. export * from "babylonjs/Engines/engineCapabilities";
  46584. export * from "babylonjs/Engines/instancingAttributeInfo";
  46585. export * from "babylonjs/Engines/thinEngine";
  46586. export * from "babylonjs/Engines/engine";
  46587. export * from "babylonjs/Engines/engineStore";
  46588. export * from "babylonjs/Engines/nullEngine";
  46589. export * from "babylonjs/Engines/Extensions/index";
  46590. export * from "babylonjs/Engines/IPipelineContext";
  46591. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46592. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46593. export * from "babylonjs/Engines/nativeEngine";
  46594. }
  46595. declare module "babylonjs/Events/clipboardEvents" {
  46596. /**
  46597. * Gather the list of clipboard event types as constants.
  46598. */
  46599. export class ClipboardEventTypes {
  46600. /**
  46601. * The clipboard event is fired when a copy command is active (pressed).
  46602. */
  46603. static readonly COPY: number;
  46604. /**
  46605. * The clipboard event is fired when a cut command is active (pressed).
  46606. */
  46607. static readonly CUT: number;
  46608. /**
  46609. * The clipboard event is fired when a paste command is active (pressed).
  46610. */
  46611. static readonly PASTE: number;
  46612. }
  46613. /**
  46614. * This class is used to store clipboard related info for the onClipboardObservable event.
  46615. */
  46616. export class ClipboardInfo {
  46617. /**
  46618. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46619. */
  46620. type: number;
  46621. /**
  46622. * Defines the related dom event
  46623. */
  46624. event: ClipboardEvent;
  46625. /**
  46626. *Creates an instance of ClipboardInfo.
  46627. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46628. * @param event Defines the related dom event
  46629. */
  46630. constructor(
  46631. /**
  46632. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46633. */
  46634. type: number,
  46635. /**
  46636. * Defines the related dom event
  46637. */
  46638. event: ClipboardEvent);
  46639. /**
  46640. * Get the clipboard event's type from the keycode.
  46641. * @param keyCode Defines the keyCode for the current keyboard event.
  46642. * @return {number}
  46643. */
  46644. static GetTypeFromCharacter(keyCode: number): number;
  46645. }
  46646. }
  46647. declare module "babylonjs/Events/index" {
  46648. export * from "babylonjs/Events/keyboardEvents";
  46649. export * from "babylonjs/Events/pointerEvents";
  46650. export * from "babylonjs/Events/clipboardEvents";
  46651. }
  46652. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46653. import { Scene } from "babylonjs/scene";
  46654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46655. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46656. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46657. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46658. /**
  46659. * Google Daydream controller
  46660. */
  46661. export class DaydreamController extends WebVRController {
  46662. /**
  46663. * Base Url for the controller model.
  46664. */
  46665. static MODEL_BASE_URL: string;
  46666. /**
  46667. * File name for the controller model.
  46668. */
  46669. static MODEL_FILENAME: string;
  46670. /**
  46671. * Gamepad Id prefix used to identify Daydream Controller.
  46672. */
  46673. static readonly GAMEPAD_ID_PREFIX: string;
  46674. /**
  46675. * Creates a new DaydreamController from a gamepad
  46676. * @param vrGamepad the gamepad that the controller should be created from
  46677. */
  46678. constructor(vrGamepad: any);
  46679. /**
  46680. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46681. * @param scene scene in which to add meshes
  46682. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46683. */
  46684. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46685. /**
  46686. * Called once for each button that changed state since the last frame
  46687. * @param buttonIdx Which button index changed
  46688. * @param state New state of the button
  46689. * @param changes Which properties on the state changed since last frame
  46690. */
  46691. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46692. }
  46693. }
  46694. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46695. import { Scene } from "babylonjs/scene";
  46696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46697. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46698. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46699. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46700. /**
  46701. * Gear VR Controller
  46702. */
  46703. export class GearVRController extends WebVRController {
  46704. /**
  46705. * Base Url for the controller model.
  46706. */
  46707. static MODEL_BASE_URL: string;
  46708. /**
  46709. * File name for the controller model.
  46710. */
  46711. static MODEL_FILENAME: string;
  46712. /**
  46713. * Gamepad Id prefix used to identify this controller.
  46714. */
  46715. static readonly GAMEPAD_ID_PREFIX: string;
  46716. private readonly _buttonIndexToObservableNameMap;
  46717. /**
  46718. * Creates a new GearVRController from a gamepad
  46719. * @param vrGamepad the gamepad that the controller should be created from
  46720. */
  46721. constructor(vrGamepad: any);
  46722. /**
  46723. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46724. * @param scene scene in which to add meshes
  46725. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46726. */
  46727. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46728. /**
  46729. * Called once for each button that changed state since the last frame
  46730. * @param buttonIdx Which button index changed
  46731. * @param state New state of the button
  46732. * @param changes Which properties on the state changed since last frame
  46733. */
  46734. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46735. }
  46736. }
  46737. declare module "babylonjs/Gamepads/Controllers/index" {
  46738. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46739. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46740. export * from "babylonjs/Gamepads/Controllers/genericController";
  46741. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46742. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46743. export * from "babylonjs/Gamepads/Controllers/viveController";
  46744. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46745. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46746. }
  46747. declare module "babylonjs/Gamepads/index" {
  46748. export * from "babylonjs/Gamepads/Controllers/index";
  46749. export * from "babylonjs/Gamepads/gamepad";
  46750. export * from "babylonjs/Gamepads/gamepadManager";
  46751. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46752. export * from "babylonjs/Gamepads/xboxGamepad";
  46753. export * from "babylonjs/Gamepads/dualShockGamepad";
  46754. }
  46755. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46756. import { Scene } from "babylonjs/scene";
  46757. import { Vector4 } from "babylonjs/Maths/math.vector";
  46758. import { Color4 } from "babylonjs/Maths/math.color";
  46759. import { Mesh } from "babylonjs/Meshes/mesh";
  46760. import { Nullable } from "babylonjs/types";
  46761. /**
  46762. * Class containing static functions to help procedurally build meshes
  46763. */
  46764. export class PolyhedronBuilder {
  46765. /**
  46766. * Creates a polyhedron mesh
  46767. * * 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
  46768. * * The parameter `size` (positive float, default 1) sets the polygon size
  46769. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46770. * * 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`
  46771. * * 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
  46772. * * 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)`)
  46773. * * 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
  46774. * * 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
  46775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46778. * @param name defines the name of the mesh
  46779. * @param options defines the options used to create the mesh
  46780. * @param scene defines the hosting scene
  46781. * @returns the polyhedron mesh
  46782. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46783. */
  46784. static CreatePolyhedron(name: string, options: {
  46785. type?: number;
  46786. size?: number;
  46787. sizeX?: number;
  46788. sizeY?: number;
  46789. sizeZ?: number;
  46790. custom?: any;
  46791. faceUV?: Vector4[];
  46792. faceColors?: Color4[];
  46793. flat?: boolean;
  46794. updatable?: boolean;
  46795. sideOrientation?: number;
  46796. frontUVs?: Vector4;
  46797. backUVs?: Vector4;
  46798. }, scene?: Nullable<Scene>): Mesh;
  46799. }
  46800. }
  46801. declare module "babylonjs/Gizmos/scaleGizmo" {
  46802. import { Observable } from "babylonjs/Misc/observable";
  46803. import { Nullable } from "babylonjs/types";
  46804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46805. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46806. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46807. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46808. /**
  46809. * Gizmo that enables scaling a mesh along 3 axis
  46810. */
  46811. export class ScaleGizmo extends Gizmo {
  46812. /**
  46813. * Internal gizmo used for interactions on the x axis
  46814. */
  46815. xGizmo: AxisScaleGizmo;
  46816. /**
  46817. * Internal gizmo used for interactions on the y axis
  46818. */
  46819. yGizmo: AxisScaleGizmo;
  46820. /**
  46821. * Internal gizmo used for interactions on the z axis
  46822. */
  46823. zGizmo: AxisScaleGizmo;
  46824. /**
  46825. * Internal gizmo used to scale all axis equally
  46826. */
  46827. uniformScaleGizmo: AxisScaleGizmo;
  46828. private _meshAttached;
  46829. private _updateGizmoRotationToMatchAttachedMesh;
  46830. private _snapDistance;
  46831. private _scaleRatio;
  46832. private _uniformScalingMesh;
  46833. private _octahedron;
  46834. /** Fires an event when any of it's sub gizmos are dragged */
  46835. onDragStartObservable: Observable<unknown>;
  46836. /** Fires an event when any of it's sub gizmos are released from dragging */
  46837. onDragEndObservable: Observable<unknown>;
  46838. attachedMesh: Nullable<AbstractMesh>;
  46839. /**
  46840. * Creates a ScaleGizmo
  46841. * @param gizmoLayer The utility layer the gizmo will be added to
  46842. */
  46843. constructor(gizmoLayer?: UtilityLayerRenderer);
  46844. updateGizmoRotationToMatchAttachedMesh: boolean;
  46845. /**
  46846. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46847. */
  46848. snapDistance: number;
  46849. /**
  46850. * Ratio for the scale of the gizmo (Default: 1)
  46851. */
  46852. scaleRatio: number;
  46853. /**
  46854. * Disposes of the gizmo
  46855. */
  46856. dispose(): void;
  46857. }
  46858. }
  46859. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46860. import { Observable } from "babylonjs/Misc/observable";
  46861. import { Nullable } from "babylonjs/types";
  46862. import { Vector3 } from "babylonjs/Maths/math.vector";
  46863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46864. import { Mesh } from "babylonjs/Meshes/mesh";
  46865. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46866. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46867. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46868. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46869. import { Color3 } from "babylonjs/Maths/math.color";
  46870. /**
  46871. * Single axis scale gizmo
  46872. */
  46873. export class AxisScaleGizmo extends Gizmo {
  46874. /**
  46875. * Drag behavior responsible for the gizmos dragging interactions
  46876. */
  46877. dragBehavior: PointerDragBehavior;
  46878. private _pointerObserver;
  46879. /**
  46880. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46881. */
  46882. snapDistance: number;
  46883. /**
  46884. * Event that fires each time the gizmo snaps to a new location.
  46885. * * snapDistance is the the change in distance
  46886. */
  46887. onSnapObservable: Observable<{
  46888. snapDistance: number;
  46889. }>;
  46890. /**
  46891. * If the scaling operation should be done on all axis (default: false)
  46892. */
  46893. uniformScaling: boolean;
  46894. private _isEnabled;
  46895. private _parent;
  46896. private _arrow;
  46897. private _coloredMaterial;
  46898. private _hoverMaterial;
  46899. /**
  46900. * Creates an AxisScaleGizmo
  46901. * @param gizmoLayer The utility layer the gizmo will be added to
  46902. * @param dragAxis The axis which the gizmo will be able to scale on
  46903. * @param color The color of the gizmo
  46904. */
  46905. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46906. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46907. /**
  46908. * If the gizmo is enabled
  46909. */
  46910. isEnabled: boolean;
  46911. /**
  46912. * Disposes of the gizmo
  46913. */
  46914. dispose(): void;
  46915. /**
  46916. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46917. * @param mesh The mesh to replace the default mesh of the gizmo
  46918. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46919. */
  46920. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46921. }
  46922. }
  46923. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46924. import { Observable } from "babylonjs/Misc/observable";
  46925. import { Nullable } from "babylonjs/types";
  46926. import { Vector3 } from "babylonjs/Maths/math.vector";
  46927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46928. import { Mesh } from "babylonjs/Meshes/mesh";
  46929. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46930. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46931. import { Color3 } from "babylonjs/Maths/math.color";
  46932. import "babylonjs/Meshes/Builders/boxBuilder";
  46933. /**
  46934. * Bounding box gizmo
  46935. */
  46936. export class BoundingBoxGizmo extends Gizmo {
  46937. private _lineBoundingBox;
  46938. private _rotateSpheresParent;
  46939. private _scaleBoxesParent;
  46940. private _boundingDimensions;
  46941. private _renderObserver;
  46942. private _pointerObserver;
  46943. private _scaleDragSpeed;
  46944. private _tmpQuaternion;
  46945. private _tmpVector;
  46946. private _tmpRotationMatrix;
  46947. /**
  46948. * 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)
  46949. */
  46950. ignoreChildren: boolean;
  46951. /**
  46952. * 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)
  46953. */
  46954. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46955. /**
  46956. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46957. */
  46958. rotationSphereSize: number;
  46959. /**
  46960. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46961. */
  46962. scaleBoxSize: number;
  46963. /**
  46964. * 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)
  46965. */
  46966. fixedDragMeshScreenSize: boolean;
  46967. /**
  46968. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46969. */
  46970. fixedDragMeshScreenSizeDistanceFactor: number;
  46971. /**
  46972. * Fired when a rotation sphere or scale box is dragged
  46973. */
  46974. onDragStartObservable: Observable<{}>;
  46975. /**
  46976. * Fired when a scale box is dragged
  46977. */
  46978. onScaleBoxDragObservable: Observable<{}>;
  46979. /**
  46980. * Fired when a scale box drag is ended
  46981. */
  46982. onScaleBoxDragEndObservable: Observable<{}>;
  46983. /**
  46984. * Fired when a rotation sphere is dragged
  46985. */
  46986. onRotationSphereDragObservable: Observable<{}>;
  46987. /**
  46988. * Fired when a rotation sphere drag is ended
  46989. */
  46990. onRotationSphereDragEndObservable: Observable<{}>;
  46991. /**
  46992. * 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)
  46993. */
  46994. scalePivot: Nullable<Vector3>;
  46995. /**
  46996. * Mesh used as a pivot to rotate the attached mesh
  46997. */
  46998. private _anchorMesh;
  46999. private _existingMeshScale;
  47000. private _dragMesh;
  47001. private pointerDragBehavior;
  47002. private coloredMaterial;
  47003. private hoverColoredMaterial;
  47004. /**
  47005. * Sets the color of the bounding box gizmo
  47006. * @param color the color to set
  47007. */
  47008. setColor(color: Color3): void;
  47009. /**
  47010. * Creates an BoundingBoxGizmo
  47011. * @param gizmoLayer The utility layer the gizmo will be added to
  47012. * @param color The color of the gizmo
  47013. */
  47014. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47015. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47016. private _selectNode;
  47017. /**
  47018. * Updates the bounding box information for the Gizmo
  47019. */
  47020. updateBoundingBox(): void;
  47021. private _updateRotationSpheres;
  47022. private _updateScaleBoxes;
  47023. /**
  47024. * Enables rotation on the specified axis and disables rotation on the others
  47025. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47026. */
  47027. setEnabledRotationAxis(axis: string): void;
  47028. /**
  47029. * Enables/disables scaling
  47030. * @param enable if scaling should be enabled
  47031. */
  47032. setEnabledScaling(enable: boolean): void;
  47033. private _updateDummy;
  47034. /**
  47035. * Enables a pointer drag behavior on the bounding box of the gizmo
  47036. */
  47037. enableDragBehavior(): void;
  47038. /**
  47039. * Disposes of the gizmo
  47040. */
  47041. dispose(): void;
  47042. /**
  47043. * 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)
  47044. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47045. * @returns the bounding box mesh with the passed in mesh as a child
  47046. */
  47047. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47048. /**
  47049. * CustomMeshes are not supported by this gizmo
  47050. * @param mesh The mesh to replace the default mesh of the gizmo
  47051. */
  47052. setCustomMesh(mesh: Mesh): void;
  47053. }
  47054. }
  47055. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47056. import { Observable } from "babylonjs/Misc/observable";
  47057. import { Nullable } from "babylonjs/types";
  47058. import { Vector3 } from "babylonjs/Maths/math.vector";
  47059. import { Color3 } from "babylonjs/Maths/math.color";
  47060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47061. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47062. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47063. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47064. import "babylonjs/Meshes/Builders/linesBuilder";
  47065. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47066. /**
  47067. * Single plane rotation gizmo
  47068. */
  47069. export class PlaneRotationGizmo extends Gizmo {
  47070. /**
  47071. * Drag behavior responsible for the gizmos dragging interactions
  47072. */
  47073. dragBehavior: PointerDragBehavior;
  47074. private _pointerObserver;
  47075. /**
  47076. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47077. */
  47078. snapDistance: number;
  47079. /**
  47080. * Event that fires each time the gizmo snaps to a new location.
  47081. * * snapDistance is the the change in distance
  47082. */
  47083. onSnapObservable: Observable<{
  47084. snapDistance: number;
  47085. }>;
  47086. private _isEnabled;
  47087. private _parent;
  47088. /**
  47089. * Creates a PlaneRotationGizmo
  47090. * @param gizmoLayer The utility layer the gizmo will be added to
  47091. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47092. * @param color The color of the gizmo
  47093. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47094. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47095. */
  47096. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47097. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47098. /**
  47099. * If the gizmo is enabled
  47100. */
  47101. isEnabled: boolean;
  47102. /**
  47103. * Disposes of the gizmo
  47104. */
  47105. dispose(): void;
  47106. }
  47107. }
  47108. declare module "babylonjs/Gizmos/rotationGizmo" {
  47109. import { Observable } from "babylonjs/Misc/observable";
  47110. import { Nullable } from "babylonjs/types";
  47111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47112. import { Mesh } from "babylonjs/Meshes/mesh";
  47113. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47114. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47115. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47116. /**
  47117. * Gizmo that enables rotating a mesh along 3 axis
  47118. */
  47119. export class RotationGizmo extends Gizmo {
  47120. /**
  47121. * Internal gizmo used for interactions on the x axis
  47122. */
  47123. xGizmo: PlaneRotationGizmo;
  47124. /**
  47125. * Internal gizmo used for interactions on the y axis
  47126. */
  47127. yGizmo: PlaneRotationGizmo;
  47128. /**
  47129. * Internal gizmo used for interactions on the z axis
  47130. */
  47131. zGizmo: PlaneRotationGizmo;
  47132. /** Fires an event when any of it's sub gizmos are dragged */
  47133. onDragStartObservable: Observable<unknown>;
  47134. /** Fires an event when any of it's sub gizmos are released from dragging */
  47135. onDragEndObservable: Observable<unknown>;
  47136. private _meshAttached;
  47137. attachedMesh: Nullable<AbstractMesh>;
  47138. /**
  47139. * Creates a RotationGizmo
  47140. * @param gizmoLayer The utility layer the gizmo will be added to
  47141. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47142. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47143. */
  47144. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47145. updateGizmoRotationToMatchAttachedMesh: boolean;
  47146. /**
  47147. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47148. */
  47149. snapDistance: number;
  47150. /**
  47151. * Ratio for the scale of the gizmo (Default: 1)
  47152. */
  47153. scaleRatio: number;
  47154. /**
  47155. * Disposes of the gizmo
  47156. */
  47157. dispose(): void;
  47158. /**
  47159. * CustomMeshes are not supported by this gizmo
  47160. * @param mesh The mesh to replace the default mesh of the gizmo
  47161. */
  47162. setCustomMesh(mesh: Mesh): void;
  47163. }
  47164. }
  47165. declare module "babylonjs/Gizmos/gizmoManager" {
  47166. import { Observable } from "babylonjs/Misc/observable";
  47167. import { Nullable } from "babylonjs/types";
  47168. import { Scene, IDisposable } from "babylonjs/scene";
  47169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47170. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47171. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47172. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47173. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47174. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47175. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47176. /**
  47177. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47178. */
  47179. export class GizmoManager implements IDisposable {
  47180. private scene;
  47181. /**
  47182. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47183. */
  47184. gizmos: {
  47185. positionGizmo: Nullable<PositionGizmo>;
  47186. rotationGizmo: Nullable<RotationGizmo>;
  47187. scaleGizmo: Nullable<ScaleGizmo>;
  47188. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47189. };
  47190. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47191. clearGizmoOnEmptyPointerEvent: boolean;
  47192. /** Fires an event when the manager is attached to a mesh */
  47193. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47194. private _gizmosEnabled;
  47195. private _pointerObserver;
  47196. private _attachedMesh;
  47197. private _boundingBoxColor;
  47198. private _defaultUtilityLayer;
  47199. private _defaultKeepDepthUtilityLayer;
  47200. /**
  47201. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47202. */
  47203. boundingBoxDragBehavior: SixDofDragBehavior;
  47204. /**
  47205. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47206. */
  47207. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47208. /**
  47209. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47210. */
  47211. usePointerToAttachGizmos: boolean;
  47212. /**
  47213. * Utility layer that the bounding box gizmo belongs to
  47214. */
  47215. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47216. /**
  47217. * Utility layer that all gizmos besides bounding box belong to
  47218. */
  47219. readonly utilityLayer: UtilityLayerRenderer;
  47220. /**
  47221. * Instatiates a gizmo manager
  47222. * @param scene the scene to overlay the gizmos on top of
  47223. */
  47224. constructor(scene: Scene);
  47225. /**
  47226. * Attaches a set of gizmos to the specified mesh
  47227. * @param mesh The mesh the gizmo's should be attached to
  47228. */
  47229. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47230. /**
  47231. * If the position gizmo is enabled
  47232. */
  47233. positionGizmoEnabled: boolean;
  47234. /**
  47235. * If the rotation gizmo is enabled
  47236. */
  47237. rotationGizmoEnabled: boolean;
  47238. /**
  47239. * If the scale gizmo is enabled
  47240. */
  47241. scaleGizmoEnabled: boolean;
  47242. /**
  47243. * If the boundingBox gizmo is enabled
  47244. */
  47245. boundingBoxGizmoEnabled: boolean;
  47246. /**
  47247. * Disposes of the gizmo manager
  47248. */
  47249. dispose(): void;
  47250. }
  47251. }
  47252. declare module "babylonjs/Lights/directionalLight" {
  47253. import { Camera } from "babylonjs/Cameras/camera";
  47254. import { Scene } from "babylonjs/scene";
  47255. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47257. import { Light } from "babylonjs/Lights/light";
  47258. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47259. import { Effect } from "babylonjs/Materials/effect";
  47260. /**
  47261. * A directional light is defined by a direction (what a surprise!).
  47262. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47263. * 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.
  47264. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47265. */
  47266. export class DirectionalLight extends ShadowLight {
  47267. private _shadowFrustumSize;
  47268. /**
  47269. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47270. */
  47271. /**
  47272. * Specifies a fix frustum size for the shadow generation.
  47273. */
  47274. shadowFrustumSize: number;
  47275. private _shadowOrthoScale;
  47276. /**
  47277. * Gets the shadow projection scale against the optimal computed one.
  47278. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47279. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47280. */
  47281. /**
  47282. * Sets the shadow projection scale against the optimal computed one.
  47283. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47284. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47285. */
  47286. shadowOrthoScale: number;
  47287. /**
  47288. * Automatically compute the projection matrix to best fit (including all the casters)
  47289. * on each frame.
  47290. */
  47291. autoUpdateExtends: boolean;
  47292. private _orthoLeft;
  47293. private _orthoRight;
  47294. private _orthoTop;
  47295. private _orthoBottom;
  47296. /**
  47297. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47298. * The directional light is emitted from everywhere in the given direction.
  47299. * It can cast shadows.
  47300. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47301. * @param name The friendly name of the light
  47302. * @param direction The direction of the light
  47303. * @param scene The scene the light belongs to
  47304. */
  47305. constructor(name: string, direction: Vector3, scene: Scene);
  47306. /**
  47307. * Returns the string "DirectionalLight".
  47308. * @return The class name
  47309. */
  47310. getClassName(): string;
  47311. /**
  47312. * Returns the integer 1.
  47313. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47314. */
  47315. getTypeID(): number;
  47316. /**
  47317. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47318. * Returns the DirectionalLight Shadow projection matrix.
  47319. */
  47320. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47321. /**
  47322. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47323. * Returns the DirectionalLight Shadow projection matrix.
  47324. */
  47325. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47326. /**
  47327. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47328. * Returns the DirectionalLight Shadow projection matrix.
  47329. */
  47330. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47331. protected _buildUniformLayout(): void;
  47332. /**
  47333. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47334. * @param effect The effect to update
  47335. * @param lightIndex The index of the light in the effect to update
  47336. * @returns The directional light
  47337. */
  47338. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47339. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47340. /**
  47341. * Gets the minZ used for shadow according to both the scene and the light.
  47342. *
  47343. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47344. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47345. * @param activeCamera The camera we are returning the min for
  47346. * @returns the depth min z
  47347. */
  47348. getDepthMinZ(activeCamera: Camera): number;
  47349. /**
  47350. * Gets the maxZ used for shadow according to both the scene and the light.
  47351. *
  47352. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47353. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47354. * @param activeCamera The camera we are returning the max for
  47355. * @returns the depth max z
  47356. */
  47357. getDepthMaxZ(activeCamera: Camera): number;
  47358. /**
  47359. * Prepares the list of defines specific to the light type.
  47360. * @param defines the list of defines
  47361. * @param lightIndex defines the index of the light for the effect
  47362. */
  47363. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47364. }
  47365. }
  47366. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47367. import { Mesh } from "babylonjs/Meshes/mesh";
  47368. /**
  47369. * Class containing static functions to help procedurally build meshes
  47370. */
  47371. export class HemisphereBuilder {
  47372. /**
  47373. * Creates a hemisphere mesh
  47374. * @param name defines the name of the mesh
  47375. * @param options defines the options used to create the mesh
  47376. * @param scene defines the hosting scene
  47377. * @returns the hemisphere mesh
  47378. */
  47379. static CreateHemisphere(name: string, options: {
  47380. segments?: number;
  47381. diameter?: number;
  47382. sideOrientation?: number;
  47383. }, scene: any): Mesh;
  47384. }
  47385. }
  47386. declare module "babylonjs/Lights/spotLight" {
  47387. import { Nullable } from "babylonjs/types";
  47388. import { Scene } from "babylonjs/scene";
  47389. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47391. import { Effect } from "babylonjs/Materials/effect";
  47392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47393. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47394. /**
  47395. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47396. * These values define a cone of light starting from the position, emitting toward the direction.
  47397. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47398. * and the exponent defines the speed of the decay of the light with distance (reach).
  47399. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47400. */
  47401. export class SpotLight extends ShadowLight {
  47402. private _angle;
  47403. private _innerAngle;
  47404. private _cosHalfAngle;
  47405. private _lightAngleScale;
  47406. private _lightAngleOffset;
  47407. /**
  47408. * Gets the cone angle of the spot light in Radians.
  47409. */
  47410. /**
  47411. * Sets the cone angle of the spot light in Radians.
  47412. */
  47413. angle: number;
  47414. /**
  47415. * Only used in gltf falloff mode, this defines the angle where
  47416. * the directional falloff will start before cutting at angle which could be seen
  47417. * as outer angle.
  47418. */
  47419. /**
  47420. * Only used in gltf falloff mode, this defines the angle where
  47421. * the directional falloff will start before cutting at angle which could be seen
  47422. * as outer angle.
  47423. */
  47424. innerAngle: number;
  47425. private _shadowAngleScale;
  47426. /**
  47427. * Allows scaling the angle of the light for shadow generation only.
  47428. */
  47429. /**
  47430. * Allows scaling the angle of the light for shadow generation only.
  47431. */
  47432. shadowAngleScale: number;
  47433. /**
  47434. * The light decay speed with the distance from the emission spot.
  47435. */
  47436. exponent: number;
  47437. private _projectionTextureMatrix;
  47438. /**
  47439. * Allows reading the projecton texture
  47440. */
  47441. readonly projectionTextureMatrix: Matrix;
  47442. protected _projectionTextureLightNear: number;
  47443. /**
  47444. * Gets the near clip of the Spotlight for texture projection.
  47445. */
  47446. /**
  47447. * Sets the near clip of the Spotlight for texture projection.
  47448. */
  47449. projectionTextureLightNear: number;
  47450. protected _projectionTextureLightFar: number;
  47451. /**
  47452. * Gets the far clip of the Spotlight for texture projection.
  47453. */
  47454. /**
  47455. * Sets the far clip of the Spotlight for texture projection.
  47456. */
  47457. projectionTextureLightFar: number;
  47458. protected _projectionTextureUpDirection: Vector3;
  47459. /**
  47460. * Gets the Up vector of the Spotlight for texture projection.
  47461. */
  47462. /**
  47463. * Sets the Up vector of the Spotlight for texture projection.
  47464. */
  47465. projectionTextureUpDirection: Vector3;
  47466. private _projectionTexture;
  47467. /**
  47468. * Gets the projection texture of the light.
  47469. */
  47470. /**
  47471. * Sets the projection texture of the light.
  47472. */
  47473. projectionTexture: Nullable<BaseTexture>;
  47474. private _projectionTextureViewLightDirty;
  47475. private _projectionTextureProjectionLightDirty;
  47476. private _projectionTextureDirty;
  47477. private _projectionTextureViewTargetVector;
  47478. private _projectionTextureViewLightMatrix;
  47479. private _projectionTextureProjectionLightMatrix;
  47480. private _projectionTextureScalingMatrix;
  47481. /**
  47482. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47483. * It can cast shadows.
  47484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47485. * @param name The light friendly name
  47486. * @param position The position of the spot light in the scene
  47487. * @param direction The direction of the light in the scene
  47488. * @param angle The cone angle of the light in Radians
  47489. * @param exponent The light decay speed with the distance from the emission spot
  47490. * @param scene The scene the lights belongs to
  47491. */
  47492. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47493. /**
  47494. * Returns the string "SpotLight".
  47495. * @returns the class name
  47496. */
  47497. getClassName(): string;
  47498. /**
  47499. * Returns the integer 2.
  47500. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47501. */
  47502. getTypeID(): number;
  47503. /**
  47504. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47505. */
  47506. protected _setDirection(value: Vector3): void;
  47507. /**
  47508. * Overrides the position setter to recompute the projection texture view light Matrix.
  47509. */
  47510. protected _setPosition(value: Vector3): void;
  47511. /**
  47512. * 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.
  47513. * Returns the SpotLight.
  47514. */
  47515. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47516. protected _computeProjectionTextureViewLightMatrix(): void;
  47517. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47518. /**
  47519. * Main function for light texture projection matrix computing.
  47520. */
  47521. protected _computeProjectionTextureMatrix(): void;
  47522. protected _buildUniformLayout(): void;
  47523. private _computeAngleValues;
  47524. /**
  47525. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47526. * @param effect The effect to update
  47527. * @param lightIndex The index of the light in the effect to update
  47528. * @returns The spot light
  47529. */
  47530. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47531. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47532. /**
  47533. * Disposes the light and the associated resources.
  47534. */
  47535. dispose(): void;
  47536. /**
  47537. * Prepares the list of defines specific to the light type.
  47538. * @param defines the list of defines
  47539. * @param lightIndex defines the index of the light for the effect
  47540. */
  47541. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47542. }
  47543. }
  47544. declare module "babylonjs/Gizmos/lightGizmo" {
  47545. import { Nullable } from "babylonjs/types";
  47546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47547. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47548. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47549. import { Light } from "babylonjs/Lights/light";
  47550. /**
  47551. * Gizmo that enables viewing a light
  47552. */
  47553. export class LightGizmo extends Gizmo {
  47554. private _lightMesh;
  47555. private _material;
  47556. private cachedPosition;
  47557. private cachedForward;
  47558. /**
  47559. * Creates a LightGizmo
  47560. * @param gizmoLayer The utility layer the gizmo will be added to
  47561. */
  47562. constructor(gizmoLayer?: UtilityLayerRenderer);
  47563. private _light;
  47564. /**
  47565. * The light that the gizmo is attached to
  47566. */
  47567. light: Nullable<Light>;
  47568. /**
  47569. * Gets the material used to render the light gizmo
  47570. */
  47571. readonly material: StandardMaterial;
  47572. /**
  47573. * @hidden
  47574. * Updates the gizmo to match the attached mesh's position/rotation
  47575. */
  47576. protected _update(): void;
  47577. private static _Scale;
  47578. /**
  47579. * Creates the lines for a light mesh
  47580. */
  47581. private static _createLightLines;
  47582. /**
  47583. * Disposes of the light gizmo
  47584. */
  47585. dispose(): void;
  47586. private static _CreateHemisphericLightMesh;
  47587. private static _CreatePointLightMesh;
  47588. private static _CreateSpotLightMesh;
  47589. private static _CreateDirectionalLightMesh;
  47590. }
  47591. }
  47592. declare module "babylonjs/Gizmos/index" {
  47593. export * from "babylonjs/Gizmos/axisDragGizmo";
  47594. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47595. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47596. export * from "babylonjs/Gizmos/gizmo";
  47597. export * from "babylonjs/Gizmos/gizmoManager";
  47598. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47599. export * from "babylonjs/Gizmos/positionGizmo";
  47600. export * from "babylonjs/Gizmos/rotationGizmo";
  47601. export * from "babylonjs/Gizmos/scaleGizmo";
  47602. export * from "babylonjs/Gizmos/lightGizmo";
  47603. export * from "babylonjs/Gizmos/planeDragGizmo";
  47604. }
  47605. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47606. /** @hidden */
  47607. export var backgroundFragmentDeclaration: {
  47608. name: string;
  47609. shader: string;
  47610. };
  47611. }
  47612. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47613. /** @hidden */
  47614. export var backgroundUboDeclaration: {
  47615. name: string;
  47616. shader: string;
  47617. };
  47618. }
  47619. declare module "babylonjs/Shaders/background.fragment" {
  47620. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47621. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47622. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47623. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47624. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47625. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47626. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47627. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47628. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47629. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47630. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47631. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47632. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47633. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47634. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47635. /** @hidden */
  47636. export var backgroundPixelShader: {
  47637. name: string;
  47638. shader: string;
  47639. };
  47640. }
  47641. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47642. /** @hidden */
  47643. export var backgroundVertexDeclaration: {
  47644. name: string;
  47645. shader: string;
  47646. };
  47647. }
  47648. declare module "babylonjs/Shaders/background.vertex" {
  47649. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47650. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47651. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47652. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47653. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47654. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47655. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47656. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47657. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47658. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47659. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47660. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47661. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47662. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47663. /** @hidden */
  47664. export var backgroundVertexShader: {
  47665. name: string;
  47666. shader: string;
  47667. };
  47668. }
  47669. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47670. import { Nullable, int, float } from "babylonjs/types";
  47671. import { Scene } from "babylonjs/scene";
  47672. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47673. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47675. import { Mesh } from "babylonjs/Meshes/mesh";
  47676. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47677. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47678. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47680. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47681. import { Color3 } from "babylonjs/Maths/math.color";
  47682. import "babylonjs/Shaders/background.fragment";
  47683. import "babylonjs/Shaders/background.vertex";
  47684. /**
  47685. * Background material used to create an efficient environement around your scene.
  47686. */
  47687. export class BackgroundMaterial extends PushMaterial {
  47688. /**
  47689. * Standard reflectance value at parallel view angle.
  47690. */
  47691. static StandardReflectance0: number;
  47692. /**
  47693. * Standard reflectance value at grazing angle.
  47694. */
  47695. static StandardReflectance90: number;
  47696. protected _primaryColor: Color3;
  47697. /**
  47698. * Key light Color (multiply against the environement texture)
  47699. */
  47700. primaryColor: Color3;
  47701. protected __perceptualColor: Nullable<Color3>;
  47702. /**
  47703. * Experimental Internal Use Only.
  47704. *
  47705. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47706. * This acts as a helper to set the primary color to a more "human friendly" value.
  47707. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47708. * output color as close as possible from the chosen value.
  47709. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47710. * part of lighting setup.)
  47711. */
  47712. _perceptualColor: Nullable<Color3>;
  47713. protected _primaryColorShadowLevel: float;
  47714. /**
  47715. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47716. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47717. */
  47718. primaryColorShadowLevel: float;
  47719. protected _primaryColorHighlightLevel: float;
  47720. /**
  47721. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47722. * The primary color is used at the level chosen to define what the white area would look.
  47723. */
  47724. primaryColorHighlightLevel: float;
  47725. protected _reflectionTexture: Nullable<BaseTexture>;
  47726. /**
  47727. * Reflection Texture used in the material.
  47728. * Should be author in a specific way for the best result (refer to the documentation).
  47729. */
  47730. reflectionTexture: Nullable<BaseTexture>;
  47731. protected _reflectionBlur: float;
  47732. /**
  47733. * Reflection Texture level of blur.
  47734. *
  47735. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47736. * texture twice.
  47737. */
  47738. reflectionBlur: float;
  47739. protected _diffuseTexture: Nullable<BaseTexture>;
  47740. /**
  47741. * Diffuse Texture used in the material.
  47742. * Should be author in a specific way for the best result (refer to the documentation).
  47743. */
  47744. diffuseTexture: Nullable<BaseTexture>;
  47745. protected _shadowLights: Nullable<IShadowLight[]>;
  47746. /**
  47747. * Specify the list of lights casting shadow on the material.
  47748. * All scene shadow lights will be included if null.
  47749. */
  47750. shadowLights: Nullable<IShadowLight[]>;
  47751. protected _shadowLevel: float;
  47752. /**
  47753. * Helps adjusting the shadow to a softer level if required.
  47754. * 0 means black shadows and 1 means no shadows.
  47755. */
  47756. shadowLevel: float;
  47757. protected _sceneCenter: Vector3;
  47758. /**
  47759. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47760. * It is usually zero but might be interesting to modify according to your setup.
  47761. */
  47762. sceneCenter: Vector3;
  47763. protected _opacityFresnel: boolean;
  47764. /**
  47765. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47766. * This helps ensuring a nice transition when the camera goes under the ground.
  47767. */
  47768. opacityFresnel: boolean;
  47769. protected _reflectionFresnel: boolean;
  47770. /**
  47771. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47772. * This helps adding a mirror texture on the ground.
  47773. */
  47774. reflectionFresnel: boolean;
  47775. protected _reflectionFalloffDistance: number;
  47776. /**
  47777. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47778. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47779. */
  47780. reflectionFalloffDistance: number;
  47781. protected _reflectionAmount: number;
  47782. /**
  47783. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47784. */
  47785. reflectionAmount: number;
  47786. protected _reflectionReflectance0: number;
  47787. /**
  47788. * This specifies the weight of the reflection at grazing angle.
  47789. */
  47790. reflectionReflectance0: number;
  47791. protected _reflectionReflectance90: number;
  47792. /**
  47793. * This specifies the weight of the reflection at a perpendicular point of view.
  47794. */
  47795. reflectionReflectance90: number;
  47796. /**
  47797. * Sets the reflection reflectance fresnel values according to the default standard
  47798. * empirically know to work well :-)
  47799. */
  47800. reflectionStandardFresnelWeight: number;
  47801. protected _useRGBColor: boolean;
  47802. /**
  47803. * Helps to directly use the maps channels instead of their level.
  47804. */
  47805. useRGBColor: boolean;
  47806. protected _enableNoise: boolean;
  47807. /**
  47808. * This helps reducing the banding effect that could occur on the background.
  47809. */
  47810. enableNoise: boolean;
  47811. /**
  47812. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47813. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47814. * Recommended to be keep at 1.0 except for special cases.
  47815. */
  47816. fovMultiplier: number;
  47817. private _fovMultiplier;
  47818. /**
  47819. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47820. */
  47821. useEquirectangularFOV: boolean;
  47822. private _maxSimultaneousLights;
  47823. /**
  47824. * Number of Simultaneous lights allowed on the material.
  47825. */
  47826. maxSimultaneousLights: int;
  47827. /**
  47828. * Default configuration related to image processing available in the Background Material.
  47829. */
  47830. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47831. /**
  47832. * Keep track of the image processing observer to allow dispose and replace.
  47833. */
  47834. private _imageProcessingObserver;
  47835. /**
  47836. * Attaches a new image processing configuration to the PBR Material.
  47837. * @param configuration (if null the scene configuration will be use)
  47838. */
  47839. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47840. /**
  47841. * Gets the image processing configuration used either in this material.
  47842. */
  47843. /**
  47844. * Sets the Default image processing configuration used either in the this material.
  47845. *
  47846. * If sets to null, the scene one is in use.
  47847. */
  47848. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47849. /**
  47850. * Gets wether the color curves effect is enabled.
  47851. */
  47852. /**
  47853. * Sets wether the color curves effect is enabled.
  47854. */
  47855. cameraColorCurvesEnabled: boolean;
  47856. /**
  47857. * Gets wether the color grading effect is enabled.
  47858. */
  47859. /**
  47860. * Gets wether the color grading effect is enabled.
  47861. */
  47862. cameraColorGradingEnabled: boolean;
  47863. /**
  47864. * Gets wether tonemapping is enabled or not.
  47865. */
  47866. /**
  47867. * Sets wether tonemapping is enabled or not
  47868. */
  47869. cameraToneMappingEnabled: boolean;
  47870. /**
  47871. * The camera exposure used on this material.
  47872. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47873. * This corresponds to a photographic exposure.
  47874. */
  47875. /**
  47876. * The camera exposure used on this material.
  47877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47878. * This corresponds to a photographic exposure.
  47879. */
  47880. cameraExposure: float;
  47881. /**
  47882. * Gets The camera contrast used on this material.
  47883. */
  47884. /**
  47885. * Sets The camera contrast used on this material.
  47886. */
  47887. cameraContrast: float;
  47888. /**
  47889. * Gets the Color Grading 2D Lookup Texture.
  47890. */
  47891. /**
  47892. * Sets the Color Grading 2D Lookup Texture.
  47893. */
  47894. cameraColorGradingTexture: Nullable<BaseTexture>;
  47895. /**
  47896. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47897. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47898. * 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;
  47899. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47900. */
  47901. /**
  47902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47904. * 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;
  47905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47906. */
  47907. cameraColorCurves: Nullable<ColorCurves>;
  47908. /**
  47909. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47910. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47911. */
  47912. switchToBGR: boolean;
  47913. private _renderTargets;
  47914. private _reflectionControls;
  47915. private _white;
  47916. private _primaryShadowColor;
  47917. private _primaryHighlightColor;
  47918. /**
  47919. * Instantiates a Background Material in the given scene
  47920. * @param name The friendly name of the material
  47921. * @param scene The scene to add the material to
  47922. */
  47923. constructor(name: string, scene: Scene);
  47924. /**
  47925. * Gets a boolean indicating that current material needs to register RTT
  47926. */
  47927. readonly hasRenderTargetTextures: boolean;
  47928. /**
  47929. * The entire material has been created in order to prevent overdraw.
  47930. * @returns false
  47931. */
  47932. needAlphaTesting(): boolean;
  47933. /**
  47934. * The entire material has been created in order to prevent overdraw.
  47935. * @returns true if blending is enable
  47936. */
  47937. needAlphaBlending(): boolean;
  47938. /**
  47939. * Checks wether the material is ready to be rendered for a given mesh.
  47940. * @param mesh The mesh to render
  47941. * @param subMesh The submesh to check against
  47942. * @param useInstances Specify wether or not the material is used with instances
  47943. * @returns true if all the dependencies are ready (Textures, Effects...)
  47944. */
  47945. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47946. /**
  47947. * Compute the primary color according to the chosen perceptual color.
  47948. */
  47949. private _computePrimaryColorFromPerceptualColor;
  47950. /**
  47951. * Compute the highlights and shadow colors according to their chosen levels.
  47952. */
  47953. private _computePrimaryColors;
  47954. /**
  47955. * Build the uniform buffer used in the material.
  47956. */
  47957. buildUniformLayout(): void;
  47958. /**
  47959. * Unbind the material.
  47960. */
  47961. unbind(): void;
  47962. /**
  47963. * Bind only the world matrix to the material.
  47964. * @param world The world matrix to bind.
  47965. */
  47966. bindOnlyWorldMatrix(world: Matrix): void;
  47967. /**
  47968. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47969. * @param world The world matrix to bind.
  47970. * @param subMesh The submesh to bind for.
  47971. */
  47972. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47973. /**
  47974. * Checks to see if a texture is used in the material.
  47975. * @param texture - Base texture to use.
  47976. * @returns - Boolean specifying if a texture is used in the material.
  47977. */
  47978. hasTexture(texture: BaseTexture): boolean;
  47979. /**
  47980. * Dispose the material.
  47981. * @param forceDisposeEffect Force disposal of the associated effect.
  47982. * @param forceDisposeTextures Force disposal of the associated textures.
  47983. */
  47984. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47985. /**
  47986. * Clones the material.
  47987. * @param name The cloned name.
  47988. * @returns The cloned material.
  47989. */
  47990. clone(name: string): BackgroundMaterial;
  47991. /**
  47992. * Serializes the current material to its JSON representation.
  47993. * @returns The JSON representation.
  47994. */
  47995. serialize(): any;
  47996. /**
  47997. * Gets the class name of the material
  47998. * @returns "BackgroundMaterial"
  47999. */
  48000. getClassName(): string;
  48001. /**
  48002. * Parse a JSON input to create back a background material.
  48003. * @param source The JSON data to parse
  48004. * @param scene The scene to create the parsed material in
  48005. * @param rootUrl The root url of the assets the material depends upon
  48006. * @returns the instantiated BackgroundMaterial.
  48007. */
  48008. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48009. }
  48010. }
  48011. declare module "babylonjs/Helpers/environmentHelper" {
  48012. import { Observable } from "babylonjs/Misc/observable";
  48013. import { Nullable } from "babylonjs/types";
  48014. import { Scene } from "babylonjs/scene";
  48015. import { Vector3 } from "babylonjs/Maths/math.vector";
  48016. import { Color3 } from "babylonjs/Maths/math.color";
  48017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48018. import { Mesh } from "babylonjs/Meshes/mesh";
  48019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48020. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48021. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48022. import "babylonjs/Meshes/Builders/planeBuilder";
  48023. import "babylonjs/Meshes/Builders/boxBuilder";
  48024. /**
  48025. * Represents the different options available during the creation of
  48026. * a Environment helper.
  48027. *
  48028. * This can control the default ground, skybox and image processing setup of your scene.
  48029. */
  48030. export interface IEnvironmentHelperOptions {
  48031. /**
  48032. * Specifies wether or not to create a ground.
  48033. * True by default.
  48034. */
  48035. createGround: boolean;
  48036. /**
  48037. * Specifies the ground size.
  48038. * 15 by default.
  48039. */
  48040. groundSize: number;
  48041. /**
  48042. * The texture used on the ground for the main color.
  48043. * Comes from the BabylonJS CDN by default.
  48044. *
  48045. * Remarks: Can be either a texture or a url.
  48046. */
  48047. groundTexture: string | BaseTexture;
  48048. /**
  48049. * The color mixed in the ground texture by default.
  48050. * BabylonJS clearColor by default.
  48051. */
  48052. groundColor: Color3;
  48053. /**
  48054. * Specifies the ground opacity.
  48055. * 1 by default.
  48056. */
  48057. groundOpacity: number;
  48058. /**
  48059. * Enables the ground to receive shadows.
  48060. * True by default.
  48061. */
  48062. enableGroundShadow: boolean;
  48063. /**
  48064. * Helps preventing the shadow to be fully black on the ground.
  48065. * 0.5 by default.
  48066. */
  48067. groundShadowLevel: number;
  48068. /**
  48069. * Creates a mirror texture attach to the ground.
  48070. * false by default.
  48071. */
  48072. enableGroundMirror: boolean;
  48073. /**
  48074. * Specifies the ground mirror size ratio.
  48075. * 0.3 by default as the default kernel is 64.
  48076. */
  48077. groundMirrorSizeRatio: number;
  48078. /**
  48079. * Specifies the ground mirror blur kernel size.
  48080. * 64 by default.
  48081. */
  48082. groundMirrorBlurKernel: number;
  48083. /**
  48084. * Specifies the ground mirror visibility amount.
  48085. * 1 by default
  48086. */
  48087. groundMirrorAmount: number;
  48088. /**
  48089. * Specifies the ground mirror reflectance weight.
  48090. * This uses the standard weight of the background material to setup the fresnel effect
  48091. * of the mirror.
  48092. * 1 by default.
  48093. */
  48094. groundMirrorFresnelWeight: number;
  48095. /**
  48096. * Specifies the ground mirror Falloff distance.
  48097. * This can helps reducing the size of the reflection.
  48098. * 0 by Default.
  48099. */
  48100. groundMirrorFallOffDistance: number;
  48101. /**
  48102. * Specifies the ground mirror texture type.
  48103. * Unsigned Int by Default.
  48104. */
  48105. groundMirrorTextureType: number;
  48106. /**
  48107. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48108. * the shown objects.
  48109. */
  48110. groundYBias: number;
  48111. /**
  48112. * Specifies wether or not to create a skybox.
  48113. * True by default.
  48114. */
  48115. createSkybox: boolean;
  48116. /**
  48117. * Specifies the skybox size.
  48118. * 20 by default.
  48119. */
  48120. skyboxSize: number;
  48121. /**
  48122. * The texture used on the skybox for the main color.
  48123. * Comes from the BabylonJS CDN by default.
  48124. *
  48125. * Remarks: Can be either a texture or a url.
  48126. */
  48127. skyboxTexture: string | BaseTexture;
  48128. /**
  48129. * The color mixed in the skybox texture by default.
  48130. * BabylonJS clearColor by default.
  48131. */
  48132. skyboxColor: Color3;
  48133. /**
  48134. * The background rotation around the Y axis of the scene.
  48135. * This helps aligning the key lights of your scene with the background.
  48136. * 0 by default.
  48137. */
  48138. backgroundYRotation: number;
  48139. /**
  48140. * Compute automatically the size of the elements to best fit with the scene.
  48141. */
  48142. sizeAuto: boolean;
  48143. /**
  48144. * Default position of the rootMesh if autoSize is not true.
  48145. */
  48146. rootPosition: Vector3;
  48147. /**
  48148. * Sets up the image processing in the scene.
  48149. * true by default.
  48150. */
  48151. setupImageProcessing: boolean;
  48152. /**
  48153. * The texture used as your environment texture in the scene.
  48154. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48155. *
  48156. * Remarks: Can be either a texture or a url.
  48157. */
  48158. environmentTexture: string | BaseTexture;
  48159. /**
  48160. * The value of the exposure to apply to the scene.
  48161. * 0.6 by default if setupImageProcessing is true.
  48162. */
  48163. cameraExposure: number;
  48164. /**
  48165. * The value of the contrast to apply to the scene.
  48166. * 1.6 by default if setupImageProcessing is true.
  48167. */
  48168. cameraContrast: number;
  48169. /**
  48170. * Specifies wether or not tonemapping should be enabled in the scene.
  48171. * true by default if setupImageProcessing is true.
  48172. */
  48173. toneMappingEnabled: boolean;
  48174. }
  48175. /**
  48176. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48177. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48178. * It also helps with the default setup of your imageProcessing configuration.
  48179. */
  48180. export class EnvironmentHelper {
  48181. /**
  48182. * Default ground texture URL.
  48183. */
  48184. private static _groundTextureCDNUrl;
  48185. /**
  48186. * Default skybox texture URL.
  48187. */
  48188. private static _skyboxTextureCDNUrl;
  48189. /**
  48190. * Default environment texture URL.
  48191. */
  48192. private static _environmentTextureCDNUrl;
  48193. /**
  48194. * Creates the default options for the helper.
  48195. */
  48196. private static _getDefaultOptions;
  48197. private _rootMesh;
  48198. /**
  48199. * Gets the root mesh created by the helper.
  48200. */
  48201. readonly rootMesh: Mesh;
  48202. private _skybox;
  48203. /**
  48204. * Gets the skybox created by the helper.
  48205. */
  48206. readonly skybox: Nullable<Mesh>;
  48207. private _skyboxTexture;
  48208. /**
  48209. * Gets the skybox texture created by the helper.
  48210. */
  48211. readonly skyboxTexture: Nullable<BaseTexture>;
  48212. private _skyboxMaterial;
  48213. /**
  48214. * Gets the skybox material created by the helper.
  48215. */
  48216. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48217. private _ground;
  48218. /**
  48219. * Gets the ground mesh created by the helper.
  48220. */
  48221. readonly ground: Nullable<Mesh>;
  48222. private _groundTexture;
  48223. /**
  48224. * Gets the ground texture created by the helper.
  48225. */
  48226. readonly groundTexture: Nullable<BaseTexture>;
  48227. private _groundMirror;
  48228. /**
  48229. * Gets the ground mirror created by the helper.
  48230. */
  48231. readonly groundMirror: Nullable<MirrorTexture>;
  48232. /**
  48233. * Gets the ground mirror render list to helps pushing the meshes
  48234. * you wish in the ground reflection.
  48235. */
  48236. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48237. private _groundMaterial;
  48238. /**
  48239. * Gets the ground material created by the helper.
  48240. */
  48241. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48242. /**
  48243. * Stores the creation options.
  48244. */
  48245. private readonly _scene;
  48246. private _options;
  48247. /**
  48248. * This observable will be notified with any error during the creation of the environment,
  48249. * mainly texture creation errors.
  48250. */
  48251. onErrorObservable: Observable<{
  48252. message?: string;
  48253. exception?: any;
  48254. }>;
  48255. /**
  48256. * constructor
  48257. * @param options Defines the options we want to customize the helper
  48258. * @param scene The scene to add the material to
  48259. */
  48260. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48261. /**
  48262. * Updates the background according to the new options
  48263. * @param options
  48264. */
  48265. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48266. /**
  48267. * Sets the primary color of all the available elements.
  48268. * @param color the main color to affect to the ground and the background
  48269. */
  48270. setMainColor(color: Color3): void;
  48271. /**
  48272. * Setup the image processing according to the specified options.
  48273. */
  48274. private _setupImageProcessing;
  48275. /**
  48276. * Setup the environment texture according to the specified options.
  48277. */
  48278. private _setupEnvironmentTexture;
  48279. /**
  48280. * Setup the background according to the specified options.
  48281. */
  48282. private _setupBackground;
  48283. /**
  48284. * Get the scene sizes according to the setup.
  48285. */
  48286. private _getSceneSize;
  48287. /**
  48288. * Setup the ground according to the specified options.
  48289. */
  48290. private _setupGround;
  48291. /**
  48292. * Setup the ground material according to the specified options.
  48293. */
  48294. private _setupGroundMaterial;
  48295. /**
  48296. * Setup the ground diffuse texture according to the specified options.
  48297. */
  48298. private _setupGroundDiffuseTexture;
  48299. /**
  48300. * Setup the ground mirror texture according to the specified options.
  48301. */
  48302. private _setupGroundMirrorTexture;
  48303. /**
  48304. * Setup the ground to receive the mirror texture.
  48305. */
  48306. private _setupMirrorInGroundMaterial;
  48307. /**
  48308. * Setup the skybox according to the specified options.
  48309. */
  48310. private _setupSkybox;
  48311. /**
  48312. * Setup the skybox material according to the specified options.
  48313. */
  48314. private _setupSkyboxMaterial;
  48315. /**
  48316. * Setup the skybox reflection texture according to the specified options.
  48317. */
  48318. private _setupSkyboxReflectionTexture;
  48319. private _errorHandler;
  48320. /**
  48321. * Dispose all the elements created by the Helper.
  48322. */
  48323. dispose(): void;
  48324. }
  48325. }
  48326. declare module "babylonjs/Helpers/photoDome" {
  48327. import { Observable } from "babylonjs/Misc/observable";
  48328. import { Nullable } from "babylonjs/types";
  48329. import { Scene } from "babylonjs/scene";
  48330. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48331. import { Mesh } from "babylonjs/Meshes/mesh";
  48332. import { Texture } from "babylonjs/Materials/Textures/texture";
  48333. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48334. import "babylonjs/Meshes/Builders/sphereBuilder";
  48335. /**
  48336. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48337. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48338. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48339. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48340. */
  48341. export class PhotoDome extends TransformNode {
  48342. /**
  48343. * Define the image as a Monoscopic panoramic 360 image.
  48344. */
  48345. static readonly MODE_MONOSCOPIC: number;
  48346. /**
  48347. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48348. */
  48349. static readonly MODE_TOPBOTTOM: number;
  48350. /**
  48351. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48352. */
  48353. static readonly MODE_SIDEBYSIDE: number;
  48354. private _useDirectMapping;
  48355. /**
  48356. * The texture being displayed on the sphere
  48357. */
  48358. protected _photoTexture: Texture;
  48359. /**
  48360. * Gets or sets the texture being displayed on the sphere
  48361. */
  48362. photoTexture: Texture;
  48363. /**
  48364. * Observable raised when an error occured while loading the 360 image
  48365. */
  48366. onLoadErrorObservable: Observable<string>;
  48367. /**
  48368. * The skybox material
  48369. */
  48370. protected _material: BackgroundMaterial;
  48371. /**
  48372. * The surface used for the skybox
  48373. */
  48374. protected _mesh: Mesh;
  48375. /**
  48376. * Gets the mesh used for the skybox.
  48377. */
  48378. readonly mesh: Mesh;
  48379. /**
  48380. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48381. * Also see the options.resolution property.
  48382. */
  48383. fovMultiplier: number;
  48384. private _imageMode;
  48385. /**
  48386. * Gets or set the current video mode for the video. It can be:
  48387. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48388. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48389. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48390. */
  48391. imageMode: number;
  48392. /**
  48393. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48394. * @param name Element's name, child elements will append suffixes for their own names.
  48395. * @param urlsOfPhoto defines the url of the photo to display
  48396. * @param options defines an object containing optional or exposed sub element properties
  48397. * @param onError defines a callback called when an error occured while loading the texture
  48398. */
  48399. constructor(name: string, urlOfPhoto: string, options: {
  48400. resolution?: number;
  48401. size?: number;
  48402. useDirectMapping?: boolean;
  48403. faceForward?: boolean;
  48404. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48405. private _onBeforeCameraRenderObserver;
  48406. private _changeImageMode;
  48407. /**
  48408. * Releases resources associated with this node.
  48409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48411. */
  48412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48413. }
  48414. }
  48415. declare module "babylonjs/Misc/rgbdTextureTools" {
  48416. import "babylonjs/Shaders/rgbdDecode.fragment";
  48417. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48418. import { Texture } from "babylonjs/Materials/Textures/texture";
  48419. /**
  48420. * Class used to host RGBD texture specific utilities
  48421. */
  48422. export class RGBDTextureTools {
  48423. /**
  48424. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48425. * @param texture the texture to expand.
  48426. */
  48427. static ExpandRGBDTexture(texture: Texture): void;
  48428. }
  48429. }
  48430. declare module "babylonjs/Misc/brdfTextureTools" {
  48431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48432. import { Scene } from "babylonjs/scene";
  48433. /**
  48434. * Class used to host texture specific utilities
  48435. */
  48436. export class BRDFTextureTools {
  48437. /**
  48438. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48439. * @param scene defines the hosting scene
  48440. * @returns the environment BRDF texture
  48441. */
  48442. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48443. private static _environmentBRDFBase64Texture;
  48444. }
  48445. }
  48446. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48447. import { Nullable } from "babylonjs/types";
  48448. import { Color3 } from "babylonjs/Maths/math.color";
  48449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48450. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48451. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48452. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48453. import { Engine } from "babylonjs/Engines/engine";
  48454. import { Scene } from "babylonjs/scene";
  48455. /**
  48456. * @hidden
  48457. */
  48458. export interface IMaterialClearCoatDefines {
  48459. CLEARCOAT: boolean;
  48460. CLEARCOAT_DEFAULTIOR: boolean;
  48461. CLEARCOAT_TEXTURE: boolean;
  48462. CLEARCOAT_TEXTUREDIRECTUV: number;
  48463. CLEARCOAT_BUMP: boolean;
  48464. CLEARCOAT_BUMPDIRECTUV: number;
  48465. CLEARCOAT_TINT: boolean;
  48466. CLEARCOAT_TINT_TEXTURE: boolean;
  48467. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48468. /** @hidden */
  48469. _areTexturesDirty: boolean;
  48470. }
  48471. /**
  48472. * Define the code related to the clear coat parameters of the pbr material.
  48473. */
  48474. export class PBRClearCoatConfiguration {
  48475. /**
  48476. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48477. * The default fits with a polyurethane material.
  48478. */
  48479. private static readonly _DefaultIndexOfRefraction;
  48480. private _isEnabled;
  48481. /**
  48482. * Defines if the clear coat is enabled in the material.
  48483. */
  48484. isEnabled: boolean;
  48485. /**
  48486. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48487. */
  48488. intensity: number;
  48489. /**
  48490. * Defines the clear coat layer roughness.
  48491. */
  48492. roughness: number;
  48493. private _indexOfRefraction;
  48494. /**
  48495. * Defines the index of refraction of the clear coat.
  48496. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48497. * The default fits with a polyurethane material.
  48498. * Changing the default value is more performance intensive.
  48499. */
  48500. indexOfRefraction: number;
  48501. private _texture;
  48502. /**
  48503. * Stores the clear coat values in a texture.
  48504. */
  48505. texture: Nullable<BaseTexture>;
  48506. private _bumpTexture;
  48507. /**
  48508. * Define the clear coat specific bump texture.
  48509. */
  48510. bumpTexture: Nullable<BaseTexture>;
  48511. private _isTintEnabled;
  48512. /**
  48513. * Defines if the clear coat tint is enabled in the material.
  48514. */
  48515. isTintEnabled: boolean;
  48516. /**
  48517. * Defines the clear coat tint of the material.
  48518. * This is only use if tint is enabled
  48519. */
  48520. tintColor: Color3;
  48521. /**
  48522. * Defines the distance at which the tint color should be found in the
  48523. * clear coat media.
  48524. * This is only use if tint is enabled
  48525. */
  48526. tintColorAtDistance: number;
  48527. /**
  48528. * Defines the clear coat layer thickness.
  48529. * This is only use if tint is enabled
  48530. */
  48531. tintThickness: number;
  48532. private _tintTexture;
  48533. /**
  48534. * Stores the clear tint values in a texture.
  48535. * rgb is tint
  48536. * a is a thickness factor
  48537. */
  48538. tintTexture: Nullable<BaseTexture>;
  48539. /** @hidden */
  48540. private _internalMarkAllSubMeshesAsTexturesDirty;
  48541. /** @hidden */
  48542. _markAllSubMeshesAsTexturesDirty(): void;
  48543. /**
  48544. * Instantiate a new istance of clear coat configuration.
  48545. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48546. */
  48547. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48548. /**
  48549. * Gets wehter the submesh is ready to be used or not.
  48550. * @param defines the list of "defines" to update.
  48551. * @param scene defines the scene the material belongs to.
  48552. * @param engine defines the engine the material belongs to.
  48553. * @param disableBumpMap defines wether the material disables bump or not.
  48554. * @returns - boolean indicating that the submesh is ready or not.
  48555. */
  48556. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48557. /**
  48558. * Checks to see if a texture is used in the material.
  48559. * @param defines the list of "defines" to update.
  48560. * @param scene defines the scene to the material belongs to.
  48561. */
  48562. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48563. /**
  48564. * Binds the material data.
  48565. * @param uniformBuffer defines the Uniform buffer to fill in.
  48566. * @param scene defines the scene the material belongs to.
  48567. * @param engine defines the engine the material belongs to.
  48568. * @param disableBumpMap defines wether the material disables bump or not.
  48569. * @param isFrozen defines wether the material is frozen or not.
  48570. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48571. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48572. */
  48573. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48574. /**
  48575. * Checks to see if a texture is used in the material.
  48576. * @param texture - Base texture to use.
  48577. * @returns - Boolean specifying if a texture is used in the material.
  48578. */
  48579. hasTexture(texture: BaseTexture): boolean;
  48580. /**
  48581. * Returns an array of the actively used textures.
  48582. * @param activeTextures Array of BaseTextures
  48583. */
  48584. getActiveTextures(activeTextures: BaseTexture[]): void;
  48585. /**
  48586. * Returns the animatable textures.
  48587. * @param animatables Array of animatable textures.
  48588. */
  48589. getAnimatables(animatables: IAnimatable[]): void;
  48590. /**
  48591. * Disposes the resources of the material.
  48592. * @param forceDisposeTextures - Forces the disposal of all textures.
  48593. */
  48594. dispose(forceDisposeTextures?: boolean): void;
  48595. /**
  48596. * Get the current class name of the texture useful for serialization or dynamic coding.
  48597. * @returns "PBRClearCoatConfiguration"
  48598. */
  48599. getClassName(): string;
  48600. /**
  48601. * Add fallbacks to the effect fallbacks list.
  48602. * @param defines defines the Base texture to use.
  48603. * @param fallbacks defines the current fallback list.
  48604. * @param currentRank defines the current fallback rank.
  48605. * @returns the new fallback rank.
  48606. */
  48607. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48608. /**
  48609. * Add the required uniforms to the current list.
  48610. * @param uniforms defines the current uniform list.
  48611. */
  48612. static AddUniforms(uniforms: string[]): void;
  48613. /**
  48614. * Add the required samplers to the current list.
  48615. * @param samplers defines the current sampler list.
  48616. */
  48617. static AddSamplers(samplers: string[]): void;
  48618. /**
  48619. * Add the required uniforms to the current buffer.
  48620. * @param uniformBuffer defines the current uniform buffer.
  48621. */
  48622. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48623. /**
  48624. * Makes a duplicate of the current configuration into another one.
  48625. * @param clearCoatConfiguration define the config where to copy the info
  48626. */
  48627. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48628. /**
  48629. * Serializes this clear coat configuration.
  48630. * @returns - An object with the serialized config.
  48631. */
  48632. serialize(): any;
  48633. /**
  48634. * Parses a anisotropy Configuration from a serialized object.
  48635. * @param source - Serialized object.
  48636. * @param scene Defines the scene we are parsing for
  48637. * @param rootUrl Defines the rootUrl to load from
  48638. */
  48639. parse(source: any, scene: Scene, rootUrl: string): void;
  48640. }
  48641. }
  48642. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48643. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48645. import { Vector2 } from "babylonjs/Maths/math.vector";
  48646. import { Scene } from "babylonjs/scene";
  48647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48648. import { Nullable } from "babylonjs/types";
  48649. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48650. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48651. /**
  48652. * @hidden
  48653. */
  48654. export interface IMaterialAnisotropicDefines {
  48655. ANISOTROPIC: boolean;
  48656. ANISOTROPIC_TEXTURE: boolean;
  48657. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48658. MAINUV1: boolean;
  48659. _areTexturesDirty: boolean;
  48660. _needUVs: boolean;
  48661. }
  48662. /**
  48663. * Define the code related to the anisotropic parameters of the pbr material.
  48664. */
  48665. export class PBRAnisotropicConfiguration {
  48666. private _isEnabled;
  48667. /**
  48668. * Defines if the anisotropy is enabled in the material.
  48669. */
  48670. isEnabled: boolean;
  48671. /**
  48672. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48673. */
  48674. intensity: number;
  48675. /**
  48676. * Defines if the effect is along the tangents, bitangents or in between.
  48677. * By default, the effect is "strectching" the highlights along the tangents.
  48678. */
  48679. direction: Vector2;
  48680. private _texture;
  48681. /**
  48682. * Stores the anisotropy values in a texture.
  48683. * rg is direction (like normal from -1 to 1)
  48684. * b is a intensity
  48685. */
  48686. texture: Nullable<BaseTexture>;
  48687. /** @hidden */
  48688. private _internalMarkAllSubMeshesAsTexturesDirty;
  48689. /** @hidden */
  48690. _markAllSubMeshesAsTexturesDirty(): void;
  48691. /**
  48692. * Instantiate a new istance of anisotropy configuration.
  48693. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48694. */
  48695. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48696. /**
  48697. * Specifies that the submesh is ready to be used.
  48698. * @param defines the list of "defines" to update.
  48699. * @param scene defines the scene the material belongs to.
  48700. * @returns - boolean indicating that the submesh is ready or not.
  48701. */
  48702. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48703. /**
  48704. * Checks to see if a texture is used in the material.
  48705. * @param defines the list of "defines" to update.
  48706. * @param mesh the mesh we are preparing the defines for.
  48707. * @param scene defines the scene the material belongs to.
  48708. */
  48709. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48710. /**
  48711. * Binds the material data.
  48712. * @param uniformBuffer defines the Uniform buffer to fill in.
  48713. * @param scene defines the scene the material belongs to.
  48714. * @param isFrozen defines wether the material is frozen or not.
  48715. */
  48716. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48717. /**
  48718. * Checks to see if a texture is used in the material.
  48719. * @param texture - Base texture to use.
  48720. * @returns - Boolean specifying if a texture is used in the material.
  48721. */
  48722. hasTexture(texture: BaseTexture): boolean;
  48723. /**
  48724. * Returns an array of the actively used textures.
  48725. * @param activeTextures Array of BaseTextures
  48726. */
  48727. getActiveTextures(activeTextures: BaseTexture[]): void;
  48728. /**
  48729. * Returns the animatable textures.
  48730. * @param animatables Array of animatable textures.
  48731. */
  48732. getAnimatables(animatables: IAnimatable[]): void;
  48733. /**
  48734. * Disposes the resources of the material.
  48735. * @param forceDisposeTextures - Forces the disposal of all textures.
  48736. */
  48737. dispose(forceDisposeTextures?: boolean): void;
  48738. /**
  48739. * Get the current class name of the texture useful for serialization or dynamic coding.
  48740. * @returns "PBRAnisotropicConfiguration"
  48741. */
  48742. getClassName(): string;
  48743. /**
  48744. * Add fallbacks to the effect fallbacks list.
  48745. * @param defines defines the Base texture to use.
  48746. * @param fallbacks defines the current fallback list.
  48747. * @param currentRank defines the current fallback rank.
  48748. * @returns the new fallback rank.
  48749. */
  48750. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48751. /**
  48752. * Add the required uniforms to the current list.
  48753. * @param uniforms defines the current uniform list.
  48754. */
  48755. static AddUniforms(uniforms: string[]): void;
  48756. /**
  48757. * Add the required uniforms to the current buffer.
  48758. * @param uniformBuffer defines the current uniform buffer.
  48759. */
  48760. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48761. /**
  48762. * Add the required samplers to the current list.
  48763. * @param samplers defines the current sampler list.
  48764. */
  48765. static AddSamplers(samplers: string[]): void;
  48766. /**
  48767. * Makes a duplicate of the current configuration into another one.
  48768. * @param anisotropicConfiguration define the config where to copy the info
  48769. */
  48770. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48771. /**
  48772. * Serializes this anisotropy configuration.
  48773. * @returns - An object with the serialized config.
  48774. */
  48775. serialize(): any;
  48776. /**
  48777. * Parses a anisotropy Configuration from a serialized object.
  48778. * @param source - Serialized object.
  48779. * @param scene Defines the scene we are parsing for
  48780. * @param rootUrl Defines the rootUrl to load from
  48781. */
  48782. parse(source: any, scene: Scene, rootUrl: string): void;
  48783. }
  48784. }
  48785. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48786. import { Scene } from "babylonjs/scene";
  48787. /**
  48788. * @hidden
  48789. */
  48790. export interface IMaterialBRDFDefines {
  48791. BRDF_V_HEIGHT_CORRELATED: boolean;
  48792. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48793. SPHERICAL_HARMONICS: boolean;
  48794. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48795. /** @hidden */
  48796. _areMiscDirty: boolean;
  48797. }
  48798. /**
  48799. * Define the code related to the BRDF parameters of the pbr material.
  48800. */
  48801. export class PBRBRDFConfiguration {
  48802. /**
  48803. * Default value used for the energy conservation.
  48804. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48805. */
  48806. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48807. /**
  48808. * Default value used for the Smith Visibility Height Correlated mode.
  48809. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48810. */
  48811. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48812. /**
  48813. * Default value used for the IBL diffuse part.
  48814. * This can help switching back to the polynomials mode globally which is a tiny bit
  48815. * less GPU intensive at the drawback of a lower quality.
  48816. */
  48817. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48818. /**
  48819. * Default value used for activating energy conservation for the specular workflow.
  48820. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48821. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48822. */
  48823. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48824. private _useEnergyConservation;
  48825. /**
  48826. * Defines if the material uses energy conservation.
  48827. */
  48828. useEnergyConservation: boolean;
  48829. private _useSmithVisibilityHeightCorrelated;
  48830. /**
  48831. * LEGACY Mode set to false
  48832. * Defines if the material uses height smith correlated visibility term.
  48833. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48834. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48835. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48836. * Not relying on height correlated will also disable energy conservation.
  48837. */
  48838. useSmithVisibilityHeightCorrelated: boolean;
  48839. private _useSphericalHarmonics;
  48840. /**
  48841. * LEGACY Mode set to false
  48842. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48843. * diffuse part of the IBL.
  48844. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48845. * to the ground truth.
  48846. */
  48847. useSphericalHarmonics: boolean;
  48848. private _useSpecularGlossinessInputEnergyConservation;
  48849. /**
  48850. * Defines if the material uses energy conservation, when the specular workflow is active.
  48851. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48852. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48853. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48854. */
  48855. useSpecularGlossinessInputEnergyConservation: boolean;
  48856. /** @hidden */
  48857. private _internalMarkAllSubMeshesAsMiscDirty;
  48858. /** @hidden */
  48859. _markAllSubMeshesAsMiscDirty(): void;
  48860. /**
  48861. * Instantiate a new istance of clear coat configuration.
  48862. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48863. */
  48864. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48865. /**
  48866. * Checks to see if a texture is used in the material.
  48867. * @param defines the list of "defines" to update.
  48868. */
  48869. prepareDefines(defines: IMaterialBRDFDefines): void;
  48870. /**
  48871. * Get the current class name of the texture useful for serialization or dynamic coding.
  48872. * @returns "PBRClearCoatConfiguration"
  48873. */
  48874. getClassName(): string;
  48875. /**
  48876. * Makes a duplicate of the current configuration into another one.
  48877. * @param brdfConfiguration define the config where to copy the info
  48878. */
  48879. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48880. /**
  48881. * Serializes this BRDF configuration.
  48882. * @returns - An object with the serialized config.
  48883. */
  48884. serialize(): any;
  48885. /**
  48886. * Parses a anisotropy Configuration from a serialized object.
  48887. * @param source - Serialized object.
  48888. * @param scene Defines the scene we are parsing for
  48889. * @param rootUrl Defines the rootUrl to load from
  48890. */
  48891. parse(source: any, scene: Scene, rootUrl: string): void;
  48892. }
  48893. }
  48894. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48895. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48896. import { Color3 } from "babylonjs/Maths/math.color";
  48897. import { Scene } from "babylonjs/scene";
  48898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48899. import { Nullable } from "babylonjs/types";
  48900. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48901. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48902. /**
  48903. * @hidden
  48904. */
  48905. export interface IMaterialSheenDefines {
  48906. SHEEN: boolean;
  48907. SHEEN_TEXTURE: boolean;
  48908. SHEEN_TEXTUREDIRECTUV: number;
  48909. SHEEN_LINKWITHALBEDO: boolean;
  48910. /** @hidden */
  48911. _areTexturesDirty: boolean;
  48912. }
  48913. /**
  48914. * Define the code related to the Sheen parameters of the pbr material.
  48915. */
  48916. export class PBRSheenConfiguration {
  48917. private _isEnabled;
  48918. /**
  48919. * Defines if the material uses sheen.
  48920. */
  48921. isEnabled: boolean;
  48922. private _linkSheenWithAlbedo;
  48923. /**
  48924. * Defines if the sheen is linked to the sheen color.
  48925. */
  48926. linkSheenWithAlbedo: boolean;
  48927. /**
  48928. * Defines the sheen intensity.
  48929. */
  48930. intensity: number;
  48931. /**
  48932. * Defines the sheen color.
  48933. */
  48934. color: Color3;
  48935. private _texture;
  48936. /**
  48937. * Stores the sheen tint values in a texture.
  48938. * rgb is tint
  48939. * a is a intensity
  48940. */
  48941. texture: Nullable<BaseTexture>;
  48942. /** @hidden */
  48943. private _internalMarkAllSubMeshesAsTexturesDirty;
  48944. /** @hidden */
  48945. _markAllSubMeshesAsTexturesDirty(): void;
  48946. /**
  48947. * Instantiate a new istance of clear coat configuration.
  48948. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48949. */
  48950. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48951. /**
  48952. * Specifies that the submesh is ready to be used.
  48953. * @param defines the list of "defines" to update.
  48954. * @param scene defines the scene the material belongs to.
  48955. * @returns - boolean indicating that the submesh is ready or not.
  48956. */
  48957. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48958. /**
  48959. * Checks to see if a texture is used in the material.
  48960. * @param defines the list of "defines" to update.
  48961. * @param scene defines the scene the material belongs to.
  48962. */
  48963. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48964. /**
  48965. * Binds the material data.
  48966. * @param uniformBuffer defines the Uniform buffer to fill in.
  48967. * @param scene defines the scene the material belongs to.
  48968. * @param isFrozen defines wether the material is frozen or not.
  48969. */
  48970. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48971. /**
  48972. * Checks to see if a texture is used in the material.
  48973. * @param texture - Base texture to use.
  48974. * @returns - Boolean specifying if a texture is used in the material.
  48975. */
  48976. hasTexture(texture: BaseTexture): boolean;
  48977. /**
  48978. * Returns an array of the actively used textures.
  48979. * @param activeTextures Array of BaseTextures
  48980. */
  48981. getActiveTextures(activeTextures: BaseTexture[]): void;
  48982. /**
  48983. * Returns the animatable textures.
  48984. * @param animatables Array of animatable textures.
  48985. */
  48986. getAnimatables(animatables: IAnimatable[]): void;
  48987. /**
  48988. * Disposes the resources of the material.
  48989. * @param forceDisposeTextures - Forces the disposal of all textures.
  48990. */
  48991. dispose(forceDisposeTextures?: boolean): void;
  48992. /**
  48993. * Get the current class name of the texture useful for serialization or dynamic coding.
  48994. * @returns "PBRSheenConfiguration"
  48995. */
  48996. getClassName(): string;
  48997. /**
  48998. * Add fallbacks to the effect fallbacks list.
  48999. * @param defines defines the Base texture to use.
  49000. * @param fallbacks defines the current fallback list.
  49001. * @param currentRank defines the current fallback rank.
  49002. * @returns the new fallback rank.
  49003. */
  49004. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49005. /**
  49006. * Add the required uniforms to the current list.
  49007. * @param uniforms defines the current uniform list.
  49008. */
  49009. static AddUniforms(uniforms: string[]): void;
  49010. /**
  49011. * Add the required uniforms to the current buffer.
  49012. * @param uniformBuffer defines the current uniform buffer.
  49013. */
  49014. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49015. /**
  49016. * Add the required samplers to the current list.
  49017. * @param samplers defines the current sampler list.
  49018. */
  49019. static AddSamplers(samplers: string[]): void;
  49020. /**
  49021. * Makes a duplicate of the current configuration into another one.
  49022. * @param sheenConfiguration define the config where to copy the info
  49023. */
  49024. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49025. /**
  49026. * Serializes this BRDF configuration.
  49027. * @returns - An object with the serialized config.
  49028. */
  49029. serialize(): any;
  49030. /**
  49031. * Parses a anisotropy Configuration from a serialized object.
  49032. * @param source - Serialized object.
  49033. * @param scene Defines the scene we are parsing for
  49034. * @param rootUrl Defines the rootUrl to load from
  49035. */
  49036. parse(source: any, scene: Scene, rootUrl: string): void;
  49037. }
  49038. }
  49039. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49040. import { Nullable } from "babylonjs/types";
  49041. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49042. import { Color3 } from "babylonjs/Maths/math.color";
  49043. import { SmartArray } from "babylonjs/Misc/smartArray";
  49044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49045. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49046. import { Effect } from "babylonjs/Materials/effect";
  49047. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49048. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49049. import { Engine } from "babylonjs/Engines/engine";
  49050. import { Scene } from "babylonjs/scene";
  49051. /**
  49052. * @hidden
  49053. */
  49054. export interface IMaterialSubSurfaceDefines {
  49055. SUBSURFACE: boolean;
  49056. SS_REFRACTION: boolean;
  49057. SS_TRANSLUCENCY: boolean;
  49058. SS_SCATERRING: boolean;
  49059. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49060. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49061. SS_REFRACTIONMAP_3D: boolean;
  49062. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49063. SS_LODINREFRACTIONALPHA: boolean;
  49064. SS_GAMMAREFRACTION: boolean;
  49065. SS_RGBDREFRACTION: boolean;
  49066. SS_LINEARSPECULARREFRACTION: boolean;
  49067. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49068. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49069. /** @hidden */
  49070. _areTexturesDirty: boolean;
  49071. }
  49072. /**
  49073. * Define the code related to the sub surface parameters of the pbr material.
  49074. */
  49075. export class PBRSubSurfaceConfiguration {
  49076. private _isRefractionEnabled;
  49077. /**
  49078. * Defines if the refraction is enabled in the material.
  49079. */
  49080. isRefractionEnabled: boolean;
  49081. private _isTranslucencyEnabled;
  49082. /**
  49083. * Defines if the translucency is enabled in the material.
  49084. */
  49085. isTranslucencyEnabled: boolean;
  49086. private _isScatteringEnabled;
  49087. /**
  49088. * Defines the refraction intensity of the material.
  49089. * The refraction when enabled replaces the Diffuse part of the material.
  49090. * The intensity helps transitionning between diffuse and refraction.
  49091. */
  49092. refractionIntensity: number;
  49093. /**
  49094. * Defines the translucency intensity of the material.
  49095. * When translucency has been enabled, this defines how much of the "translucency"
  49096. * is addded to the diffuse part of the material.
  49097. */
  49098. translucencyIntensity: number;
  49099. /**
  49100. * Defines the scattering intensity of the material.
  49101. * When scattering has been enabled, this defines how much of the "scattered light"
  49102. * is addded to the diffuse part of the material.
  49103. */
  49104. scatteringIntensity: number;
  49105. private _thicknessTexture;
  49106. /**
  49107. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49108. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49109. * 0 would mean minimumThickness
  49110. * 1 would mean maximumThickness
  49111. * The other channels might be use as a mask to vary the different effects intensity.
  49112. */
  49113. thicknessTexture: Nullable<BaseTexture>;
  49114. private _refractionTexture;
  49115. /**
  49116. * Defines the texture to use for refraction.
  49117. */
  49118. refractionTexture: Nullable<BaseTexture>;
  49119. private _indexOfRefraction;
  49120. /**
  49121. * Defines the index of refraction used in the material.
  49122. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49123. */
  49124. indexOfRefraction: number;
  49125. private _invertRefractionY;
  49126. /**
  49127. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49128. */
  49129. invertRefractionY: boolean;
  49130. private _linkRefractionWithTransparency;
  49131. /**
  49132. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49133. * Materials half opaque for instance using refraction could benefit from this control.
  49134. */
  49135. linkRefractionWithTransparency: boolean;
  49136. /**
  49137. * Defines the minimum thickness stored in the thickness map.
  49138. * If no thickness map is defined, this value will be used to simulate thickness.
  49139. */
  49140. minimumThickness: number;
  49141. /**
  49142. * Defines the maximum thickness stored in the thickness map.
  49143. */
  49144. maximumThickness: number;
  49145. /**
  49146. * Defines the volume tint of the material.
  49147. * This is used for both translucency and scattering.
  49148. */
  49149. tintColor: Color3;
  49150. /**
  49151. * Defines the distance at which the tint color should be found in the media.
  49152. * This is used for refraction only.
  49153. */
  49154. tintColorAtDistance: number;
  49155. /**
  49156. * Defines how far each channel transmit through the media.
  49157. * It is defined as a color to simplify it selection.
  49158. */
  49159. diffusionDistance: Color3;
  49160. private _useMaskFromThicknessTexture;
  49161. /**
  49162. * Stores the intensity of the different subsurface effects in the thickness texture.
  49163. * * the green channel is the translucency intensity.
  49164. * * the blue channel is the scattering intensity.
  49165. * * the alpha channel is the refraction intensity.
  49166. */
  49167. useMaskFromThicknessTexture: boolean;
  49168. /** @hidden */
  49169. private _internalMarkAllSubMeshesAsTexturesDirty;
  49170. /** @hidden */
  49171. _markAllSubMeshesAsTexturesDirty(): void;
  49172. /**
  49173. * Instantiate a new istance of sub surface configuration.
  49174. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49175. */
  49176. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49177. /**
  49178. * Gets wehter the submesh is ready to be used or not.
  49179. * @param defines the list of "defines" to update.
  49180. * @param scene defines the scene the material belongs to.
  49181. * @returns - boolean indicating that the submesh is ready or not.
  49182. */
  49183. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49184. /**
  49185. * Checks to see if a texture is used in the material.
  49186. * @param defines the list of "defines" to update.
  49187. * @param scene defines the scene to the material belongs to.
  49188. */
  49189. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49190. /**
  49191. * Binds the material data.
  49192. * @param uniformBuffer defines the Uniform buffer to fill in.
  49193. * @param scene defines the scene the material belongs to.
  49194. * @param engine defines the engine the material belongs to.
  49195. * @param isFrozen defines wether the material is frozen or not.
  49196. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49197. */
  49198. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49199. /**
  49200. * Unbinds the material from the mesh.
  49201. * @param activeEffect defines the effect that should be unbound from.
  49202. * @returns true if unbound, otherwise false
  49203. */
  49204. unbind(activeEffect: Effect): boolean;
  49205. /**
  49206. * Returns the texture used for refraction or null if none is used.
  49207. * @param scene defines the scene the material belongs to.
  49208. * @returns - Refraction texture if present. If no refraction texture and refraction
  49209. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49210. */
  49211. private _getRefractionTexture;
  49212. /**
  49213. * Returns true if alpha blending should be disabled.
  49214. */
  49215. readonly disableAlphaBlending: boolean;
  49216. /**
  49217. * Fills the list of render target textures.
  49218. * @param renderTargets the list of render targets to update
  49219. */
  49220. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49221. /**
  49222. * Checks to see if a texture is used in the material.
  49223. * @param texture - Base texture to use.
  49224. * @returns - Boolean specifying if a texture is used in the material.
  49225. */
  49226. hasTexture(texture: BaseTexture): boolean;
  49227. /**
  49228. * Gets a boolean indicating that current material needs to register RTT
  49229. * @returns true if this uses a render target otherwise false.
  49230. */
  49231. hasRenderTargetTextures(): boolean;
  49232. /**
  49233. * Returns an array of the actively used textures.
  49234. * @param activeTextures Array of BaseTextures
  49235. */
  49236. getActiveTextures(activeTextures: BaseTexture[]): void;
  49237. /**
  49238. * Returns the animatable textures.
  49239. * @param animatables Array of animatable textures.
  49240. */
  49241. getAnimatables(animatables: IAnimatable[]): void;
  49242. /**
  49243. * Disposes the resources of the material.
  49244. * @param forceDisposeTextures - Forces the disposal of all textures.
  49245. */
  49246. dispose(forceDisposeTextures?: boolean): void;
  49247. /**
  49248. * Get the current class name of the texture useful for serialization or dynamic coding.
  49249. * @returns "PBRSubSurfaceConfiguration"
  49250. */
  49251. getClassName(): string;
  49252. /**
  49253. * Add fallbacks to the effect fallbacks list.
  49254. * @param defines defines the Base texture to use.
  49255. * @param fallbacks defines the current fallback list.
  49256. * @param currentRank defines the current fallback rank.
  49257. * @returns the new fallback rank.
  49258. */
  49259. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49260. /**
  49261. * Add the required uniforms to the current list.
  49262. * @param uniforms defines the current uniform list.
  49263. */
  49264. static AddUniforms(uniforms: string[]): void;
  49265. /**
  49266. * Add the required samplers to the current list.
  49267. * @param samplers defines the current sampler list.
  49268. */
  49269. static AddSamplers(samplers: string[]): void;
  49270. /**
  49271. * Add the required uniforms to the current buffer.
  49272. * @param uniformBuffer defines the current uniform buffer.
  49273. */
  49274. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49275. /**
  49276. * Makes a duplicate of the current configuration into another one.
  49277. * @param configuration define the config where to copy the info
  49278. */
  49279. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49280. /**
  49281. * Serializes this Sub Surface configuration.
  49282. * @returns - An object with the serialized config.
  49283. */
  49284. serialize(): any;
  49285. /**
  49286. * Parses a anisotropy Configuration from a serialized object.
  49287. * @param source - Serialized object.
  49288. * @param scene Defines the scene we are parsing for
  49289. * @param rootUrl Defines the rootUrl to load from
  49290. */
  49291. parse(source: any, scene: Scene, rootUrl: string): void;
  49292. }
  49293. }
  49294. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49295. /** @hidden */
  49296. export var pbrFragmentDeclaration: {
  49297. name: string;
  49298. shader: string;
  49299. };
  49300. }
  49301. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49302. /** @hidden */
  49303. export var pbrUboDeclaration: {
  49304. name: string;
  49305. shader: string;
  49306. };
  49307. }
  49308. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49309. /** @hidden */
  49310. export var pbrFragmentExtraDeclaration: {
  49311. name: string;
  49312. shader: string;
  49313. };
  49314. }
  49315. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49316. /** @hidden */
  49317. export var pbrFragmentSamplersDeclaration: {
  49318. name: string;
  49319. shader: string;
  49320. };
  49321. }
  49322. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49323. /** @hidden */
  49324. export var pbrHelperFunctions: {
  49325. name: string;
  49326. shader: string;
  49327. };
  49328. }
  49329. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49330. /** @hidden */
  49331. export var harmonicsFunctions: {
  49332. name: string;
  49333. shader: string;
  49334. };
  49335. }
  49336. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49337. /** @hidden */
  49338. export var pbrDirectLightingSetupFunctions: {
  49339. name: string;
  49340. shader: string;
  49341. };
  49342. }
  49343. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49344. /** @hidden */
  49345. export var pbrDirectLightingFalloffFunctions: {
  49346. name: string;
  49347. shader: string;
  49348. };
  49349. }
  49350. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49351. /** @hidden */
  49352. export var pbrBRDFFunctions: {
  49353. name: string;
  49354. shader: string;
  49355. };
  49356. }
  49357. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49358. /** @hidden */
  49359. export var pbrDirectLightingFunctions: {
  49360. name: string;
  49361. shader: string;
  49362. };
  49363. }
  49364. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49365. /** @hidden */
  49366. export var pbrIBLFunctions: {
  49367. name: string;
  49368. shader: string;
  49369. };
  49370. }
  49371. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49372. /** @hidden */
  49373. export var pbrDebug: {
  49374. name: string;
  49375. shader: string;
  49376. };
  49377. }
  49378. declare module "babylonjs/Shaders/pbr.fragment" {
  49379. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49380. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49381. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49382. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49383. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49384. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49385. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49386. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49387. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49388. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49390. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49391. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49392. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49393. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49394. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49395. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49396. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49397. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49398. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49399. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49400. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49401. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49402. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49403. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49404. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49405. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49406. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49407. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49408. /** @hidden */
  49409. export var pbrPixelShader: {
  49410. name: string;
  49411. shader: string;
  49412. };
  49413. }
  49414. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49415. /** @hidden */
  49416. export var pbrVertexDeclaration: {
  49417. name: string;
  49418. shader: string;
  49419. };
  49420. }
  49421. declare module "babylonjs/Shaders/pbr.vertex" {
  49422. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49423. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49424. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49425. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49426. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49427. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49428. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49429. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49430. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49431. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49432. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49434. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49435. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49437. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49438. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49439. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49440. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49441. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49442. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49443. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49444. /** @hidden */
  49445. export var pbrVertexShader: {
  49446. name: string;
  49447. shader: string;
  49448. };
  49449. }
  49450. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49451. import { Nullable } from "babylonjs/types";
  49452. import { Scene } from "babylonjs/scene";
  49453. import { Matrix } from "babylonjs/Maths/math.vector";
  49454. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49456. import { Mesh } from "babylonjs/Meshes/mesh";
  49457. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49458. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49459. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49460. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49461. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49462. import { Color3 } from "babylonjs/Maths/math.color";
  49463. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49464. import { Material } from "babylonjs/Materials/material";
  49465. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49466. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49468. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49469. import "babylonjs/Shaders/pbr.fragment";
  49470. import "babylonjs/Shaders/pbr.vertex";
  49471. /**
  49472. * Manages the defines for the PBR Material.
  49473. * @hidden
  49474. */
  49475. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49476. PBR: boolean;
  49477. MAINUV1: boolean;
  49478. MAINUV2: boolean;
  49479. UV1: boolean;
  49480. UV2: boolean;
  49481. ALBEDO: boolean;
  49482. ALBEDODIRECTUV: number;
  49483. VERTEXCOLOR: boolean;
  49484. AMBIENT: boolean;
  49485. AMBIENTDIRECTUV: number;
  49486. AMBIENTINGRAYSCALE: boolean;
  49487. OPACITY: boolean;
  49488. VERTEXALPHA: boolean;
  49489. OPACITYDIRECTUV: number;
  49490. OPACITYRGB: boolean;
  49491. ALPHATEST: boolean;
  49492. DEPTHPREPASS: boolean;
  49493. ALPHABLEND: boolean;
  49494. ALPHAFROMALBEDO: boolean;
  49495. ALPHATESTVALUE: string;
  49496. SPECULAROVERALPHA: boolean;
  49497. RADIANCEOVERALPHA: boolean;
  49498. ALPHAFRESNEL: boolean;
  49499. LINEARALPHAFRESNEL: boolean;
  49500. PREMULTIPLYALPHA: boolean;
  49501. EMISSIVE: boolean;
  49502. EMISSIVEDIRECTUV: number;
  49503. REFLECTIVITY: boolean;
  49504. REFLECTIVITYDIRECTUV: number;
  49505. SPECULARTERM: boolean;
  49506. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49507. MICROSURFACEAUTOMATIC: boolean;
  49508. LODBASEDMICROSFURACE: boolean;
  49509. MICROSURFACEMAP: boolean;
  49510. MICROSURFACEMAPDIRECTUV: number;
  49511. METALLICWORKFLOW: boolean;
  49512. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49513. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49514. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49515. AOSTOREINMETALMAPRED: boolean;
  49516. ENVIRONMENTBRDF: boolean;
  49517. ENVIRONMENTBRDF_RGBD: boolean;
  49518. NORMAL: boolean;
  49519. TANGENT: boolean;
  49520. BUMP: boolean;
  49521. BUMPDIRECTUV: number;
  49522. OBJECTSPACE_NORMALMAP: boolean;
  49523. PARALLAX: boolean;
  49524. PARALLAXOCCLUSION: boolean;
  49525. NORMALXYSCALE: boolean;
  49526. LIGHTMAP: boolean;
  49527. LIGHTMAPDIRECTUV: number;
  49528. USELIGHTMAPASSHADOWMAP: boolean;
  49529. GAMMALIGHTMAP: boolean;
  49530. RGBDLIGHTMAP: boolean;
  49531. REFLECTION: boolean;
  49532. REFLECTIONMAP_3D: boolean;
  49533. REFLECTIONMAP_SPHERICAL: boolean;
  49534. REFLECTIONMAP_PLANAR: boolean;
  49535. REFLECTIONMAP_CUBIC: boolean;
  49536. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49537. REFLECTIONMAP_PROJECTION: boolean;
  49538. REFLECTIONMAP_SKYBOX: boolean;
  49539. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49540. REFLECTIONMAP_EXPLICIT: boolean;
  49541. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49542. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49543. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49544. INVERTCUBICMAP: boolean;
  49545. USESPHERICALFROMREFLECTIONMAP: boolean;
  49546. USEIRRADIANCEMAP: boolean;
  49547. SPHERICAL_HARMONICS: boolean;
  49548. USESPHERICALINVERTEX: boolean;
  49549. REFLECTIONMAP_OPPOSITEZ: boolean;
  49550. LODINREFLECTIONALPHA: boolean;
  49551. GAMMAREFLECTION: boolean;
  49552. RGBDREFLECTION: boolean;
  49553. LINEARSPECULARREFLECTION: boolean;
  49554. RADIANCEOCCLUSION: boolean;
  49555. HORIZONOCCLUSION: boolean;
  49556. INSTANCES: boolean;
  49557. NUM_BONE_INFLUENCERS: number;
  49558. BonesPerMesh: number;
  49559. BONETEXTURE: boolean;
  49560. NONUNIFORMSCALING: boolean;
  49561. MORPHTARGETS: boolean;
  49562. MORPHTARGETS_NORMAL: boolean;
  49563. MORPHTARGETS_TANGENT: boolean;
  49564. MORPHTARGETS_UV: boolean;
  49565. NUM_MORPH_INFLUENCERS: number;
  49566. IMAGEPROCESSING: boolean;
  49567. VIGNETTE: boolean;
  49568. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49569. VIGNETTEBLENDMODEOPAQUE: boolean;
  49570. TONEMAPPING: boolean;
  49571. TONEMAPPING_ACES: boolean;
  49572. CONTRAST: boolean;
  49573. COLORCURVES: boolean;
  49574. COLORGRADING: boolean;
  49575. COLORGRADING3D: boolean;
  49576. SAMPLER3DGREENDEPTH: boolean;
  49577. SAMPLER3DBGRMAP: boolean;
  49578. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49579. EXPOSURE: boolean;
  49580. MULTIVIEW: boolean;
  49581. USEPHYSICALLIGHTFALLOFF: boolean;
  49582. USEGLTFLIGHTFALLOFF: boolean;
  49583. TWOSIDEDLIGHTING: boolean;
  49584. SHADOWFLOAT: boolean;
  49585. CLIPPLANE: boolean;
  49586. CLIPPLANE2: boolean;
  49587. CLIPPLANE3: boolean;
  49588. CLIPPLANE4: boolean;
  49589. POINTSIZE: boolean;
  49590. FOG: boolean;
  49591. LOGARITHMICDEPTH: boolean;
  49592. FORCENORMALFORWARD: boolean;
  49593. SPECULARAA: boolean;
  49594. CLEARCOAT: boolean;
  49595. CLEARCOAT_DEFAULTIOR: boolean;
  49596. CLEARCOAT_TEXTURE: boolean;
  49597. CLEARCOAT_TEXTUREDIRECTUV: number;
  49598. CLEARCOAT_BUMP: boolean;
  49599. CLEARCOAT_BUMPDIRECTUV: number;
  49600. CLEARCOAT_TINT: boolean;
  49601. CLEARCOAT_TINT_TEXTURE: boolean;
  49602. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49603. ANISOTROPIC: boolean;
  49604. ANISOTROPIC_TEXTURE: boolean;
  49605. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49606. BRDF_V_HEIGHT_CORRELATED: boolean;
  49607. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49608. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49609. SHEEN: boolean;
  49610. SHEEN_TEXTURE: boolean;
  49611. SHEEN_TEXTUREDIRECTUV: number;
  49612. SHEEN_LINKWITHALBEDO: boolean;
  49613. SUBSURFACE: boolean;
  49614. SS_REFRACTION: boolean;
  49615. SS_TRANSLUCENCY: boolean;
  49616. SS_SCATERRING: boolean;
  49617. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49618. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49619. SS_REFRACTIONMAP_3D: boolean;
  49620. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49621. SS_LODINREFRACTIONALPHA: boolean;
  49622. SS_GAMMAREFRACTION: boolean;
  49623. SS_RGBDREFRACTION: boolean;
  49624. SS_LINEARSPECULARREFRACTION: boolean;
  49625. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49626. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49627. UNLIT: boolean;
  49628. DEBUGMODE: number;
  49629. /**
  49630. * Initializes the PBR Material defines.
  49631. */
  49632. constructor();
  49633. /**
  49634. * Resets the PBR Material defines.
  49635. */
  49636. reset(): void;
  49637. }
  49638. /**
  49639. * The Physically based material base class of BJS.
  49640. *
  49641. * This offers the main features of a standard PBR material.
  49642. * For more information, please refer to the documentation :
  49643. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49644. */
  49645. export abstract class PBRBaseMaterial extends PushMaterial {
  49646. /**
  49647. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49648. */
  49649. static readonly PBRMATERIAL_OPAQUE: number;
  49650. /**
  49651. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49652. */
  49653. static readonly PBRMATERIAL_ALPHATEST: number;
  49654. /**
  49655. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49656. */
  49657. static readonly PBRMATERIAL_ALPHABLEND: number;
  49658. /**
  49659. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49660. * They are also discarded below the alpha cutoff threshold to improve performances.
  49661. */
  49662. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49663. /**
  49664. * Defines the default value of how much AO map is occluding the analytical lights
  49665. * (point spot...).
  49666. */
  49667. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49668. /**
  49669. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49670. */
  49671. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49672. /**
  49673. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49674. * to enhance interoperability with other engines.
  49675. */
  49676. static readonly LIGHTFALLOFF_GLTF: number;
  49677. /**
  49678. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49679. * to enhance interoperability with other materials.
  49680. */
  49681. static readonly LIGHTFALLOFF_STANDARD: number;
  49682. /**
  49683. * Intensity of the direct lights e.g. the four lights available in your scene.
  49684. * This impacts both the direct diffuse and specular highlights.
  49685. */
  49686. protected _directIntensity: number;
  49687. /**
  49688. * Intensity of the emissive part of the material.
  49689. * This helps controlling the emissive effect without modifying the emissive color.
  49690. */
  49691. protected _emissiveIntensity: number;
  49692. /**
  49693. * Intensity of the environment e.g. how much the environment will light the object
  49694. * either through harmonics for rough material or through the refelction for shiny ones.
  49695. */
  49696. protected _environmentIntensity: number;
  49697. /**
  49698. * This is a special control allowing the reduction of the specular highlights coming from the
  49699. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49700. */
  49701. protected _specularIntensity: number;
  49702. /**
  49703. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49704. */
  49705. private _lightingInfos;
  49706. /**
  49707. * Debug Control allowing disabling the bump map on this material.
  49708. */
  49709. protected _disableBumpMap: boolean;
  49710. /**
  49711. * AKA Diffuse Texture in standard nomenclature.
  49712. */
  49713. protected _albedoTexture: Nullable<BaseTexture>;
  49714. /**
  49715. * AKA Occlusion Texture in other nomenclature.
  49716. */
  49717. protected _ambientTexture: Nullable<BaseTexture>;
  49718. /**
  49719. * AKA Occlusion Texture Intensity in other nomenclature.
  49720. */
  49721. protected _ambientTextureStrength: number;
  49722. /**
  49723. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49724. * 1 means it completely occludes it
  49725. * 0 mean it has no impact
  49726. */
  49727. protected _ambientTextureImpactOnAnalyticalLights: number;
  49728. /**
  49729. * Stores the alpha values in a texture.
  49730. */
  49731. protected _opacityTexture: Nullable<BaseTexture>;
  49732. /**
  49733. * Stores the reflection values in a texture.
  49734. */
  49735. protected _reflectionTexture: Nullable<BaseTexture>;
  49736. /**
  49737. * Stores the emissive values in a texture.
  49738. */
  49739. protected _emissiveTexture: Nullable<BaseTexture>;
  49740. /**
  49741. * AKA Specular texture in other nomenclature.
  49742. */
  49743. protected _reflectivityTexture: Nullable<BaseTexture>;
  49744. /**
  49745. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49746. */
  49747. protected _metallicTexture: Nullable<BaseTexture>;
  49748. /**
  49749. * Specifies the metallic scalar of the metallic/roughness workflow.
  49750. * Can also be used to scale the metalness values of the metallic texture.
  49751. */
  49752. protected _metallic: Nullable<number>;
  49753. /**
  49754. * Specifies the roughness scalar of the metallic/roughness workflow.
  49755. * Can also be used to scale the roughness values of the metallic texture.
  49756. */
  49757. protected _roughness: Nullable<number>;
  49758. /**
  49759. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49760. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49761. */
  49762. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49763. /**
  49764. * Stores surface normal data used to displace a mesh in a texture.
  49765. */
  49766. protected _bumpTexture: Nullable<BaseTexture>;
  49767. /**
  49768. * Stores the pre-calculated light information of a mesh in a texture.
  49769. */
  49770. protected _lightmapTexture: Nullable<BaseTexture>;
  49771. /**
  49772. * The color of a material in ambient lighting.
  49773. */
  49774. protected _ambientColor: Color3;
  49775. /**
  49776. * AKA Diffuse Color in other nomenclature.
  49777. */
  49778. protected _albedoColor: Color3;
  49779. /**
  49780. * AKA Specular Color in other nomenclature.
  49781. */
  49782. protected _reflectivityColor: Color3;
  49783. /**
  49784. * The color applied when light is reflected from a material.
  49785. */
  49786. protected _reflectionColor: Color3;
  49787. /**
  49788. * The color applied when light is emitted from a material.
  49789. */
  49790. protected _emissiveColor: Color3;
  49791. /**
  49792. * AKA Glossiness in other nomenclature.
  49793. */
  49794. protected _microSurface: number;
  49795. /**
  49796. * Specifies that the material will use the light map as a show map.
  49797. */
  49798. protected _useLightmapAsShadowmap: boolean;
  49799. /**
  49800. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49801. * makes the reflect vector face the model (under horizon).
  49802. */
  49803. protected _useHorizonOcclusion: boolean;
  49804. /**
  49805. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49806. * too much the area relying on ambient texture to define their ambient occlusion.
  49807. */
  49808. protected _useRadianceOcclusion: boolean;
  49809. /**
  49810. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49811. */
  49812. protected _useAlphaFromAlbedoTexture: boolean;
  49813. /**
  49814. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49815. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49816. */
  49817. protected _useSpecularOverAlpha: boolean;
  49818. /**
  49819. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49820. */
  49821. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49822. /**
  49823. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49824. */
  49825. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49826. /**
  49827. * Specifies if the metallic texture contains the roughness information in its green channel.
  49828. */
  49829. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49830. /**
  49831. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49832. */
  49833. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49834. /**
  49835. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49836. */
  49837. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49838. /**
  49839. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49840. */
  49841. protected _useAmbientInGrayScale: boolean;
  49842. /**
  49843. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49844. * The material will try to infer what glossiness each pixel should be.
  49845. */
  49846. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49847. /**
  49848. * Defines the falloff type used in this material.
  49849. * It by default is Physical.
  49850. */
  49851. protected _lightFalloff: number;
  49852. /**
  49853. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49854. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49855. */
  49856. protected _useRadianceOverAlpha: boolean;
  49857. /**
  49858. * Allows using an object space normal map (instead of tangent space).
  49859. */
  49860. protected _useObjectSpaceNormalMap: boolean;
  49861. /**
  49862. * Allows using the bump map in parallax mode.
  49863. */
  49864. protected _useParallax: boolean;
  49865. /**
  49866. * Allows using the bump map in parallax occlusion mode.
  49867. */
  49868. protected _useParallaxOcclusion: boolean;
  49869. /**
  49870. * Controls the scale bias of the parallax mode.
  49871. */
  49872. protected _parallaxScaleBias: number;
  49873. /**
  49874. * If sets to true, disables all the lights affecting the material.
  49875. */
  49876. protected _disableLighting: boolean;
  49877. /**
  49878. * Number of Simultaneous lights allowed on the material.
  49879. */
  49880. protected _maxSimultaneousLights: number;
  49881. /**
  49882. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49883. */
  49884. protected _invertNormalMapX: boolean;
  49885. /**
  49886. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49887. */
  49888. protected _invertNormalMapY: boolean;
  49889. /**
  49890. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49891. */
  49892. protected _twoSidedLighting: boolean;
  49893. /**
  49894. * Defines the alpha limits in alpha test mode.
  49895. */
  49896. protected _alphaCutOff: number;
  49897. /**
  49898. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49899. */
  49900. protected _forceAlphaTest: boolean;
  49901. /**
  49902. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49903. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49904. */
  49905. protected _useAlphaFresnel: boolean;
  49906. /**
  49907. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49908. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49909. */
  49910. protected _useLinearAlphaFresnel: boolean;
  49911. /**
  49912. * The transparency mode of the material.
  49913. */
  49914. protected _transparencyMode: Nullable<number>;
  49915. /**
  49916. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49917. * from cos thetav and roughness:
  49918. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49919. */
  49920. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49921. /**
  49922. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49923. */
  49924. protected _forceIrradianceInFragment: boolean;
  49925. /**
  49926. * Force normal to face away from face.
  49927. */
  49928. protected _forceNormalForward: boolean;
  49929. /**
  49930. * Enables specular anti aliasing in the PBR shader.
  49931. * It will both interacts on the Geometry for analytical and IBL lighting.
  49932. * It also prefilter the roughness map based on the bump values.
  49933. */
  49934. protected _enableSpecularAntiAliasing: boolean;
  49935. /**
  49936. * Default configuration related to image processing available in the PBR Material.
  49937. */
  49938. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49939. /**
  49940. * Keep track of the image processing observer to allow dispose and replace.
  49941. */
  49942. private _imageProcessingObserver;
  49943. /**
  49944. * Attaches a new image processing configuration to the PBR Material.
  49945. * @param configuration
  49946. */
  49947. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49948. /**
  49949. * Stores the available render targets.
  49950. */
  49951. private _renderTargets;
  49952. /**
  49953. * Sets the global ambient color for the material used in lighting calculations.
  49954. */
  49955. private _globalAmbientColor;
  49956. /**
  49957. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49958. */
  49959. private _useLogarithmicDepth;
  49960. /**
  49961. * If set to true, no lighting calculations will be applied.
  49962. */
  49963. private _unlit;
  49964. private _debugMode;
  49965. /**
  49966. * @hidden
  49967. * This is reserved for the inspector.
  49968. * Defines the material debug mode.
  49969. * It helps seeing only some components of the material while troubleshooting.
  49970. */
  49971. debugMode: number;
  49972. /**
  49973. * @hidden
  49974. * This is reserved for the inspector.
  49975. * Specify from where on screen the debug mode should start.
  49976. * The value goes from -1 (full screen) to 1 (not visible)
  49977. * It helps with side by side comparison against the final render
  49978. * This defaults to -1
  49979. */
  49980. private debugLimit;
  49981. /**
  49982. * @hidden
  49983. * This is reserved for the inspector.
  49984. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49985. * You can use the factor to better multiply the final value.
  49986. */
  49987. private debugFactor;
  49988. /**
  49989. * Defines the clear coat layer parameters for the material.
  49990. */
  49991. readonly clearCoat: PBRClearCoatConfiguration;
  49992. /**
  49993. * Defines the anisotropic parameters for the material.
  49994. */
  49995. readonly anisotropy: PBRAnisotropicConfiguration;
  49996. /**
  49997. * Defines the BRDF parameters for the material.
  49998. */
  49999. readonly brdf: PBRBRDFConfiguration;
  50000. /**
  50001. * Defines the Sheen parameters for the material.
  50002. */
  50003. readonly sheen: PBRSheenConfiguration;
  50004. /**
  50005. * Defines the SubSurface parameters for the material.
  50006. */
  50007. readonly subSurface: PBRSubSurfaceConfiguration;
  50008. /**
  50009. * Custom callback helping to override the default shader used in the material.
  50010. */
  50011. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50012. protected _rebuildInParallel: boolean;
  50013. /**
  50014. * Instantiates a new PBRMaterial instance.
  50015. *
  50016. * @param name The material name
  50017. * @param scene The scene the material will be use in.
  50018. */
  50019. constructor(name: string, scene: Scene);
  50020. /**
  50021. * Gets a boolean indicating that current material needs to register RTT
  50022. */
  50023. readonly hasRenderTargetTextures: boolean;
  50024. /**
  50025. * Gets the name of the material class.
  50026. */
  50027. getClassName(): string;
  50028. /**
  50029. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50030. */
  50031. /**
  50032. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50033. */
  50034. useLogarithmicDepth: boolean;
  50035. /**
  50036. * Gets the current transparency mode.
  50037. */
  50038. /**
  50039. * Sets the transparency mode of the material.
  50040. *
  50041. * | Value | Type | Description |
  50042. * | ----- | ----------------------------------- | ----------- |
  50043. * | 0 | OPAQUE | |
  50044. * | 1 | ALPHATEST | |
  50045. * | 2 | ALPHABLEND | |
  50046. * | 3 | ALPHATESTANDBLEND | |
  50047. *
  50048. */
  50049. transparencyMode: Nullable<number>;
  50050. /**
  50051. * Returns true if alpha blending should be disabled.
  50052. */
  50053. private readonly _disableAlphaBlending;
  50054. /**
  50055. * Specifies whether or not this material should be rendered in alpha blend mode.
  50056. */
  50057. needAlphaBlending(): boolean;
  50058. /**
  50059. * Specifies if the mesh will require alpha blending.
  50060. * @param mesh - BJS mesh.
  50061. */
  50062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50063. /**
  50064. * Specifies whether or not this material should be rendered in alpha test mode.
  50065. */
  50066. needAlphaTesting(): boolean;
  50067. /**
  50068. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50069. */
  50070. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50071. /**
  50072. * Gets the texture used for the alpha test.
  50073. */
  50074. getAlphaTestTexture(): Nullable<BaseTexture>;
  50075. /**
  50076. * Specifies that the submesh is ready to be used.
  50077. * @param mesh - BJS mesh.
  50078. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50079. * @param useInstances - Specifies that instances should be used.
  50080. * @returns - boolean indicating that the submesh is ready or not.
  50081. */
  50082. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50083. /**
  50084. * Specifies if the material uses metallic roughness workflow.
  50085. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50086. */
  50087. isMetallicWorkflow(): boolean;
  50088. private _prepareEffect;
  50089. private _prepareDefines;
  50090. /**
  50091. * Force shader compilation
  50092. */
  50093. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50094. clipPlane: boolean;
  50095. }>): void;
  50096. /**
  50097. * Initializes the uniform buffer layout for the shader.
  50098. */
  50099. buildUniformLayout(): void;
  50100. /**
  50101. * Unbinds the material from the mesh
  50102. */
  50103. unbind(): void;
  50104. /**
  50105. * Binds the submesh data.
  50106. * @param world - The world matrix.
  50107. * @param mesh - The BJS mesh.
  50108. * @param subMesh - A submesh of the BJS mesh.
  50109. */
  50110. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50111. /**
  50112. * Returns the animatable textures.
  50113. * @returns - Array of animatable textures.
  50114. */
  50115. getAnimatables(): IAnimatable[];
  50116. /**
  50117. * Returns the texture used for reflections.
  50118. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50119. */
  50120. private _getReflectionTexture;
  50121. /**
  50122. * Returns an array of the actively used textures.
  50123. * @returns - Array of BaseTextures
  50124. */
  50125. getActiveTextures(): BaseTexture[];
  50126. /**
  50127. * Checks to see if a texture is used in the material.
  50128. * @param texture - Base texture to use.
  50129. * @returns - Boolean specifying if a texture is used in the material.
  50130. */
  50131. hasTexture(texture: BaseTexture): boolean;
  50132. /**
  50133. * Disposes the resources of the material.
  50134. * @param forceDisposeEffect - Forces the disposal of effects.
  50135. * @param forceDisposeTextures - Forces the disposal of all textures.
  50136. */
  50137. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50138. }
  50139. }
  50140. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50141. import { Nullable } from "babylonjs/types";
  50142. import { Scene } from "babylonjs/scene";
  50143. import { Color3 } from "babylonjs/Maths/math.color";
  50144. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50145. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50147. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50148. /**
  50149. * The Physically based material of BJS.
  50150. *
  50151. * This offers the main features of a standard PBR material.
  50152. * For more information, please refer to the documentation :
  50153. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50154. */
  50155. export class PBRMaterial extends PBRBaseMaterial {
  50156. /**
  50157. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50158. */
  50159. static readonly PBRMATERIAL_OPAQUE: number;
  50160. /**
  50161. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50162. */
  50163. static readonly PBRMATERIAL_ALPHATEST: number;
  50164. /**
  50165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50166. */
  50167. static readonly PBRMATERIAL_ALPHABLEND: number;
  50168. /**
  50169. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50170. * They are also discarded below the alpha cutoff threshold to improve performances.
  50171. */
  50172. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50173. /**
  50174. * Defines the default value of how much AO map is occluding the analytical lights
  50175. * (point spot...).
  50176. */
  50177. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50178. /**
  50179. * Intensity of the direct lights e.g. the four lights available in your scene.
  50180. * This impacts both the direct diffuse and specular highlights.
  50181. */
  50182. directIntensity: number;
  50183. /**
  50184. * Intensity of the emissive part of the material.
  50185. * This helps controlling the emissive effect without modifying the emissive color.
  50186. */
  50187. emissiveIntensity: number;
  50188. /**
  50189. * Intensity of the environment e.g. how much the environment will light the object
  50190. * either through harmonics for rough material or through the refelction for shiny ones.
  50191. */
  50192. environmentIntensity: number;
  50193. /**
  50194. * This is a special control allowing the reduction of the specular highlights coming from the
  50195. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50196. */
  50197. specularIntensity: number;
  50198. /**
  50199. * Debug Control allowing disabling the bump map on this material.
  50200. */
  50201. disableBumpMap: boolean;
  50202. /**
  50203. * AKA Diffuse Texture in standard nomenclature.
  50204. */
  50205. albedoTexture: BaseTexture;
  50206. /**
  50207. * AKA Occlusion Texture in other nomenclature.
  50208. */
  50209. ambientTexture: BaseTexture;
  50210. /**
  50211. * AKA Occlusion Texture Intensity in other nomenclature.
  50212. */
  50213. ambientTextureStrength: number;
  50214. /**
  50215. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50216. * 1 means it completely occludes it
  50217. * 0 mean it has no impact
  50218. */
  50219. ambientTextureImpactOnAnalyticalLights: number;
  50220. /**
  50221. * Stores the alpha values in a texture.
  50222. */
  50223. opacityTexture: BaseTexture;
  50224. /**
  50225. * Stores the reflection values in a texture.
  50226. */
  50227. reflectionTexture: Nullable<BaseTexture>;
  50228. /**
  50229. * Stores the emissive values in a texture.
  50230. */
  50231. emissiveTexture: BaseTexture;
  50232. /**
  50233. * AKA Specular texture in other nomenclature.
  50234. */
  50235. reflectivityTexture: BaseTexture;
  50236. /**
  50237. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50238. */
  50239. metallicTexture: BaseTexture;
  50240. /**
  50241. * Specifies the metallic scalar of the metallic/roughness workflow.
  50242. * Can also be used to scale the metalness values of the metallic texture.
  50243. */
  50244. metallic: Nullable<number>;
  50245. /**
  50246. * Specifies the roughness scalar of the metallic/roughness workflow.
  50247. * Can also be used to scale the roughness values of the metallic texture.
  50248. */
  50249. roughness: Nullable<number>;
  50250. /**
  50251. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50252. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50253. */
  50254. microSurfaceTexture: BaseTexture;
  50255. /**
  50256. * Stores surface normal data used to displace a mesh in a texture.
  50257. */
  50258. bumpTexture: BaseTexture;
  50259. /**
  50260. * Stores the pre-calculated light information of a mesh in a texture.
  50261. */
  50262. lightmapTexture: BaseTexture;
  50263. /**
  50264. * Stores the refracted light information in a texture.
  50265. */
  50266. refractionTexture: Nullable<BaseTexture>;
  50267. /**
  50268. * The color of a material in ambient lighting.
  50269. */
  50270. ambientColor: Color3;
  50271. /**
  50272. * AKA Diffuse Color in other nomenclature.
  50273. */
  50274. albedoColor: Color3;
  50275. /**
  50276. * AKA Specular Color in other nomenclature.
  50277. */
  50278. reflectivityColor: Color3;
  50279. /**
  50280. * The color reflected from the material.
  50281. */
  50282. reflectionColor: Color3;
  50283. /**
  50284. * The color emitted from the material.
  50285. */
  50286. emissiveColor: Color3;
  50287. /**
  50288. * AKA Glossiness in other nomenclature.
  50289. */
  50290. microSurface: number;
  50291. /**
  50292. * source material index of refraction (IOR)' / 'destination material IOR.
  50293. */
  50294. indexOfRefraction: number;
  50295. /**
  50296. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50297. */
  50298. invertRefractionY: boolean;
  50299. /**
  50300. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50301. * Materials half opaque for instance using refraction could benefit from this control.
  50302. */
  50303. linkRefractionWithTransparency: boolean;
  50304. /**
  50305. * If true, the light map contains occlusion information instead of lighting info.
  50306. */
  50307. useLightmapAsShadowmap: boolean;
  50308. /**
  50309. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50310. */
  50311. useAlphaFromAlbedoTexture: boolean;
  50312. /**
  50313. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50314. */
  50315. forceAlphaTest: boolean;
  50316. /**
  50317. * Defines the alpha limits in alpha test mode.
  50318. */
  50319. alphaCutOff: number;
  50320. /**
  50321. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50322. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50323. */
  50324. useSpecularOverAlpha: boolean;
  50325. /**
  50326. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50327. */
  50328. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50329. /**
  50330. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50331. */
  50332. useRoughnessFromMetallicTextureAlpha: boolean;
  50333. /**
  50334. * Specifies if the metallic texture contains the roughness information in its green channel.
  50335. */
  50336. useRoughnessFromMetallicTextureGreen: boolean;
  50337. /**
  50338. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50339. */
  50340. useMetallnessFromMetallicTextureBlue: boolean;
  50341. /**
  50342. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50343. */
  50344. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50345. /**
  50346. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50347. */
  50348. useAmbientInGrayScale: boolean;
  50349. /**
  50350. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50351. * The material will try to infer what glossiness each pixel should be.
  50352. */
  50353. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50354. /**
  50355. * BJS is using an harcoded light falloff based on a manually sets up range.
  50356. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50357. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50358. */
  50359. /**
  50360. * BJS is using an harcoded light falloff based on a manually sets up range.
  50361. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50362. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50363. */
  50364. usePhysicalLightFalloff: boolean;
  50365. /**
  50366. * In order to support the falloff compatibility with gltf, a special mode has been added
  50367. * to reproduce the gltf light falloff.
  50368. */
  50369. /**
  50370. * In order to support the falloff compatibility with gltf, a special mode has been added
  50371. * to reproduce the gltf light falloff.
  50372. */
  50373. useGLTFLightFalloff: boolean;
  50374. /**
  50375. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50376. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50377. */
  50378. useRadianceOverAlpha: boolean;
  50379. /**
  50380. * Allows using an object space normal map (instead of tangent space).
  50381. */
  50382. useObjectSpaceNormalMap: boolean;
  50383. /**
  50384. * Allows using the bump map in parallax mode.
  50385. */
  50386. useParallax: boolean;
  50387. /**
  50388. * Allows using the bump map in parallax occlusion mode.
  50389. */
  50390. useParallaxOcclusion: boolean;
  50391. /**
  50392. * Controls the scale bias of the parallax mode.
  50393. */
  50394. parallaxScaleBias: number;
  50395. /**
  50396. * If sets to true, disables all the lights affecting the material.
  50397. */
  50398. disableLighting: boolean;
  50399. /**
  50400. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50401. */
  50402. forceIrradianceInFragment: boolean;
  50403. /**
  50404. * Number of Simultaneous lights allowed on the material.
  50405. */
  50406. maxSimultaneousLights: number;
  50407. /**
  50408. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50409. */
  50410. invertNormalMapX: boolean;
  50411. /**
  50412. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50413. */
  50414. invertNormalMapY: boolean;
  50415. /**
  50416. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50417. */
  50418. twoSidedLighting: boolean;
  50419. /**
  50420. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50421. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50422. */
  50423. useAlphaFresnel: boolean;
  50424. /**
  50425. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50426. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50427. */
  50428. useLinearAlphaFresnel: boolean;
  50429. /**
  50430. * Let user defines the brdf lookup texture used for IBL.
  50431. * A default 8bit version is embedded but you could point at :
  50432. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50433. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50434. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50435. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50436. */
  50437. environmentBRDFTexture: Nullable<BaseTexture>;
  50438. /**
  50439. * Force normal to face away from face.
  50440. */
  50441. forceNormalForward: boolean;
  50442. /**
  50443. * Enables specular anti aliasing in the PBR shader.
  50444. * It will both interacts on the Geometry for analytical and IBL lighting.
  50445. * It also prefilter the roughness map based on the bump values.
  50446. */
  50447. enableSpecularAntiAliasing: boolean;
  50448. /**
  50449. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50450. * makes the reflect vector face the model (under horizon).
  50451. */
  50452. useHorizonOcclusion: boolean;
  50453. /**
  50454. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50455. * too much the area relying on ambient texture to define their ambient occlusion.
  50456. */
  50457. useRadianceOcclusion: boolean;
  50458. /**
  50459. * If set to true, no lighting calculations will be applied.
  50460. */
  50461. unlit: boolean;
  50462. /**
  50463. * Gets the image processing configuration used either in this material.
  50464. */
  50465. /**
  50466. * Sets the Default image processing configuration used either in the this material.
  50467. *
  50468. * If sets to null, the scene one is in use.
  50469. */
  50470. imageProcessingConfiguration: ImageProcessingConfiguration;
  50471. /**
  50472. * Gets wether the color curves effect is enabled.
  50473. */
  50474. /**
  50475. * Sets wether the color curves effect is enabled.
  50476. */
  50477. cameraColorCurvesEnabled: boolean;
  50478. /**
  50479. * Gets wether the color grading effect is enabled.
  50480. */
  50481. /**
  50482. * Gets wether the color grading effect is enabled.
  50483. */
  50484. cameraColorGradingEnabled: boolean;
  50485. /**
  50486. * Gets wether tonemapping is enabled or not.
  50487. */
  50488. /**
  50489. * Sets wether tonemapping is enabled or not
  50490. */
  50491. cameraToneMappingEnabled: boolean;
  50492. /**
  50493. * The camera exposure used on this material.
  50494. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50495. * This corresponds to a photographic exposure.
  50496. */
  50497. /**
  50498. * The camera exposure used on this material.
  50499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50500. * This corresponds to a photographic exposure.
  50501. */
  50502. cameraExposure: number;
  50503. /**
  50504. * Gets The camera contrast used on this material.
  50505. */
  50506. /**
  50507. * Sets The camera contrast used on this material.
  50508. */
  50509. cameraContrast: number;
  50510. /**
  50511. * Gets the Color Grading 2D Lookup Texture.
  50512. */
  50513. /**
  50514. * Sets the Color Grading 2D Lookup Texture.
  50515. */
  50516. cameraColorGradingTexture: Nullable<BaseTexture>;
  50517. /**
  50518. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50519. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50520. * 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;
  50521. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50522. */
  50523. /**
  50524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50526. * 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;
  50527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50528. */
  50529. cameraColorCurves: Nullable<ColorCurves>;
  50530. /**
  50531. * Instantiates a new PBRMaterial instance.
  50532. *
  50533. * @param name The material name
  50534. * @param scene The scene the material will be use in.
  50535. */
  50536. constructor(name: string, scene: Scene);
  50537. /**
  50538. * Returns the name of this material class.
  50539. */
  50540. getClassName(): string;
  50541. /**
  50542. * Makes a duplicate of the current material.
  50543. * @param name - name to use for the new material.
  50544. */
  50545. clone(name: string): PBRMaterial;
  50546. /**
  50547. * Serializes this PBR Material.
  50548. * @returns - An object with the serialized material.
  50549. */
  50550. serialize(): any;
  50551. /**
  50552. * Parses a PBR Material from a serialized object.
  50553. * @param source - Serialized object.
  50554. * @param scene - BJS scene instance.
  50555. * @param rootUrl - url for the scene object
  50556. * @returns - PBRMaterial
  50557. */
  50558. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50559. }
  50560. }
  50561. declare module "babylonjs/Misc/dds" {
  50562. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50564. import { Nullable } from "babylonjs/types";
  50565. import { Scene } from "babylonjs/scene";
  50566. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50567. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50568. /**
  50569. * Direct draw surface info
  50570. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50571. */
  50572. export interface DDSInfo {
  50573. /**
  50574. * Width of the texture
  50575. */
  50576. width: number;
  50577. /**
  50578. * Width of the texture
  50579. */
  50580. height: number;
  50581. /**
  50582. * Number of Mipmaps for the texture
  50583. * @see https://en.wikipedia.org/wiki/Mipmap
  50584. */
  50585. mipmapCount: number;
  50586. /**
  50587. * If the textures format is a known fourCC format
  50588. * @see https://www.fourcc.org/
  50589. */
  50590. isFourCC: boolean;
  50591. /**
  50592. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50593. */
  50594. isRGB: boolean;
  50595. /**
  50596. * If the texture is a lumincance format
  50597. */
  50598. isLuminance: boolean;
  50599. /**
  50600. * If this is a cube texture
  50601. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50602. */
  50603. isCube: boolean;
  50604. /**
  50605. * If the texture is a compressed format eg. FOURCC_DXT1
  50606. */
  50607. isCompressed: boolean;
  50608. /**
  50609. * The dxgiFormat of the texture
  50610. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50611. */
  50612. dxgiFormat: number;
  50613. /**
  50614. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50615. */
  50616. textureType: number;
  50617. /**
  50618. * Sphericle polynomial created for the dds texture
  50619. */
  50620. sphericalPolynomial?: SphericalPolynomial;
  50621. }
  50622. /**
  50623. * Class used to provide DDS decompression tools
  50624. */
  50625. export class DDSTools {
  50626. /**
  50627. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50628. */
  50629. static StoreLODInAlphaChannel: boolean;
  50630. /**
  50631. * Gets DDS information from an array buffer
  50632. * @param arrayBuffer defines the array buffer to read data from
  50633. * @returns the DDS information
  50634. */
  50635. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50636. private static _FloatView;
  50637. private static _Int32View;
  50638. private static _ToHalfFloat;
  50639. private static _FromHalfFloat;
  50640. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50641. private static _GetHalfFloatRGBAArrayBuffer;
  50642. private static _GetFloatRGBAArrayBuffer;
  50643. private static _GetFloatAsUIntRGBAArrayBuffer;
  50644. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50645. private static _GetRGBAArrayBuffer;
  50646. private static _ExtractLongWordOrder;
  50647. private static _GetRGBArrayBuffer;
  50648. private static _GetLuminanceArrayBuffer;
  50649. /**
  50650. * Uploads DDS Levels to a Babylon Texture
  50651. * @hidden
  50652. */
  50653. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50654. }
  50655. module "babylonjs/Engines/thinEngine" {
  50656. interface ThinEngine {
  50657. /**
  50658. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50659. * @param rootUrl defines the url where the file to load is located
  50660. * @param scene defines the current scene
  50661. * @param lodScale defines scale to apply to the mip map selection
  50662. * @param lodOffset defines offset to apply to the mip map selection
  50663. * @param onLoad defines an optional callback raised when the texture is loaded
  50664. * @param onError defines an optional callback raised if there is an issue to load the texture
  50665. * @param format defines the format of the data
  50666. * @param forcedExtension defines the extension to use to pick the right loader
  50667. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50668. * @returns the cube texture as an InternalTexture
  50669. */
  50670. 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;
  50671. }
  50672. }
  50673. }
  50674. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50675. import { Nullable } from "babylonjs/types";
  50676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50677. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50678. /**
  50679. * Implementation of the DDS Texture Loader.
  50680. * @hidden
  50681. */
  50682. export class _DDSTextureLoader implements IInternalTextureLoader {
  50683. /**
  50684. * Defines wether the loader supports cascade loading the different faces.
  50685. */
  50686. readonly supportCascades: boolean;
  50687. /**
  50688. * This returns if the loader support the current file information.
  50689. * @param extension defines the file extension of the file being loaded
  50690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50691. * @param fallback defines the fallback internal texture if any
  50692. * @param isBase64 defines whether the texture is encoded as a base64
  50693. * @param isBuffer defines whether the texture data are stored as a buffer
  50694. * @returns true if the loader can load the specified file
  50695. */
  50696. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50697. /**
  50698. * Transform the url before loading if required.
  50699. * @param rootUrl the url of the texture
  50700. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50701. * @returns the transformed texture
  50702. */
  50703. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50704. /**
  50705. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50706. * @param rootUrl the url of the texture
  50707. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50708. * @returns the fallback texture
  50709. */
  50710. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50711. /**
  50712. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50713. * @param data contains the texture data
  50714. * @param texture defines the BabylonJS internal texture
  50715. * @param createPolynomials will be true if polynomials have been requested
  50716. * @param onLoad defines the callback to trigger once the texture is ready
  50717. * @param onError defines the callback to trigger in case of error
  50718. */
  50719. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50720. /**
  50721. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50722. * @param data contains the texture data
  50723. * @param texture defines the BabylonJS internal texture
  50724. * @param callback defines the method to call once ready to upload
  50725. */
  50726. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50727. }
  50728. }
  50729. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50730. import { Nullable } from "babylonjs/types";
  50731. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50732. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50733. /**
  50734. * Implementation of the ENV Texture Loader.
  50735. * @hidden
  50736. */
  50737. export class _ENVTextureLoader implements IInternalTextureLoader {
  50738. /**
  50739. * Defines wether the loader supports cascade loading the different faces.
  50740. */
  50741. readonly supportCascades: boolean;
  50742. /**
  50743. * This returns if the loader support the current file information.
  50744. * @param extension defines the file extension of the file being loaded
  50745. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50746. * @param fallback defines the fallback internal texture if any
  50747. * @param isBase64 defines whether the texture is encoded as a base64
  50748. * @param isBuffer defines whether the texture data are stored as a buffer
  50749. * @returns true if the loader can load the specified file
  50750. */
  50751. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50752. /**
  50753. * Transform the url before loading if required.
  50754. * @param rootUrl the url of the texture
  50755. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50756. * @returns the transformed texture
  50757. */
  50758. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50759. /**
  50760. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50761. * @param rootUrl the url of the texture
  50762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50763. * @returns the fallback texture
  50764. */
  50765. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50766. /**
  50767. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50768. * @param data contains the texture data
  50769. * @param texture defines the BabylonJS internal texture
  50770. * @param createPolynomials will be true if polynomials have been requested
  50771. * @param onLoad defines the callback to trigger once the texture is ready
  50772. * @param onError defines the callback to trigger in case of error
  50773. */
  50774. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50775. /**
  50776. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50777. * @param data contains the texture data
  50778. * @param texture defines the BabylonJS internal texture
  50779. * @param callback defines the method to call once ready to upload
  50780. */
  50781. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50782. }
  50783. }
  50784. declare module "babylonjs/Misc/khronosTextureContainer" {
  50785. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50786. /**
  50787. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50788. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50789. */
  50790. export class KhronosTextureContainer {
  50791. /** contents of the KTX container file */
  50792. arrayBuffer: any;
  50793. private static HEADER_LEN;
  50794. private static COMPRESSED_2D;
  50795. private static COMPRESSED_3D;
  50796. private static TEX_2D;
  50797. private static TEX_3D;
  50798. /**
  50799. * Gets the openGL type
  50800. */
  50801. glType: number;
  50802. /**
  50803. * Gets the openGL type size
  50804. */
  50805. glTypeSize: number;
  50806. /**
  50807. * Gets the openGL format
  50808. */
  50809. glFormat: number;
  50810. /**
  50811. * Gets the openGL internal format
  50812. */
  50813. glInternalFormat: number;
  50814. /**
  50815. * Gets the base internal format
  50816. */
  50817. glBaseInternalFormat: number;
  50818. /**
  50819. * Gets image width in pixel
  50820. */
  50821. pixelWidth: number;
  50822. /**
  50823. * Gets image height in pixel
  50824. */
  50825. pixelHeight: number;
  50826. /**
  50827. * Gets image depth in pixels
  50828. */
  50829. pixelDepth: number;
  50830. /**
  50831. * Gets the number of array elements
  50832. */
  50833. numberOfArrayElements: number;
  50834. /**
  50835. * Gets the number of faces
  50836. */
  50837. numberOfFaces: number;
  50838. /**
  50839. * Gets the number of mipmap levels
  50840. */
  50841. numberOfMipmapLevels: number;
  50842. /**
  50843. * Gets the bytes of key value data
  50844. */
  50845. bytesOfKeyValueData: number;
  50846. /**
  50847. * Gets the load type
  50848. */
  50849. loadType: number;
  50850. /**
  50851. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50852. */
  50853. isInvalid: boolean;
  50854. /**
  50855. * Creates a new KhronosTextureContainer
  50856. * @param arrayBuffer contents of the KTX container file
  50857. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50858. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50859. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50860. */
  50861. constructor(
  50862. /** contents of the KTX container file */
  50863. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50864. /**
  50865. * Uploads KTX content to a Babylon Texture.
  50866. * It is assumed that the texture has already been created & is currently bound
  50867. * @hidden
  50868. */
  50869. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50870. private _upload2DCompressedLevels;
  50871. }
  50872. }
  50873. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50874. import { Nullable } from "babylonjs/types";
  50875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50876. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50877. /**
  50878. * Implementation of the KTX Texture Loader.
  50879. * @hidden
  50880. */
  50881. export class _KTXTextureLoader implements IInternalTextureLoader {
  50882. /**
  50883. * Defines wether the loader supports cascade loading the different faces.
  50884. */
  50885. readonly supportCascades: boolean;
  50886. /**
  50887. * This returns if the loader support the current file information.
  50888. * @param extension defines the file extension of the file being loaded
  50889. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50890. * @param fallback defines the fallback internal texture if any
  50891. * @param isBase64 defines whether the texture is encoded as a base64
  50892. * @param isBuffer defines whether the texture data are stored as a buffer
  50893. * @returns true if the loader can load the specified file
  50894. */
  50895. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50896. /**
  50897. * Transform the url before loading if required.
  50898. * @param rootUrl the url of the texture
  50899. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50900. * @returns the transformed texture
  50901. */
  50902. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50903. /**
  50904. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50905. * @param rootUrl the url of the texture
  50906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50907. * @returns the fallback texture
  50908. */
  50909. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50910. /**
  50911. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50912. * @param data contains the texture data
  50913. * @param texture defines the BabylonJS internal texture
  50914. * @param createPolynomials will be true if polynomials have been requested
  50915. * @param onLoad defines the callback to trigger once the texture is ready
  50916. * @param onError defines the callback to trigger in case of error
  50917. */
  50918. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50919. /**
  50920. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50921. * @param data contains the texture data
  50922. * @param texture defines the BabylonJS internal texture
  50923. * @param callback defines the method to call once ready to upload
  50924. */
  50925. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50926. }
  50927. }
  50928. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50929. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50930. import { Scene } from "babylonjs/scene";
  50931. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50932. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50933. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50934. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50935. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50936. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50938. /**
  50939. * Options for the default xr helper
  50940. */
  50941. export class WebXRDefaultExperienceOptions {
  50942. /**
  50943. * Floor meshes that should be used for teleporting
  50944. */
  50945. floorMeshes: Array<AbstractMesh>;
  50946. }
  50947. /**
  50948. * Default experience which provides a similar setup to the previous webVRExperience
  50949. */
  50950. export class WebXRDefaultExperience {
  50951. /**
  50952. * Base experience
  50953. */
  50954. baseExperience: WebXRExperienceHelper;
  50955. /**
  50956. * Input experience extension
  50957. */
  50958. input: WebXRInput;
  50959. /**
  50960. * Loads the controller models
  50961. */
  50962. controllerModelLoader: WebXRControllerModelLoader;
  50963. /**
  50964. * Enables laser pointer and selection
  50965. */
  50966. pointerSelection: WebXRControllerPointerSelection;
  50967. /**
  50968. * Enables teleportation
  50969. */
  50970. teleportation: WebXRControllerTeleportation;
  50971. /**
  50972. * Enables ui for enetering/exiting xr
  50973. */
  50974. enterExitUI: WebXREnterExitUI;
  50975. /**
  50976. * Default output canvas xr should render to
  50977. */
  50978. outputCanvas: WebXRManagedOutputCanvas;
  50979. /**
  50980. * Creates the default xr experience
  50981. * @param scene scene
  50982. * @param options options for basic configuration
  50983. * @returns resulting WebXRDefaultExperience
  50984. */
  50985. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50986. private constructor();
  50987. /**
  50988. * DIsposes of the experience helper
  50989. */
  50990. dispose(): void;
  50991. }
  50992. }
  50993. declare module "babylonjs/Helpers/sceneHelpers" {
  50994. import { Nullable } from "babylonjs/types";
  50995. import { Mesh } from "babylonjs/Meshes/mesh";
  50996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50997. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50998. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50999. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51000. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51001. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51002. import "babylonjs/Meshes/Builders/boxBuilder";
  51003. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51004. /** @hidden */
  51005. export var _forceSceneHelpersToBundle: boolean;
  51006. module "babylonjs/scene" {
  51007. interface Scene {
  51008. /**
  51009. * Creates a default light for the scene.
  51010. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51011. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51012. */
  51013. createDefaultLight(replace?: boolean): void;
  51014. /**
  51015. * Creates a default camera for the scene.
  51016. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51017. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51018. * @param replace has default false, when true replaces the active camera in the scene
  51019. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51020. */
  51021. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51022. /**
  51023. * Creates a default camera and a default light.
  51024. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51025. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51026. * @param replace has the default false, when true replaces the active camera/light in the scene
  51027. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51028. */
  51029. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51030. /**
  51031. * Creates a new sky box
  51032. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51033. * @param environmentTexture defines the texture to use as environment texture
  51034. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51035. * @param scale defines the overall scale of the skybox
  51036. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51037. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51038. * @returns a new mesh holding the sky box
  51039. */
  51040. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51041. /**
  51042. * Creates a new environment
  51043. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51044. * @param options defines the options you can use to configure the environment
  51045. * @returns the new EnvironmentHelper
  51046. */
  51047. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51048. /**
  51049. * Creates a new VREXperienceHelper
  51050. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51051. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51052. * @returns a new VREXperienceHelper
  51053. */
  51054. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51055. /**
  51056. * Creates a new WebXRDefaultExperience
  51057. * @see http://doc.babylonjs.com/how_to/webxr
  51058. * @param options experience options
  51059. * @returns a promise for a new WebXRDefaultExperience
  51060. */
  51061. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51062. }
  51063. }
  51064. }
  51065. declare module "babylonjs/Helpers/videoDome" {
  51066. import { Scene } from "babylonjs/scene";
  51067. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51068. import { Mesh } from "babylonjs/Meshes/mesh";
  51069. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51070. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51071. import "babylonjs/Meshes/Builders/sphereBuilder";
  51072. /**
  51073. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51074. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51075. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51076. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51077. */
  51078. export class VideoDome extends TransformNode {
  51079. /**
  51080. * Define the video source as a Monoscopic panoramic 360 video.
  51081. */
  51082. static readonly MODE_MONOSCOPIC: number;
  51083. /**
  51084. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51085. */
  51086. static readonly MODE_TOPBOTTOM: number;
  51087. /**
  51088. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51089. */
  51090. static readonly MODE_SIDEBYSIDE: number;
  51091. private _halfDome;
  51092. private _useDirectMapping;
  51093. /**
  51094. * The video texture being displayed on the sphere
  51095. */
  51096. protected _videoTexture: VideoTexture;
  51097. /**
  51098. * Gets the video texture being displayed on the sphere
  51099. */
  51100. readonly videoTexture: VideoTexture;
  51101. /**
  51102. * The skybox material
  51103. */
  51104. protected _material: BackgroundMaterial;
  51105. /**
  51106. * The surface used for the skybox
  51107. */
  51108. protected _mesh: Mesh;
  51109. /**
  51110. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51111. */
  51112. private _halfDomeMask;
  51113. /**
  51114. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51115. * Also see the options.resolution property.
  51116. */
  51117. fovMultiplier: number;
  51118. private _videoMode;
  51119. /**
  51120. * Gets or set the current video mode for the video. It can be:
  51121. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51122. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51123. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51124. */
  51125. videoMode: number;
  51126. /**
  51127. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51128. *
  51129. */
  51130. /**
  51131. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51132. */
  51133. halfDome: boolean;
  51134. /**
  51135. * Oberserver used in Stereoscopic VR Mode.
  51136. */
  51137. private _onBeforeCameraRenderObserver;
  51138. /**
  51139. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51140. * @param name Element's name, child elements will append suffixes for their own names.
  51141. * @param urlsOrVideo defines the url(s) or the video element to use
  51142. * @param options An object containing optional or exposed sub element properties
  51143. */
  51144. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51145. resolution?: number;
  51146. clickToPlay?: boolean;
  51147. autoPlay?: boolean;
  51148. loop?: boolean;
  51149. size?: number;
  51150. poster?: string;
  51151. faceForward?: boolean;
  51152. useDirectMapping?: boolean;
  51153. halfDomeMode?: boolean;
  51154. }, scene: Scene);
  51155. private _changeVideoMode;
  51156. /**
  51157. * Releases resources associated with this node.
  51158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51160. */
  51161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51162. }
  51163. }
  51164. declare module "babylonjs/Helpers/index" {
  51165. export * from "babylonjs/Helpers/environmentHelper";
  51166. export * from "babylonjs/Helpers/photoDome";
  51167. export * from "babylonjs/Helpers/sceneHelpers";
  51168. export * from "babylonjs/Helpers/videoDome";
  51169. }
  51170. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51171. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51172. import { IDisposable } from "babylonjs/scene";
  51173. import { Engine } from "babylonjs/Engines/engine";
  51174. /**
  51175. * This class can be used to get instrumentation data from a Babylon engine
  51176. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51177. */
  51178. export class EngineInstrumentation implements IDisposable {
  51179. /**
  51180. * Define the instrumented engine.
  51181. */
  51182. engine: Engine;
  51183. private _captureGPUFrameTime;
  51184. private _gpuFrameTimeToken;
  51185. private _gpuFrameTime;
  51186. private _captureShaderCompilationTime;
  51187. private _shaderCompilationTime;
  51188. private _onBeginFrameObserver;
  51189. private _onEndFrameObserver;
  51190. private _onBeforeShaderCompilationObserver;
  51191. private _onAfterShaderCompilationObserver;
  51192. /**
  51193. * Gets the perf counter used for GPU frame time
  51194. */
  51195. readonly gpuFrameTimeCounter: PerfCounter;
  51196. /**
  51197. * Gets the GPU frame time capture status
  51198. */
  51199. /**
  51200. * Enable or disable the GPU frame time capture
  51201. */
  51202. captureGPUFrameTime: boolean;
  51203. /**
  51204. * Gets the perf counter used for shader compilation time
  51205. */
  51206. readonly shaderCompilationTimeCounter: PerfCounter;
  51207. /**
  51208. * Gets the shader compilation time capture status
  51209. */
  51210. /**
  51211. * Enable or disable the shader compilation time capture
  51212. */
  51213. captureShaderCompilationTime: boolean;
  51214. /**
  51215. * Instantiates a new engine instrumentation.
  51216. * This class can be used to get instrumentation data from a Babylon engine
  51217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51218. * @param engine Defines the engine to instrument
  51219. */
  51220. constructor(
  51221. /**
  51222. * Define the instrumented engine.
  51223. */
  51224. engine: Engine);
  51225. /**
  51226. * Dispose and release associated resources.
  51227. */
  51228. dispose(): void;
  51229. }
  51230. }
  51231. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51232. import { Scene, IDisposable } from "babylonjs/scene";
  51233. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51234. /**
  51235. * This class can be used to get instrumentation data from a Babylon engine
  51236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51237. */
  51238. export class SceneInstrumentation implements IDisposable {
  51239. /**
  51240. * Defines the scene to instrument
  51241. */
  51242. scene: Scene;
  51243. private _captureActiveMeshesEvaluationTime;
  51244. private _activeMeshesEvaluationTime;
  51245. private _captureRenderTargetsRenderTime;
  51246. private _renderTargetsRenderTime;
  51247. private _captureFrameTime;
  51248. private _frameTime;
  51249. private _captureRenderTime;
  51250. private _renderTime;
  51251. private _captureInterFrameTime;
  51252. private _interFrameTime;
  51253. private _captureParticlesRenderTime;
  51254. private _particlesRenderTime;
  51255. private _captureSpritesRenderTime;
  51256. private _spritesRenderTime;
  51257. private _capturePhysicsTime;
  51258. private _physicsTime;
  51259. private _captureAnimationsTime;
  51260. private _animationsTime;
  51261. private _captureCameraRenderTime;
  51262. private _cameraRenderTime;
  51263. private _onBeforeActiveMeshesEvaluationObserver;
  51264. private _onAfterActiveMeshesEvaluationObserver;
  51265. private _onBeforeRenderTargetsRenderObserver;
  51266. private _onAfterRenderTargetsRenderObserver;
  51267. private _onAfterRenderObserver;
  51268. private _onBeforeDrawPhaseObserver;
  51269. private _onAfterDrawPhaseObserver;
  51270. private _onBeforeAnimationsObserver;
  51271. private _onBeforeParticlesRenderingObserver;
  51272. private _onAfterParticlesRenderingObserver;
  51273. private _onBeforeSpritesRenderingObserver;
  51274. private _onAfterSpritesRenderingObserver;
  51275. private _onBeforePhysicsObserver;
  51276. private _onAfterPhysicsObserver;
  51277. private _onAfterAnimationsObserver;
  51278. private _onBeforeCameraRenderObserver;
  51279. private _onAfterCameraRenderObserver;
  51280. /**
  51281. * Gets the perf counter used for active meshes evaluation time
  51282. */
  51283. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51284. /**
  51285. * Gets the active meshes evaluation time capture status
  51286. */
  51287. /**
  51288. * Enable or disable the active meshes evaluation time capture
  51289. */
  51290. captureActiveMeshesEvaluationTime: boolean;
  51291. /**
  51292. * Gets the perf counter used for render targets render time
  51293. */
  51294. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51295. /**
  51296. * Gets the render targets render time capture status
  51297. */
  51298. /**
  51299. * Enable or disable the render targets render time capture
  51300. */
  51301. captureRenderTargetsRenderTime: boolean;
  51302. /**
  51303. * Gets the perf counter used for particles render time
  51304. */
  51305. readonly particlesRenderTimeCounter: PerfCounter;
  51306. /**
  51307. * Gets the particles render time capture status
  51308. */
  51309. /**
  51310. * Enable or disable the particles render time capture
  51311. */
  51312. captureParticlesRenderTime: boolean;
  51313. /**
  51314. * Gets the perf counter used for sprites render time
  51315. */
  51316. readonly spritesRenderTimeCounter: PerfCounter;
  51317. /**
  51318. * Gets the sprites render time capture status
  51319. */
  51320. /**
  51321. * Enable or disable the sprites render time capture
  51322. */
  51323. captureSpritesRenderTime: boolean;
  51324. /**
  51325. * Gets the perf counter used for physics time
  51326. */
  51327. readonly physicsTimeCounter: PerfCounter;
  51328. /**
  51329. * Gets the physics time capture status
  51330. */
  51331. /**
  51332. * Enable or disable the physics time capture
  51333. */
  51334. capturePhysicsTime: boolean;
  51335. /**
  51336. * Gets the perf counter used for animations time
  51337. */
  51338. readonly animationsTimeCounter: PerfCounter;
  51339. /**
  51340. * Gets the animations time capture status
  51341. */
  51342. /**
  51343. * Enable or disable the animations time capture
  51344. */
  51345. captureAnimationsTime: boolean;
  51346. /**
  51347. * Gets the perf counter used for frame time capture
  51348. */
  51349. readonly frameTimeCounter: PerfCounter;
  51350. /**
  51351. * Gets the frame time capture status
  51352. */
  51353. /**
  51354. * Enable or disable the frame time capture
  51355. */
  51356. captureFrameTime: boolean;
  51357. /**
  51358. * Gets the perf counter used for inter-frames time capture
  51359. */
  51360. readonly interFrameTimeCounter: PerfCounter;
  51361. /**
  51362. * Gets the inter-frames time capture status
  51363. */
  51364. /**
  51365. * Enable or disable the inter-frames time capture
  51366. */
  51367. captureInterFrameTime: boolean;
  51368. /**
  51369. * Gets the perf counter used for render time capture
  51370. */
  51371. readonly renderTimeCounter: PerfCounter;
  51372. /**
  51373. * Gets the render time capture status
  51374. */
  51375. /**
  51376. * Enable or disable the render time capture
  51377. */
  51378. captureRenderTime: boolean;
  51379. /**
  51380. * Gets the perf counter used for camera render time capture
  51381. */
  51382. readonly cameraRenderTimeCounter: PerfCounter;
  51383. /**
  51384. * Gets the camera render time capture status
  51385. */
  51386. /**
  51387. * Enable or disable the camera render time capture
  51388. */
  51389. captureCameraRenderTime: boolean;
  51390. /**
  51391. * Gets the perf counter used for draw calls
  51392. */
  51393. readonly drawCallsCounter: PerfCounter;
  51394. /**
  51395. * Instantiates a new scene instrumentation.
  51396. * This class can be used to get instrumentation data from a Babylon engine
  51397. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51398. * @param scene Defines the scene to instrument
  51399. */
  51400. constructor(
  51401. /**
  51402. * Defines the scene to instrument
  51403. */
  51404. scene: Scene);
  51405. /**
  51406. * Dispose and release associated resources.
  51407. */
  51408. dispose(): void;
  51409. }
  51410. }
  51411. declare module "babylonjs/Instrumentation/index" {
  51412. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51413. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51414. export * from "babylonjs/Instrumentation/timeToken";
  51415. }
  51416. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51417. /** @hidden */
  51418. export var glowMapGenerationPixelShader: {
  51419. name: string;
  51420. shader: string;
  51421. };
  51422. }
  51423. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51424. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51427. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51429. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51430. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51431. /** @hidden */
  51432. export var glowMapGenerationVertexShader: {
  51433. name: string;
  51434. shader: string;
  51435. };
  51436. }
  51437. declare module "babylonjs/Layers/effectLayer" {
  51438. import { Observable } from "babylonjs/Misc/observable";
  51439. import { Nullable } from "babylonjs/types";
  51440. import { Camera } from "babylonjs/Cameras/camera";
  51441. import { Scene } from "babylonjs/scene";
  51442. import { ISize } from "babylonjs/Maths/math.size";
  51443. import { Color4 } from "babylonjs/Maths/math.color";
  51444. import { Engine } from "babylonjs/Engines/engine";
  51445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51447. import { Mesh } from "babylonjs/Meshes/mesh";
  51448. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51450. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51451. import { Effect } from "babylonjs/Materials/effect";
  51452. import { Material } from "babylonjs/Materials/material";
  51453. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51454. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51455. /**
  51456. * Effect layer options. This helps customizing the behaviour
  51457. * of the effect layer.
  51458. */
  51459. export interface IEffectLayerOptions {
  51460. /**
  51461. * Multiplication factor apply to the canvas size to compute the render target size
  51462. * used to generated the objects (the smaller the faster).
  51463. */
  51464. mainTextureRatio: number;
  51465. /**
  51466. * Enforces a fixed size texture to ensure effect stability across devices.
  51467. */
  51468. mainTextureFixedSize?: number;
  51469. /**
  51470. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51471. */
  51472. alphaBlendingMode: number;
  51473. /**
  51474. * The camera attached to the layer.
  51475. */
  51476. camera: Nullable<Camera>;
  51477. /**
  51478. * The rendering group to draw the layer in.
  51479. */
  51480. renderingGroupId: number;
  51481. }
  51482. /**
  51483. * The effect layer Helps adding post process effect blended with the main pass.
  51484. *
  51485. * This can be for instance use to generate glow or higlight effects on the scene.
  51486. *
  51487. * The effect layer class can not be used directly and is intented to inherited from to be
  51488. * customized per effects.
  51489. */
  51490. export abstract class EffectLayer {
  51491. private _vertexBuffers;
  51492. private _indexBuffer;
  51493. private _cachedDefines;
  51494. private _effectLayerMapGenerationEffect;
  51495. private _effectLayerOptions;
  51496. private _mergeEffect;
  51497. protected _scene: Scene;
  51498. protected _engine: Engine;
  51499. protected _maxSize: number;
  51500. protected _mainTextureDesiredSize: ISize;
  51501. protected _mainTexture: RenderTargetTexture;
  51502. protected _shouldRender: boolean;
  51503. protected _postProcesses: PostProcess[];
  51504. protected _textures: BaseTexture[];
  51505. protected _emissiveTextureAndColor: {
  51506. texture: Nullable<BaseTexture>;
  51507. color: Color4;
  51508. };
  51509. /**
  51510. * The name of the layer
  51511. */
  51512. name: string;
  51513. /**
  51514. * The clear color of the texture used to generate the glow map.
  51515. */
  51516. neutralColor: Color4;
  51517. /**
  51518. * Specifies wether the highlight layer is enabled or not.
  51519. */
  51520. isEnabled: boolean;
  51521. /**
  51522. * Gets the camera attached to the layer.
  51523. */
  51524. readonly camera: Nullable<Camera>;
  51525. /**
  51526. * Gets the rendering group id the layer should render in.
  51527. */
  51528. renderingGroupId: number;
  51529. /**
  51530. * An event triggered when the effect layer has been disposed.
  51531. */
  51532. onDisposeObservable: Observable<EffectLayer>;
  51533. /**
  51534. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51535. */
  51536. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51537. /**
  51538. * An event triggered when the generated texture is being merged in the scene.
  51539. */
  51540. onBeforeComposeObservable: Observable<EffectLayer>;
  51541. /**
  51542. * An event triggered when the generated texture has been merged in the scene.
  51543. */
  51544. onAfterComposeObservable: Observable<EffectLayer>;
  51545. /**
  51546. * An event triggered when the efffect layer changes its size.
  51547. */
  51548. onSizeChangedObservable: Observable<EffectLayer>;
  51549. /** @hidden */
  51550. static _SceneComponentInitialization: (scene: Scene) => void;
  51551. /**
  51552. * Instantiates a new effect Layer and references it in the scene.
  51553. * @param name The name of the layer
  51554. * @param scene The scene to use the layer in
  51555. */
  51556. constructor(
  51557. /** The Friendly of the effect in the scene */
  51558. name: string, scene: Scene);
  51559. /**
  51560. * Get the effect name of the layer.
  51561. * @return The effect name
  51562. */
  51563. abstract getEffectName(): string;
  51564. /**
  51565. * Checks for the readiness of the element composing the layer.
  51566. * @param subMesh the mesh to check for
  51567. * @param useInstances specify wether or not to use instances to render the mesh
  51568. * @return true if ready otherwise, false
  51569. */
  51570. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51571. /**
  51572. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51573. * @returns true if the effect requires stencil during the main canvas render pass.
  51574. */
  51575. abstract needStencil(): boolean;
  51576. /**
  51577. * Create the merge effect. This is the shader use to blit the information back
  51578. * to the main canvas at the end of the scene rendering.
  51579. * @returns The effect containing the shader used to merge the effect on the main canvas
  51580. */
  51581. protected abstract _createMergeEffect(): Effect;
  51582. /**
  51583. * Creates the render target textures and post processes used in the effect layer.
  51584. */
  51585. protected abstract _createTextureAndPostProcesses(): void;
  51586. /**
  51587. * Implementation specific of rendering the generating effect on the main canvas.
  51588. * @param effect The effect used to render through
  51589. */
  51590. protected abstract _internalRender(effect: Effect): void;
  51591. /**
  51592. * Sets the required values for both the emissive texture and and the main color.
  51593. */
  51594. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51595. /**
  51596. * Free any resources and references associated to a mesh.
  51597. * Internal use
  51598. * @param mesh The mesh to free.
  51599. */
  51600. abstract _disposeMesh(mesh: Mesh): void;
  51601. /**
  51602. * Serializes this layer (Glow or Highlight for example)
  51603. * @returns a serialized layer object
  51604. */
  51605. abstract serialize?(): any;
  51606. /**
  51607. * Initializes the effect layer with the required options.
  51608. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51609. */
  51610. protected _init(options: Partial<IEffectLayerOptions>): void;
  51611. /**
  51612. * Generates the index buffer of the full screen quad blending to the main canvas.
  51613. */
  51614. private _generateIndexBuffer;
  51615. /**
  51616. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51617. */
  51618. private _generateVertexBuffer;
  51619. /**
  51620. * Sets the main texture desired size which is the closest power of two
  51621. * of the engine canvas size.
  51622. */
  51623. private _setMainTextureSize;
  51624. /**
  51625. * Creates the main texture for the effect layer.
  51626. */
  51627. protected _createMainTexture(): void;
  51628. /**
  51629. * Adds specific effects defines.
  51630. * @param defines The defines to add specifics to.
  51631. */
  51632. protected _addCustomEffectDefines(defines: string[]): void;
  51633. /**
  51634. * Checks for the readiness of the element composing the layer.
  51635. * @param subMesh the mesh to check for
  51636. * @param useInstances specify wether or not to use instances to render the mesh
  51637. * @param emissiveTexture the associated emissive texture used to generate the glow
  51638. * @return true if ready otherwise, false
  51639. */
  51640. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51641. /**
  51642. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51643. */
  51644. render(): void;
  51645. /**
  51646. * Determine if a given mesh will be used in the current effect.
  51647. * @param mesh mesh to test
  51648. * @returns true if the mesh will be used
  51649. */
  51650. hasMesh(mesh: AbstractMesh): boolean;
  51651. /**
  51652. * Returns true if the layer contains information to display, otherwise false.
  51653. * @returns true if the glow layer should be rendered
  51654. */
  51655. shouldRender(): boolean;
  51656. /**
  51657. * Returns true if the mesh should render, otherwise false.
  51658. * @param mesh The mesh to render
  51659. * @returns true if it should render otherwise false
  51660. */
  51661. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51662. /**
  51663. * Returns true if the mesh can be rendered, otherwise false.
  51664. * @param mesh The mesh to render
  51665. * @param material The material used on the mesh
  51666. * @returns true if it can be rendered otherwise false
  51667. */
  51668. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51669. /**
  51670. * Returns true if the mesh should render, otherwise false.
  51671. * @param mesh The mesh to render
  51672. * @returns true if it should render otherwise false
  51673. */
  51674. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51675. /**
  51676. * Renders the submesh passed in parameter to the generation map.
  51677. */
  51678. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51679. /**
  51680. * Rebuild the required buffers.
  51681. * @hidden Internal use only.
  51682. */
  51683. _rebuild(): void;
  51684. /**
  51685. * Dispose only the render target textures and post process.
  51686. */
  51687. private _disposeTextureAndPostProcesses;
  51688. /**
  51689. * Dispose the highlight layer and free resources.
  51690. */
  51691. dispose(): void;
  51692. /**
  51693. * Gets the class name of the effect layer
  51694. * @returns the string with the class name of the effect layer
  51695. */
  51696. getClassName(): string;
  51697. /**
  51698. * Creates an effect layer from parsed effect layer data
  51699. * @param parsedEffectLayer defines effect layer data
  51700. * @param scene defines the current scene
  51701. * @param rootUrl defines the root URL containing the effect layer information
  51702. * @returns a parsed effect Layer
  51703. */
  51704. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51705. }
  51706. }
  51707. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51708. import { Scene } from "babylonjs/scene";
  51709. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51710. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51711. import { AbstractScene } from "babylonjs/abstractScene";
  51712. module "babylonjs/abstractScene" {
  51713. interface AbstractScene {
  51714. /**
  51715. * The list of effect layers (highlights/glow) added to the scene
  51716. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51717. * @see http://doc.babylonjs.com/how_to/glow_layer
  51718. */
  51719. effectLayers: Array<EffectLayer>;
  51720. /**
  51721. * Removes the given effect layer from this scene.
  51722. * @param toRemove defines the effect layer to remove
  51723. * @returns the index of the removed effect layer
  51724. */
  51725. removeEffectLayer(toRemove: EffectLayer): number;
  51726. /**
  51727. * Adds the given effect layer to this scene
  51728. * @param newEffectLayer defines the effect layer to add
  51729. */
  51730. addEffectLayer(newEffectLayer: EffectLayer): void;
  51731. }
  51732. }
  51733. /**
  51734. * Defines the layer scene component responsible to manage any effect layers
  51735. * in a given scene.
  51736. */
  51737. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51738. /**
  51739. * The component name helpfull to identify the component in the list of scene components.
  51740. */
  51741. readonly name: string;
  51742. /**
  51743. * The scene the component belongs to.
  51744. */
  51745. scene: Scene;
  51746. private _engine;
  51747. private _renderEffects;
  51748. private _needStencil;
  51749. private _previousStencilState;
  51750. /**
  51751. * Creates a new instance of the component for the given scene
  51752. * @param scene Defines the scene to register the component in
  51753. */
  51754. constructor(scene: Scene);
  51755. /**
  51756. * Registers the component in a given scene
  51757. */
  51758. register(): void;
  51759. /**
  51760. * Rebuilds the elements related to this component in case of
  51761. * context lost for instance.
  51762. */
  51763. rebuild(): void;
  51764. /**
  51765. * Serializes the component data to the specified json object
  51766. * @param serializationObject The object to serialize to
  51767. */
  51768. serialize(serializationObject: any): void;
  51769. /**
  51770. * Adds all the elements from the container to the scene
  51771. * @param container the container holding the elements
  51772. */
  51773. addFromContainer(container: AbstractScene): void;
  51774. /**
  51775. * Removes all the elements in the container from the scene
  51776. * @param container contains the elements to remove
  51777. * @param dispose if the removed element should be disposed (default: false)
  51778. */
  51779. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51780. /**
  51781. * Disposes the component and the associated ressources.
  51782. */
  51783. dispose(): void;
  51784. private _isReadyForMesh;
  51785. private _renderMainTexture;
  51786. private _setStencil;
  51787. private _setStencilBack;
  51788. private _draw;
  51789. private _drawCamera;
  51790. private _drawRenderingGroup;
  51791. }
  51792. }
  51793. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51794. /** @hidden */
  51795. export var glowMapMergePixelShader: {
  51796. name: string;
  51797. shader: string;
  51798. };
  51799. }
  51800. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51801. /** @hidden */
  51802. export var glowMapMergeVertexShader: {
  51803. name: string;
  51804. shader: string;
  51805. };
  51806. }
  51807. declare module "babylonjs/Layers/glowLayer" {
  51808. import { Nullable } from "babylonjs/types";
  51809. import { Camera } from "babylonjs/Cameras/camera";
  51810. import { Scene } from "babylonjs/scene";
  51811. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51813. import { Mesh } from "babylonjs/Meshes/mesh";
  51814. import { Texture } from "babylonjs/Materials/Textures/texture";
  51815. import { Effect } from "babylonjs/Materials/effect";
  51816. import { Material } from "babylonjs/Materials/material";
  51817. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51818. import { Color4 } from "babylonjs/Maths/math.color";
  51819. import "babylonjs/Shaders/glowMapMerge.fragment";
  51820. import "babylonjs/Shaders/glowMapMerge.vertex";
  51821. import "babylonjs/Layers/effectLayerSceneComponent";
  51822. module "babylonjs/abstractScene" {
  51823. interface AbstractScene {
  51824. /**
  51825. * Return a the first highlight layer of the scene with a given name.
  51826. * @param name The name of the highlight layer to look for.
  51827. * @return The highlight layer if found otherwise null.
  51828. */
  51829. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51830. }
  51831. }
  51832. /**
  51833. * Glow layer options. This helps customizing the behaviour
  51834. * of the glow layer.
  51835. */
  51836. export interface IGlowLayerOptions {
  51837. /**
  51838. * Multiplication factor apply to the canvas size to compute the render target size
  51839. * used to generated the glowing objects (the smaller the faster).
  51840. */
  51841. mainTextureRatio: number;
  51842. /**
  51843. * Enforces a fixed size texture to ensure resize independant blur.
  51844. */
  51845. mainTextureFixedSize?: number;
  51846. /**
  51847. * How big is the kernel of the blur texture.
  51848. */
  51849. blurKernelSize: number;
  51850. /**
  51851. * The camera attached to the layer.
  51852. */
  51853. camera: Nullable<Camera>;
  51854. /**
  51855. * Enable MSAA by chosing the number of samples.
  51856. */
  51857. mainTextureSamples?: number;
  51858. /**
  51859. * The rendering group to draw the layer in.
  51860. */
  51861. renderingGroupId: number;
  51862. }
  51863. /**
  51864. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51865. *
  51866. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51867. * glowy meshes to your scene.
  51868. *
  51869. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51870. */
  51871. export class GlowLayer extends EffectLayer {
  51872. /**
  51873. * Effect Name of the layer.
  51874. */
  51875. static readonly EffectName: string;
  51876. /**
  51877. * The default blur kernel size used for the glow.
  51878. */
  51879. static DefaultBlurKernelSize: number;
  51880. /**
  51881. * The default texture size ratio used for the glow.
  51882. */
  51883. static DefaultTextureRatio: number;
  51884. /**
  51885. * Sets the kernel size of the blur.
  51886. */
  51887. /**
  51888. * Gets the kernel size of the blur.
  51889. */
  51890. blurKernelSize: number;
  51891. /**
  51892. * Sets the glow intensity.
  51893. */
  51894. /**
  51895. * Gets the glow intensity.
  51896. */
  51897. intensity: number;
  51898. private _options;
  51899. private _intensity;
  51900. private _horizontalBlurPostprocess1;
  51901. private _verticalBlurPostprocess1;
  51902. private _horizontalBlurPostprocess2;
  51903. private _verticalBlurPostprocess2;
  51904. private _blurTexture1;
  51905. private _blurTexture2;
  51906. private _postProcesses1;
  51907. private _postProcesses2;
  51908. private _includedOnlyMeshes;
  51909. private _excludedMeshes;
  51910. /**
  51911. * Callback used to let the user override the color selection on a per mesh basis
  51912. */
  51913. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51914. /**
  51915. * Callback used to let the user override the texture selection on a per mesh basis
  51916. */
  51917. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51918. /**
  51919. * Instantiates a new glow Layer and references it to the scene.
  51920. * @param name The name of the layer
  51921. * @param scene The scene to use the layer in
  51922. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51923. */
  51924. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51925. /**
  51926. * Get the effect name of the layer.
  51927. * @return The effect name
  51928. */
  51929. getEffectName(): string;
  51930. /**
  51931. * Create the merge effect. This is the shader use to blit the information back
  51932. * to the main canvas at the end of the scene rendering.
  51933. */
  51934. protected _createMergeEffect(): Effect;
  51935. /**
  51936. * Creates the render target textures and post processes used in the glow layer.
  51937. */
  51938. protected _createTextureAndPostProcesses(): void;
  51939. /**
  51940. * Checks for the readiness of the element composing the layer.
  51941. * @param subMesh the mesh to check for
  51942. * @param useInstances specify wether or not to use instances to render the mesh
  51943. * @param emissiveTexture the associated emissive texture used to generate the glow
  51944. * @return true if ready otherwise, false
  51945. */
  51946. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51947. /**
  51948. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51949. */
  51950. needStencil(): boolean;
  51951. /**
  51952. * Returns true if the mesh can be rendered, otherwise false.
  51953. * @param mesh The mesh to render
  51954. * @param material The material used on the mesh
  51955. * @returns true if it can be rendered otherwise false
  51956. */
  51957. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51958. /**
  51959. * Implementation specific of rendering the generating effect on the main canvas.
  51960. * @param effect The effect used to render through
  51961. */
  51962. protected _internalRender(effect: Effect): void;
  51963. /**
  51964. * Sets the required values for both the emissive texture and and the main color.
  51965. */
  51966. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51967. /**
  51968. * Returns true if the mesh should render, otherwise false.
  51969. * @param mesh The mesh to render
  51970. * @returns true if it should render otherwise false
  51971. */
  51972. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51973. /**
  51974. * Adds specific effects defines.
  51975. * @param defines The defines to add specifics to.
  51976. */
  51977. protected _addCustomEffectDefines(defines: string[]): void;
  51978. /**
  51979. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51980. * @param mesh The mesh to exclude from the glow layer
  51981. */
  51982. addExcludedMesh(mesh: Mesh): void;
  51983. /**
  51984. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51985. * @param mesh The mesh to remove
  51986. */
  51987. removeExcludedMesh(mesh: Mesh): void;
  51988. /**
  51989. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51990. * @param mesh The mesh to include in the glow layer
  51991. */
  51992. addIncludedOnlyMesh(mesh: Mesh): void;
  51993. /**
  51994. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51995. * @param mesh The mesh to remove
  51996. */
  51997. removeIncludedOnlyMesh(mesh: Mesh): void;
  51998. /**
  51999. * Determine if a given mesh will be used in the glow layer
  52000. * @param mesh The mesh to test
  52001. * @returns true if the mesh will be highlighted by the current glow layer
  52002. */
  52003. hasMesh(mesh: AbstractMesh): boolean;
  52004. /**
  52005. * Free any resources and references associated to a mesh.
  52006. * Internal use
  52007. * @param mesh The mesh to free.
  52008. * @hidden
  52009. */
  52010. _disposeMesh(mesh: Mesh): void;
  52011. /**
  52012. * Gets the class name of the effect layer
  52013. * @returns the string with the class name of the effect layer
  52014. */
  52015. getClassName(): string;
  52016. /**
  52017. * Serializes this glow layer
  52018. * @returns a serialized glow layer object
  52019. */
  52020. serialize(): any;
  52021. /**
  52022. * Creates a Glow Layer from parsed glow layer data
  52023. * @param parsedGlowLayer defines glow layer data
  52024. * @param scene defines the current scene
  52025. * @param rootUrl defines the root URL containing the glow layer information
  52026. * @returns a parsed Glow Layer
  52027. */
  52028. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52029. }
  52030. }
  52031. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52032. /** @hidden */
  52033. export var glowBlurPostProcessPixelShader: {
  52034. name: string;
  52035. shader: string;
  52036. };
  52037. }
  52038. declare module "babylonjs/Layers/highlightLayer" {
  52039. import { Observable } from "babylonjs/Misc/observable";
  52040. import { Nullable } from "babylonjs/types";
  52041. import { Camera } from "babylonjs/Cameras/camera";
  52042. import { Scene } from "babylonjs/scene";
  52043. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52045. import { Mesh } from "babylonjs/Meshes/mesh";
  52046. import { Effect } from "babylonjs/Materials/effect";
  52047. import { Material } from "babylonjs/Materials/material";
  52048. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52049. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52050. import "babylonjs/Shaders/glowMapMerge.fragment";
  52051. import "babylonjs/Shaders/glowMapMerge.vertex";
  52052. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52053. module "babylonjs/abstractScene" {
  52054. interface AbstractScene {
  52055. /**
  52056. * Return a the first highlight layer of the scene with a given name.
  52057. * @param name The name of the highlight layer to look for.
  52058. * @return The highlight layer if found otherwise null.
  52059. */
  52060. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52061. }
  52062. }
  52063. /**
  52064. * Highlight layer options. This helps customizing the behaviour
  52065. * of the highlight layer.
  52066. */
  52067. export interface IHighlightLayerOptions {
  52068. /**
  52069. * Multiplication factor apply to the canvas size to compute the render target size
  52070. * used to generated the glowing objects (the smaller the faster).
  52071. */
  52072. mainTextureRatio: number;
  52073. /**
  52074. * Enforces a fixed size texture to ensure resize independant blur.
  52075. */
  52076. mainTextureFixedSize?: number;
  52077. /**
  52078. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52079. * of the picture to blur (the smaller the faster).
  52080. */
  52081. blurTextureSizeRatio: number;
  52082. /**
  52083. * How big in texel of the blur texture is the vertical blur.
  52084. */
  52085. blurVerticalSize: number;
  52086. /**
  52087. * How big in texel of the blur texture is the horizontal blur.
  52088. */
  52089. blurHorizontalSize: number;
  52090. /**
  52091. * Alpha blending mode used to apply the blur. Default is combine.
  52092. */
  52093. alphaBlendingMode: number;
  52094. /**
  52095. * The camera attached to the layer.
  52096. */
  52097. camera: Nullable<Camera>;
  52098. /**
  52099. * Should we display highlight as a solid stroke?
  52100. */
  52101. isStroke?: boolean;
  52102. /**
  52103. * The rendering group to draw the layer in.
  52104. */
  52105. renderingGroupId: number;
  52106. }
  52107. /**
  52108. * The highlight layer Helps adding a glow effect around a mesh.
  52109. *
  52110. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52111. * glowy meshes to your scene.
  52112. *
  52113. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52114. */
  52115. export class HighlightLayer extends EffectLayer {
  52116. name: string;
  52117. /**
  52118. * Effect Name of the highlight layer.
  52119. */
  52120. static readonly EffectName: string;
  52121. /**
  52122. * The neutral color used during the preparation of the glow effect.
  52123. * This is black by default as the blend operation is a blend operation.
  52124. */
  52125. static NeutralColor: Color4;
  52126. /**
  52127. * Stencil value used for glowing meshes.
  52128. */
  52129. static GlowingMeshStencilReference: number;
  52130. /**
  52131. * Stencil value used for the other meshes in the scene.
  52132. */
  52133. static NormalMeshStencilReference: number;
  52134. /**
  52135. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52136. */
  52137. innerGlow: boolean;
  52138. /**
  52139. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52140. */
  52141. outerGlow: boolean;
  52142. /**
  52143. * Specifies the horizontal size of the blur.
  52144. */
  52145. /**
  52146. * Gets the horizontal size of the blur.
  52147. */
  52148. blurHorizontalSize: number;
  52149. /**
  52150. * Specifies the vertical size of the blur.
  52151. */
  52152. /**
  52153. * Gets the vertical size of the blur.
  52154. */
  52155. blurVerticalSize: number;
  52156. /**
  52157. * An event triggered when the highlight layer is being blurred.
  52158. */
  52159. onBeforeBlurObservable: Observable<HighlightLayer>;
  52160. /**
  52161. * An event triggered when the highlight layer has been blurred.
  52162. */
  52163. onAfterBlurObservable: Observable<HighlightLayer>;
  52164. private _instanceGlowingMeshStencilReference;
  52165. private _options;
  52166. private _downSamplePostprocess;
  52167. private _horizontalBlurPostprocess;
  52168. private _verticalBlurPostprocess;
  52169. private _blurTexture;
  52170. private _meshes;
  52171. private _excludedMeshes;
  52172. /**
  52173. * Instantiates a new highlight Layer and references it to the scene..
  52174. * @param name The name of the layer
  52175. * @param scene The scene to use the layer in
  52176. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52177. */
  52178. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52179. /**
  52180. * Get the effect name of the layer.
  52181. * @return The effect name
  52182. */
  52183. getEffectName(): string;
  52184. /**
  52185. * Create the merge effect. This is the shader use to blit the information back
  52186. * to the main canvas at the end of the scene rendering.
  52187. */
  52188. protected _createMergeEffect(): Effect;
  52189. /**
  52190. * Creates the render target textures and post processes used in the highlight layer.
  52191. */
  52192. protected _createTextureAndPostProcesses(): void;
  52193. /**
  52194. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52195. */
  52196. needStencil(): boolean;
  52197. /**
  52198. * Checks for the readiness of the element composing the layer.
  52199. * @param subMesh the mesh to check for
  52200. * @param useInstances specify wether or not to use instances to render the mesh
  52201. * @param emissiveTexture the associated emissive texture used to generate the glow
  52202. * @return true if ready otherwise, false
  52203. */
  52204. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52205. /**
  52206. * Implementation specific of rendering the generating effect on the main canvas.
  52207. * @param effect The effect used to render through
  52208. */
  52209. protected _internalRender(effect: Effect): void;
  52210. /**
  52211. * Returns true if the layer contains information to display, otherwise false.
  52212. */
  52213. shouldRender(): boolean;
  52214. /**
  52215. * Returns true if the mesh should render, otherwise false.
  52216. * @param mesh The mesh to render
  52217. * @returns true if it should render otherwise false
  52218. */
  52219. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52220. /**
  52221. * Sets the required values for both the emissive texture and and the main color.
  52222. */
  52223. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52224. /**
  52225. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52226. * @param mesh The mesh to exclude from the highlight layer
  52227. */
  52228. addExcludedMesh(mesh: Mesh): void;
  52229. /**
  52230. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52231. * @param mesh The mesh to highlight
  52232. */
  52233. removeExcludedMesh(mesh: Mesh): void;
  52234. /**
  52235. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52236. * @param mesh mesh to test
  52237. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52238. */
  52239. hasMesh(mesh: AbstractMesh): boolean;
  52240. /**
  52241. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52242. * @param mesh The mesh to highlight
  52243. * @param color The color of the highlight
  52244. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52245. */
  52246. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52247. /**
  52248. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52249. * @param mesh The mesh to highlight
  52250. */
  52251. removeMesh(mesh: Mesh): void;
  52252. /**
  52253. * Force the stencil to the normal expected value for none glowing parts
  52254. */
  52255. private _defaultStencilReference;
  52256. /**
  52257. * Free any resources and references associated to a mesh.
  52258. * Internal use
  52259. * @param mesh The mesh to free.
  52260. * @hidden
  52261. */
  52262. _disposeMesh(mesh: Mesh): void;
  52263. /**
  52264. * Dispose the highlight layer and free resources.
  52265. */
  52266. dispose(): void;
  52267. /**
  52268. * Gets the class name of the effect layer
  52269. * @returns the string with the class name of the effect layer
  52270. */
  52271. getClassName(): string;
  52272. /**
  52273. * Serializes this Highlight layer
  52274. * @returns a serialized Highlight layer object
  52275. */
  52276. serialize(): any;
  52277. /**
  52278. * Creates a Highlight layer from parsed Highlight layer data
  52279. * @param parsedHightlightLayer defines the Highlight layer data
  52280. * @param scene defines the current scene
  52281. * @param rootUrl defines the root URL containing the Highlight layer information
  52282. * @returns a parsed Highlight layer
  52283. */
  52284. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52285. }
  52286. }
  52287. declare module "babylonjs/Layers/layerSceneComponent" {
  52288. import { Scene } from "babylonjs/scene";
  52289. import { ISceneComponent } from "babylonjs/sceneComponent";
  52290. import { Layer } from "babylonjs/Layers/layer";
  52291. import { AbstractScene } from "babylonjs/abstractScene";
  52292. module "babylonjs/abstractScene" {
  52293. interface AbstractScene {
  52294. /**
  52295. * The list of layers (background and foreground) of the scene
  52296. */
  52297. layers: Array<Layer>;
  52298. }
  52299. }
  52300. /**
  52301. * Defines the layer scene component responsible to manage any layers
  52302. * in a given scene.
  52303. */
  52304. export class LayerSceneComponent implements ISceneComponent {
  52305. /**
  52306. * The component name helpfull to identify the component in the list of scene components.
  52307. */
  52308. readonly name: string;
  52309. /**
  52310. * The scene the component belongs to.
  52311. */
  52312. scene: Scene;
  52313. private _engine;
  52314. /**
  52315. * Creates a new instance of the component for the given scene
  52316. * @param scene Defines the scene to register the component in
  52317. */
  52318. constructor(scene: Scene);
  52319. /**
  52320. * Registers the component in a given scene
  52321. */
  52322. register(): void;
  52323. /**
  52324. * Rebuilds the elements related to this component in case of
  52325. * context lost for instance.
  52326. */
  52327. rebuild(): void;
  52328. /**
  52329. * Disposes the component and the associated ressources.
  52330. */
  52331. dispose(): void;
  52332. private _draw;
  52333. private _drawCameraPredicate;
  52334. private _drawCameraBackground;
  52335. private _drawCameraForeground;
  52336. private _drawRenderTargetPredicate;
  52337. private _drawRenderTargetBackground;
  52338. private _drawRenderTargetForeground;
  52339. /**
  52340. * Adds all the elements from the container to the scene
  52341. * @param container the container holding the elements
  52342. */
  52343. addFromContainer(container: AbstractScene): void;
  52344. /**
  52345. * Removes all the elements in the container from the scene
  52346. * @param container contains the elements to remove
  52347. * @param dispose if the removed element should be disposed (default: false)
  52348. */
  52349. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52350. }
  52351. }
  52352. declare module "babylonjs/Shaders/layer.fragment" {
  52353. /** @hidden */
  52354. export var layerPixelShader: {
  52355. name: string;
  52356. shader: string;
  52357. };
  52358. }
  52359. declare module "babylonjs/Shaders/layer.vertex" {
  52360. /** @hidden */
  52361. export var layerVertexShader: {
  52362. name: string;
  52363. shader: string;
  52364. };
  52365. }
  52366. declare module "babylonjs/Layers/layer" {
  52367. import { Observable } from "babylonjs/Misc/observable";
  52368. import { Nullable } from "babylonjs/types";
  52369. import { Scene } from "babylonjs/scene";
  52370. import { Vector2 } from "babylonjs/Maths/math.vector";
  52371. import { Color4 } from "babylonjs/Maths/math.color";
  52372. import { Texture } from "babylonjs/Materials/Textures/texture";
  52373. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52374. import "babylonjs/Shaders/layer.fragment";
  52375. import "babylonjs/Shaders/layer.vertex";
  52376. /**
  52377. * This represents a full screen 2d layer.
  52378. * This can be useful to display a picture in the background of your scene for instance.
  52379. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52380. */
  52381. export class Layer {
  52382. /**
  52383. * Define the name of the layer.
  52384. */
  52385. name: string;
  52386. /**
  52387. * Define the texture the layer should display.
  52388. */
  52389. texture: Nullable<Texture>;
  52390. /**
  52391. * Is the layer in background or foreground.
  52392. */
  52393. isBackground: boolean;
  52394. /**
  52395. * Define the color of the layer (instead of texture).
  52396. */
  52397. color: Color4;
  52398. /**
  52399. * Define the scale of the layer in order to zoom in out of the texture.
  52400. */
  52401. scale: Vector2;
  52402. /**
  52403. * Define an offset for the layer in order to shift the texture.
  52404. */
  52405. offset: Vector2;
  52406. /**
  52407. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52408. */
  52409. alphaBlendingMode: number;
  52410. /**
  52411. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52412. * Alpha test will not mix with the background color in case of transparency.
  52413. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52414. */
  52415. alphaTest: boolean;
  52416. /**
  52417. * Define a mask to restrict the layer to only some of the scene cameras.
  52418. */
  52419. layerMask: number;
  52420. /**
  52421. * Define the list of render target the layer is visible into.
  52422. */
  52423. renderTargetTextures: RenderTargetTexture[];
  52424. /**
  52425. * Define if the layer is only used in renderTarget or if it also
  52426. * renders in the main frame buffer of the canvas.
  52427. */
  52428. renderOnlyInRenderTargetTextures: boolean;
  52429. private _scene;
  52430. private _vertexBuffers;
  52431. private _indexBuffer;
  52432. private _effect;
  52433. private _alphaTestEffect;
  52434. /**
  52435. * An event triggered when the layer is disposed.
  52436. */
  52437. onDisposeObservable: Observable<Layer>;
  52438. private _onDisposeObserver;
  52439. /**
  52440. * Back compatibility with callback before the onDisposeObservable existed.
  52441. * The set callback will be triggered when the layer has been disposed.
  52442. */
  52443. onDispose: () => void;
  52444. /**
  52445. * An event triggered before rendering the scene
  52446. */
  52447. onBeforeRenderObservable: Observable<Layer>;
  52448. private _onBeforeRenderObserver;
  52449. /**
  52450. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52451. * The set callback will be triggered just before rendering the layer.
  52452. */
  52453. onBeforeRender: () => void;
  52454. /**
  52455. * An event triggered after rendering the scene
  52456. */
  52457. onAfterRenderObservable: Observable<Layer>;
  52458. private _onAfterRenderObserver;
  52459. /**
  52460. * Back compatibility with callback before the onAfterRenderObservable existed.
  52461. * The set callback will be triggered just after rendering the layer.
  52462. */
  52463. onAfterRender: () => void;
  52464. /**
  52465. * Instantiates a new layer.
  52466. * This represents a full screen 2d layer.
  52467. * This can be useful to display a picture in the background of your scene for instance.
  52468. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52469. * @param name Define the name of the layer in the scene
  52470. * @param imgUrl Define the url of the texture to display in the layer
  52471. * @param scene Define the scene the layer belongs to
  52472. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52473. * @param color Defines a color for the layer
  52474. */
  52475. constructor(
  52476. /**
  52477. * Define the name of the layer.
  52478. */
  52479. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52480. private _createIndexBuffer;
  52481. /** @hidden */
  52482. _rebuild(): void;
  52483. /**
  52484. * Renders the layer in the scene.
  52485. */
  52486. render(): void;
  52487. /**
  52488. * Disposes and releases the associated ressources.
  52489. */
  52490. dispose(): void;
  52491. }
  52492. }
  52493. declare module "babylonjs/Layers/index" {
  52494. export * from "babylonjs/Layers/effectLayer";
  52495. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52496. export * from "babylonjs/Layers/glowLayer";
  52497. export * from "babylonjs/Layers/highlightLayer";
  52498. export * from "babylonjs/Layers/layer";
  52499. export * from "babylonjs/Layers/layerSceneComponent";
  52500. }
  52501. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52502. /** @hidden */
  52503. export var lensFlarePixelShader: {
  52504. name: string;
  52505. shader: string;
  52506. };
  52507. }
  52508. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52509. /** @hidden */
  52510. export var lensFlareVertexShader: {
  52511. name: string;
  52512. shader: string;
  52513. };
  52514. }
  52515. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52516. import { Scene } from "babylonjs/scene";
  52517. import { Vector3 } from "babylonjs/Maths/math.vector";
  52518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52519. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52520. import "babylonjs/Shaders/lensFlare.fragment";
  52521. import "babylonjs/Shaders/lensFlare.vertex";
  52522. import { Viewport } from "babylonjs/Maths/math.viewport";
  52523. /**
  52524. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52525. * It is usually composed of several `lensFlare`.
  52526. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52527. */
  52528. export class LensFlareSystem {
  52529. /**
  52530. * Define the name of the lens flare system
  52531. */
  52532. name: string;
  52533. /**
  52534. * List of lens flares used in this system.
  52535. */
  52536. lensFlares: LensFlare[];
  52537. /**
  52538. * Define a limit from the border the lens flare can be visible.
  52539. */
  52540. borderLimit: number;
  52541. /**
  52542. * Define a viewport border we do not want to see the lens flare in.
  52543. */
  52544. viewportBorder: number;
  52545. /**
  52546. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52547. */
  52548. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52549. /**
  52550. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52551. */
  52552. layerMask: number;
  52553. /**
  52554. * Define the id of the lens flare system in the scene.
  52555. * (equal to name by default)
  52556. */
  52557. id: string;
  52558. private _scene;
  52559. private _emitter;
  52560. private _vertexBuffers;
  52561. private _indexBuffer;
  52562. private _effect;
  52563. private _positionX;
  52564. private _positionY;
  52565. private _isEnabled;
  52566. /** @hidden */
  52567. static _SceneComponentInitialization: (scene: Scene) => void;
  52568. /**
  52569. * Instantiates a lens flare system.
  52570. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52571. * It is usually composed of several `lensFlare`.
  52572. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52573. * @param name Define the name of the lens flare system in the scene
  52574. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52575. * @param scene Define the scene the lens flare system belongs to
  52576. */
  52577. constructor(
  52578. /**
  52579. * Define the name of the lens flare system
  52580. */
  52581. name: string, emitter: any, scene: Scene);
  52582. /**
  52583. * Define if the lens flare system is enabled.
  52584. */
  52585. isEnabled: boolean;
  52586. /**
  52587. * Get the scene the effects belongs to.
  52588. * @returns the scene holding the lens flare system
  52589. */
  52590. getScene(): Scene;
  52591. /**
  52592. * Get the emitter of the lens flare system.
  52593. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52594. * @returns the emitter of the lens flare system
  52595. */
  52596. getEmitter(): any;
  52597. /**
  52598. * Set the emitter of the lens flare system.
  52599. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52600. * @param newEmitter Define the new emitter of the system
  52601. */
  52602. setEmitter(newEmitter: any): void;
  52603. /**
  52604. * Get the lens flare system emitter position.
  52605. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52606. * @returns the position
  52607. */
  52608. getEmitterPosition(): Vector3;
  52609. /**
  52610. * @hidden
  52611. */
  52612. computeEffectivePosition(globalViewport: Viewport): boolean;
  52613. /** @hidden */
  52614. _isVisible(): boolean;
  52615. /**
  52616. * @hidden
  52617. */
  52618. render(): boolean;
  52619. /**
  52620. * Dispose and release the lens flare with its associated resources.
  52621. */
  52622. dispose(): void;
  52623. /**
  52624. * Parse a lens flare system from a JSON repressentation
  52625. * @param parsedLensFlareSystem Define the JSON to parse
  52626. * @param scene Define the scene the parsed system should be instantiated in
  52627. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52628. * @returns the parsed system
  52629. */
  52630. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52631. /**
  52632. * Serialize the current Lens Flare System into a JSON representation.
  52633. * @returns the serialized JSON
  52634. */
  52635. serialize(): any;
  52636. }
  52637. }
  52638. declare module "babylonjs/LensFlares/lensFlare" {
  52639. import { Nullable } from "babylonjs/types";
  52640. import { Color3 } from "babylonjs/Maths/math.color";
  52641. import { Texture } from "babylonjs/Materials/Textures/texture";
  52642. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52643. /**
  52644. * This represents one of the lens effect in a `lensFlareSystem`.
  52645. * It controls one of the indiviual texture used in the effect.
  52646. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52647. */
  52648. export class LensFlare {
  52649. /**
  52650. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52651. */
  52652. size: number;
  52653. /**
  52654. * 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.
  52655. */
  52656. position: number;
  52657. /**
  52658. * Define the lens color.
  52659. */
  52660. color: Color3;
  52661. /**
  52662. * Define the lens texture.
  52663. */
  52664. texture: Nullable<Texture>;
  52665. /**
  52666. * Define the alpha mode to render this particular lens.
  52667. */
  52668. alphaMode: number;
  52669. private _system;
  52670. /**
  52671. * Creates a new Lens Flare.
  52672. * This represents one of the lens effect in a `lensFlareSystem`.
  52673. * It controls one of the indiviual texture used in the effect.
  52674. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52675. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52676. * @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.
  52677. * @param color Define the lens color
  52678. * @param imgUrl Define the lens texture url
  52679. * @param system Define the `lensFlareSystem` this flare is part of
  52680. * @returns The newly created Lens Flare
  52681. */
  52682. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52683. /**
  52684. * Instantiates a new Lens Flare.
  52685. * This represents one of the lens effect in a `lensFlareSystem`.
  52686. * It controls one of the indiviual texture used in the effect.
  52687. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52688. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52689. * @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.
  52690. * @param color Define the lens color
  52691. * @param imgUrl Define the lens texture url
  52692. * @param system Define the `lensFlareSystem` this flare is part of
  52693. */
  52694. constructor(
  52695. /**
  52696. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52697. */
  52698. size: number,
  52699. /**
  52700. * 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.
  52701. */
  52702. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52703. /**
  52704. * Dispose and release the lens flare with its associated resources.
  52705. */
  52706. dispose(): void;
  52707. }
  52708. }
  52709. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52710. import { Nullable } from "babylonjs/types";
  52711. import { Scene } from "babylonjs/scene";
  52712. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52713. import { AbstractScene } from "babylonjs/abstractScene";
  52714. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52715. module "babylonjs/abstractScene" {
  52716. interface AbstractScene {
  52717. /**
  52718. * The list of lens flare system added to the scene
  52719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52720. */
  52721. lensFlareSystems: Array<LensFlareSystem>;
  52722. /**
  52723. * Removes the given lens flare system from this scene.
  52724. * @param toRemove The lens flare system to remove
  52725. * @returns The index of the removed lens flare system
  52726. */
  52727. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52728. /**
  52729. * Adds the given lens flare system to this scene
  52730. * @param newLensFlareSystem The lens flare system to add
  52731. */
  52732. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52733. /**
  52734. * Gets a lens flare system using its name
  52735. * @param name defines the name to look for
  52736. * @returns the lens flare system or null if not found
  52737. */
  52738. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52739. /**
  52740. * Gets a lens flare system using its id
  52741. * @param id defines the id to look for
  52742. * @returns the lens flare system or null if not found
  52743. */
  52744. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52745. }
  52746. }
  52747. /**
  52748. * Defines the lens flare scene component responsible to manage any lens flares
  52749. * in a given scene.
  52750. */
  52751. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52752. /**
  52753. * The component name helpfull to identify the component in the list of scene components.
  52754. */
  52755. readonly name: string;
  52756. /**
  52757. * The scene the component belongs to.
  52758. */
  52759. scene: Scene;
  52760. /**
  52761. * Creates a new instance of the component for the given scene
  52762. * @param scene Defines the scene to register the component in
  52763. */
  52764. constructor(scene: Scene);
  52765. /**
  52766. * Registers the component in a given scene
  52767. */
  52768. register(): void;
  52769. /**
  52770. * Rebuilds the elements related to this component in case of
  52771. * context lost for instance.
  52772. */
  52773. rebuild(): void;
  52774. /**
  52775. * Adds all the elements from the container to the scene
  52776. * @param container the container holding the elements
  52777. */
  52778. addFromContainer(container: AbstractScene): void;
  52779. /**
  52780. * Removes all the elements in the container from the scene
  52781. * @param container contains the elements to remove
  52782. * @param dispose if the removed element should be disposed (default: false)
  52783. */
  52784. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52785. /**
  52786. * Serializes the component data to the specified json object
  52787. * @param serializationObject The object to serialize to
  52788. */
  52789. serialize(serializationObject: any): void;
  52790. /**
  52791. * Disposes the component and the associated ressources.
  52792. */
  52793. dispose(): void;
  52794. private _draw;
  52795. }
  52796. }
  52797. declare module "babylonjs/LensFlares/index" {
  52798. export * from "babylonjs/LensFlares/lensFlare";
  52799. export * from "babylonjs/LensFlares/lensFlareSystem";
  52800. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52801. }
  52802. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52803. import { Scene } from "babylonjs/scene";
  52804. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52805. import { AbstractScene } from "babylonjs/abstractScene";
  52806. /**
  52807. * Defines the shadow generator component responsible to manage any shadow generators
  52808. * in a given scene.
  52809. */
  52810. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52811. /**
  52812. * The component name helpfull to identify the component in the list of scene components.
  52813. */
  52814. readonly name: string;
  52815. /**
  52816. * The scene the component belongs to.
  52817. */
  52818. scene: Scene;
  52819. /**
  52820. * Creates a new instance of the component for the given scene
  52821. * @param scene Defines the scene to register the component in
  52822. */
  52823. constructor(scene: Scene);
  52824. /**
  52825. * Registers the component in a given scene
  52826. */
  52827. register(): void;
  52828. /**
  52829. * Rebuilds the elements related to this component in case of
  52830. * context lost for instance.
  52831. */
  52832. rebuild(): void;
  52833. /**
  52834. * Serializes the component data to the specified json object
  52835. * @param serializationObject The object to serialize to
  52836. */
  52837. serialize(serializationObject: any): void;
  52838. /**
  52839. * Adds all the elements from the container to the scene
  52840. * @param container the container holding the elements
  52841. */
  52842. addFromContainer(container: AbstractScene): void;
  52843. /**
  52844. * Removes all the elements in the container from the scene
  52845. * @param container contains the elements to remove
  52846. * @param dispose if the removed element should be disposed (default: false)
  52847. */
  52848. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52849. /**
  52850. * Rebuilds the elements related to this component in case of
  52851. * context lost for instance.
  52852. */
  52853. dispose(): void;
  52854. private _gatherRenderTargets;
  52855. }
  52856. }
  52857. declare module "babylonjs/Lights/Shadows/index" {
  52858. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52859. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52860. }
  52861. declare module "babylonjs/Lights/pointLight" {
  52862. import { Scene } from "babylonjs/scene";
  52863. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52865. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52866. import { Effect } from "babylonjs/Materials/effect";
  52867. /**
  52868. * A point light is a light defined by an unique point in world space.
  52869. * The light is emitted in every direction from this point.
  52870. * A good example of a point light is a standard light bulb.
  52871. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52872. */
  52873. export class PointLight extends ShadowLight {
  52874. private _shadowAngle;
  52875. /**
  52876. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52877. * This specifies what angle the shadow will use to be created.
  52878. *
  52879. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52880. */
  52881. /**
  52882. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52883. * This specifies what angle the shadow will use to be created.
  52884. *
  52885. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52886. */
  52887. shadowAngle: number;
  52888. /**
  52889. * Gets the direction if it has been set.
  52890. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52891. */
  52892. /**
  52893. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52894. */
  52895. direction: Vector3;
  52896. /**
  52897. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52898. * A PointLight emits the light in every direction.
  52899. * It can cast shadows.
  52900. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52901. * ```javascript
  52902. * var pointLight = new PointLight("pl", camera.position, scene);
  52903. * ```
  52904. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52905. * @param name The light friendly name
  52906. * @param position The position of the point light in the scene
  52907. * @param scene The scene the lights belongs to
  52908. */
  52909. constructor(name: string, position: Vector3, scene: Scene);
  52910. /**
  52911. * Returns the string "PointLight"
  52912. * @returns the class name
  52913. */
  52914. getClassName(): string;
  52915. /**
  52916. * Returns the integer 0.
  52917. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52918. */
  52919. getTypeID(): number;
  52920. /**
  52921. * Specifies wether or not the shadowmap should be a cube texture.
  52922. * @returns true if the shadowmap needs to be a cube texture.
  52923. */
  52924. needCube(): boolean;
  52925. /**
  52926. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52927. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52928. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52929. */
  52930. getShadowDirection(faceIndex?: number): Vector3;
  52931. /**
  52932. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52933. * - fov = PI / 2
  52934. * - aspect ratio : 1.0
  52935. * - z-near and far equal to the active camera minZ and maxZ.
  52936. * Returns the PointLight.
  52937. */
  52938. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52939. protected _buildUniformLayout(): void;
  52940. /**
  52941. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52942. * @param effect The effect to update
  52943. * @param lightIndex The index of the light in the effect to update
  52944. * @returns The point light
  52945. */
  52946. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52947. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52948. /**
  52949. * Prepares the list of defines specific to the light type.
  52950. * @param defines the list of defines
  52951. * @param lightIndex defines the index of the light for the effect
  52952. */
  52953. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52954. }
  52955. }
  52956. declare module "babylonjs/Lights/index" {
  52957. export * from "babylonjs/Lights/light";
  52958. export * from "babylonjs/Lights/shadowLight";
  52959. export * from "babylonjs/Lights/Shadows/index";
  52960. export * from "babylonjs/Lights/directionalLight";
  52961. export * from "babylonjs/Lights/hemisphericLight";
  52962. export * from "babylonjs/Lights/pointLight";
  52963. export * from "babylonjs/Lights/spotLight";
  52964. }
  52965. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52966. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52967. /**
  52968. * Header information of HDR texture files.
  52969. */
  52970. export interface HDRInfo {
  52971. /**
  52972. * The height of the texture in pixels.
  52973. */
  52974. height: number;
  52975. /**
  52976. * The width of the texture in pixels.
  52977. */
  52978. width: number;
  52979. /**
  52980. * The index of the beginning of the data in the binary file.
  52981. */
  52982. dataPosition: number;
  52983. }
  52984. /**
  52985. * This groups tools to convert HDR texture to native colors array.
  52986. */
  52987. export class HDRTools {
  52988. private static Ldexp;
  52989. private static Rgbe2float;
  52990. private static readStringLine;
  52991. /**
  52992. * Reads header information from an RGBE texture stored in a native array.
  52993. * More information on this format are available here:
  52994. * https://en.wikipedia.org/wiki/RGBE_image_format
  52995. *
  52996. * @param uint8array The binary file stored in native array.
  52997. * @return The header information.
  52998. */
  52999. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53000. /**
  53001. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53002. * This RGBE texture needs to store the information as a panorama.
  53003. *
  53004. * More information on this format are available here:
  53005. * https://en.wikipedia.org/wiki/RGBE_image_format
  53006. *
  53007. * @param buffer The binary file stored in an array buffer.
  53008. * @param size The expected size of the extracted cubemap.
  53009. * @return The Cube Map information.
  53010. */
  53011. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53012. /**
  53013. * Returns the pixels data extracted from an RGBE texture.
  53014. * This pixels will be stored left to right up to down in the R G B order in one array.
  53015. *
  53016. * More information on this format are available here:
  53017. * https://en.wikipedia.org/wiki/RGBE_image_format
  53018. *
  53019. * @param uint8array The binary file stored in an array buffer.
  53020. * @param hdrInfo The header information of the file.
  53021. * @return The pixels data in RGB right to left up to down order.
  53022. */
  53023. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53024. private static RGBE_ReadPixels_RLE;
  53025. }
  53026. }
  53027. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53028. import { Nullable } from "babylonjs/types";
  53029. import { Scene } from "babylonjs/scene";
  53030. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53032. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53033. /**
  53034. * This represents a texture coming from an HDR input.
  53035. *
  53036. * The only supported format is currently panorama picture stored in RGBE format.
  53037. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53038. */
  53039. export class HDRCubeTexture extends BaseTexture {
  53040. private static _facesMapping;
  53041. private _generateHarmonics;
  53042. private _noMipmap;
  53043. private _textureMatrix;
  53044. private _size;
  53045. private _onLoad;
  53046. private _onError;
  53047. /**
  53048. * The texture URL.
  53049. */
  53050. url: string;
  53051. /**
  53052. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53053. */
  53054. coordinatesMode: number;
  53055. protected _isBlocking: boolean;
  53056. /**
  53057. * Sets wether or not the texture is blocking during loading.
  53058. */
  53059. /**
  53060. * Gets wether or not the texture is blocking during loading.
  53061. */
  53062. isBlocking: boolean;
  53063. protected _rotationY: number;
  53064. /**
  53065. * Sets texture matrix rotation angle around Y axis in radians.
  53066. */
  53067. /**
  53068. * Gets texture matrix rotation angle around Y axis radians.
  53069. */
  53070. rotationY: number;
  53071. /**
  53072. * Gets or sets the center of the bounding box associated with the cube texture
  53073. * It must define where the camera used to render the texture was set
  53074. */
  53075. boundingBoxPosition: Vector3;
  53076. private _boundingBoxSize;
  53077. /**
  53078. * Gets or sets the size of the bounding box associated with the cube texture
  53079. * When defined, the cubemap will switch to local mode
  53080. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53081. * @example https://www.babylonjs-playground.com/#RNASML
  53082. */
  53083. boundingBoxSize: Vector3;
  53084. /**
  53085. * Instantiates an HDRTexture from the following parameters.
  53086. *
  53087. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53088. * @param scene The scene the texture will be used in
  53089. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53090. * @param noMipmap Forces to not generate the mipmap if true
  53091. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53092. * @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)
  53093. * @param reserved Reserved flag for internal use.
  53094. */
  53095. 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>);
  53096. /**
  53097. * Get the current class name of the texture useful for serialization or dynamic coding.
  53098. * @returns "HDRCubeTexture"
  53099. */
  53100. getClassName(): string;
  53101. /**
  53102. * Occurs when the file is raw .hdr file.
  53103. */
  53104. private loadTexture;
  53105. clone(): HDRCubeTexture;
  53106. delayLoad(): void;
  53107. /**
  53108. * Get the texture reflection matrix used to rotate/transform the reflection.
  53109. * @returns the reflection matrix
  53110. */
  53111. getReflectionTextureMatrix(): Matrix;
  53112. /**
  53113. * Set the texture reflection matrix used to rotate/transform the reflection.
  53114. * @param value Define the reflection matrix to set
  53115. */
  53116. setReflectionTextureMatrix(value: Matrix): void;
  53117. /**
  53118. * Parses a JSON representation of an HDR Texture in order to create the texture
  53119. * @param parsedTexture Define the JSON representation
  53120. * @param scene Define the scene the texture should be created in
  53121. * @param rootUrl Define the root url in case we need to load relative dependencies
  53122. * @returns the newly created texture after parsing
  53123. */
  53124. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53125. serialize(): any;
  53126. }
  53127. }
  53128. declare module "babylonjs/Physics/physicsEngine" {
  53129. import { Nullable } from "babylonjs/types";
  53130. import { Vector3 } from "babylonjs/Maths/math.vector";
  53131. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53132. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53133. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53134. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53135. /**
  53136. * Class used to control physics engine
  53137. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53138. */
  53139. export class PhysicsEngine implements IPhysicsEngine {
  53140. private _physicsPlugin;
  53141. /**
  53142. * Global value used to control the smallest number supported by the simulation
  53143. */
  53144. static Epsilon: number;
  53145. private _impostors;
  53146. private _joints;
  53147. /**
  53148. * Gets the gravity vector used by the simulation
  53149. */
  53150. gravity: Vector3;
  53151. /**
  53152. * Factory used to create the default physics plugin.
  53153. * @returns The default physics plugin
  53154. */
  53155. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53156. /**
  53157. * Creates a new Physics Engine
  53158. * @param gravity defines the gravity vector used by the simulation
  53159. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53160. */
  53161. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53162. /**
  53163. * Sets the gravity vector used by the simulation
  53164. * @param gravity defines the gravity vector to use
  53165. */
  53166. setGravity(gravity: Vector3): void;
  53167. /**
  53168. * Set the time step of the physics engine.
  53169. * Default is 1/60.
  53170. * To slow it down, enter 1/600 for example.
  53171. * To speed it up, 1/30
  53172. * @param newTimeStep defines the new timestep to apply to this world.
  53173. */
  53174. setTimeStep(newTimeStep?: number): void;
  53175. /**
  53176. * Get the time step of the physics engine.
  53177. * @returns the current time step
  53178. */
  53179. getTimeStep(): number;
  53180. /**
  53181. * Release all resources
  53182. */
  53183. dispose(): void;
  53184. /**
  53185. * Gets the name of the current physics plugin
  53186. * @returns the name of the plugin
  53187. */
  53188. getPhysicsPluginName(): string;
  53189. /**
  53190. * Adding a new impostor for the impostor tracking.
  53191. * This will be done by the impostor itself.
  53192. * @param impostor the impostor to add
  53193. */
  53194. addImpostor(impostor: PhysicsImpostor): void;
  53195. /**
  53196. * Remove an impostor from the engine.
  53197. * This impostor and its mesh will not longer be updated by the physics engine.
  53198. * @param impostor the impostor to remove
  53199. */
  53200. removeImpostor(impostor: PhysicsImpostor): void;
  53201. /**
  53202. * Add a joint to the physics engine
  53203. * @param mainImpostor defines the main impostor to which the joint is added.
  53204. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53205. * @param joint defines the joint that will connect both impostors.
  53206. */
  53207. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53208. /**
  53209. * Removes a joint from the simulation
  53210. * @param mainImpostor defines the impostor used with the joint
  53211. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53212. * @param joint defines the joint to remove
  53213. */
  53214. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53215. /**
  53216. * Called by the scene. No need to call it.
  53217. * @param delta defines the timespam between frames
  53218. */
  53219. _step(delta: number): void;
  53220. /**
  53221. * Gets the current plugin used to run the simulation
  53222. * @returns current plugin
  53223. */
  53224. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53225. /**
  53226. * Gets the list of physic impostors
  53227. * @returns an array of PhysicsImpostor
  53228. */
  53229. getImpostors(): Array<PhysicsImpostor>;
  53230. /**
  53231. * Gets the impostor for a physics enabled object
  53232. * @param object defines the object impersonated by the impostor
  53233. * @returns the PhysicsImpostor or null if not found
  53234. */
  53235. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53236. /**
  53237. * Gets the impostor for a physics body object
  53238. * @param body defines physics body used by the impostor
  53239. * @returns the PhysicsImpostor or null if not found
  53240. */
  53241. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53242. /**
  53243. * Does a raycast in the physics world
  53244. * @param from when should the ray start?
  53245. * @param to when should the ray end?
  53246. * @returns PhysicsRaycastResult
  53247. */
  53248. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53249. }
  53250. }
  53251. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53252. import { Nullable } from "babylonjs/types";
  53253. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53255. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53256. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53257. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53258. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53259. /** @hidden */
  53260. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53261. private _useDeltaForWorldStep;
  53262. world: any;
  53263. name: string;
  53264. private _physicsMaterials;
  53265. private _fixedTimeStep;
  53266. private _cannonRaycastResult;
  53267. private _raycastResult;
  53268. private _physicsBodysToRemoveAfterStep;
  53269. BJSCANNON: any;
  53270. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53271. setGravity(gravity: Vector3): void;
  53272. setTimeStep(timeStep: number): void;
  53273. getTimeStep(): number;
  53274. executeStep(delta: number): void;
  53275. private _removeMarkedPhysicsBodiesFromWorld;
  53276. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53277. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53278. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53279. private _processChildMeshes;
  53280. removePhysicsBody(impostor: PhysicsImpostor): void;
  53281. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53282. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53283. private _addMaterial;
  53284. private _checkWithEpsilon;
  53285. private _createShape;
  53286. private _createHeightmap;
  53287. private _minus90X;
  53288. private _plus90X;
  53289. private _tmpPosition;
  53290. private _tmpDeltaPosition;
  53291. private _tmpUnityRotation;
  53292. private _updatePhysicsBodyTransformation;
  53293. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53294. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53295. isSupported(): boolean;
  53296. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53297. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53298. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53299. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53300. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53301. getBodyMass(impostor: PhysicsImpostor): number;
  53302. getBodyFriction(impostor: PhysicsImpostor): number;
  53303. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53304. getBodyRestitution(impostor: PhysicsImpostor): number;
  53305. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53306. sleepBody(impostor: PhysicsImpostor): void;
  53307. wakeUpBody(impostor: PhysicsImpostor): void;
  53308. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53309. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53310. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53311. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53312. getRadius(impostor: PhysicsImpostor): number;
  53313. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53314. dispose(): void;
  53315. private _extendNamespace;
  53316. /**
  53317. * Does a raycast in the physics world
  53318. * @param from when should the ray start?
  53319. * @param to when should the ray end?
  53320. * @returns PhysicsRaycastResult
  53321. */
  53322. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53323. }
  53324. }
  53325. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53326. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53327. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53328. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53330. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53331. import { Nullable } from "babylonjs/types";
  53332. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53333. /** @hidden */
  53334. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53335. world: any;
  53336. name: string;
  53337. BJSOIMO: any;
  53338. private _raycastResult;
  53339. constructor(iterations?: number, oimoInjection?: any);
  53340. setGravity(gravity: Vector3): void;
  53341. setTimeStep(timeStep: number): void;
  53342. getTimeStep(): number;
  53343. private _tmpImpostorsArray;
  53344. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53345. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53346. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53347. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53348. private _tmpPositionVector;
  53349. removePhysicsBody(impostor: PhysicsImpostor): void;
  53350. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53351. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53352. isSupported(): boolean;
  53353. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53354. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53355. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53356. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53357. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53358. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53359. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53360. getBodyMass(impostor: PhysicsImpostor): number;
  53361. getBodyFriction(impostor: PhysicsImpostor): number;
  53362. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53363. getBodyRestitution(impostor: PhysicsImpostor): number;
  53364. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53365. sleepBody(impostor: PhysicsImpostor): void;
  53366. wakeUpBody(impostor: PhysicsImpostor): void;
  53367. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53368. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53369. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53370. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53371. getRadius(impostor: PhysicsImpostor): number;
  53372. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53373. dispose(): void;
  53374. /**
  53375. * Does a raycast in the physics world
  53376. * @param from when should the ray start?
  53377. * @param to when should the ray end?
  53378. * @returns PhysicsRaycastResult
  53379. */
  53380. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53381. }
  53382. }
  53383. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53384. import { Nullable } from "babylonjs/types";
  53385. import { Scene } from "babylonjs/scene";
  53386. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53387. import { Color4 } from "babylonjs/Maths/math.color";
  53388. import { Mesh } from "babylonjs/Meshes/mesh";
  53389. /**
  53390. * Class containing static functions to help procedurally build meshes
  53391. */
  53392. export class RibbonBuilder {
  53393. /**
  53394. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53395. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53396. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53397. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53398. * * 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
  53399. * * 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
  53400. * * 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
  53401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53403. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53404. * * 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
  53405. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53406. * * 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
  53407. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53409. * @param name defines the name of the mesh
  53410. * @param options defines the options used to create the mesh
  53411. * @param scene defines the hosting scene
  53412. * @returns the ribbon mesh
  53413. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53414. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53415. */
  53416. static CreateRibbon(name: string, options: {
  53417. pathArray: Vector3[][];
  53418. closeArray?: boolean;
  53419. closePath?: boolean;
  53420. offset?: number;
  53421. updatable?: boolean;
  53422. sideOrientation?: number;
  53423. frontUVs?: Vector4;
  53424. backUVs?: Vector4;
  53425. instance?: Mesh;
  53426. invertUV?: boolean;
  53427. uvs?: Vector2[];
  53428. colors?: Color4[];
  53429. }, scene?: Nullable<Scene>): Mesh;
  53430. }
  53431. }
  53432. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53433. import { Nullable } from "babylonjs/types";
  53434. import { Scene } from "babylonjs/scene";
  53435. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53436. import { Mesh } from "babylonjs/Meshes/mesh";
  53437. /**
  53438. * Class containing static functions to help procedurally build meshes
  53439. */
  53440. export class ShapeBuilder {
  53441. /**
  53442. * 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.
  53443. * * 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.
  53444. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53445. * * 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.
  53446. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53447. * * 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
  53448. * * 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
  53449. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53454. * @param name defines the name of the mesh
  53455. * @param options defines the options used to create the mesh
  53456. * @param scene defines the hosting scene
  53457. * @returns the extruded shape mesh
  53458. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53460. */
  53461. static ExtrudeShape(name: string, options: {
  53462. shape: Vector3[];
  53463. path: Vector3[];
  53464. scale?: number;
  53465. rotation?: number;
  53466. cap?: number;
  53467. updatable?: boolean;
  53468. sideOrientation?: number;
  53469. frontUVs?: Vector4;
  53470. backUVs?: Vector4;
  53471. instance?: Mesh;
  53472. invertUV?: boolean;
  53473. }, scene?: Nullable<Scene>): Mesh;
  53474. /**
  53475. * Creates an custom extruded shape mesh.
  53476. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53477. * * 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.
  53478. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53479. * * 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
  53480. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53481. * * 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
  53482. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53483. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53484. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53485. * * 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
  53486. * * 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
  53487. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53492. * @param name defines the name of the mesh
  53493. * @param options defines the options used to create the mesh
  53494. * @param scene defines the hosting scene
  53495. * @returns the custom extruded shape mesh
  53496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53499. */
  53500. static ExtrudeShapeCustom(name: string, options: {
  53501. shape: Vector3[];
  53502. path: Vector3[];
  53503. scaleFunction?: any;
  53504. rotationFunction?: any;
  53505. ribbonCloseArray?: boolean;
  53506. ribbonClosePath?: boolean;
  53507. cap?: number;
  53508. updatable?: boolean;
  53509. sideOrientation?: number;
  53510. frontUVs?: Vector4;
  53511. backUVs?: Vector4;
  53512. instance?: Mesh;
  53513. invertUV?: boolean;
  53514. }, scene?: Nullable<Scene>): Mesh;
  53515. private static _ExtrudeShapeGeneric;
  53516. }
  53517. }
  53518. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53519. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53520. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53521. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53522. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53523. import { Nullable } from "babylonjs/types";
  53524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53525. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53526. /**
  53527. * AmmoJS Physics plugin
  53528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53529. * @see https://github.com/kripken/ammo.js/
  53530. */
  53531. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53532. private _useDeltaForWorldStep;
  53533. /**
  53534. * Reference to the Ammo library
  53535. */
  53536. bjsAMMO: any;
  53537. /**
  53538. * Created ammoJS world which physics bodies are added to
  53539. */
  53540. world: any;
  53541. /**
  53542. * Name of the plugin
  53543. */
  53544. name: string;
  53545. private _timeStep;
  53546. private _fixedTimeStep;
  53547. private _maxSteps;
  53548. private _tmpQuaternion;
  53549. private _tmpAmmoTransform;
  53550. private _tmpAmmoQuaternion;
  53551. private _tmpAmmoConcreteContactResultCallback;
  53552. private _collisionConfiguration;
  53553. private _dispatcher;
  53554. private _overlappingPairCache;
  53555. private _solver;
  53556. private _softBodySolver;
  53557. private _tmpAmmoVectorA;
  53558. private _tmpAmmoVectorB;
  53559. private _tmpAmmoVectorC;
  53560. private _tmpAmmoVectorD;
  53561. private _tmpContactCallbackResult;
  53562. private _tmpAmmoVectorRCA;
  53563. private _tmpAmmoVectorRCB;
  53564. private _raycastResult;
  53565. private static readonly DISABLE_COLLISION_FLAG;
  53566. private static readonly KINEMATIC_FLAG;
  53567. private static readonly DISABLE_DEACTIVATION_FLAG;
  53568. /**
  53569. * Initializes the ammoJS plugin
  53570. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53571. * @param ammoInjection can be used to inject your own ammo reference
  53572. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53573. */
  53574. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53575. /**
  53576. * Sets the gravity of the physics world (m/(s^2))
  53577. * @param gravity Gravity to set
  53578. */
  53579. setGravity(gravity: Vector3): void;
  53580. /**
  53581. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53582. * @param timeStep timestep to use in seconds
  53583. */
  53584. setTimeStep(timeStep: number): void;
  53585. /**
  53586. * 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)
  53587. * @param fixedTimeStep fixedTimeStep to use in seconds
  53588. */
  53589. setFixedTimeStep(fixedTimeStep: number): void;
  53590. /**
  53591. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53592. * @param maxSteps the maximum number of steps by the physics engine per frame
  53593. */
  53594. setMaxSteps(maxSteps: number): void;
  53595. /**
  53596. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53597. * @returns the current timestep in seconds
  53598. */
  53599. getTimeStep(): number;
  53600. private _isImpostorInContact;
  53601. private _isImpostorPairInContact;
  53602. private _stepSimulation;
  53603. /**
  53604. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53605. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53606. * After the step the babylon meshes are set to the position of the physics imposters
  53607. * @param delta amount of time to step forward
  53608. * @param impostors array of imposters to update before/after the step
  53609. */
  53610. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53611. /**
  53612. * Update babylon mesh to match physics world object
  53613. * @param impostor imposter to match
  53614. */
  53615. private _afterSoftStep;
  53616. /**
  53617. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53618. * @param impostor imposter to match
  53619. */
  53620. private _ropeStep;
  53621. /**
  53622. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53623. * @param impostor imposter to match
  53624. */
  53625. private _softbodyOrClothStep;
  53626. private _tmpVector;
  53627. private _tmpMatrix;
  53628. /**
  53629. * Applies an impulse on the imposter
  53630. * @param impostor imposter to apply impulse to
  53631. * @param force amount of force to be applied to the imposter
  53632. * @param contactPoint the location to apply the impulse on the imposter
  53633. */
  53634. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53635. /**
  53636. * Applies a force on the imposter
  53637. * @param impostor imposter to apply force
  53638. * @param force amount of force to be applied to the imposter
  53639. * @param contactPoint the location to apply the force on the imposter
  53640. */
  53641. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53642. /**
  53643. * Creates a physics body using the plugin
  53644. * @param impostor the imposter to create the physics body on
  53645. */
  53646. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53647. /**
  53648. * Removes the physics body from the imposter and disposes of the body's memory
  53649. * @param impostor imposter to remove the physics body from
  53650. */
  53651. removePhysicsBody(impostor: PhysicsImpostor): void;
  53652. /**
  53653. * Generates a joint
  53654. * @param impostorJoint the imposter joint to create the joint with
  53655. */
  53656. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53657. /**
  53658. * Removes a joint
  53659. * @param impostorJoint the imposter joint to remove the joint from
  53660. */
  53661. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53662. private _addMeshVerts;
  53663. /**
  53664. * Initialise the soft body vertices to match its object's (mesh) vertices
  53665. * Softbody vertices (nodes) are in world space and to match this
  53666. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53667. * @param impostor to create the softbody for
  53668. */
  53669. private _softVertexData;
  53670. /**
  53671. * Create an impostor's soft body
  53672. * @param impostor to create the softbody for
  53673. */
  53674. private _createSoftbody;
  53675. /**
  53676. * Create cloth for an impostor
  53677. * @param impostor to create the softbody for
  53678. */
  53679. private _createCloth;
  53680. /**
  53681. * Create rope for an impostor
  53682. * @param impostor to create the softbody for
  53683. */
  53684. private _createRope;
  53685. private _addHullVerts;
  53686. private _createShape;
  53687. /**
  53688. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53689. * @param impostor imposter containing the physics body and babylon object
  53690. */
  53691. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53692. /**
  53693. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53694. * @param impostor imposter containing the physics body and babylon object
  53695. * @param newPosition new position
  53696. * @param newRotation new rotation
  53697. */
  53698. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53699. /**
  53700. * If this plugin is supported
  53701. * @returns true if its supported
  53702. */
  53703. isSupported(): boolean;
  53704. /**
  53705. * Sets the linear velocity of the physics body
  53706. * @param impostor imposter to set the velocity on
  53707. * @param velocity velocity to set
  53708. */
  53709. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53710. /**
  53711. * Sets the angular velocity of the physics body
  53712. * @param impostor imposter to set the velocity on
  53713. * @param velocity velocity to set
  53714. */
  53715. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53716. /**
  53717. * gets the linear velocity
  53718. * @param impostor imposter to get linear velocity from
  53719. * @returns linear velocity
  53720. */
  53721. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53722. /**
  53723. * gets the angular velocity
  53724. * @param impostor imposter to get angular velocity from
  53725. * @returns angular velocity
  53726. */
  53727. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53728. /**
  53729. * Sets the mass of physics body
  53730. * @param impostor imposter to set the mass on
  53731. * @param mass mass to set
  53732. */
  53733. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53734. /**
  53735. * Gets the mass of the physics body
  53736. * @param impostor imposter to get the mass from
  53737. * @returns mass
  53738. */
  53739. getBodyMass(impostor: PhysicsImpostor): number;
  53740. /**
  53741. * Gets friction of the impostor
  53742. * @param impostor impostor to get friction from
  53743. * @returns friction value
  53744. */
  53745. getBodyFriction(impostor: PhysicsImpostor): number;
  53746. /**
  53747. * Sets friction of the impostor
  53748. * @param impostor impostor to set friction on
  53749. * @param friction friction value
  53750. */
  53751. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53752. /**
  53753. * Gets restitution of the impostor
  53754. * @param impostor impostor to get restitution from
  53755. * @returns restitution value
  53756. */
  53757. getBodyRestitution(impostor: PhysicsImpostor): number;
  53758. /**
  53759. * Sets resitution of the impostor
  53760. * @param impostor impostor to set resitution on
  53761. * @param restitution resitution value
  53762. */
  53763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53764. /**
  53765. * Gets pressure inside the impostor
  53766. * @param impostor impostor to get pressure from
  53767. * @returns pressure value
  53768. */
  53769. getBodyPressure(impostor: PhysicsImpostor): number;
  53770. /**
  53771. * Sets pressure inside a soft body impostor
  53772. * Cloth and rope must remain 0 pressure
  53773. * @param impostor impostor to set pressure on
  53774. * @param pressure pressure value
  53775. */
  53776. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53777. /**
  53778. * Gets stiffness of the impostor
  53779. * @param impostor impostor to get stiffness from
  53780. * @returns pressure value
  53781. */
  53782. getBodyStiffness(impostor: PhysicsImpostor): number;
  53783. /**
  53784. * Sets stiffness of the impostor
  53785. * @param impostor impostor to set stiffness on
  53786. * @param stiffness stiffness value from 0 to 1
  53787. */
  53788. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53789. /**
  53790. * Gets velocityIterations of the impostor
  53791. * @param impostor impostor to get velocity iterations from
  53792. * @returns velocityIterations value
  53793. */
  53794. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53795. /**
  53796. * Sets velocityIterations of the impostor
  53797. * @param impostor impostor to set velocity iterations on
  53798. * @param velocityIterations velocityIterations value
  53799. */
  53800. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53801. /**
  53802. * Gets positionIterations of the impostor
  53803. * @param impostor impostor to get position iterations from
  53804. * @returns positionIterations value
  53805. */
  53806. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53807. /**
  53808. * Sets positionIterations of the impostor
  53809. * @param impostor impostor to set position on
  53810. * @param positionIterations positionIterations value
  53811. */
  53812. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53813. /**
  53814. * Append an anchor to a cloth object
  53815. * @param impostor is the cloth impostor to add anchor to
  53816. * @param otherImpostor is the rigid impostor to anchor to
  53817. * @param width ratio across width from 0 to 1
  53818. * @param height ratio up height from 0 to 1
  53819. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53820. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53821. */
  53822. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53823. /**
  53824. * Append an hook to a rope object
  53825. * @param impostor is the rope impostor to add hook to
  53826. * @param otherImpostor is the rigid impostor to hook to
  53827. * @param length ratio along the rope from 0 to 1
  53828. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53829. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53830. */
  53831. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53832. /**
  53833. * Sleeps the physics body and stops it from being active
  53834. * @param impostor impostor to sleep
  53835. */
  53836. sleepBody(impostor: PhysicsImpostor): void;
  53837. /**
  53838. * Activates the physics body
  53839. * @param impostor impostor to activate
  53840. */
  53841. wakeUpBody(impostor: PhysicsImpostor): void;
  53842. /**
  53843. * Updates the distance parameters of the joint
  53844. * @param joint joint to update
  53845. * @param maxDistance maximum distance of the joint
  53846. * @param minDistance minimum distance of the joint
  53847. */
  53848. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53849. /**
  53850. * Sets a motor on the joint
  53851. * @param joint joint to set motor on
  53852. * @param speed speed of the motor
  53853. * @param maxForce maximum force of the motor
  53854. * @param motorIndex index of the motor
  53855. */
  53856. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53857. /**
  53858. * Sets the motors limit
  53859. * @param joint joint to set limit on
  53860. * @param upperLimit upper limit
  53861. * @param lowerLimit lower limit
  53862. */
  53863. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53864. /**
  53865. * Syncs the position and rotation of a mesh with the impostor
  53866. * @param mesh mesh to sync
  53867. * @param impostor impostor to update the mesh with
  53868. */
  53869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53870. /**
  53871. * Gets the radius of the impostor
  53872. * @param impostor impostor to get radius from
  53873. * @returns the radius
  53874. */
  53875. getRadius(impostor: PhysicsImpostor): number;
  53876. /**
  53877. * Gets the box size of the impostor
  53878. * @param impostor impostor to get box size from
  53879. * @param result the resulting box size
  53880. */
  53881. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53882. /**
  53883. * Disposes of the impostor
  53884. */
  53885. dispose(): void;
  53886. /**
  53887. * Does a raycast in the physics world
  53888. * @param from when should the ray start?
  53889. * @param to when should the ray end?
  53890. * @returns PhysicsRaycastResult
  53891. */
  53892. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53893. }
  53894. }
  53895. declare module "babylonjs/Probes/reflectionProbe" {
  53896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53897. import { Vector3 } from "babylonjs/Maths/math.vector";
  53898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53899. import { Nullable } from "babylonjs/types";
  53900. import { Scene } from "babylonjs/scene";
  53901. module "babylonjs/abstractScene" {
  53902. interface AbstractScene {
  53903. /**
  53904. * The list of reflection probes added to the scene
  53905. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53906. */
  53907. reflectionProbes: Array<ReflectionProbe>;
  53908. /**
  53909. * Removes the given reflection probe from this scene.
  53910. * @param toRemove The reflection probe to remove
  53911. * @returns The index of the removed reflection probe
  53912. */
  53913. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53914. /**
  53915. * Adds the given reflection probe to this scene.
  53916. * @param newReflectionProbe The reflection probe to add
  53917. */
  53918. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53919. }
  53920. }
  53921. /**
  53922. * Class used to generate realtime reflection / refraction cube textures
  53923. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53924. */
  53925. export class ReflectionProbe {
  53926. /** defines the name of the probe */
  53927. name: string;
  53928. private _scene;
  53929. private _renderTargetTexture;
  53930. private _projectionMatrix;
  53931. private _viewMatrix;
  53932. private _target;
  53933. private _add;
  53934. private _attachedMesh;
  53935. private _invertYAxis;
  53936. /** Gets or sets probe position (center of the cube map) */
  53937. position: Vector3;
  53938. /**
  53939. * Creates a new reflection probe
  53940. * @param name defines the name of the probe
  53941. * @param size defines the texture resolution (for each face)
  53942. * @param scene defines the hosting scene
  53943. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53944. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53945. */
  53946. constructor(
  53947. /** defines the name of the probe */
  53948. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53949. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53950. samples: number;
  53951. /** Gets or sets the refresh rate to use (on every frame by default) */
  53952. refreshRate: number;
  53953. /**
  53954. * Gets the hosting scene
  53955. * @returns a Scene
  53956. */
  53957. getScene(): Scene;
  53958. /** Gets the internal CubeTexture used to render to */
  53959. readonly cubeTexture: RenderTargetTexture;
  53960. /** Gets the list of meshes to render */
  53961. readonly renderList: Nullable<AbstractMesh[]>;
  53962. /**
  53963. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53964. * @param mesh defines the mesh to attach to
  53965. */
  53966. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53967. /**
  53968. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53969. * @param renderingGroupId The rendering group id corresponding to its index
  53970. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53971. */
  53972. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53973. /**
  53974. * Clean all associated resources
  53975. */
  53976. dispose(): void;
  53977. /**
  53978. * Converts the reflection probe information to a readable string for debug purpose.
  53979. * @param fullDetails Supports for multiple levels of logging within scene loading
  53980. * @returns the human readable reflection probe info
  53981. */
  53982. toString(fullDetails?: boolean): string;
  53983. /**
  53984. * Get the class name of the relfection probe.
  53985. * @returns "ReflectionProbe"
  53986. */
  53987. getClassName(): string;
  53988. /**
  53989. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53990. * @returns The JSON representation of the texture
  53991. */
  53992. serialize(): any;
  53993. /**
  53994. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53995. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53996. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53997. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53998. * @returns The parsed reflection probe if successful
  53999. */
  54000. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54001. }
  54002. }
  54003. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54004. /** @hidden */
  54005. export var _BabylonLoaderRegistered: boolean;
  54006. }
  54007. declare module "babylonjs/Loading/Plugins/index" {
  54008. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54009. }
  54010. declare module "babylonjs/Loading/index" {
  54011. export * from "babylonjs/Loading/loadingScreen";
  54012. export * from "babylonjs/Loading/Plugins/index";
  54013. export * from "babylonjs/Loading/sceneLoader";
  54014. export * from "babylonjs/Loading/sceneLoaderFlags";
  54015. }
  54016. declare module "babylonjs/Materials/Background/index" {
  54017. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54018. }
  54019. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54020. import { Scene } from "babylonjs/scene";
  54021. import { Color3 } from "babylonjs/Maths/math.color";
  54022. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54023. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54024. /**
  54025. * The Physically based simple base material of BJS.
  54026. *
  54027. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54028. * It is used as the base class for both the specGloss and metalRough conventions.
  54029. */
  54030. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54031. /**
  54032. * Number of Simultaneous lights allowed on the material.
  54033. */
  54034. maxSimultaneousLights: number;
  54035. /**
  54036. * If sets to true, disables all the lights affecting the material.
  54037. */
  54038. disableLighting: boolean;
  54039. /**
  54040. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54041. */
  54042. environmentTexture: BaseTexture;
  54043. /**
  54044. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54045. */
  54046. invertNormalMapX: boolean;
  54047. /**
  54048. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54049. */
  54050. invertNormalMapY: boolean;
  54051. /**
  54052. * Normal map used in the model.
  54053. */
  54054. normalTexture: BaseTexture;
  54055. /**
  54056. * Emissivie color used to self-illuminate the model.
  54057. */
  54058. emissiveColor: Color3;
  54059. /**
  54060. * Emissivie texture used to self-illuminate the model.
  54061. */
  54062. emissiveTexture: BaseTexture;
  54063. /**
  54064. * Occlusion Channel Strenght.
  54065. */
  54066. occlusionStrength: number;
  54067. /**
  54068. * Occlusion Texture of the material (adding extra occlusion effects).
  54069. */
  54070. occlusionTexture: BaseTexture;
  54071. /**
  54072. * Defines the alpha limits in alpha test mode.
  54073. */
  54074. alphaCutOff: number;
  54075. /**
  54076. * Gets the current double sided mode.
  54077. */
  54078. /**
  54079. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54080. */
  54081. doubleSided: boolean;
  54082. /**
  54083. * Stores the pre-calculated light information of a mesh in a texture.
  54084. */
  54085. lightmapTexture: BaseTexture;
  54086. /**
  54087. * If true, the light map contains occlusion information instead of lighting info.
  54088. */
  54089. useLightmapAsShadowmap: boolean;
  54090. /**
  54091. * Instantiates a new PBRMaterial instance.
  54092. *
  54093. * @param name The material name
  54094. * @param scene The scene the material will be use in.
  54095. */
  54096. constructor(name: string, scene: Scene);
  54097. getClassName(): string;
  54098. }
  54099. }
  54100. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54101. import { Scene } from "babylonjs/scene";
  54102. import { Color3 } from "babylonjs/Maths/math.color";
  54103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54104. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54105. /**
  54106. * The PBR material of BJS following the metal roughness convention.
  54107. *
  54108. * This fits to the PBR convention in the GLTF definition:
  54109. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54110. */
  54111. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54112. /**
  54113. * The base color has two different interpretations depending on the value of metalness.
  54114. * When the material is a metal, the base color is the specific measured reflectance value
  54115. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54116. * of the material.
  54117. */
  54118. baseColor: Color3;
  54119. /**
  54120. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54121. * well as opacity information in the alpha channel.
  54122. */
  54123. baseTexture: BaseTexture;
  54124. /**
  54125. * Specifies the metallic scalar value of the material.
  54126. * Can also be used to scale the metalness values of the metallic texture.
  54127. */
  54128. metallic: number;
  54129. /**
  54130. * Specifies the roughness scalar value of the material.
  54131. * Can also be used to scale the roughness values of the metallic texture.
  54132. */
  54133. roughness: number;
  54134. /**
  54135. * Texture containing both the metallic value in the B channel and the
  54136. * roughness value in the G channel to keep better precision.
  54137. */
  54138. metallicRoughnessTexture: BaseTexture;
  54139. /**
  54140. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54141. *
  54142. * @param name The material name
  54143. * @param scene The scene the material will be use in.
  54144. */
  54145. constructor(name: string, scene: Scene);
  54146. /**
  54147. * Return the currrent class name of the material.
  54148. */
  54149. getClassName(): string;
  54150. /**
  54151. * Makes a duplicate of the current material.
  54152. * @param name - name to use for the new material.
  54153. */
  54154. clone(name: string): PBRMetallicRoughnessMaterial;
  54155. /**
  54156. * Serialize the material to a parsable JSON object.
  54157. */
  54158. serialize(): any;
  54159. /**
  54160. * Parses a JSON object correponding to the serialize function.
  54161. */
  54162. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54163. }
  54164. }
  54165. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54166. import { Scene } from "babylonjs/scene";
  54167. import { Color3 } from "babylonjs/Maths/math.color";
  54168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54169. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54170. /**
  54171. * The PBR material of BJS following the specular glossiness convention.
  54172. *
  54173. * This fits to the PBR convention in the GLTF definition:
  54174. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54175. */
  54176. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54177. /**
  54178. * Specifies the diffuse color of the material.
  54179. */
  54180. diffuseColor: Color3;
  54181. /**
  54182. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54183. * channel.
  54184. */
  54185. diffuseTexture: BaseTexture;
  54186. /**
  54187. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54188. */
  54189. specularColor: Color3;
  54190. /**
  54191. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54192. */
  54193. glossiness: number;
  54194. /**
  54195. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54196. */
  54197. specularGlossinessTexture: BaseTexture;
  54198. /**
  54199. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54200. *
  54201. * @param name The material name
  54202. * @param scene The scene the material will be use in.
  54203. */
  54204. constructor(name: string, scene: Scene);
  54205. /**
  54206. * Return the currrent class name of the material.
  54207. */
  54208. getClassName(): string;
  54209. /**
  54210. * Makes a duplicate of the current material.
  54211. * @param name - name to use for the new material.
  54212. */
  54213. clone(name: string): PBRSpecularGlossinessMaterial;
  54214. /**
  54215. * Serialize the material to a parsable JSON object.
  54216. */
  54217. serialize(): any;
  54218. /**
  54219. * Parses a JSON object correponding to the serialize function.
  54220. */
  54221. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54222. }
  54223. }
  54224. declare module "babylonjs/Materials/PBR/index" {
  54225. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54226. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54227. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54228. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54229. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54230. }
  54231. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54232. import { Nullable } from "babylonjs/types";
  54233. import { Scene } from "babylonjs/scene";
  54234. import { Matrix } from "babylonjs/Maths/math.vector";
  54235. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54236. /**
  54237. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54238. * It can help converting any input color in a desired output one. This can then be used to create effects
  54239. * from sepia, black and white to sixties or futuristic rendering...
  54240. *
  54241. * The only supported format is currently 3dl.
  54242. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54243. */
  54244. export class ColorGradingTexture extends BaseTexture {
  54245. /**
  54246. * The current texture matrix. (will always be identity in color grading texture)
  54247. */
  54248. private _textureMatrix;
  54249. /**
  54250. * The texture URL.
  54251. */
  54252. url: string;
  54253. /**
  54254. * Empty line regex stored for GC.
  54255. */
  54256. private static _noneEmptyLineRegex;
  54257. private _engine;
  54258. /**
  54259. * Instantiates a ColorGradingTexture from the following parameters.
  54260. *
  54261. * @param url The location of the color gradind data (currently only supporting 3dl)
  54262. * @param scene The scene the texture will be used in
  54263. */
  54264. constructor(url: string, scene: Scene);
  54265. /**
  54266. * Returns the texture matrix used in most of the material.
  54267. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54268. */
  54269. getTextureMatrix(): Matrix;
  54270. /**
  54271. * Occurs when the file being loaded is a .3dl LUT file.
  54272. */
  54273. private load3dlTexture;
  54274. /**
  54275. * Starts the loading process of the texture.
  54276. */
  54277. private loadTexture;
  54278. /**
  54279. * Clones the color gradind texture.
  54280. */
  54281. clone(): ColorGradingTexture;
  54282. /**
  54283. * Called during delayed load for textures.
  54284. */
  54285. delayLoad(): void;
  54286. /**
  54287. * Parses a color grading texture serialized by Babylon.
  54288. * @param parsedTexture The texture information being parsedTexture
  54289. * @param scene The scene to load the texture in
  54290. * @param rootUrl The root url of the data assets to load
  54291. * @return A color gradind texture
  54292. */
  54293. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54294. /**
  54295. * Serializes the LUT texture to json format.
  54296. */
  54297. serialize(): any;
  54298. }
  54299. }
  54300. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54302. import { Scene } from "babylonjs/scene";
  54303. import { Nullable } from "babylonjs/types";
  54304. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54305. /**
  54306. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54307. */
  54308. export class EquiRectangularCubeTexture extends BaseTexture {
  54309. /** The six faces of the cube. */
  54310. private static _FacesMapping;
  54311. private _noMipmap;
  54312. private _onLoad;
  54313. private _onError;
  54314. /** The size of the cubemap. */
  54315. private _size;
  54316. /** The buffer of the image. */
  54317. private _buffer;
  54318. /** The width of the input image. */
  54319. private _width;
  54320. /** The height of the input image. */
  54321. private _height;
  54322. /** The URL to the image. */
  54323. url: string;
  54324. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54325. coordinatesMode: number;
  54326. /**
  54327. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54328. * @param url The location of the image
  54329. * @param scene The scene the texture will be used in
  54330. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54331. * @param noMipmap Forces to not generate the mipmap if true
  54332. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54333. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54334. * @param onLoad — defines a callback called when texture is loaded
  54335. * @param onError — defines a callback called if there is an error
  54336. */
  54337. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54338. /**
  54339. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54340. */
  54341. private loadImage;
  54342. /**
  54343. * Convert the image buffer into a cubemap and create a CubeTexture.
  54344. */
  54345. private loadTexture;
  54346. /**
  54347. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54348. * @param buffer The ArrayBuffer that should be converted.
  54349. * @returns The buffer as Float32Array.
  54350. */
  54351. private getFloat32ArrayFromArrayBuffer;
  54352. /**
  54353. * Get the current class name of the texture useful for serialization or dynamic coding.
  54354. * @returns "EquiRectangularCubeTexture"
  54355. */
  54356. getClassName(): string;
  54357. /**
  54358. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54359. * @returns A clone of the current EquiRectangularCubeTexture.
  54360. */
  54361. clone(): EquiRectangularCubeTexture;
  54362. }
  54363. }
  54364. declare module "babylonjs/Misc/tga" {
  54365. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54366. /**
  54367. * Based on jsTGALoader - Javascript loader for TGA file
  54368. * By Vincent Thibault
  54369. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54370. */
  54371. export class TGATools {
  54372. private static _TYPE_INDEXED;
  54373. private static _TYPE_RGB;
  54374. private static _TYPE_GREY;
  54375. private static _TYPE_RLE_INDEXED;
  54376. private static _TYPE_RLE_RGB;
  54377. private static _TYPE_RLE_GREY;
  54378. private static _ORIGIN_MASK;
  54379. private static _ORIGIN_SHIFT;
  54380. private static _ORIGIN_BL;
  54381. private static _ORIGIN_BR;
  54382. private static _ORIGIN_UL;
  54383. private static _ORIGIN_UR;
  54384. /**
  54385. * Gets the header of a TGA file
  54386. * @param data defines the TGA data
  54387. * @returns the header
  54388. */
  54389. static GetTGAHeader(data: Uint8Array): any;
  54390. /**
  54391. * Uploads TGA content to a Babylon Texture
  54392. * @hidden
  54393. */
  54394. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54395. /** @hidden */
  54396. 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;
  54397. /** @hidden */
  54398. 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;
  54399. /** @hidden */
  54400. 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;
  54401. /** @hidden */
  54402. 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;
  54403. /** @hidden */
  54404. 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;
  54405. /** @hidden */
  54406. 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;
  54407. }
  54408. }
  54409. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54410. import { Nullable } from "babylonjs/types";
  54411. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54412. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54413. /**
  54414. * Implementation of the TGA Texture Loader.
  54415. * @hidden
  54416. */
  54417. export class _TGATextureLoader implements IInternalTextureLoader {
  54418. /**
  54419. * Defines wether the loader supports cascade loading the different faces.
  54420. */
  54421. readonly supportCascades: boolean;
  54422. /**
  54423. * This returns if the loader support the current file information.
  54424. * @param extension defines the file extension of the file being loaded
  54425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54426. * @param fallback defines the fallback internal texture if any
  54427. * @param isBase64 defines whether the texture is encoded as a base64
  54428. * @param isBuffer defines whether the texture data are stored as a buffer
  54429. * @returns true if the loader can load the specified file
  54430. */
  54431. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54432. /**
  54433. * Transform the url before loading if required.
  54434. * @param rootUrl the url of the texture
  54435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54436. * @returns the transformed texture
  54437. */
  54438. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54439. /**
  54440. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54441. * @param rootUrl the url of the texture
  54442. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54443. * @returns the fallback texture
  54444. */
  54445. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54446. /**
  54447. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54448. * @param data contains the texture data
  54449. * @param texture defines the BabylonJS internal texture
  54450. * @param createPolynomials will be true if polynomials have been requested
  54451. * @param onLoad defines the callback to trigger once the texture is ready
  54452. * @param onError defines the callback to trigger in case of error
  54453. */
  54454. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54455. /**
  54456. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54457. * @param data contains the texture data
  54458. * @param texture defines the BabylonJS internal texture
  54459. * @param callback defines the method to call once ready to upload
  54460. */
  54461. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54462. }
  54463. }
  54464. declare module "babylonjs/Misc/basis" {
  54465. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54466. /**
  54467. * Info about the .basis files
  54468. */
  54469. class BasisFileInfo {
  54470. /**
  54471. * If the file has alpha
  54472. */
  54473. hasAlpha: boolean;
  54474. /**
  54475. * Info about each image of the basis file
  54476. */
  54477. images: Array<{
  54478. levels: Array<{
  54479. width: number;
  54480. height: number;
  54481. transcodedPixels: ArrayBufferView;
  54482. }>;
  54483. }>;
  54484. }
  54485. /**
  54486. * Result of transcoding a basis file
  54487. */
  54488. class TranscodeResult {
  54489. /**
  54490. * Info about the .basis file
  54491. */
  54492. fileInfo: BasisFileInfo;
  54493. /**
  54494. * Format to use when loading the file
  54495. */
  54496. format: number;
  54497. }
  54498. /**
  54499. * Configuration options for the Basis transcoder
  54500. */
  54501. export class BasisTranscodeConfiguration {
  54502. /**
  54503. * Supported compression formats used to determine the supported output format of the transcoder
  54504. */
  54505. supportedCompressionFormats?: {
  54506. /**
  54507. * etc1 compression format
  54508. */
  54509. etc1?: boolean;
  54510. /**
  54511. * s3tc compression format
  54512. */
  54513. s3tc?: boolean;
  54514. /**
  54515. * pvrtc compression format
  54516. */
  54517. pvrtc?: boolean;
  54518. /**
  54519. * etc2 compression format
  54520. */
  54521. etc2?: boolean;
  54522. };
  54523. /**
  54524. * If mipmap levels should be loaded for transcoded images (Default: true)
  54525. */
  54526. loadMipmapLevels?: boolean;
  54527. /**
  54528. * Index of a single image to load (Default: all images)
  54529. */
  54530. loadSingleImage?: number;
  54531. }
  54532. /**
  54533. * Used to load .Basis files
  54534. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54535. */
  54536. export class BasisTools {
  54537. private static _IgnoreSupportedFormats;
  54538. /**
  54539. * URL to use when loading the basis transcoder
  54540. */
  54541. static JSModuleURL: string;
  54542. /**
  54543. * URL to use when loading the wasm module for the transcoder
  54544. */
  54545. static WasmModuleURL: string;
  54546. /**
  54547. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54548. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54549. * @returns internal format corresponding to the Basis format
  54550. */
  54551. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54552. private static _WorkerPromise;
  54553. private static _Worker;
  54554. private static _actionId;
  54555. private static _CreateWorkerAsync;
  54556. /**
  54557. * Transcodes a loaded image file to compressed pixel data
  54558. * @param imageData image data to transcode
  54559. * @param config configuration options for the transcoding
  54560. * @returns a promise resulting in the transcoded image
  54561. */
  54562. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54563. /**
  54564. * Loads a texture from the transcode result
  54565. * @param texture texture load to
  54566. * @param transcodeResult the result of transcoding the basis file to load from
  54567. */
  54568. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54569. }
  54570. }
  54571. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54572. import { Nullable } from "babylonjs/types";
  54573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54574. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54575. /**
  54576. * Loader for .basis file format
  54577. */
  54578. export class _BasisTextureLoader implements IInternalTextureLoader {
  54579. /**
  54580. * Defines whether the loader supports cascade loading the different faces.
  54581. */
  54582. readonly supportCascades: boolean;
  54583. /**
  54584. * This returns if the loader support the current file information.
  54585. * @param extension defines the file extension of the file being loaded
  54586. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54587. * @param fallback defines the fallback internal texture if any
  54588. * @param isBase64 defines whether the texture is encoded as a base64
  54589. * @param isBuffer defines whether the texture data are stored as a buffer
  54590. * @returns true if the loader can load the specified file
  54591. */
  54592. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54593. /**
  54594. * Transform the url before loading if required.
  54595. * @param rootUrl the url of the texture
  54596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54597. * @returns the transformed texture
  54598. */
  54599. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54600. /**
  54601. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54602. * @param rootUrl the url of the texture
  54603. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54604. * @returns the fallback texture
  54605. */
  54606. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54607. /**
  54608. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54609. * @param data contains the texture data
  54610. * @param texture defines the BabylonJS internal texture
  54611. * @param createPolynomials will be true if polynomials have been requested
  54612. * @param onLoad defines the callback to trigger once the texture is ready
  54613. * @param onError defines the callback to trigger in case of error
  54614. */
  54615. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54616. /**
  54617. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54618. * @param data contains the texture data
  54619. * @param texture defines the BabylonJS internal texture
  54620. * @param callback defines the method to call once ready to upload
  54621. */
  54622. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54623. }
  54624. }
  54625. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54626. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54627. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54628. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54629. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54630. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54631. }
  54632. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54633. import { Scene } from "babylonjs/scene";
  54634. import { Texture } from "babylonjs/Materials/Textures/texture";
  54635. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54636. /**
  54637. * 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.
  54638. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54639. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54640. */
  54641. export class CustomProceduralTexture extends ProceduralTexture {
  54642. private _animate;
  54643. private _time;
  54644. private _config;
  54645. private _texturePath;
  54646. /**
  54647. * Instantiates a new Custom Procedural Texture.
  54648. * 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.
  54649. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54650. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54651. * @param name Define the name of the texture
  54652. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54653. * @param size Define the size of the texture to create
  54654. * @param scene Define the scene the texture belongs to
  54655. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54656. * @param generateMipMaps Define if the texture should creates mip maps or not
  54657. */
  54658. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54659. private _loadJson;
  54660. /**
  54661. * Is the texture ready to be used ? (rendered at least once)
  54662. * @returns true if ready, otherwise, false.
  54663. */
  54664. isReady(): boolean;
  54665. /**
  54666. * Render the texture to its associated render target.
  54667. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54668. */
  54669. render(useCameraPostProcess?: boolean): void;
  54670. /**
  54671. * Update the list of dependant textures samplers in the shader.
  54672. */
  54673. updateTextures(): void;
  54674. /**
  54675. * Update the uniform values of the procedural texture in the shader.
  54676. */
  54677. updateShaderUniforms(): void;
  54678. /**
  54679. * Define if the texture animates or not.
  54680. */
  54681. animate: boolean;
  54682. }
  54683. }
  54684. declare module "babylonjs/Shaders/noise.fragment" {
  54685. /** @hidden */
  54686. export var noisePixelShader: {
  54687. name: string;
  54688. shader: string;
  54689. };
  54690. }
  54691. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54692. import { Nullable } from "babylonjs/types";
  54693. import { Scene } from "babylonjs/scene";
  54694. import { Texture } from "babylonjs/Materials/Textures/texture";
  54695. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54696. import "babylonjs/Shaders/noise.fragment";
  54697. /**
  54698. * Class used to generate noise procedural textures
  54699. */
  54700. export class NoiseProceduralTexture extends ProceduralTexture {
  54701. private _time;
  54702. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54703. brightness: number;
  54704. /** Defines the number of octaves to process */
  54705. octaves: number;
  54706. /** Defines the level of persistence (0.8 by default) */
  54707. persistence: number;
  54708. /** Gets or sets animation speed factor (default is 1) */
  54709. animationSpeedFactor: number;
  54710. /**
  54711. * Creates a new NoiseProceduralTexture
  54712. * @param name defines the name fo the texture
  54713. * @param size defines the size of the texture (default is 256)
  54714. * @param scene defines the hosting scene
  54715. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54716. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54717. */
  54718. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54719. private _updateShaderUniforms;
  54720. protected _getDefines(): string;
  54721. /** Generate the current state of the procedural texture */
  54722. render(useCameraPostProcess?: boolean): void;
  54723. /**
  54724. * Serializes this noise procedural texture
  54725. * @returns a serialized noise procedural texture object
  54726. */
  54727. serialize(): any;
  54728. /**
  54729. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54730. * @param parsedTexture defines parsed texture data
  54731. * @param scene defines the current scene
  54732. * @param rootUrl defines the root URL containing noise procedural texture information
  54733. * @returns a parsed NoiseProceduralTexture
  54734. */
  54735. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54736. }
  54737. }
  54738. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54739. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54740. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54741. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54742. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54743. }
  54744. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54745. import { Nullable } from "babylonjs/types";
  54746. import { Scene } from "babylonjs/scene";
  54747. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54749. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54750. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54751. /**
  54752. * Raw cube texture where the raw buffers are passed in
  54753. */
  54754. export class RawCubeTexture extends CubeTexture {
  54755. /**
  54756. * Creates a cube texture where the raw buffers are passed in.
  54757. * @param scene defines the scene the texture is attached to
  54758. * @param data defines the array of data to use to create each face
  54759. * @param size defines the size of the textures
  54760. * @param format defines the format of the data
  54761. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54762. * @param generateMipMaps defines if the engine should generate the mip levels
  54763. * @param invertY defines if data must be stored with Y axis inverted
  54764. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54765. * @param compression defines the compression used (null by default)
  54766. */
  54767. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54768. /**
  54769. * Updates the raw cube texture.
  54770. * @param data defines the data to store
  54771. * @param format defines the data format
  54772. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54773. * @param invertY defines if data must be stored with Y axis inverted
  54774. * @param compression defines the compression used (null by default)
  54775. * @param level defines which level of the texture to update
  54776. */
  54777. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54778. /**
  54779. * Updates a raw cube texture with RGBD encoded data.
  54780. * @param data defines the array of data [mipmap][face] to use to create each face
  54781. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54782. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54783. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54784. * @returns a promsie that resolves when the operation is complete
  54785. */
  54786. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54787. /**
  54788. * Clones the raw cube texture.
  54789. * @return a new cube texture
  54790. */
  54791. clone(): CubeTexture;
  54792. /** @hidden */
  54793. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54794. }
  54795. }
  54796. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54797. import { Scene } from "babylonjs/scene";
  54798. import { Texture } from "babylonjs/Materials/Textures/texture";
  54799. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54800. /**
  54801. * Class used to store 3D textures containing user data
  54802. */
  54803. export class RawTexture3D extends Texture {
  54804. /** Gets or sets the texture format to use */
  54805. format: number;
  54806. private _engine;
  54807. /**
  54808. * Create a new RawTexture3D
  54809. * @param data defines the data of the texture
  54810. * @param width defines the width of the texture
  54811. * @param height defines the height of the texture
  54812. * @param depth defines the depth of the texture
  54813. * @param format defines the texture format to use
  54814. * @param scene defines the hosting scene
  54815. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54816. * @param invertY defines if texture must be stored with Y axis inverted
  54817. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54818. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54819. */
  54820. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54821. /** Gets or sets the texture format to use */
  54822. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54823. /**
  54824. * Update the texture with new data
  54825. * @param data defines the data to store in the texture
  54826. */
  54827. update(data: ArrayBufferView): void;
  54828. }
  54829. }
  54830. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54831. import { Scene } from "babylonjs/scene";
  54832. import { Plane } from "babylonjs/Maths/math.plane";
  54833. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54834. /**
  54835. * Creates a refraction texture used by refraction channel of the standard material.
  54836. * It is like a mirror but to see through a material.
  54837. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54838. */
  54839. export class RefractionTexture extends RenderTargetTexture {
  54840. /**
  54841. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54842. * 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.
  54843. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54844. */
  54845. refractionPlane: Plane;
  54846. /**
  54847. * Define how deep under the surface we should see.
  54848. */
  54849. depth: number;
  54850. /**
  54851. * Creates a refraction texture used by refraction channel of the standard material.
  54852. * It is like a mirror but to see through a material.
  54853. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54854. * @param name Define the texture name
  54855. * @param size Define the size of the underlying texture
  54856. * @param scene Define the scene the refraction belongs to
  54857. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54858. */
  54859. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54860. /**
  54861. * Clone the refraction texture.
  54862. * @returns the cloned texture
  54863. */
  54864. clone(): RefractionTexture;
  54865. /**
  54866. * Serialize the texture to a JSON representation you could use in Parse later on
  54867. * @returns the serialized JSON representation
  54868. */
  54869. serialize(): any;
  54870. }
  54871. }
  54872. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54873. import { Nullable } from "babylonjs/types";
  54874. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54875. import { Matrix } from "babylonjs/Maths/math.vector";
  54876. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54877. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54878. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54879. import { Scene } from "babylonjs/scene";
  54880. /**
  54881. * Defines the options related to the creation of an HtmlElementTexture
  54882. */
  54883. export interface IHtmlElementTextureOptions {
  54884. /**
  54885. * Defines wether mip maps should be created or not.
  54886. */
  54887. generateMipMaps?: boolean;
  54888. /**
  54889. * Defines the sampling mode of the texture.
  54890. */
  54891. samplingMode?: number;
  54892. /**
  54893. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54894. */
  54895. engine: Nullable<ThinEngine>;
  54896. /**
  54897. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54898. */
  54899. scene: Nullable<Scene>;
  54900. }
  54901. /**
  54902. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54903. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54904. * is automatically managed.
  54905. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54906. * in your application.
  54907. *
  54908. * As the update is not automatic, you need to call them manually.
  54909. */
  54910. export class HtmlElementTexture extends BaseTexture {
  54911. /**
  54912. * The texture URL.
  54913. */
  54914. element: HTMLVideoElement | HTMLCanvasElement;
  54915. private static readonly DefaultOptions;
  54916. private _textureMatrix;
  54917. private _engine;
  54918. private _isVideo;
  54919. private _generateMipMaps;
  54920. private _samplingMode;
  54921. /**
  54922. * Instantiates a HtmlElementTexture from the following parameters.
  54923. *
  54924. * @param name Defines the name of the texture
  54925. * @param element Defines the video or canvas the texture is filled with
  54926. * @param options Defines the other none mandatory texture creation options
  54927. */
  54928. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54929. private _createInternalTexture;
  54930. /**
  54931. * Returns the texture matrix used in most of the material.
  54932. */
  54933. getTextureMatrix(): Matrix;
  54934. /**
  54935. * Updates the content of the texture.
  54936. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54937. */
  54938. update(invertY?: Nullable<boolean>): void;
  54939. }
  54940. }
  54941. declare module "babylonjs/Materials/Textures/index" {
  54942. export * from "babylonjs/Materials/Textures/baseTexture";
  54943. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54944. export * from "babylonjs/Materials/Textures/cubeTexture";
  54945. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54946. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54947. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54948. export * from "babylonjs/Materials/Textures/internalTexture";
  54949. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54950. export * from "babylonjs/Materials/Textures/Loaders/index";
  54951. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54952. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54953. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54954. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54955. export * from "babylonjs/Materials/Textures/rawTexture";
  54956. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54957. export * from "babylonjs/Materials/Textures/refractionTexture";
  54958. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54959. export * from "babylonjs/Materials/Textures/texture";
  54960. export * from "babylonjs/Materials/Textures/videoTexture";
  54961. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54962. }
  54963. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54964. /**
  54965. * Enum used to define the target of a block
  54966. */
  54967. export enum NodeMaterialBlockTargets {
  54968. /** Vertex shader */
  54969. Vertex = 1,
  54970. /** Fragment shader */
  54971. Fragment = 2,
  54972. /** Neutral */
  54973. Neutral = 4,
  54974. /** Vertex and Fragment */
  54975. VertexAndFragment = 3
  54976. }
  54977. }
  54978. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54979. /**
  54980. * Defines the kind of connection point for node based material
  54981. */
  54982. export enum NodeMaterialBlockConnectionPointTypes {
  54983. /** Float */
  54984. Float = 1,
  54985. /** Int */
  54986. Int = 2,
  54987. /** Vector2 */
  54988. Vector2 = 4,
  54989. /** Vector3 */
  54990. Vector3 = 8,
  54991. /** Vector4 */
  54992. Vector4 = 16,
  54993. /** Color3 */
  54994. Color3 = 32,
  54995. /** Color4 */
  54996. Color4 = 64,
  54997. /** Matrix */
  54998. Matrix = 128,
  54999. /** Detect type based on connection */
  55000. AutoDetect = 1024,
  55001. /** Output type that will be defined by input type */
  55002. BasedOnInput = 2048
  55003. }
  55004. }
  55005. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55006. /**
  55007. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55008. */
  55009. export enum NodeMaterialBlockConnectionPointMode {
  55010. /** Value is an uniform */
  55011. Uniform = 0,
  55012. /** Value is a mesh attribute */
  55013. Attribute = 1,
  55014. /** Value is a varying between vertex and fragment shaders */
  55015. Varying = 2,
  55016. /** Mode is undefined */
  55017. Undefined = 3
  55018. }
  55019. }
  55020. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55021. /**
  55022. * Enum used to define system values e.g. values automatically provided by the system
  55023. */
  55024. export enum NodeMaterialSystemValues {
  55025. /** World */
  55026. World = 1,
  55027. /** View */
  55028. View = 2,
  55029. /** Projection */
  55030. Projection = 3,
  55031. /** ViewProjection */
  55032. ViewProjection = 4,
  55033. /** WorldView */
  55034. WorldView = 5,
  55035. /** WorldViewProjection */
  55036. WorldViewProjection = 6,
  55037. /** CameraPosition */
  55038. CameraPosition = 7,
  55039. /** Fog Color */
  55040. FogColor = 8,
  55041. /** Delta time */
  55042. DeltaTime = 9
  55043. }
  55044. }
  55045. declare module "babylonjs/Materials/Node/Enums/index" {
  55046. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55047. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55048. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55049. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55050. }
  55051. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55053. /**
  55054. * Root class for all node material optimizers
  55055. */
  55056. export class NodeMaterialOptimizer {
  55057. /**
  55058. * Function used to optimize a NodeMaterial graph
  55059. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55060. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55061. */
  55062. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55063. }
  55064. }
  55065. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55069. import { Scene } from "babylonjs/scene";
  55070. /**
  55071. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55072. */
  55073. export class TransformBlock extends NodeMaterialBlock {
  55074. /**
  55075. * Defines the value to use to complement W value to transform it to a Vector4
  55076. */
  55077. complementW: number;
  55078. /**
  55079. * Defines the value to use to complement z value to transform it to a Vector4
  55080. */
  55081. complementZ: number;
  55082. /**
  55083. * Creates a new TransformBlock
  55084. * @param name defines the block name
  55085. */
  55086. constructor(name: string);
  55087. /**
  55088. * Gets the current class name
  55089. * @returns the class name
  55090. */
  55091. getClassName(): string;
  55092. /**
  55093. * Gets the vector input
  55094. */
  55095. readonly vector: NodeMaterialConnectionPoint;
  55096. /**
  55097. * Gets the output component
  55098. */
  55099. readonly output: NodeMaterialConnectionPoint;
  55100. /**
  55101. * Gets the matrix transform input
  55102. */
  55103. readonly transform: NodeMaterialConnectionPoint;
  55104. protected _buildBlock(state: NodeMaterialBuildState): this;
  55105. serialize(): any;
  55106. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55107. protected _dumpPropertiesCode(): string;
  55108. }
  55109. }
  55110. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55114. /**
  55115. * Block used to output the vertex position
  55116. */
  55117. export class VertexOutputBlock extends NodeMaterialBlock {
  55118. /**
  55119. * Creates a new VertexOutputBlock
  55120. * @param name defines the block name
  55121. */
  55122. constructor(name: string);
  55123. /**
  55124. * Gets the current class name
  55125. * @returns the class name
  55126. */
  55127. getClassName(): string;
  55128. /**
  55129. * Gets the vector input component
  55130. */
  55131. readonly vector: NodeMaterialConnectionPoint;
  55132. protected _buildBlock(state: NodeMaterialBuildState): this;
  55133. }
  55134. }
  55135. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55139. /**
  55140. * Block used to output the final color
  55141. */
  55142. export class FragmentOutputBlock extends NodeMaterialBlock {
  55143. /**
  55144. * Create a new FragmentOutputBlock
  55145. * @param name defines the block name
  55146. */
  55147. constructor(name: string);
  55148. /**
  55149. * Gets the current class name
  55150. * @returns the class name
  55151. */
  55152. getClassName(): string;
  55153. /**
  55154. * Gets the rgba input component
  55155. */
  55156. readonly rgba: NodeMaterialConnectionPoint;
  55157. /**
  55158. * Gets the rgb input component
  55159. */
  55160. readonly rgb: NodeMaterialConnectionPoint;
  55161. /**
  55162. * Gets the a input component
  55163. */
  55164. readonly a: NodeMaterialConnectionPoint;
  55165. protected _buildBlock(state: NodeMaterialBuildState): this;
  55166. }
  55167. }
  55168. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55172. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55174. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55175. import { Effect } from "babylonjs/Materials/effect";
  55176. import { Mesh } from "babylonjs/Meshes/mesh";
  55177. import { Nullable } from "babylonjs/types";
  55178. import { Scene } from "babylonjs/scene";
  55179. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55180. /**
  55181. * Block used to read a reflection texture from a sampler
  55182. */
  55183. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55184. private _define3DName;
  55185. private _defineCubicName;
  55186. private _defineExplicitName;
  55187. private _defineProjectionName;
  55188. private _defineLocalCubicName;
  55189. private _defineSphericalName;
  55190. private _definePlanarName;
  55191. private _defineEquirectangularName;
  55192. private _defineMirroredEquirectangularFixedName;
  55193. private _defineEquirectangularFixedName;
  55194. private _defineSkyboxName;
  55195. private _cubeSamplerName;
  55196. private _2DSamplerName;
  55197. private _positionUVWName;
  55198. private _directionWName;
  55199. private _reflectionCoordsName;
  55200. private _reflection2DCoordsName;
  55201. private _reflectionColorName;
  55202. private _reflectionMatrixName;
  55203. /**
  55204. * Gets or sets the texture associated with the node
  55205. */
  55206. texture: Nullable<BaseTexture>;
  55207. /**
  55208. * Create a new TextureBlock
  55209. * @param name defines the block name
  55210. */
  55211. constructor(name: string);
  55212. /**
  55213. * Gets the current class name
  55214. * @returns the class name
  55215. */
  55216. getClassName(): string;
  55217. /**
  55218. * Gets the world position input component
  55219. */
  55220. readonly position: NodeMaterialConnectionPoint;
  55221. /**
  55222. * Gets the world position input component
  55223. */
  55224. readonly worldPosition: NodeMaterialConnectionPoint;
  55225. /**
  55226. * Gets the world normal input component
  55227. */
  55228. readonly worldNormal: NodeMaterialConnectionPoint;
  55229. /**
  55230. * Gets the world input component
  55231. */
  55232. readonly world: NodeMaterialConnectionPoint;
  55233. /**
  55234. * Gets the camera (or eye) position component
  55235. */
  55236. readonly cameraPosition: NodeMaterialConnectionPoint;
  55237. /**
  55238. * Gets the view input component
  55239. */
  55240. readonly view: NodeMaterialConnectionPoint;
  55241. /**
  55242. * Gets the rgb output component
  55243. */
  55244. readonly rgb: NodeMaterialConnectionPoint;
  55245. /**
  55246. * Gets the r output component
  55247. */
  55248. readonly r: NodeMaterialConnectionPoint;
  55249. /**
  55250. * Gets the g output component
  55251. */
  55252. readonly g: NodeMaterialConnectionPoint;
  55253. /**
  55254. * Gets the b output component
  55255. */
  55256. readonly b: NodeMaterialConnectionPoint;
  55257. autoConfigure(material: NodeMaterial): void;
  55258. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55259. isReady(): boolean;
  55260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55261. private _injectVertexCode;
  55262. private _writeOutput;
  55263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55264. serialize(): any;
  55265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55266. }
  55267. }
  55268. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55270. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55271. import { Scene } from "babylonjs/scene";
  55272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55273. import { Matrix } from "babylonjs/Maths/math.vector";
  55274. import { Mesh } from "babylonjs/Meshes/mesh";
  55275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55276. import { Observable } from "babylonjs/Misc/observable";
  55277. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55278. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55279. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55280. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55281. import { Nullable } from "babylonjs/types";
  55282. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55283. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55284. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55285. /**
  55286. * Interface used to configure the node material editor
  55287. */
  55288. export interface INodeMaterialEditorOptions {
  55289. /** Define the URl to load node editor script */
  55290. editorURL?: string;
  55291. }
  55292. /** @hidden */
  55293. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55294. /** BONES */
  55295. NUM_BONE_INFLUENCERS: number;
  55296. BonesPerMesh: number;
  55297. BONETEXTURE: boolean;
  55298. /** MORPH TARGETS */
  55299. MORPHTARGETS: boolean;
  55300. MORPHTARGETS_NORMAL: boolean;
  55301. MORPHTARGETS_TANGENT: boolean;
  55302. MORPHTARGETS_UV: boolean;
  55303. NUM_MORPH_INFLUENCERS: number;
  55304. /** IMAGE PROCESSING */
  55305. IMAGEPROCESSING: boolean;
  55306. VIGNETTE: boolean;
  55307. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55308. VIGNETTEBLENDMODEOPAQUE: boolean;
  55309. TONEMAPPING: boolean;
  55310. TONEMAPPING_ACES: boolean;
  55311. CONTRAST: boolean;
  55312. EXPOSURE: boolean;
  55313. COLORCURVES: boolean;
  55314. COLORGRADING: boolean;
  55315. COLORGRADING3D: boolean;
  55316. SAMPLER3DGREENDEPTH: boolean;
  55317. SAMPLER3DBGRMAP: boolean;
  55318. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55319. /** MISC. */
  55320. BUMPDIRECTUV: number;
  55321. constructor();
  55322. setValue(name: string, value: boolean): void;
  55323. }
  55324. /**
  55325. * Class used to configure NodeMaterial
  55326. */
  55327. export interface INodeMaterialOptions {
  55328. /**
  55329. * Defines if blocks should emit comments
  55330. */
  55331. emitComments: boolean;
  55332. }
  55333. /**
  55334. * Class used to create a node based material built by assembling shader blocks
  55335. */
  55336. export class NodeMaterial extends PushMaterial {
  55337. private static _BuildIdGenerator;
  55338. private _options;
  55339. private _vertexCompilationState;
  55340. private _fragmentCompilationState;
  55341. private _sharedData;
  55342. private _buildId;
  55343. private _buildWasSuccessful;
  55344. private _cachedWorldViewMatrix;
  55345. private _cachedWorldViewProjectionMatrix;
  55346. private _optimizers;
  55347. private _animationFrame;
  55348. /** Define the URl to load node editor script */
  55349. static EditorURL: string;
  55350. private BJSNODEMATERIALEDITOR;
  55351. /** Get the inspector from bundle or global */
  55352. private _getGlobalNodeMaterialEditor;
  55353. /**
  55354. * 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)
  55355. */
  55356. ignoreAlpha: boolean;
  55357. /**
  55358. * Defines the maximum number of lights that can be used in the material
  55359. */
  55360. maxSimultaneousLights: number;
  55361. /**
  55362. * Observable raised when the material is built
  55363. */
  55364. onBuildObservable: Observable<NodeMaterial>;
  55365. /**
  55366. * Gets or sets the root nodes of the material vertex shader
  55367. */
  55368. _vertexOutputNodes: NodeMaterialBlock[];
  55369. /**
  55370. * Gets or sets the root nodes of the material fragment (pixel) shader
  55371. */
  55372. _fragmentOutputNodes: NodeMaterialBlock[];
  55373. /** Gets or sets options to control the node material overall behavior */
  55374. options: INodeMaterialOptions;
  55375. /**
  55376. * Default configuration related to image processing available in the standard Material.
  55377. */
  55378. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55379. /**
  55380. * Gets the image processing configuration used either in this material.
  55381. */
  55382. /**
  55383. * Sets the Default image processing configuration used either in the this material.
  55384. *
  55385. * If sets to null, the scene one is in use.
  55386. */
  55387. imageProcessingConfiguration: ImageProcessingConfiguration;
  55388. /**
  55389. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55390. */
  55391. attachedBlocks: NodeMaterialBlock[];
  55392. /**
  55393. * Create a new node based material
  55394. * @param name defines the material name
  55395. * @param scene defines the hosting scene
  55396. * @param options defines creation option
  55397. */
  55398. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55399. /**
  55400. * Gets the current class name of the material e.g. "NodeMaterial"
  55401. * @returns the class name
  55402. */
  55403. getClassName(): string;
  55404. /**
  55405. * Keep track of the image processing observer to allow dispose and replace.
  55406. */
  55407. private _imageProcessingObserver;
  55408. /**
  55409. * Attaches a new image processing configuration to the Standard Material.
  55410. * @param configuration
  55411. */
  55412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55413. /**
  55414. * Get a block by its name
  55415. * @param name defines the name of the block to retrieve
  55416. * @returns the required block or null if not found
  55417. */
  55418. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55419. /**
  55420. * Get a block by its name
  55421. * @param predicate defines the predicate used to find the good candidate
  55422. * @returns the required block or null if not found
  55423. */
  55424. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55425. /**
  55426. * Get an input block by its name
  55427. * @param predicate defines the predicate used to find the good candidate
  55428. * @returns the required input block or null if not found
  55429. */
  55430. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55431. /**
  55432. * Gets the list of input blocks attached to this material
  55433. * @returns an array of InputBlocks
  55434. */
  55435. getInputBlocks(): InputBlock[];
  55436. /**
  55437. * Adds a new optimizer to the list of optimizers
  55438. * @param optimizer defines the optimizers to add
  55439. * @returns the current material
  55440. */
  55441. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55442. /**
  55443. * Remove an optimizer from the list of optimizers
  55444. * @param optimizer defines the optimizers to remove
  55445. * @returns the current material
  55446. */
  55447. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55448. /**
  55449. * Add a new block to the list of output nodes
  55450. * @param node defines the node to add
  55451. * @returns the current material
  55452. */
  55453. addOutputNode(node: NodeMaterialBlock): this;
  55454. /**
  55455. * Remove a block from the list of root nodes
  55456. * @param node defines the node to remove
  55457. * @returns the current material
  55458. */
  55459. removeOutputNode(node: NodeMaterialBlock): this;
  55460. private _addVertexOutputNode;
  55461. private _removeVertexOutputNode;
  55462. private _addFragmentOutputNode;
  55463. private _removeFragmentOutputNode;
  55464. /**
  55465. * Specifies if the material will require alpha blending
  55466. * @returns a boolean specifying if alpha blending is needed
  55467. */
  55468. needAlphaBlending(): boolean;
  55469. /**
  55470. * Specifies if this material should be rendered in alpha test mode
  55471. * @returns a boolean specifying if an alpha test is needed.
  55472. */
  55473. needAlphaTesting(): boolean;
  55474. private _initializeBlock;
  55475. private _resetDualBlocks;
  55476. /**
  55477. * Build the material and generates the inner effect
  55478. * @param verbose defines if the build should log activity
  55479. */
  55480. build(verbose?: boolean): void;
  55481. /**
  55482. * Runs an otpimization phase to try to improve the shader code
  55483. */
  55484. optimize(): void;
  55485. private _prepareDefinesForAttributes;
  55486. /**
  55487. * Get if the submesh is ready to be used and all its information available.
  55488. * Child classes can use it to update shaders
  55489. * @param mesh defines the mesh to check
  55490. * @param subMesh defines which submesh to check
  55491. * @param useInstances specifies that instances should be used
  55492. * @returns a boolean indicating that the submesh is ready or not
  55493. */
  55494. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55495. /**
  55496. * Get a string representing the shaders built by the current node graph
  55497. */
  55498. readonly compiledShaders: string;
  55499. /**
  55500. * Binds the world matrix to the material
  55501. * @param world defines the world transformation matrix
  55502. */
  55503. bindOnlyWorldMatrix(world: Matrix): void;
  55504. /**
  55505. * Binds the submesh to this material by preparing the effect and shader to draw
  55506. * @param world defines the world transformation matrix
  55507. * @param mesh defines the mesh containing the submesh
  55508. * @param subMesh defines the submesh to bind the material to
  55509. */
  55510. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55511. /**
  55512. * Gets the active textures from the material
  55513. * @returns an array of textures
  55514. */
  55515. getActiveTextures(): BaseTexture[];
  55516. /**
  55517. * Gets the list of texture blocks
  55518. * @returns an array of texture blocks
  55519. */
  55520. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55521. /**
  55522. * Specifies if the material uses a texture
  55523. * @param texture defines the texture to check against the material
  55524. * @returns a boolean specifying if the material uses the texture
  55525. */
  55526. hasTexture(texture: BaseTexture): boolean;
  55527. /**
  55528. * Disposes the material
  55529. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55530. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55531. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55532. */
  55533. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55534. /** Creates the node editor window. */
  55535. private _createNodeEditor;
  55536. /**
  55537. * Launch the node material editor
  55538. * @param config Define the configuration of the editor
  55539. * @return a promise fulfilled when the node editor is visible
  55540. */
  55541. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55542. /**
  55543. * Clear the current material
  55544. */
  55545. clear(): void;
  55546. /**
  55547. * Clear the current material and set it to a default state
  55548. */
  55549. setToDefault(): void;
  55550. /**
  55551. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55552. * @param url defines the url to load from
  55553. * @returns a promise that will fullfil when the material is fully loaded
  55554. */
  55555. loadAsync(url: string): Promise<unknown>;
  55556. private _gatherBlocks;
  55557. /**
  55558. * Generate a string containing the code declaration required to create an equivalent of this material
  55559. * @returns a string
  55560. */
  55561. generateCode(): string;
  55562. /**
  55563. * Serializes this material in a JSON representation
  55564. * @returns the serialized material object
  55565. */
  55566. serialize(): any;
  55567. private _restoreConnections;
  55568. /**
  55569. * Clear the current graph and load a new one from a serialization object
  55570. * @param source defines the JSON representation of the material
  55571. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55572. */
  55573. loadFromSerialization(source: any, rootUrl?: string): void;
  55574. /**
  55575. * Creates a node material from parsed material data
  55576. * @param source defines the JSON representation of the material
  55577. * @param scene defines the hosting scene
  55578. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55579. * @returns a new node material
  55580. */
  55581. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55582. /**
  55583. * Creates a new node material set to default basic configuration
  55584. * @param name defines the name of the material
  55585. * @param scene defines the hosting scene
  55586. * @returns a new NodeMaterial
  55587. */
  55588. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55589. }
  55590. }
  55591. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55594. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55597. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55598. import { Effect } from "babylonjs/Materials/effect";
  55599. import { Mesh } from "babylonjs/Meshes/mesh";
  55600. import { Nullable } from "babylonjs/types";
  55601. import { Texture } from "babylonjs/Materials/Textures/texture";
  55602. import { Scene } from "babylonjs/scene";
  55603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55604. /**
  55605. * Block used to read a texture from a sampler
  55606. */
  55607. export class TextureBlock extends NodeMaterialBlock {
  55608. private _defineName;
  55609. private _linearDefineName;
  55610. private _samplerName;
  55611. private _transformedUVName;
  55612. private _textureTransformName;
  55613. private _textureInfoName;
  55614. private _mainUVName;
  55615. private _mainUVDefineName;
  55616. /**
  55617. * Gets or sets the texture associated with the node
  55618. */
  55619. texture: Nullable<Texture>;
  55620. /**
  55621. * Create a new TextureBlock
  55622. * @param name defines the block name
  55623. */
  55624. constructor(name: string);
  55625. /**
  55626. * Gets the current class name
  55627. * @returns the class name
  55628. */
  55629. getClassName(): string;
  55630. /**
  55631. * Gets the uv input component
  55632. */
  55633. readonly uv: NodeMaterialConnectionPoint;
  55634. /**
  55635. * Gets the rgba output component
  55636. */
  55637. readonly rgba: NodeMaterialConnectionPoint;
  55638. /**
  55639. * Gets the rgb output component
  55640. */
  55641. readonly rgb: NodeMaterialConnectionPoint;
  55642. /**
  55643. * Gets the r output component
  55644. */
  55645. readonly r: NodeMaterialConnectionPoint;
  55646. /**
  55647. * Gets the g output component
  55648. */
  55649. readonly g: NodeMaterialConnectionPoint;
  55650. /**
  55651. * Gets the b output component
  55652. */
  55653. readonly b: NodeMaterialConnectionPoint;
  55654. /**
  55655. * Gets the a output component
  55656. */
  55657. readonly a: NodeMaterialConnectionPoint;
  55658. readonly target: NodeMaterialBlockTargets;
  55659. autoConfigure(material: NodeMaterial): void;
  55660. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55662. isReady(): boolean;
  55663. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55664. private readonly _isMixed;
  55665. private _injectVertexCode;
  55666. private _writeOutput;
  55667. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55668. protected _dumpPropertiesCode(): string;
  55669. serialize(): any;
  55670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55671. }
  55672. }
  55673. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55676. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55677. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55678. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55679. import { Scene } from "babylonjs/scene";
  55680. /**
  55681. * Class used to store shared data between 2 NodeMaterialBuildState
  55682. */
  55683. export class NodeMaterialBuildStateSharedData {
  55684. /**
  55685. * Gets the list of emitted varyings
  55686. */
  55687. temps: string[];
  55688. /**
  55689. * Gets the list of emitted varyings
  55690. */
  55691. varyings: string[];
  55692. /**
  55693. * Gets the varying declaration string
  55694. */
  55695. varyingDeclaration: string;
  55696. /**
  55697. * Input blocks
  55698. */
  55699. inputBlocks: InputBlock[];
  55700. /**
  55701. * Input blocks
  55702. */
  55703. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55704. /**
  55705. * Bindable blocks (Blocks that need to set data to the effect)
  55706. */
  55707. bindableBlocks: NodeMaterialBlock[];
  55708. /**
  55709. * List of blocks that can provide a compilation fallback
  55710. */
  55711. blocksWithFallbacks: NodeMaterialBlock[];
  55712. /**
  55713. * List of blocks that can provide a define update
  55714. */
  55715. blocksWithDefines: NodeMaterialBlock[];
  55716. /**
  55717. * List of blocks that can provide a repeatable content
  55718. */
  55719. repeatableContentBlocks: NodeMaterialBlock[];
  55720. /**
  55721. * List of blocks that can provide a dynamic list of uniforms
  55722. */
  55723. dynamicUniformBlocks: NodeMaterialBlock[];
  55724. /**
  55725. * List of blocks that can block the isReady function for the material
  55726. */
  55727. blockingBlocks: NodeMaterialBlock[];
  55728. /**
  55729. * Gets the list of animated inputs
  55730. */
  55731. animatedInputs: InputBlock[];
  55732. /**
  55733. * Build Id used to avoid multiple recompilations
  55734. */
  55735. buildId: number;
  55736. /** List of emitted variables */
  55737. variableNames: {
  55738. [key: string]: number;
  55739. };
  55740. /** List of emitted defines */
  55741. defineNames: {
  55742. [key: string]: number;
  55743. };
  55744. /** Should emit comments? */
  55745. emitComments: boolean;
  55746. /** Emit build activity */
  55747. verbose: boolean;
  55748. /** Gets or sets the hosting scene */
  55749. scene: Scene;
  55750. /**
  55751. * Gets the compilation hints emitted at compilation time
  55752. */
  55753. hints: {
  55754. needWorldViewMatrix: boolean;
  55755. needWorldViewProjectionMatrix: boolean;
  55756. needAlphaBlending: boolean;
  55757. needAlphaTesting: boolean;
  55758. };
  55759. /**
  55760. * List of compilation checks
  55761. */
  55762. checks: {
  55763. emitVertex: boolean;
  55764. emitFragment: boolean;
  55765. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55766. };
  55767. /** Creates a new shared data */
  55768. constructor();
  55769. /**
  55770. * Emits console errors and exceptions if there is a failing check
  55771. */
  55772. emitErrors(): void;
  55773. }
  55774. }
  55775. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55776. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55777. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55778. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55779. /**
  55780. * Class used to store node based material build state
  55781. */
  55782. export class NodeMaterialBuildState {
  55783. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55784. supportUniformBuffers: boolean;
  55785. /**
  55786. * Gets the list of emitted attributes
  55787. */
  55788. attributes: string[];
  55789. /**
  55790. * Gets the list of emitted uniforms
  55791. */
  55792. uniforms: string[];
  55793. /**
  55794. * Gets the list of emitted constants
  55795. */
  55796. constants: string[];
  55797. /**
  55798. * Gets the list of emitted uniform buffers
  55799. */
  55800. uniformBuffers: string[];
  55801. /**
  55802. * Gets the list of emitted samplers
  55803. */
  55804. samplers: string[];
  55805. /**
  55806. * Gets the list of emitted functions
  55807. */
  55808. functions: {
  55809. [key: string]: string;
  55810. };
  55811. /**
  55812. * Gets the list of emitted extensions
  55813. */
  55814. extensions: {
  55815. [key: string]: string;
  55816. };
  55817. /**
  55818. * Gets the target of the compilation state
  55819. */
  55820. target: NodeMaterialBlockTargets;
  55821. /**
  55822. * Gets the list of emitted counters
  55823. */
  55824. counters: {
  55825. [key: string]: number;
  55826. };
  55827. /**
  55828. * Shared data between multiple NodeMaterialBuildState instances
  55829. */
  55830. sharedData: NodeMaterialBuildStateSharedData;
  55831. /** @hidden */
  55832. _vertexState: NodeMaterialBuildState;
  55833. /** @hidden */
  55834. _attributeDeclaration: string;
  55835. /** @hidden */
  55836. _uniformDeclaration: string;
  55837. /** @hidden */
  55838. _constantDeclaration: string;
  55839. /** @hidden */
  55840. _samplerDeclaration: string;
  55841. /** @hidden */
  55842. _varyingTransfer: string;
  55843. private _repeatableContentAnchorIndex;
  55844. /** @hidden */
  55845. _builtCompilationString: string;
  55846. /**
  55847. * Gets the emitted compilation strings
  55848. */
  55849. compilationString: string;
  55850. /**
  55851. * Finalize the compilation strings
  55852. * @param state defines the current compilation state
  55853. */
  55854. finalize(state: NodeMaterialBuildState): void;
  55855. /** @hidden */
  55856. readonly _repeatableContentAnchor: string;
  55857. /** @hidden */
  55858. _getFreeVariableName(prefix: string): string;
  55859. /** @hidden */
  55860. _getFreeDefineName(prefix: string): string;
  55861. /** @hidden */
  55862. _excludeVariableName(name: string): void;
  55863. /** @hidden */
  55864. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55865. /** @hidden */
  55866. _emitExtension(name: string, extension: string): void;
  55867. /** @hidden */
  55868. _emitFunction(name: string, code: string, comments: string): void;
  55869. /** @hidden */
  55870. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55871. replaceStrings?: {
  55872. search: RegExp;
  55873. replace: string;
  55874. }[];
  55875. repeatKey?: string;
  55876. }): string;
  55877. /** @hidden */
  55878. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55879. repeatKey?: string;
  55880. removeAttributes?: boolean;
  55881. removeUniforms?: boolean;
  55882. removeVaryings?: boolean;
  55883. removeIfDef?: boolean;
  55884. replaceStrings?: {
  55885. search: RegExp;
  55886. replace: string;
  55887. }[];
  55888. }, storeKey?: string): void;
  55889. /** @hidden */
  55890. _registerTempVariable(name: string): boolean;
  55891. /** @hidden */
  55892. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55893. /** @hidden */
  55894. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55895. /** @hidden */
  55896. _emitFloat(value: number): string;
  55897. }
  55898. }
  55899. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55900. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55902. import { Nullable } from "babylonjs/types";
  55903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55904. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55905. import { Effect } from "babylonjs/Materials/effect";
  55906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55907. import { Mesh } from "babylonjs/Meshes/mesh";
  55908. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55909. import { Scene } from "babylonjs/scene";
  55910. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55911. /**
  55912. * Defines a block that can be used inside a node based material
  55913. */
  55914. export class NodeMaterialBlock {
  55915. private _buildId;
  55916. private _buildTarget;
  55917. private _target;
  55918. private _isFinalMerger;
  55919. private _isInput;
  55920. /** @hidden */
  55921. _codeVariableName: string;
  55922. /** @hidden */
  55923. _inputs: NodeMaterialConnectionPoint[];
  55924. /** @hidden */
  55925. _outputs: NodeMaterialConnectionPoint[];
  55926. /** @hidden */
  55927. _preparationId: number;
  55928. /**
  55929. * Gets or sets the name of the block
  55930. */
  55931. name: string;
  55932. /**
  55933. * Gets or sets the unique id of the node
  55934. */
  55935. uniqueId: number;
  55936. /**
  55937. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55938. */
  55939. readonly isFinalMerger: boolean;
  55940. /**
  55941. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55942. */
  55943. readonly isInput: boolean;
  55944. /**
  55945. * Gets or sets the build Id
  55946. */
  55947. buildId: number;
  55948. /**
  55949. * Gets or sets the target of the block
  55950. */
  55951. target: NodeMaterialBlockTargets;
  55952. /**
  55953. * Gets the list of input points
  55954. */
  55955. readonly inputs: NodeMaterialConnectionPoint[];
  55956. /** Gets the list of output points */
  55957. readonly outputs: NodeMaterialConnectionPoint[];
  55958. /**
  55959. * Find an input by its name
  55960. * @param name defines the name of the input to look for
  55961. * @returns the input or null if not found
  55962. */
  55963. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55964. /**
  55965. * Find an output by its name
  55966. * @param name defines the name of the outputto look for
  55967. * @returns the output or null if not found
  55968. */
  55969. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55970. /**
  55971. * Creates a new NodeMaterialBlock
  55972. * @param name defines the block name
  55973. * @param target defines the target of that block (Vertex by default)
  55974. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55975. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55976. */
  55977. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55978. /**
  55979. * Initialize the block and prepare the context for build
  55980. * @param state defines the state that will be used for the build
  55981. */
  55982. initialize(state: NodeMaterialBuildState): void;
  55983. /**
  55984. * Bind data to effect. Will only be called for blocks with isBindable === true
  55985. * @param effect defines the effect to bind data to
  55986. * @param nodeMaterial defines the hosting NodeMaterial
  55987. * @param mesh defines the mesh that will be rendered
  55988. */
  55989. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55990. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55991. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55992. protected _writeFloat(value: number): string;
  55993. /**
  55994. * Gets the current class name e.g. "NodeMaterialBlock"
  55995. * @returns the class name
  55996. */
  55997. getClassName(): string;
  55998. /**
  55999. * Register a new input. Must be called inside a block constructor
  56000. * @param name defines the connection point name
  56001. * @param type defines the connection point type
  56002. * @param isOptional defines a boolean indicating that this input can be omitted
  56003. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56004. * @returns the current block
  56005. */
  56006. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56007. /**
  56008. * Register a new output. Must be called inside a block constructor
  56009. * @param name defines the connection point name
  56010. * @param type defines the connection point type
  56011. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56012. * @returns the current block
  56013. */
  56014. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56015. /**
  56016. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56017. * @param forOutput defines an optional connection point to check compatibility with
  56018. * @returns the first available input or null
  56019. */
  56020. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56021. /**
  56022. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56023. * @param forBlock defines an optional block to check compatibility with
  56024. * @returns the first available input or null
  56025. */
  56026. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56027. /**
  56028. * Gets the sibling of the given output
  56029. * @param current defines the current output
  56030. * @returns the next output in the list or null
  56031. */
  56032. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56033. /**
  56034. * Connect current block with another block
  56035. * @param other defines the block to connect with
  56036. * @param options define the various options to help pick the right connections
  56037. * @returns the current block
  56038. */
  56039. connectTo(other: NodeMaterialBlock, options?: {
  56040. input?: string;
  56041. output?: string;
  56042. outputSwizzle?: string;
  56043. }): this | undefined;
  56044. protected _buildBlock(state: NodeMaterialBuildState): void;
  56045. /**
  56046. * Add uniforms, samplers and uniform buffers at compilation time
  56047. * @param state defines the state to update
  56048. * @param nodeMaterial defines the node material requesting the update
  56049. * @param defines defines the material defines to update
  56050. */
  56051. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56052. /**
  56053. * Add potential fallbacks if shader compilation fails
  56054. * @param mesh defines the mesh to be rendered
  56055. * @param fallbacks defines the current prioritized list of fallbacks
  56056. */
  56057. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56058. /**
  56059. * Initialize defines for shader compilation
  56060. * @param mesh defines the mesh to be rendered
  56061. * @param nodeMaterial defines the node material requesting the update
  56062. * @param defines defines the material defines to update
  56063. * @param useInstances specifies that instances should be used
  56064. */
  56065. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56066. /**
  56067. * Update defines for shader compilation
  56068. * @param mesh defines the mesh to be rendered
  56069. * @param nodeMaterial defines the node material requesting the update
  56070. * @param defines defines the material defines to update
  56071. * @param useInstances specifies that instances should be used
  56072. */
  56073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56074. /**
  56075. * Lets the block try to connect some inputs automatically
  56076. * @param material defines the hosting NodeMaterial
  56077. */
  56078. autoConfigure(material: NodeMaterial): void;
  56079. /**
  56080. * Function called when a block is declared as repeatable content generator
  56081. * @param vertexShaderState defines the current compilation state for the vertex shader
  56082. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56083. * @param mesh defines the mesh to be rendered
  56084. * @param defines defines the material defines to update
  56085. */
  56086. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56087. /**
  56088. * Checks if the block is ready
  56089. * @param mesh defines the mesh to be rendered
  56090. * @param nodeMaterial defines the node material requesting the update
  56091. * @param defines defines the material defines to update
  56092. * @param useInstances specifies that instances should be used
  56093. * @returns true if the block is ready
  56094. */
  56095. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56096. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56097. private _processBuild;
  56098. /**
  56099. * Compile the current node and generate the shader code
  56100. * @param state defines the current compilation state (uniforms, samplers, current string)
  56101. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56102. * @returns true if already built
  56103. */
  56104. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56105. protected _inputRename(name: string): string;
  56106. protected _outputRename(name: string): string;
  56107. protected _dumpPropertiesCode(): string;
  56108. /** @hidden */
  56109. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56110. /**
  56111. * Clone the current block to a new identical block
  56112. * @param scene defines the hosting scene
  56113. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56114. * @returns a copy of the current block
  56115. */
  56116. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56117. /**
  56118. * Serializes this block in a JSON representation
  56119. * @returns the serialized block object
  56120. */
  56121. serialize(): any;
  56122. /** @hidden */
  56123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56124. }
  56125. }
  56126. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56127. /**
  56128. * Enum defining the type of animations supported by InputBlock
  56129. */
  56130. export enum AnimatedInputBlockTypes {
  56131. /** No animation */
  56132. None = 0,
  56133. /** Time based animation. Will only work for floats */
  56134. Time = 1
  56135. }
  56136. }
  56137. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56139. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56140. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56141. import { Nullable } from "babylonjs/types";
  56142. import { Effect } from "babylonjs/Materials/effect";
  56143. import { Matrix } from "babylonjs/Maths/math.vector";
  56144. import { Scene } from "babylonjs/scene";
  56145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56147. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56148. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56149. /**
  56150. * Block used to expose an input value
  56151. */
  56152. export class InputBlock extends NodeMaterialBlock {
  56153. private _mode;
  56154. private _associatedVariableName;
  56155. private _storedValue;
  56156. private _valueCallback;
  56157. private _type;
  56158. private _animationType;
  56159. /** Gets or set a value used to limit the range of float values */
  56160. min: number;
  56161. /** Gets or set a value used to limit the range of float values */
  56162. max: number;
  56163. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56164. matrixMode: number;
  56165. /** @hidden */
  56166. _systemValue: Nullable<NodeMaterialSystemValues>;
  56167. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56168. visibleInInspector: boolean;
  56169. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56170. isConstant: boolean;
  56171. /**
  56172. * Gets or sets the connection point type (default is float)
  56173. */
  56174. readonly type: NodeMaterialBlockConnectionPointTypes;
  56175. /**
  56176. * Creates a new InputBlock
  56177. * @param name defines the block name
  56178. * @param target defines the target of that block (Vertex by default)
  56179. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56180. */
  56181. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56182. /**
  56183. * Gets the output component
  56184. */
  56185. readonly output: NodeMaterialConnectionPoint;
  56186. /**
  56187. * Set the source of this connection point to a vertex attribute
  56188. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56189. * @returns the current connection point
  56190. */
  56191. setAsAttribute(attributeName?: string): InputBlock;
  56192. /**
  56193. * Set the source of this connection point to a system value
  56194. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56195. * @returns the current connection point
  56196. */
  56197. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56198. /**
  56199. * Gets or sets the value of that point.
  56200. * Please note that this value will be ignored if valueCallback is defined
  56201. */
  56202. value: any;
  56203. /**
  56204. * Gets or sets a callback used to get the value of that point.
  56205. * Please note that setting this value will force the connection point to ignore the value property
  56206. */
  56207. valueCallback: () => any;
  56208. /**
  56209. * Gets or sets the associated variable name in the shader
  56210. */
  56211. associatedVariableName: string;
  56212. /** Gets or sets the type of animation applied to the input */
  56213. animationType: AnimatedInputBlockTypes;
  56214. /**
  56215. * Gets a boolean indicating that this connection point not defined yet
  56216. */
  56217. readonly isUndefined: boolean;
  56218. /**
  56219. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56220. * In this case the connection point name must be the name of the uniform to use.
  56221. * Can only be set on inputs
  56222. */
  56223. isUniform: boolean;
  56224. /**
  56225. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56226. * In this case the connection point name must be the name of the attribute to use
  56227. * Can only be set on inputs
  56228. */
  56229. isAttribute: boolean;
  56230. /**
  56231. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56232. * Can only be set on exit points
  56233. */
  56234. isVarying: boolean;
  56235. /**
  56236. * Gets a boolean indicating that the current connection point is a system value
  56237. */
  56238. readonly isSystemValue: boolean;
  56239. /**
  56240. * Gets or sets the current well known value or null if not defined as a system value
  56241. */
  56242. systemValue: Nullable<NodeMaterialSystemValues>;
  56243. /**
  56244. * Gets the current class name
  56245. * @returns the class name
  56246. */
  56247. getClassName(): string;
  56248. /**
  56249. * Animate the input if animationType !== None
  56250. * @param scene defines the rendering scene
  56251. */
  56252. animate(scene: Scene): void;
  56253. private _emitDefine;
  56254. initialize(state: NodeMaterialBuildState): void;
  56255. /**
  56256. * Set the input block to its default value (based on its type)
  56257. */
  56258. setDefaultValue(): void;
  56259. private _emitConstant;
  56260. private _emit;
  56261. /** @hidden */
  56262. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56263. /** @hidden */
  56264. _transmit(effect: Effect, scene: Scene): void;
  56265. protected _buildBlock(state: NodeMaterialBuildState): void;
  56266. protected _dumpPropertiesCode(): string;
  56267. serialize(): any;
  56268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56269. }
  56270. }
  56271. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56272. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56273. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56274. import { Nullable } from "babylonjs/types";
  56275. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56277. /**
  56278. * Defines a connection point for a block
  56279. */
  56280. export class NodeMaterialConnectionPoint {
  56281. /** @hidden */
  56282. _ownerBlock: NodeMaterialBlock;
  56283. /** @hidden */
  56284. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56285. private _endpoints;
  56286. private _associatedVariableName;
  56287. /** @hidden */
  56288. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56289. /** @hidden */
  56290. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56291. private _type;
  56292. /** @hidden */
  56293. _enforceAssociatedVariableName: boolean;
  56294. /**
  56295. * Gets or sets the additional types supported by this connection point
  56296. */
  56297. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56298. /**
  56299. * Gets or sets the additional types excluded by this connection point
  56300. */
  56301. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56302. /**
  56303. * Gets or sets the associated variable name in the shader
  56304. */
  56305. associatedVariableName: string;
  56306. /**
  56307. * Gets or sets the connection point type (default is float)
  56308. */
  56309. type: NodeMaterialBlockConnectionPointTypes;
  56310. /**
  56311. * Gets or sets the connection point name
  56312. */
  56313. name: string;
  56314. /**
  56315. * Gets or sets a boolean indicating that this connection point can be omitted
  56316. */
  56317. isOptional: boolean;
  56318. /**
  56319. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56320. */
  56321. define: string;
  56322. /** Gets or sets the target of that connection point */
  56323. target: NodeMaterialBlockTargets;
  56324. /**
  56325. * Gets a boolean indicating that the current point is connected
  56326. */
  56327. readonly isConnected: boolean;
  56328. /**
  56329. * Gets a boolean indicating that the current point is connected to an input block
  56330. */
  56331. readonly isConnectedToInputBlock: boolean;
  56332. /**
  56333. * Gets a the connected input block (if any)
  56334. */
  56335. readonly connectInputBlock: Nullable<InputBlock>;
  56336. /** Get the other side of the connection (if any) */
  56337. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56338. /** Get the block that owns this connection point */
  56339. readonly ownerBlock: NodeMaterialBlock;
  56340. /** Get the block connected on the other side of this connection (if any) */
  56341. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56342. /** Get the block connected on the endpoints of this connection (if any) */
  56343. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56344. /** Gets the list of connected endpoints */
  56345. readonly endpoints: NodeMaterialConnectionPoint[];
  56346. /** Gets a boolean indicating if that output point is connected to at least one input */
  56347. readonly hasEndpoints: boolean;
  56348. /**
  56349. * Creates a new connection point
  56350. * @param name defines the connection point name
  56351. * @param ownerBlock defines the block hosting this connection point
  56352. */
  56353. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56354. /**
  56355. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56356. * @returns the class name
  56357. */
  56358. getClassName(): string;
  56359. /**
  56360. * Gets an boolean indicating if the current point can be connected to another point
  56361. * @param connectionPoint defines the other connection point
  56362. * @returns true if the connection is possible
  56363. */
  56364. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56365. /**
  56366. * Connect this point to another connection point
  56367. * @param connectionPoint defines the other connection point
  56368. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56369. * @returns the current connection point
  56370. */
  56371. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56372. /**
  56373. * Disconnect this point from one of his endpoint
  56374. * @param endpoint defines the other connection point
  56375. * @returns the current connection point
  56376. */
  56377. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56378. /**
  56379. * Serializes this point in a JSON representation
  56380. * @returns the serialized point object
  56381. */
  56382. serialize(): any;
  56383. }
  56384. }
  56385. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56389. import { Mesh } from "babylonjs/Meshes/mesh";
  56390. import { Effect } from "babylonjs/Materials/effect";
  56391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56392. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56393. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56394. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56395. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56396. /**
  56397. * Block used to add support for vertex skinning (bones)
  56398. */
  56399. export class BonesBlock extends NodeMaterialBlock {
  56400. /**
  56401. * Creates a new BonesBlock
  56402. * @param name defines the block name
  56403. */
  56404. constructor(name: string);
  56405. /**
  56406. * Initialize the block and prepare the context for build
  56407. * @param state defines the state that will be used for the build
  56408. */
  56409. initialize(state: NodeMaterialBuildState): void;
  56410. /**
  56411. * Gets the current class name
  56412. * @returns the class name
  56413. */
  56414. getClassName(): string;
  56415. /**
  56416. * Gets the matrix indices input component
  56417. */
  56418. readonly matricesIndices: NodeMaterialConnectionPoint;
  56419. /**
  56420. * Gets the matrix weights input component
  56421. */
  56422. readonly matricesWeights: NodeMaterialConnectionPoint;
  56423. /**
  56424. * Gets the extra matrix indices input component
  56425. */
  56426. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56427. /**
  56428. * Gets the extra matrix weights input component
  56429. */
  56430. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56431. /**
  56432. * Gets the world input component
  56433. */
  56434. readonly world: NodeMaterialConnectionPoint;
  56435. /**
  56436. * Gets the output component
  56437. */
  56438. readonly output: NodeMaterialConnectionPoint;
  56439. autoConfigure(material: NodeMaterial): void;
  56440. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56441. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56442. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56443. protected _buildBlock(state: NodeMaterialBuildState): this;
  56444. }
  56445. }
  56446. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56451. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56452. /**
  56453. * Block used to add support for instances
  56454. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56455. */
  56456. export class InstancesBlock extends NodeMaterialBlock {
  56457. /**
  56458. * Creates a new InstancesBlock
  56459. * @param name defines the block name
  56460. */
  56461. constructor(name: string);
  56462. /**
  56463. * Gets the current class name
  56464. * @returns the class name
  56465. */
  56466. getClassName(): string;
  56467. /**
  56468. * Gets the first world row input component
  56469. */
  56470. readonly world0: NodeMaterialConnectionPoint;
  56471. /**
  56472. * Gets the second world row input component
  56473. */
  56474. readonly world1: NodeMaterialConnectionPoint;
  56475. /**
  56476. * Gets the third world row input component
  56477. */
  56478. readonly world2: NodeMaterialConnectionPoint;
  56479. /**
  56480. * Gets the forth world row input component
  56481. */
  56482. readonly world3: NodeMaterialConnectionPoint;
  56483. /**
  56484. * Gets the world input component
  56485. */
  56486. readonly world: NodeMaterialConnectionPoint;
  56487. /**
  56488. * Gets the output component
  56489. */
  56490. readonly output: NodeMaterialConnectionPoint;
  56491. autoConfigure(material: NodeMaterial): void;
  56492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56493. protected _buildBlock(state: NodeMaterialBuildState): this;
  56494. }
  56495. }
  56496. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56501. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56502. import { Effect } from "babylonjs/Materials/effect";
  56503. import { Mesh } from "babylonjs/Meshes/mesh";
  56504. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56505. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56506. /**
  56507. * Block used to add morph targets support to vertex shader
  56508. */
  56509. export class MorphTargetsBlock extends NodeMaterialBlock {
  56510. private _repeatableContentAnchor;
  56511. private _repeatebleContentGenerated;
  56512. /**
  56513. * Create a new MorphTargetsBlock
  56514. * @param name defines the block name
  56515. */
  56516. constructor(name: string);
  56517. /**
  56518. * Gets the current class name
  56519. * @returns the class name
  56520. */
  56521. getClassName(): string;
  56522. /**
  56523. * Gets the position input component
  56524. */
  56525. readonly position: NodeMaterialConnectionPoint;
  56526. /**
  56527. * Gets the normal input component
  56528. */
  56529. readonly normal: NodeMaterialConnectionPoint;
  56530. /**
  56531. * Gets the tangent input component
  56532. */
  56533. readonly tangent: NodeMaterialConnectionPoint;
  56534. /**
  56535. * Gets the tangent input component
  56536. */
  56537. readonly uv: NodeMaterialConnectionPoint;
  56538. /**
  56539. * Gets the position output component
  56540. */
  56541. readonly positionOutput: NodeMaterialConnectionPoint;
  56542. /**
  56543. * Gets the normal output component
  56544. */
  56545. readonly normalOutput: NodeMaterialConnectionPoint;
  56546. /**
  56547. * Gets the tangent output component
  56548. */
  56549. readonly tangentOutput: NodeMaterialConnectionPoint;
  56550. /**
  56551. * Gets the tangent output component
  56552. */
  56553. readonly uvOutput: NodeMaterialConnectionPoint;
  56554. initialize(state: NodeMaterialBuildState): void;
  56555. autoConfigure(material: NodeMaterial): void;
  56556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56557. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56558. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56559. protected _buildBlock(state: NodeMaterialBuildState): this;
  56560. }
  56561. }
  56562. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56566. import { Nullable } from "babylonjs/types";
  56567. import { Scene } from "babylonjs/scene";
  56568. import { Effect } from "babylonjs/Materials/effect";
  56569. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56570. import { Mesh } from "babylonjs/Meshes/mesh";
  56571. import { Light } from "babylonjs/Lights/light";
  56572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56573. /**
  56574. * Block used to get data information from a light
  56575. */
  56576. export class LightInformationBlock extends NodeMaterialBlock {
  56577. private _lightDataUniformName;
  56578. private _lightColorUniformName;
  56579. private _lightTypeDefineName;
  56580. /**
  56581. * Gets or sets the light associated with this block
  56582. */
  56583. light: Nullable<Light>;
  56584. /**
  56585. * Creates a new LightInformationBlock
  56586. * @param name defines the block name
  56587. */
  56588. constructor(name: string);
  56589. /**
  56590. * Gets the current class name
  56591. * @returns the class name
  56592. */
  56593. getClassName(): string;
  56594. /**
  56595. * Gets the world position input component
  56596. */
  56597. readonly worldPosition: NodeMaterialConnectionPoint;
  56598. /**
  56599. * Gets the direction output component
  56600. */
  56601. readonly direction: NodeMaterialConnectionPoint;
  56602. /**
  56603. * Gets the direction output component
  56604. */
  56605. readonly color: NodeMaterialConnectionPoint;
  56606. /**
  56607. * Gets the direction output component
  56608. */
  56609. readonly intensity: NodeMaterialConnectionPoint;
  56610. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56612. protected _buildBlock(state: NodeMaterialBuildState): this;
  56613. serialize(): any;
  56614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56615. }
  56616. }
  56617. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56618. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56619. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56620. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56621. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56622. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56623. }
  56624. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56629. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56630. import { Effect } from "babylonjs/Materials/effect";
  56631. import { Mesh } from "babylonjs/Meshes/mesh";
  56632. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56633. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56634. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56635. /**
  56636. * Block used to add image processing support to fragment shader
  56637. */
  56638. export class ImageProcessingBlock extends NodeMaterialBlock {
  56639. /**
  56640. * Create a new ImageProcessingBlock
  56641. * @param name defines the block name
  56642. */
  56643. constructor(name: string);
  56644. /**
  56645. * Gets the current class name
  56646. * @returns the class name
  56647. */
  56648. getClassName(): string;
  56649. /**
  56650. * Gets the color input component
  56651. */
  56652. readonly color: NodeMaterialConnectionPoint;
  56653. /**
  56654. * Gets the output component
  56655. */
  56656. readonly output: NodeMaterialConnectionPoint;
  56657. /**
  56658. * Initialize the block and prepare the context for build
  56659. * @param state defines the state that will be used for the build
  56660. */
  56661. initialize(state: NodeMaterialBuildState): void;
  56662. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56663. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56665. protected _buildBlock(state: NodeMaterialBuildState): this;
  56666. }
  56667. }
  56668. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56672. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56674. import { Effect } from "babylonjs/Materials/effect";
  56675. import { Mesh } from "babylonjs/Meshes/mesh";
  56676. import { Scene } from "babylonjs/scene";
  56677. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56678. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56679. /**
  56680. * Block used to pertub normals based on a normal map
  56681. */
  56682. export class PerturbNormalBlock extends NodeMaterialBlock {
  56683. private _tangentSpaceParameterName;
  56684. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56685. invertX: boolean;
  56686. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56687. invertY: boolean;
  56688. /**
  56689. * Create a new PerturbNormalBlock
  56690. * @param name defines the block name
  56691. */
  56692. constructor(name: string);
  56693. /**
  56694. * Gets the current class name
  56695. * @returns the class name
  56696. */
  56697. getClassName(): string;
  56698. /**
  56699. * Gets the world position input component
  56700. */
  56701. readonly worldPosition: NodeMaterialConnectionPoint;
  56702. /**
  56703. * Gets the world normal input component
  56704. */
  56705. readonly worldNormal: NodeMaterialConnectionPoint;
  56706. /**
  56707. * Gets the uv input component
  56708. */
  56709. readonly uv: NodeMaterialConnectionPoint;
  56710. /**
  56711. * Gets the normal map color input component
  56712. */
  56713. readonly normalMapColor: NodeMaterialConnectionPoint;
  56714. /**
  56715. * Gets the strength input component
  56716. */
  56717. readonly strength: NodeMaterialConnectionPoint;
  56718. /**
  56719. * Gets the output component
  56720. */
  56721. readonly output: NodeMaterialConnectionPoint;
  56722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56724. autoConfigure(material: NodeMaterial): void;
  56725. protected _buildBlock(state: NodeMaterialBuildState): this;
  56726. protected _dumpPropertiesCode(): string;
  56727. serialize(): any;
  56728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56729. }
  56730. }
  56731. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56735. /**
  56736. * Block used to discard a pixel if a value is smaller than a cutoff
  56737. */
  56738. export class DiscardBlock extends NodeMaterialBlock {
  56739. /**
  56740. * Create a new DiscardBlock
  56741. * @param name defines the block name
  56742. */
  56743. constructor(name: string);
  56744. /**
  56745. * Gets the current class name
  56746. * @returns the class name
  56747. */
  56748. getClassName(): string;
  56749. /**
  56750. * Gets the color input component
  56751. */
  56752. readonly value: NodeMaterialConnectionPoint;
  56753. /**
  56754. * Gets the cutoff input component
  56755. */
  56756. readonly cutoff: NodeMaterialConnectionPoint;
  56757. protected _buildBlock(state: NodeMaterialBuildState): this;
  56758. }
  56759. }
  56760. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56761. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56762. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56763. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56764. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56765. }
  56766. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56769. import { Mesh } from "babylonjs/Meshes/mesh";
  56770. import { Effect } from "babylonjs/Materials/effect";
  56771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56773. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56774. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56775. /**
  56776. * Block used to add support for scene fog
  56777. */
  56778. export class FogBlock extends NodeMaterialBlock {
  56779. private _fogDistanceName;
  56780. private _fogParameters;
  56781. /**
  56782. * Create a new FogBlock
  56783. * @param name defines the block name
  56784. */
  56785. constructor(name: string);
  56786. /**
  56787. * Gets the current class name
  56788. * @returns the class name
  56789. */
  56790. getClassName(): string;
  56791. /**
  56792. * Gets the world position input component
  56793. */
  56794. readonly worldPosition: NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the view input component
  56797. */
  56798. readonly view: NodeMaterialConnectionPoint;
  56799. /**
  56800. * Gets the color input component
  56801. */
  56802. readonly input: NodeMaterialConnectionPoint;
  56803. /**
  56804. * Gets the fog color input component
  56805. */
  56806. readonly fogColor: NodeMaterialConnectionPoint;
  56807. /**
  56808. * Gets the output component
  56809. */
  56810. readonly output: NodeMaterialConnectionPoint;
  56811. autoConfigure(material: NodeMaterial): void;
  56812. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56813. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56814. protected _buildBlock(state: NodeMaterialBuildState): this;
  56815. }
  56816. }
  56817. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56822. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56823. import { Effect } from "babylonjs/Materials/effect";
  56824. import { Mesh } from "babylonjs/Meshes/mesh";
  56825. import { Light } from "babylonjs/Lights/light";
  56826. import { Nullable } from "babylonjs/types";
  56827. import { Scene } from "babylonjs/scene";
  56828. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56829. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56830. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56831. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56832. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56833. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56834. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56835. /**
  56836. * Block used to add light in the fragment shader
  56837. */
  56838. export class LightBlock extends NodeMaterialBlock {
  56839. private _lightId;
  56840. /**
  56841. * Gets or sets the light associated with this block
  56842. */
  56843. light: Nullable<Light>;
  56844. /**
  56845. * Create a new LightBlock
  56846. * @param name defines the block name
  56847. */
  56848. constructor(name: string);
  56849. /**
  56850. * Gets the current class name
  56851. * @returns the class name
  56852. */
  56853. getClassName(): string;
  56854. /**
  56855. * Gets the world position input component
  56856. */
  56857. readonly worldPosition: NodeMaterialConnectionPoint;
  56858. /**
  56859. * Gets the world normal input component
  56860. */
  56861. readonly worldNormal: NodeMaterialConnectionPoint;
  56862. /**
  56863. * Gets the camera (or eye) position component
  56864. */
  56865. readonly cameraPosition: NodeMaterialConnectionPoint;
  56866. /**
  56867. * Gets the glossiness component
  56868. */
  56869. readonly glossiness: NodeMaterialConnectionPoint;
  56870. /**
  56871. * Gets the glossinness power component
  56872. */
  56873. readonly glossPower: NodeMaterialConnectionPoint;
  56874. /**
  56875. * Gets the diffuse color component
  56876. */
  56877. readonly diffuseColor: NodeMaterialConnectionPoint;
  56878. /**
  56879. * Gets the specular color component
  56880. */
  56881. readonly specularColor: NodeMaterialConnectionPoint;
  56882. /**
  56883. * Gets the diffuse output component
  56884. */
  56885. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56886. /**
  56887. * Gets the specular output component
  56888. */
  56889. readonly specularOutput: NodeMaterialConnectionPoint;
  56890. autoConfigure(material: NodeMaterial): void;
  56891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56892. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56893. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56894. private _injectVertexCode;
  56895. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56896. serialize(): any;
  56897. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56898. }
  56899. }
  56900. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56901. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56902. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56903. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56904. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56905. }
  56906. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56907. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56908. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56909. }
  56910. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56914. /**
  56915. * Block used to multiply 2 values
  56916. */
  56917. export class MultiplyBlock extends NodeMaterialBlock {
  56918. /**
  56919. * Creates a new MultiplyBlock
  56920. * @param name defines the block name
  56921. */
  56922. constructor(name: string);
  56923. /**
  56924. * Gets the current class name
  56925. * @returns the class name
  56926. */
  56927. getClassName(): string;
  56928. /**
  56929. * Gets the left operand input component
  56930. */
  56931. readonly left: NodeMaterialConnectionPoint;
  56932. /**
  56933. * Gets the right operand input component
  56934. */
  56935. readonly right: NodeMaterialConnectionPoint;
  56936. /**
  56937. * Gets the output component
  56938. */
  56939. readonly output: NodeMaterialConnectionPoint;
  56940. protected _buildBlock(state: NodeMaterialBuildState): this;
  56941. }
  56942. }
  56943. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56947. /**
  56948. * Block used to add 2 vectors
  56949. */
  56950. export class AddBlock extends NodeMaterialBlock {
  56951. /**
  56952. * Creates a new AddBlock
  56953. * @param name defines the block name
  56954. */
  56955. constructor(name: string);
  56956. /**
  56957. * Gets the current class name
  56958. * @returns the class name
  56959. */
  56960. getClassName(): string;
  56961. /**
  56962. * Gets the left operand input component
  56963. */
  56964. readonly left: NodeMaterialConnectionPoint;
  56965. /**
  56966. * Gets the right operand input component
  56967. */
  56968. readonly right: NodeMaterialConnectionPoint;
  56969. /**
  56970. * Gets the output component
  56971. */
  56972. readonly output: NodeMaterialConnectionPoint;
  56973. protected _buildBlock(state: NodeMaterialBuildState): this;
  56974. }
  56975. }
  56976. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56978. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56980. /**
  56981. * Block used to scale a vector by a float
  56982. */
  56983. export class ScaleBlock extends NodeMaterialBlock {
  56984. /**
  56985. * Creates a new ScaleBlock
  56986. * @param name defines the block name
  56987. */
  56988. constructor(name: string);
  56989. /**
  56990. * Gets the current class name
  56991. * @returns the class name
  56992. */
  56993. getClassName(): string;
  56994. /**
  56995. * Gets the input component
  56996. */
  56997. readonly input: NodeMaterialConnectionPoint;
  56998. /**
  56999. * Gets the factor input component
  57000. */
  57001. readonly factor: NodeMaterialConnectionPoint;
  57002. /**
  57003. * Gets the output component
  57004. */
  57005. readonly output: NodeMaterialConnectionPoint;
  57006. protected _buildBlock(state: NodeMaterialBuildState): this;
  57007. }
  57008. }
  57009. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57013. import { Scene } from "babylonjs/scene";
  57014. /**
  57015. * Block used to clamp a float
  57016. */
  57017. export class ClampBlock extends NodeMaterialBlock {
  57018. /** Gets or sets the minimum range */
  57019. minimum: number;
  57020. /** Gets or sets the maximum range */
  57021. maximum: number;
  57022. /**
  57023. * Creates a new ClampBlock
  57024. * @param name defines the block name
  57025. */
  57026. constructor(name: string);
  57027. /**
  57028. * Gets the current class name
  57029. * @returns the class name
  57030. */
  57031. getClassName(): string;
  57032. /**
  57033. * Gets the value input component
  57034. */
  57035. readonly value: NodeMaterialConnectionPoint;
  57036. /**
  57037. * Gets the output component
  57038. */
  57039. readonly output: NodeMaterialConnectionPoint;
  57040. protected _buildBlock(state: NodeMaterialBuildState): this;
  57041. protected _dumpPropertiesCode(): string;
  57042. serialize(): any;
  57043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57044. }
  57045. }
  57046. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57050. /**
  57051. * Block used to apply a cross product between 2 vectors
  57052. */
  57053. export class CrossBlock extends NodeMaterialBlock {
  57054. /**
  57055. * Creates a new CrossBlock
  57056. * @param name defines the block name
  57057. */
  57058. constructor(name: string);
  57059. /**
  57060. * Gets the current class name
  57061. * @returns the class name
  57062. */
  57063. getClassName(): string;
  57064. /**
  57065. * Gets the left operand input component
  57066. */
  57067. readonly left: NodeMaterialConnectionPoint;
  57068. /**
  57069. * Gets the right operand input component
  57070. */
  57071. readonly right: NodeMaterialConnectionPoint;
  57072. /**
  57073. * Gets the output component
  57074. */
  57075. readonly output: NodeMaterialConnectionPoint;
  57076. protected _buildBlock(state: NodeMaterialBuildState): this;
  57077. }
  57078. }
  57079. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57080. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57081. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57083. /**
  57084. * Block used to apply a dot product between 2 vectors
  57085. */
  57086. export class DotBlock extends NodeMaterialBlock {
  57087. /**
  57088. * Creates a new DotBlock
  57089. * @param name defines the block name
  57090. */
  57091. constructor(name: string);
  57092. /**
  57093. * Gets the current class name
  57094. * @returns the class name
  57095. */
  57096. getClassName(): string;
  57097. /**
  57098. * Gets the left operand input component
  57099. */
  57100. readonly left: NodeMaterialConnectionPoint;
  57101. /**
  57102. * Gets the right operand input component
  57103. */
  57104. readonly right: NodeMaterialConnectionPoint;
  57105. /**
  57106. * Gets the output component
  57107. */
  57108. readonly output: NodeMaterialConnectionPoint;
  57109. protected _buildBlock(state: NodeMaterialBuildState): this;
  57110. }
  57111. }
  57112. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57116. import { Vector2 } from "babylonjs/Maths/math.vector";
  57117. import { Scene } from "babylonjs/scene";
  57118. /**
  57119. * Block used to remap a float from a range to a new one
  57120. */
  57121. export class RemapBlock extends NodeMaterialBlock {
  57122. /**
  57123. * Gets or sets the source range
  57124. */
  57125. sourceRange: Vector2;
  57126. /**
  57127. * Gets or sets the target range
  57128. */
  57129. targetRange: Vector2;
  57130. /**
  57131. * Creates a new RemapBlock
  57132. * @param name defines the block name
  57133. */
  57134. constructor(name: string);
  57135. /**
  57136. * Gets the current class name
  57137. * @returns the class name
  57138. */
  57139. getClassName(): string;
  57140. /**
  57141. * Gets the input component
  57142. */
  57143. readonly input: NodeMaterialConnectionPoint;
  57144. /**
  57145. * Gets the source min input component
  57146. */
  57147. readonly sourceMin: NodeMaterialConnectionPoint;
  57148. /**
  57149. * Gets the source max input component
  57150. */
  57151. readonly sourceMax: NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the target min input component
  57154. */
  57155. readonly targetMin: NodeMaterialConnectionPoint;
  57156. /**
  57157. * Gets the target max input component
  57158. */
  57159. readonly targetMax: NodeMaterialConnectionPoint;
  57160. /**
  57161. * Gets the output component
  57162. */
  57163. readonly output: NodeMaterialConnectionPoint;
  57164. protected _buildBlock(state: NodeMaterialBuildState): this;
  57165. protected _dumpPropertiesCode(): string;
  57166. serialize(): any;
  57167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57168. }
  57169. }
  57170. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57172. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57173. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57174. /**
  57175. * Block used to normalize a vector
  57176. */
  57177. export class NormalizeBlock extends NodeMaterialBlock {
  57178. /**
  57179. * Creates a new NormalizeBlock
  57180. * @param name defines the block name
  57181. */
  57182. constructor(name: string);
  57183. /**
  57184. * Gets the current class name
  57185. * @returns the class name
  57186. */
  57187. getClassName(): string;
  57188. /**
  57189. * Gets the input component
  57190. */
  57191. readonly input: NodeMaterialConnectionPoint;
  57192. /**
  57193. * Gets the output component
  57194. */
  57195. readonly output: NodeMaterialConnectionPoint;
  57196. protected _buildBlock(state: NodeMaterialBuildState): this;
  57197. }
  57198. }
  57199. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57203. import { Scene } from "babylonjs/scene";
  57204. /**
  57205. * Operations supported by the Trigonometry block
  57206. */
  57207. export enum TrigonometryBlockOperations {
  57208. /** Cos */
  57209. Cos = 0,
  57210. /** Sin */
  57211. Sin = 1,
  57212. /** Abs */
  57213. Abs = 2,
  57214. /** Exp */
  57215. Exp = 3,
  57216. /** Exp2 */
  57217. Exp2 = 4,
  57218. /** Round */
  57219. Round = 5,
  57220. /** Floor */
  57221. Floor = 6,
  57222. /** Ceiling */
  57223. Ceiling = 7,
  57224. /** Square root */
  57225. Sqrt = 8,
  57226. /** Log */
  57227. Log = 9,
  57228. /** Tangent */
  57229. Tan = 10,
  57230. /** Arc tangent */
  57231. ArcTan = 11,
  57232. /** Arc cosinus */
  57233. ArcCos = 12,
  57234. /** Arc sinus */
  57235. ArcSin = 13,
  57236. /** Fraction */
  57237. Fract = 14,
  57238. /** Sign */
  57239. Sign = 15,
  57240. /** To radians (from degrees) */
  57241. Radians = 16,
  57242. /** To degrees (from radians) */
  57243. Degrees = 17
  57244. }
  57245. /**
  57246. * Block used to apply trigonometry operation to floats
  57247. */
  57248. export class TrigonometryBlock extends NodeMaterialBlock {
  57249. /**
  57250. * Gets or sets the operation applied by the block
  57251. */
  57252. operation: TrigonometryBlockOperations;
  57253. /**
  57254. * Creates a new TrigonometryBlock
  57255. * @param name defines the block name
  57256. */
  57257. constructor(name: string);
  57258. /**
  57259. * Gets the current class name
  57260. * @returns the class name
  57261. */
  57262. getClassName(): string;
  57263. /**
  57264. * Gets the input component
  57265. */
  57266. readonly input: NodeMaterialConnectionPoint;
  57267. /**
  57268. * Gets the output component
  57269. */
  57270. readonly output: NodeMaterialConnectionPoint;
  57271. protected _buildBlock(state: NodeMaterialBuildState): this;
  57272. serialize(): any;
  57273. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57274. }
  57275. }
  57276. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57280. /**
  57281. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57282. */
  57283. export class ColorMergerBlock extends NodeMaterialBlock {
  57284. /**
  57285. * Create a new ColorMergerBlock
  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 r component (input)
  57296. */
  57297. readonly r: NodeMaterialConnectionPoint;
  57298. /**
  57299. * Gets the g component (input)
  57300. */
  57301. readonly g: NodeMaterialConnectionPoint;
  57302. /**
  57303. * Gets the b component (input)
  57304. */
  57305. readonly b: NodeMaterialConnectionPoint;
  57306. /**
  57307. * Gets the a component (input)
  57308. */
  57309. readonly a: NodeMaterialConnectionPoint;
  57310. /**
  57311. * Gets the rgba component (output)
  57312. */
  57313. readonly rgba: NodeMaterialConnectionPoint;
  57314. /**
  57315. * Gets the rgb component (output)
  57316. */
  57317. readonly rgb: NodeMaterialConnectionPoint;
  57318. protected _buildBlock(state: NodeMaterialBuildState): this;
  57319. }
  57320. }
  57321. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57325. /**
  57326. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57327. */
  57328. export class VectorMergerBlock extends NodeMaterialBlock {
  57329. /**
  57330. * Create a new VectorMergerBlock
  57331. * @param name defines the block name
  57332. */
  57333. constructor(name: string);
  57334. /**
  57335. * Gets the current class name
  57336. * @returns the class name
  57337. */
  57338. getClassName(): string;
  57339. /**
  57340. * Gets the x component (input)
  57341. */
  57342. readonly x: NodeMaterialConnectionPoint;
  57343. /**
  57344. * Gets the y component (input)
  57345. */
  57346. readonly y: NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the z component (input)
  57349. */
  57350. readonly z: NodeMaterialConnectionPoint;
  57351. /**
  57352. * Gets the w component (input)
  57353. */
  57354. readonly w: NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the xyzw component (output)
  57357. */
  57358. readonly xyzw: NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the xyz component (output)
  57361. */
  57362. readonly xyz: NodeMaterialConnectionPoint;
  57363. /**
  57364. * Gets the xy component (output)
  57365. */
  57366. readonly xy: NodeMaterialConnectionPoint;
  57367. protected _buildBlock(state: NodeMaterialBuildState): this;
  57368. }
  57369. }
  57370. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57374. /**
  57375. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57376. */
  57377. export class ColorSplitterBlock extends NodeMaterialBlock {
  57378. /**
  57379. * Create a new ColorSplitterBlock
  57380. * @param name defines the block name
  57381. */
  57382. constructor(name: string);
  57383. /**
  57384. * Gets the current class name
  57385. * @returns the class name
  57386. */
  57387. getClassName(): string;
  57388. /**
  57389. * Gets the rgba component (input)
  57390. */
  57391. readonly rgba: NodeMaterialConnectionPoint;
  57392. /**
  57393. * Gets the rgb component (input)
  57394. */
  57395. readonly rgbIn: NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the rgb component (output)
  57398. */
  57399. readonly rgbOut: NodeMaterialConnectionPoint;
  57400. /**
  57401. * Gets the r component (output)
  57402. */
  57403. readonly r: NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the g component (output)
  57406. */
  57407. readonly g: NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the b component (output)
  57410. */
  57411. readonly b: NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the a component (output)
  57414. */
  57415. readonly a: NodeMaterialConnectionPoint;
  57416. protected _inputRename(name: string): string;
  57417. protected _outputRename(name: string): string;
  57418. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57419. }
  57420. }
  57421. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57425. /**
  57426. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57427. */
  57428. export class VectorSplitterBlock extends NodeMaterialBlock {
  57429. /**
  57430. * Create a new VectorSplitterBlock
  57431. * @param name defines the block name
  57432. */
  57433. constructor(name: string);
  57434. /**
  57435. * Gets the current class name
  57436. * @returns the class name
  57437. */
  57438. getClassName(): string;
  57439. /**
  57440. * Gets the xyzw component (input)
  57441. */
  57442. readonly xyzw: NodeMaterialConnectionPoint;
  57443. /**
  57444. * Gets the xyz component (input)
  57445. */
  57446. readonly xyzIn: NodeMaterialConnectionPoint;
  57447. /**
  57448. * Gets the xy component (input)
  57449. */
  57450. readonly xyIn: NodeMaterialConnectionPoint;
  57451. /**
  57452. * Gets the xyz component (output)
  57453. */
  57454. readonly xyzOut: NodeMaterialConnectionPoint;
  57455. /**
  57456. * Gets the xy component (output)
  57457. */
  57458. readonly xyOut: NodeMaterialConnectionPoint;
  57459. /**
  57460. * Gets the x component (output)
  57461. */
  57462. readonly x: NodeMaterialConnectionPoint;
  57463. /**
  57464. * Gets the y component (output)
  57465. */
  57466. readonly y: NodeMaterialConnectionPoint;
  57467. /**
  57468. * Gets the z component (output)
  57469. */
  57470. readonly z: NodeMaterialConnectionPoint;
  57471. /**
  57472. * Gets the w component (output)
  57473. */
  57474. readonly w: NodeMaterialConnectionPoint;
  57475. protected _inputRename(name: string): string;
  57476. protected _outputRename(name: string): string;
  57477. protected _buildBlock(state: NodeMaterialBuildState): this;
  57478. }
  57479. }
  57480. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57481. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57482. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57484. /**
  57485. * Block used to lerp between 2 values
  57486. */
  57487. export class LerpBlock extends NodeMaterialBlock {
  57488. /**
  57489. * Creates a new LerpBlock
  57490. * @param name defines the block name
  57491. */
  57492. constructor(name: string);
  57493. /**
  57494. * Gets the current class name
  57495. * @returns the class name
  57496. */
  57497. getClassName(): string;
  57498. /**
  57499. * Gets the left operand input component
  57500. */
  57501. readonly left: NodeMaterialConnectionPoint;
  57502. /**
  57503. * Gets the right operand input component
  57504. */
  57505. readonly right: NodeMaterialConnectionPoint;
  57506. /**
  57507. * Gets the gradient operand input component
  57508. */
  57509. readonly gradient: NodeMaterialConnectionPoint;
  57510. /**
  57511. * Gets the output component
  57512. */
  57513. readonly output: NodeMaterialConnectionPoint;
  57514. protected _buildBlock(state: NodeMaterialBuildState): this;
  57515. }
  57516. }
  57517. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57521. /**
  57522. * Block used to divide 2 vectors
  57523. */
  57524. export class DivideBlock extends NodeMaterialBlock {
  57525. /**
  57526. * Creates a new DivideBlock
  57527. * @param name defines the block name
  57528. */
  57529. constructor(name: string);
  57530. /**
  57531. * Gets the current class name
  57532. * @returns the class name
  57533. */
  57534. getClassName(): string;
  57535. /**
  57536. * Gets the left operand input component
  57537. */
  57538. readonly left: NodeMaterialConnectionPoint;
  57539. /**
  57540. * Gets the right operand input component
  57541. */
  57542. readonly right: NodeMaterialConnectionPoint;
  57543. /**
  57544. * Gets the output component
  57545. */
  57546. readonly output: NodeMaterialConnectionPoint;
  57547. protected _buildBlock(state: NodeMaterialBuildState): this;
  57548. }
  57549. }
  57550. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57554. /**
  57555. * Block used to subtract 2 vectors
  57556. */
  57557. export class SubtractBlock extends NodeMaterialBlock {
  57558. /**
  57559. * Creates a new SubtractBlock
  57560. * @param name defines the block name
  57561. */
  57562. constructor(name: string);
  57563. /**
  57564. * Gets the current class name
  57565. * @returns the class name
  57566. */
  57567. getClassName(): string;
  57568. /**
  57569. * Gets the left operand input component
  57570. */
  57571. readonly left: NodeMaterialConnectionPoint;
  57572. /**
  57573. * Gets the right operand input component
  57574. */
  57575. readonly right: NodeMaterialConnectionPoint;
  57576. /**
  57577. * Gets the output component
  57578. */
  57579. readonly output: NodeMaterialConnectionPoint;
  57580. protected _buildBlock(state: NodeMaterialBuildState): this;
  57581. }
  57582. }
  57583. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57587. /**
  57588. * Block used to step a value
  57589. */
  57590. export class StepBlock extends NodeMaterialBlock {
  57591. /**
  57592. * Creates a new StepBlock
  57593. * @param name defines the block name
  57594. */
  57595. constructor(name: string);
  57596. /**
  57597. * Gets the current class name
  57598. * @returns the class name
  57599. */
  57600. getClassName(): string;
  57601. /**
  57602. * Gets the value operand input component
  57603. */
  57604. readonly value: NodeMaterialConnectionPoint;
  57605. /**
  57606. * Gets the edge operand input component
  57607. */
  57608. readonly edge: NodeMaterialConnectionPoint;
  57609. /**
  57610. * Gets the output component
  57611. */
  57612. readonly output: NodeMaterialConnectionPoint;
  57613. protected _buildBlock(state: NodeMaterialBuildState): this;
  57614. }
  57615. }
  57616. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57617. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57618. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57619. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57620. /**
  57621. * Block used to get the opposite (1 - x) of a value
  57622. */
  57623. export class OneMinusBlock extends NodeMaterialBlock {
  57624. /**
  57625. * Creates a new OneMinusBlock
  57626. * @param name defines the block name
  57627. */
  57628. constructor(name: string);
  57629. /**
  57630. * Gets the current class name
  57631. * @returns the class name
  57632. */
  57633. getClassName(): string;
  57634. /**
  57635. * Gets the input component
  57636. */
  57637. readonly input: NodeMaterialConnectionPoint;
  57638. /**
  57639. * Gets the output component
  57640. */
  57641. readonly output: NodeMaterialConnectionPoint;
  57642. protected _buildBlock(state: NodeMaterialBuildState): this;
  57643. }
  57644. }
  57645. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57649. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57650. /**
  57651. * Block used to get the view direction
  57652. */
  57653. export class ViewDirectionBlock extends NodeMaterialBlock {
  57654. /**
  57655. * Creates a new ViewDirectionBlock
  57656. * @param name defines the block name
  57657. */
  57658. constructor(name: string);
  57659. /**
  57660. * Gets the current class name
  57661. * @returns the class name
  57662. */
  57663. getClassName(): string;
  57664. /**
  57665. * Gets the world position component
  57666. */
  57667. readonly worldPosition: NodeMaterialConnectionPoint;
  57668. /**
  57669. * Gets the camera position component
  57670. */
  57671. readonly cameraPosition: NodeMaterialConnectionPoint;
  57672. /**
  57673. * Gets the output component
  57674. */
  57675. readonly output: NodeMaterialConnectionPoint;
  57676. autoConfigure(material: NodeMaterial): void;
  57677. protected _buildBlock(state: NodeMaterialBuildState): this;
  57678. }
  57679. }
  57680. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57684. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57685. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57686. /**
  57687. * Block used to compute fresnel value
  57688. */
  57689. export class FresnelBlock extends NodeMaterialBlock {
  57690. /**
  57691. * Create a new FresnelBlock
  57692. * @param name defines the block name
  57693. */
  57694. constructor(name: string);
  57695. /**
  57696. * Gets the current class name
  57697. * @returns the class name
  57698. */
  57699. getClassName(): string;
  57700. /**
  57701. * Gets the world normal input component
  57702. */
  57703. readonly worldNormal: NodeMaterialConnectionPoint;
  57704. /**
  57705. * Gets the view direction input component
  57706. */
  57707. readonly viewDirection: NodeMaterialConnectionPoint;
  57708. /**
  57709. * Gets the bias input component
  57710. */
  57711. readonly bias: NodeMaterialConnectionPoint;
  57712. /**
  57713. * Gets the camera (or eye) position component
  57714. */
  57715. readonly power: NodeMaterialConnectionPoint;
  57716. /**
  57717. * Gets the fresnel output component
  57718. */
  57719. readonly fresnel: NodeMaterialConnectionPoint;
  57720. autoConfigure(material: NodeMaterial): void;
  57721. protected _buildBlock(state: NodeMaterialBuildState): this;
  57722. }
  57723. }
  57724. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57728. /**
  57729. * Block used to get the max of 2 values
  57730. */
  57731. export class MaxBlock extends NodeMaterialBlock {
  57732. /**
  57733. * Creates a new MaxBlock
  57734. * @param name defines the block name
  57735. */
  57736. constructor(name: string);
  57737. /**
  57738. * Gets the current class name
  57739. * @returns the class name
  57740. */
  57741. getClassName(): string;
  57742. /**
  57743. * Gets the left operand input component
  57744. */
  57745. readonly left: NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the right operand input component
  57748. */
  57749. readonly right: NodeMaterialConnectionPoint;
  57750. /**
  57751. * Gets the output component
  57752. */
  57753. readonly output: NodeMaterialConnectionPoint;
  57754. protected _buildBlock(state: NodeMaterialBuildState): this;
  57755. }
  57756. }
  57757. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57761. /**
  57762. * Block used to get the min of 2 values
  57763. */
  57764. export class MinBlock extends NodeMaterialBlock {
  57765. /**
  57766. * Creates a new MinBlock
  57767. * @param name defines the block name
  57768. */
  57769. constructor(name: string);
  57770. /**
  57771. * Gets the current class name
  57772. * @returns the class name
  57773. */
  57774. getClassName(): string;
  57775. /**
  57776. * Gets the left operand input component
  57777. */
  57778. readonly left: NodeMaterialConnectionPoint;
  57779. /**
  57780. * Gets the right operand input component
  57781. */
  57782. readonly right: NodeMaterialConnectionPoint;
  57783. /**
  57784. * Gets the output component
  57785. */
  57786. readonly output: NodeMaterialConnectionPoint;
  57787. protected _buildBlock(state: NodeMaterialBuildState): this;
  57788. }
  57789. }
  57790. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57794. /**
  57795. * Block used to get the distance between 2 values
  57796. */
  57797. export class DistanceBlock extends NodeMaterialBlock {
  57798. /**
  57799. * Creates a new DistanceBlock
  57800. * @param name defines the block name
  57801. */
  57802. constructor(name: string);
  57803. /**
  57804. * Gets the current class name
  57805. * @returns the class name
  57806. */
  57807. getClassName(): string;
  57808. /**
  57809. * Gets the left operand input component
  57810. */
  57811. readonly left: NodeMaterialConnectionPoint;
  57812. /**
  57813. * Gets the right operand input component
  57814. */
  57815. readonly right: NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the output component
  57818. */
  57819. readonly output: NodeMaterialConnectionPoint;
  57820. protected _buildBlock(state: NodeMaterialBuildState): this;
  57821. }
  57822. }
  57823. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57827. /**
  57828. * Block used to get the length of a vector
  57829. */
  57830. export class LengthBlock extends NodeMaterialBlock {
  57831. /**
  57832. * Creates a new LengthBlock
  57833. * @param name defines the block name
  57834. */
  57835. constructor(name: string);
  57836. /**
  57837. * Gets the current class name
  57838. * @returns the class name
  57839. */
  57840. getClassName(): string;
  57841. /**
  57842. * Gets the value input component
  57843. */
  57844. readonly value: NodeMaterialConnectionPoint;
  57845. /**
  57846. * Gets the output component
  57847. */
  57848. readonly output: NodeMaterialConnectionPoint;
  57849. protected _buildBlock(state: NodeMaterialBuildState): this;
  57850. }
  57851. }
  57852. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57856. /**
  57857. * Block used to get negative version of a value (i.e. x * -1)
  57858. */
  57859. export class NegateBlock extends NodeMaterialBlock {
  57860. /**
  57861. * Creates a new NegateBlock
  57862. * @param name defines the block name
  57863. */
  57864. constructor(name: string);
  57865. /**
  57866. * Gets the current class name
  57867. * @returns the class name
  57868. */
  57869. getClassName(): string;
  57870. /**
  57871. * Gets the value input component
  57872. */
  57873. readonly value: NodeMaterialConnectionPoint;
  57874. /**
  57875. * Gets the output component
  57876. */
  57877. readonly output: NodeMaterialConnectionPoint;
  57878. protected _buildBlock(state: NodeMaterialBuildState): this;
  57879. }
  57880. }
  57881. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57882. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57883. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57885. /**
  57886. * Block used to get the value of the first parameter raised to the power of the second
  57887. */
  57888. export class PowBlock extends NodeMaterialBlock {
  57889. /**
  57890. * Creates a new PowBlock
  57891. * @param name defines the block name
  57892. */
  57893. constructor(name: string);
  57894. /**
  57895. * Gets the current class name
  57896. * @returns the class name
  57897. */
  57898. getClassName(): string;
  57899. /**
  57900. * Gets the value operand input component
  57901. */
  57902. readonly value: NodeMaterialConnectionPoint;
  57903. /**
  57904. * Gets the power operand input component
  57905. */
  57906. readonly power: NodeMaterialConnectionPoint;
  57907. /**
  57908. * Gets the output component
  57909. */
  57910. readonly output: NodeMaterialConnectionPoint;
  57911. protected _buildBlock(state: NodeMaterialBuildState): this;
  57912. }
  57913. }
  57914. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57918. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57919. /**
  57920. * Block used to get a random number
  57921. */
  57922. export class RandomNumberBlock extends NodeMaterialBlock {
  57923. /**
  57924. * Creates a new RandomNumberBlock
  57925. * @param name defines the block name
  57926. */
  57927. constructor(name: string);
  57928. /**
  57929. * Gets the current class name
  57930. * @returns the class name
  57931. */
  57932. getClassName(): string;
  57933. /**
  57934. * Gets the seed input component
  57935. */
  57936. readonly seed: NodeMaterialConnectionPoint;
  57937. /**
  57938. * Gets the output component
  57939. */
  57940. readonly output: NodeMaterialConnectionPoint;
  57941. protected _buildBlock(state: NodeMaterialBuildState): this;
  57942. }
  57943. }
  57944. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57948. /**
  57949. * Block used to compute arc tangent of 2 values
  57950. */
  57951. export class ArcTan2Block extends NodeMaterialBlock {
  57952. /**
  57953. * Creates a new ArcTan2Block
  57954. * @param name defines the block name
  57955. */
  57956. constructor(name: string);
  57957. /**
  57958. * Gets the current class name
  57959. * @returns the class name
  57960. */
  57961. getClassName(): string;
  57962. /**
  57963. * Gets the x operand input component
  57964. */
  57965. readonly x: NodeMaterialConnectionPoint;
  57966. /**
  57967. * Gets the y operand input component
  57968. */
  57969. readonly y: NodeMaterialConnectionPoint;
  57970. /**
  57971. * Gets the output component
  57972. */
  57973. readonly output: NodeMaterialConnectionPoint;
  57974. protected _buildBlock(state: NodeMaterialBuildState): this;
  57975. }
  57976. }
  57977. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  57978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57981. /**
  57982. * Block used to smooth step a value
  57983. */
  57984. export class SmoothStepBlock extends NodeMaterialBlock {
  57985. /**
  57986. * Creates a new SmoothStepBlock
  57987. * @param name defines the block name
  57988. */
  57989. constructor(name: string);
  57990. /**
  57991. * Gets the current class name
  57992. * @returns the class name
  57993. */
  57994. getClassName(): string;
  57995. /**
  57996. * Gets the value operand input component
  57997. */
  57998. readonly value: NodeMaterialConnectionPoint;
  57999. /**
  58000. * Gets the first edge operand input component
  58001. */
  58002. readonly edge0: NodeMaterialConnectionPoint;
  58003. /**
  58004. * Gets the second edge operand input component
  58005. */
  58006. readonly edge1: NodeMaterialConnectionPoint;
  58007. /**
  58008. * Gets the output component
  58009. */
  58010. readonly output: NodeMaterialConnectionPoint;
  58011. protected _buildBlock(state: NodeMaterialBuildState): this;
  58012. }
  58013. }
  58014. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58018. /**
  58019. * Block used to get the reciprocal (1 / x) of a value
  58020. */
  58021. export class ReciprocalBlock extends NodeMaterialBlock {
  58022. /**
  58023. * Creates a new ReciprocalBlock
  58024. * @param name defines the block name
  58025. */
  58026. constructor(name: string);
  58027. /**
  58028. * Gets the current class name
  58029. * @returns the class name
  58030. */
  58031. getClassName(): string;
  58032. /**
  58033. * Gets the input component
  58034. */
  58035. readonly input: NodeMaterialConnectionPoint;
  58036. /**
  58037. * Gets the output component
  58038. */
  58039. readonly output: NodeMaterialConnectionPoint;
  58040. protected _buildBlock(state: NodeMaterialBuildState): this;
  58041. }
  58042. }
  58043. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58047. /**
  58048. * Block used to replace a color by another one
  58049. */
  58050. export class ReplaceColorBlock extends NodeMaterialBlock {
  58051. /**
  58052. * Creates a new ReplaceColorBlock
  58053. * @param name defines the block name
  58054. */
  58055. constructor(name: string);
  58056. /**
  58057. * Gets the current class name
  58058. * @returns the class name
  58059. */
  58060. getClassName(): string;
  58061. /**
  58062. * Gets the value input component
  58063. */
  58064. readonly value: NodeMaterialConnectionPoint;
  58065. /**
  58066. * Gets the reference input component
  58067. */
  58068. readonly reference: NodeMaterialConnectionPoint;
  58069. /**
  58070. * Gets the distance input component
  58071. */
  58072. readonly distance: NodeMaterialConnectionPoint;
  58073. /**
  58074. * Gets the replacement input component
  58075. */
  58076. readonly replacement: NodeMaterialConnectionPoint;
  58077. /**
  58078. * Gets the output component
  58079. */
  58080. readonly output: NodeMaterialConnectionPoint;
  58081. protected _buildBlock(state: NodeMaterialBuildState): this;
  58082. }
  58083. }
  58084. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58088. /**
  58089. * Block used to posterize a value
  58090. * @see https://en.wikipedia.org/wiki/Posterization
  58091. */
  58092. export class PosterizeBlock extends NodeMaterialBlock {
  58093. /**
  58094. * Creates a new PosterizeBlock
  58095. * @param name defines the block name
  58096. */
  58097. constructor(name: string);
  58098. /**
  58099. * Gets the current class name
  58100. * @returns the class name
  58101. */
  58102. getClassName(): string;
  58103. /**
  58104. * Gets the value input component
  58105. */
  58106. readonly value: NodeMaterialConnectionPoint;
  58107. /**
  58108. * Gets the steps input component
  58109. */
  58110. readonly steps: NodeMaterialConnectionPoint;
  58111. /**
  58112. * Gets the output component
  58113. */
  58114. readonly output: NodeMaterialConnectionPoint;
  58115. protected _buildBlock(state: NodeMaterialBuildState): this;
  58116. }
  58117. }
  58118. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58122. import { Scene } from "babylonjs/scene";
  58123. /**
  58124. * Operations supported by the Wave block
  58125. */
  58126. export enum WaveBlockKind {
  58127. /** SawTooth */
  58128. SawTooth = 0,
  58129. /** Square */
  58130. Square = 1,
  58131. /** Triangle */
  58132. Triangle = 2
  58133. }
  58134. /**
  58135. * Block used to apply wave operation to floats
  58136. */
  58137. export class WaveBlock extends NodeMaterialBlock {
  58138. /**
  58139. * Gets or sets the kibnd of wave to be applied by the block
  58140. */
  58141. kind: WaveBlockKind;
  58142. /**
  58143. * Creates a new WaveBlock
  58144. * @param name defines the block name
  58145. */
  58146. constructor(name: string);
  58147. /**
  58148. * Gets the current class name
  58149. * @returns the class name
  58150. */
  58151. getClassName(): string;
  58152. /**
  58153. * Gets the input component
  58154. */
  58155. readonly input: NodeMaterialConnectionPoint;
  58156. /**
  58157. * Gets the output component
  58158. */
  58159. readonly output: NodeMaterialConnectionPoint;
  58160. protected _buildBlock(state: NodeMaterialBuildState): this;
  58161. serialize(): any;
  58162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58163. }
  58164. }
  58165. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58167. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58168. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58169. import { Color3 } from "babylonjs/Maths/math.color";
  58170. import { Scene } from "babylonjs/scene";
  58171. /**
  58172. * Class used to store a color step for the GradientBlock
  58173. */
  58174. export class GradientBlockColorStep {
  58175. /**
  58176. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58177. */
  58178. step: number;
  58179. /**
  58180. * Gets or sets the color associated with this step
  58181. */
  58182. color: Color3;
  58183. /**
  58184. * Creates a new GradientBlockColorStep
  58185. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58186. * @param color defines the color associated with this step
  58187. */
  58188. constructor(
  58189. /**
  58190. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58191. */
  58192. step: number,
  58193. /**
  58194. * Gets or sets the color associated with this step
  58195. */
  58196. color: Color3);
  58197. }
  58198. /**
  58199. * Block used to return a color from a gradient based on an input value between 0 and 1
  58200. */
  58201. export class GradientBlock extends NodeMaterialBlock {
  58202. /**
  58203. * Gets or sets the list of color steps
  58204. */
  58205. colorSteps: GradientBlockColorStep[];
  58206. /**
  58207. * Creates a new GradientBlock
  58208. * @param name defines the block name
  58209. */
  58210. constructor(name: string);
  58211. /**
  58212. * Gets the current class name
  58213. * @returns the class name
  58214. */
  58215. getClassName(): string;
  58216. /**
  58217. * Gets the gradient input component
  58218. */
  58219. readonly gradient: NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the output component
  58222. */
  58223. readonly output: NodeMaterialConnectionPoint;
  58224. private _writeColorConstant;
  58225. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58226. serialize(): any;
  58227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58228. protected _dumpPropertiesCode(): string;
  58229. }
  58230. }
  58231. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58235. /**
  58236. * Block used to normalize lerp between 2 values
  58237. */
  58238. export class NLerpBlock extends NodeMaterialBlock {
  58239. /**
  58240. * Creates a new NLerpBlock
  58241. * @param name defines the block name
  58242. */
  58243. constructor(name: string);
  58244. /**
  58245. * Gets the current class name
  58246. * @returns the class name
  58247. */
  58248. getClassName(): string;
  58249. /**
  58250. * Gets the left operand input component
  58251. */
  58252. readonly left: NodeMaterialConnectionPoint;
  58253. /**
  58254. * Gets the right operand input component
  58255. */
  58256. readonly right: NodeMaterialConnectionPoint;
  58257. /**
  58258. * Gets the gradient operand input component
  58259. */
  58260. readonly gradient: NodeMaterialConnectionPoint;
  58261. /**
  58262. * Gets the output component
  58263. */
  58264. readonly output: NodeMaterialConnectionPoint;
  58265. protected _buildBlock(state: NodeMaterialBuildState): this;
  58266. }
  58267. }
  58268. declare module "babylonjs/Materials/Node/Blocks/index" {
  58269. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58270. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58271. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58272. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58273. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58274. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58275. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58276. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58277. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58278. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58279. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58280. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58281. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58282. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58283. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58284. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58285. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58286. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58287. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58288. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58289. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58290. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58291. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58292. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58293. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58294. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58295. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58296. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58297. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58298. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58299. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58300. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58301. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58302. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58303. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58304. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58305. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58306. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58307. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58308. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58309. }
  58310. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58311. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58312. }
  58313. declare module "babylonjs/Materials/Node/index" {
  58314. export * from "babylonjs/Materials/Node/Enums/index";
  58315. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58316. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58317. export * from "babylonjs/Materials/Node/nodeMaterial";
  58318. export * from "babylonjs/Materials/Node/Blocks/index";
  58319. export * from "babylonjs/Materials/Node/Optimizers/index";
  58320. }
  58321. declare module "babylonjs/Materials/effectRenderer" {
  58322. import { Nullable } from "babylonjs/types";
  58323. import { Texture } from "babylonjs/Materials/Textures/texture";
  58324. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58325. import { Viewport } from "babylonjs/Maths/math.viewport";
  58326. import { Observable } from "babylonjs/Misc/observable";
  58327. import { Effect } from "babylonjs/Materials/effect";
  58328. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58329. import "babylonjs/Shaders/postprocess.vertex";
  58330. /**
  58331. * Effect Render Options
  58332. */
  58333. export interface IEffectRendererOptions {
  58334. /**
  58335. * Defines the vertices positions.
  58336. */
  58337. positions?: number[];
  58338. /**
  58339. * Defines the indices.
  58340. */
  58341. indices?: number[];
  58342. }
  58343. /**
  58344. * Helper class to render one or more effects
  58345. */
  58346. export class EffectRenderer {
  58347. private engine;
  58348. private static _DefaultOptions;
  58349. private _vertexBuffers;
  58350. private _indexBuffer;
  58351. private _ringBufferIndex;
  58352. private _ringScreenBuffer;
  58353. private _fullscreenViewport;
  58354. private _getNextFrameBuffer;
  58355. /**
  58356. * Creates an effect renderer
  58357. * @param engine the engine to use for rendering
  58358. * @param options defines the options of the effect renderer
  58359. */
  58360. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58361. /**
  58362. * Sets the current viewport in normalized coordinates 0-1
  58363. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58364. */
  58365. setViewport(viewport?: Viewport): void;
  58366. /**
  58367. * Binds the embedded attributes buffer to the effect.
  58368. * @param effect Defines the effect to bind the attributes for
  58369. */
  58370. bindBuffers(effect: Effect): void;
  58371. /**
  58372. * Sets the current effect wrapper to use during draw.
  58373. * The effect needs to be ready before calling this api.
  58374. * This also sets the default full screen position attribute.
  58375. * @param effectWrapper Defines the effect to draw with
  58376. */
  58377. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58378. /**
  58379. * Draws a full screen quad.
  58380. */
  58381. draw(): void;
  58382. /**
  58383. * renders one or more effects to a specified texture
  58384. * @param effectWrappers list of effects to renderer
  58385. * @param outputTexture texture to draw to, if null it will render to the screen
  58386. */
  58387. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58388. /**
  58389. * Disposes of the effect renderer
  58390. */
  58391. dispose(): void;
  58392. }
  58393. /**
  58394. * Options to create an EffectWrapper
  58395. */
  58396. interface EffectWrapperCreationOptions {
  58397. /**
  58398. * Engine to use to create the effect
  58399. */
  58400. engine: ThinEngine;
  58401. /**
  58402. * Fragment shader for the effect
  58403. */
  58404. fragmentShader: string;
  58405. /**
  58406. * Vertex shader for the effect
  58407. */
  58408. vertexShader?: string;
  58409. /**
  58410. * Attributes to use in the shader
  58411. */
  58412. attributeNames?: Array<string>;
  58413. /**
  58414. * Uniforms to use in the shader
  58415. */
  58416. uniformNames?: Array<string>;
  58417. /**
  58418. * Texture sampler names to use in the shader
  58419. */
  58420. samplerNames?: Array<string>;
  58421. /**
  58422. * The friendly name of the effect displayed in Spector.
  58423. */
  58424. name?: string;
  58425. }
  58426. /**
  58427. * Wraps an effect to be used for rendering
  58428. */
  58429. export class EffectWrapper {
  58430. /**
  58431. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58432. */
  58433. onApplyObservable: Observable<{}>;
  58434. /**
  58435. * The underlying effect
  58436. */
  58437. effect: Effect;
  58438. /**
  58439. * Creates an effect to be renderer
  58440. * @param creationOptions options to create the effect
  58441. */
  58442. constructor(creationOptions: EffectWrapperCreationOptions);
  58443. /**
  58444. * Disposes of the effect wrapper
  58445. */
  58446. dispose(): void;
  58447. }
  58448. }
  58449. declare module "babylonjs/Materials/index" {
  58450. export * from "babylonjs/Materials/Background/index";
  58451. export * from "babylonjs/Materials/colorCurves";
  58452. export * from "babylonjs/Materials/iEffectFallbacks";
  58453. export * from "babylonjs/Materials/effectFallbacks";
  58454. export * from "babylonjs/Materials/effect";
  58455. export * from "babylonjs/Materials/fresnelParameters";
  58456. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58457. export * from "babylonjs/Materials/material";
  58458. export * from "babylonjs/Materials/materialDefines";
  58459. export * from "babylonjs/Materials/materialHelper";
  58460. export * from "babylonjs/Materials/multiMaterial";
  58461. export * from "babylonjs/Materials/PBR/index";
  58462. export * from "babylonjs/Materials/pushMaterial";
  58463. export * from "babylonjs/Materials/shaderMaterial";
  58464. export * from "babylonjs/Materials/standardMaterial";
  58465. export * from "babylonjs/Materials/Textures/index";
  58466. export * from "babylonjs/Materials/uniformBuffer";
  58467. export * from "babylonjs/Materials/materialFlags";
  58468. export * from "babylonjs/Materials/Node/index";
  58469. export * from "babylonjs/Materials/effectRenderer";
  58470. }
  58471. declare module "babylonjs/Maths/index" {
  58472. export * from "babylonjs/Maths/math.scalar";
  58473. export * from "babylonjs/Maths/math";
  58474. export * from "babylonjs/Maths/sphericalPolynomial";
  58475. }
  58476. declare module "babylonjs/Misc/workerPool" {
  58477. import { IDisposable } from "babylonjs/scene";
  58478. /**
  58479. * Helper class to push actions to a pool of workers.
  58480. */
  58481. export class WorkerPool implements IDisposable {
  58482. private _workerInfos;
  58483. private _pendingActions;
  58484. /**
  58485. * Constructor
  58486. * @param workers Array of workers to use for actions
  58487. */
  58488. constructor(workers: Array<Worker>);
  58489. /**
  58490. * Terminates all workers and clears any pending actions.
  58491. */
  58492. dispose(): void;
  58493. /**
  58494. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58495. * pended until a worker has completed its action.
  58496. * @param action The action to perform. Call onComplete when the action is complete.
  58497. */
  58498. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58499. private _execute;
  58500. }
  58501. }
  58502. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58503. import { IDisposable } from "babylonjs/scene";
  58504. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58505. /**
  58506. * Configuration for Draco compression
  58507. */
  58508. export interface IDracoCompressionConfiguration {
  58509. /**
  58510. * Configuration for the decoder.
  58511. */
  58512. decoder: {
  58513. /**
  58514. * The url to the WebAssembly module.
  58515. */
  58516. wasmUrl?: string;
  58517. /**
  58518. * The url to the WebAssembly binary.
  58519. */
  58520. wasmBinaryUrl?: string;
  58521. /**
  58522. * The url to the fallback JavaScript module.
  58523. */
  58524. fallbackUrl?: string;
  58525. };
  58526. }
  58527. /**
  58528. * Draco compression (https://google.github.io/draco/)
  58529. *
  58530. * This class wraps the Draco module.
  58531. *
  58532. * **Encoder**
  58533. *
  58534. * The encoder is not currently implemented.
  58535. *
  58536. * **Decoder**
  58537. *
  58538. * 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.
  58539. *
  58540. * To update the configuration, use the following code:
  58541. * ```javascript
  58542. * DracoCompression.Configuration = {
  58543. * decoder: {
  58544. * wasmUrl: "<url to the WebAssembly library>",
  58545. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58546. * fallbackUrl: "<url to the fallback JavaScript library>",
  58547. * }
  58548. * };
  58549. * ```
  58550. *
  58551. * 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.
  58552. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58553. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58554. *
  58555. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58556. * ```javascript
  58557. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58558. * ```
  58559. *
  58560. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58561. */
  58562. export class DracoCompression implements IDisposable {
  58563. private _workerPoolPromise?;
  58564. private _decoderModulePromise?;
  58565. /**
  58566. * The configuration. Defaults to the following urls:
  58567. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58568. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58569. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58570. */
  58571. static Configuration: IDracoCompressionConfiguration;
  58572. /**
  58573. * Returns true if the decoder configuration is available.
  58574. */
  58575. static readonly DecoderAvailable: boolean;
  58576. /**
  58577. * Default number of workers to create when creating the draco compression object.
  58578. */
  58579. static DefaultNumWorkers: number;
  58580. private static GetDefaultNumWorkers;
  58581. private static _Default;
  58582. /**
  58583. * Default instance for the draco compression object.
  58584. */
  58585. static readonly Default: DracoCompression;
  58586. /**
  58587. * Constructor
  58588. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58589. */
  58590. constructor(numWorkers?: number);
  58591. /**
  58592. * Stop all async operations and release resources.
  58593. */
  58594. dispose(): void;
  58595. /**
  58596. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58597. * @returns a promise that resolves when ready
  58598. */
  58599. whenReadyAsync(): Promise<void>;
  58600. /**
  58601. * Decode Draco compressed mesh data to vertex data.
  58602. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58603. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58604. * @returns A promise that resolves with the decoded vertex data
  58605. */
  58606. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58607. [kind: string]: number;
  58608. }): Promise<VertexData>;
  58609. }
  58610. }
  58611. declare module "babylonjs/Meshes/Compression/index" {
  58612. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58613. }
  58614. declare module "babylonjs/Meshes/csg" {
  58615. import { Nullable } from "babylonjs/types";
  58616. import { Scene } from "babylonjs/scene";
  58617. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58618. import { Mesh } from "babylonjs/Meshes/mesh";
  58619. import { Material } from "babylonjs/Materials/material";
  58620. /**
  58621. * Class for building Constructive Solid Geometry
  58622. */
  58623. export class CSG {
  58624. private polygons;
  58625. /**
  58626. * The world matrix
  58627. */
  58628. matrix: Matrix;
  58629. /**
  58630. * Stores the position
  58631. */
  58632. position: Vector3;
  58633. /**
  58634. * Stores the rotation
  58635. */
  58636. rotation: Vector3;
  58637. /**
  58638. * Stores the rotation quaternion
  58639. */
  58640. rotationQuaternion: Nullable<Quaternion>;
  58641. /**
  58642. * Stores the scaling vector
  58643. */
  58644. scaling: Vector3;
  58645. /**
  58646. * Convert the Mesh to CSG
  58647. * @param mesh The Mesh to convert to CSG
  58648. * @returns A new CSG from the Mesh
  58649. */
  58650. static FromMesh(mesh: Mesh): CSG;
  58651. /**
  58652. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58653. * @param polygons Polygons used to construct a CSG solid
  58654. */
  58655. private static FromPolygons;
  58656. /**
  58657. * Clones, or makes a deep copy, of the CSG
  58658. * @returns A new CSG
  58659. */
  58660. clone(): CSG;
  58661. /**
  58662. * Unions this CSG with another CSG
  58663. * @param csg The CSG to union against this CSG
  58664. * @returns The unioned CSG
  58665. */
  58666. union(csg: CSG): CSG;
  58667. /**
  58668. * Unions this CSG with another CSG in place
  58669. * @param csg The CSG to union against this CSG
  58670. */
  58671. unionInPlace(csg: CSG): void;
  58672. /**
  58673. * Subtracts this CSG with another CSG
  58674. * @param csg The CSG to subtract against this CSG
  58675. * @returns A new CSG
  58676. */
  58677. subtract(csg: CSG): CSG;
  58678. /**
  58679. * Subtracts this CSG with another CSG in place
  58680. * @param csg The CSG to subtact against this CSG
  58681. */
  58682. subtractInPlace(csg: CSG): void;
  58683. /**
  58684. * Intersect this CSG with another CSG
  58685. * @param csg The CSG to intersect against this CSG
  58686. * @returns A new CSG
  58687. */
  58688. intersect(csg: CSG): CSG;
  58689. /**
  58690. * Intersects this CSG with another CSG in place
  58691. * @param csg The CSG to intersect against this CSG
  58692. */
  58693. intersectInPlace(csg: CSG): void;
  58694. /**
  58695. * Return a new CSG solid with solid and empty space switched. This solid is
  58696. * not modified.
  58697. * @returns A new CSG solid with solid and empty space switched
  58698. */
  58699. inverse(): CSG;
  58700. /**
  58701. * Inverses the CSG in place
  58702. */
  58703. inverseInPlace(): void;
  58704. /**
  58705. * This is used to keep meshes transformations so they can be restored
  58706. * when we build back a Babylon Mesh
  58707. * NB : All CSG operations are performed in world coordinates
  58708. * @param csg The CSG to copy the transform attributes from
  58709. * @returns This CSG
  58710. */
  58711. copyTransformAttributes(csg: CSG): CSG;
  58712. /**
  58713. * Build Raw mesh from CSG
  58714. * Coordinates here are in world space
  58715. * @param name The name of the mesh geometry
  58716. * @param scene The Scene
  58717. * @param keepSubMeshes Specifies if the submeshes should be kept
  58718. * @returns A new Mesh
  58719. */
  58720. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58721. /**
  58722. * Build Mesh from CSG taking material and transforms into account
  58723. * @param name The name of the Mesh
  58724. * @param material The material of the Mesh
  58725. * @param scene The Scene
  58726. * @param keepSubMeshes Specifies if submeshes should be kept
  58727. * @returns The new Mesh
  58728. */
  58729. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58730. }
  58731. }
  58732. declare module "babylonjs/Meshes/trailMesh" {
  58733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58734. import { Mesh } from "babylonjs/Meshes/mesh";
  58735. import { Scene } from "babylonjs/scene";
  58736. /**
  58737. * Class used to create a trail following a mesh
  58738. */
  58739. export class TrailMesh extends Mesh {
  58740. private _generator;
  58741. private _autoStart;
  58742. private _running;
  58743. private _diameter;
  58744. private _length;
  58745. private _sectionPolygonPointsCount;
  58746. private _sectionVectors;
  58747. private _sectionNormalVectors;
  58748. private _beforeRenderObserver;
  58749. /**
  58750. * @constructor
  58751. * @param name The value used by scene.getMeshByName() to do a lookup.
  58752. * @param generator The mesh to generate a trail.
  58753. * @param scene The scene to add this mesh to.
  58754. * @param diameter Diameter of trailing mesh. Default is 1.
  58755. * @param length Length of trailing mesh. Default is 60.
  58756. * @param autoStart Automatically start trailing mesh. Default true.
  58757. */
  58758. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58759. /**
  58760. * "TrailMesh"
  58761. * @returns "TrailMesh"
  58762. */
  58763. getClassName(): string;
  58764. private _createMesh;
  58765. /**
  58766. * Start trailing mesh.
  58767. */
  58768. start(): void;
  58769. /**
  58770. * Stop trailing mesh.
  58771. */
  58772. stop(): void;
  58773. /**
  58774. * Update trailing mesh geometry.
  58775. */
  58776. update(): void;
  58777. /**
  58778. * Returns a new TrailMesh object.
  58779. * @param name is a string, the name given to the new mesh
  58780. * @param newGenerator use new generator object for cloned trail mesh
  58781. * @returns a new mesh
  58782. */
  58783. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58784. /**
  58785. * Serializes this trail mesh
  58786. * @param serializationObject object to write serialization to
  58787. */
  58788. serialize(serializationObject: any): void;
  58789. /**
  58790. * Parses a serialized trail mesh
  58791. * @param parsedMesh the serialized mesh
  58792. * @param scene the scene to create the trail mesh in
  58793. * @returns the created trail mesh
  58794. */
  58795. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58796. }
  58797. }
  58798. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58799. import { Nullable } from "babylonjs/types";
  58800. import { Scene } from "babylonjs/scene";
  58801. import { Vector4 } from "babylonjs/Maths/math.vector";
  58802. import { Color4 } from "babylonjs/Maths/math.color";
  58803. import { Mesh } from "babylonjs/Meshes/mesh";
  58804. /**
  58805. * Class containing static functions to help procedurally build meshes
  58806. */
  58807. export class TiledBoxBuilder {
  58808. /**
  58809. * Creates a box mesh
  58810. * 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)
  58811. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58815. * @param name defines the name of the mesh
  58816. * @param options defines the options used to create the mesh
  58817. * @param scene defines the hosting scene
  58818. * @returns the box mesh
  58819. */
  58820. static CreateTiledBox(name: string, options: {
  58821. pattern?: number;
  58822. width?: number;
  58823. height?: number;
  58824. depth?: number;
  58825. tileSize?: number;
  58826. tileWidth?: number;
  58827. tileHeight?: number;
  58828. alignHorizontal?: number;
  58829. alignVertical?: number;
  58830. faceUV?: Vector4[];
  58831. faceColors?: Color4[];
  58832. sideOrientation?: number;
  58833. updatable?: boolean;
  58834. }, scene?: Nullable<Scene>): Mesh;
  58835. }
  58836. }
  58837. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58838. import { Vector4 } from "babylonjs/Maths/math.vector";
  58839. import { Mesh } from "babylonjs/Meshes/mesh";
  58840. /**
  58841. * Class containing static functions to help procedurally build meshes
  58842. */
  58843. export class TorusKnotBuilder {
  58844. /**
  58845. * Creates a torus knot mesh
  58846. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58847. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58848. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58849. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58853. * @param name defines the name of the mesh
  58854. * @param options defines the options used to create the mesh
  58855. * @param scene defines the hosting scene
  58856. * @returns the torus knot mesh
  58857. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58858. */
  58859. static CreateTorusKnot(name: string, options: {
  58860. radius?: number;
  58861. tube?: number;
  58862. radialSegments?: number;
  58863. tubularSegments?: number;
  58864. p?: number;
  58865. q?: number;
  58866. updatable?: boolean;
  58867. sideOrientation?: number;
  58868. frontUVs?: Vector4;
  58869. backUVs?: Vector4;
  58870. }, scene: any): Mesh;
  58871. }
  58872. }
  58873. declare module "babylonjs/Meshes/polygonMesh" {
  58874. import { Scene } from "babylonjs/scene";
  58875. import { Vector2 } from "babylonjs/Maths/math.vector";
  58876. import { Mesh } from "babylonjs/Meshes/mesh";
  58877. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58878. import { Path2 } from "babylonjs/Maths/math.path";
  58879. /**
  58880. * Polygon
  58881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58882. */
  58883. export class Polygon {
  58884. /**
  58885. * Creates a rectangle
  58886. * @param xmin bottom X coord
  58887. * @param ymin bottom Y coord
  58888. * @param xmax top X coord
  58889. * @param ymax top Y coord
  58890. * @returns points that make the resulting rectation
  58891. */
  58892. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58893. /**
  58894. * Creates a circle
  58895. * @param radius radius of circle
  58896. * @param cx scale in x
  58897. * @param cy scale in y
  58898. * @param numberOfSides number of sides that make up the circle
  58899. * @returns points that make the resulting circle
  58900. */
  58901. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58902. /**
  58903. * Creates a polygon from input string
  58904. * @param input Input polygon data
  58905. * @returns the parsed points
  58906. */
  58907. static Parse(input: string): Vector2[];
  58908. /**
  58909. * Starts building a polygon from x and y coordinates
  58910. * @param x x coordinate
  58911. * @param y y coordinate
  58912. * @returns the started path2
  58913. */
  58914. static StartingAt(x: number, y: number): Path2;
  58915. }
  58916. /**
  58917. * Builds a polygon
  58918. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58919. */
  58920. export class PolygonMeshBuilder {
  58921. private _points;
  58922. private _outlinepoints;
  58923. private _holes;
  58924. private _name;
  58925. private _scene;
  58926. private _epoints;
  58927. private _eholes;
  58928. private _addToepoint;
  58929. /**
  58930. * Babylon reference to the earcut plugin.
  58931. */
  58932. bjsEarcut: any;
  58933. /**
  58934. * Creates a PolygonMeshBuilder
  58935. * @param name name of the builder
  58936. * @param contours Path of the polygon
  58937. * @param scene scene to add to when creating the mesh
  58938. * @param earcutInjection can be used to inject your own earcut reference
  58939. */
  58940. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58941. /**
  58942. * Adds a whole within the polygon
  58943. * @param hole Array of points defining the hole
  58944. * @returns this
  58945. */
  58946. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58947. /**
  58948. * Creates the polygon
  58949. * @param updatable If the mesh should be updatable
  58950. * @param depth The depth of the mesh created
  58951. * @returns the created mesh
  58952. */
  58953. build(updatable?: boolean, depth?: number): Mesh;
  58954. /**
  58955. * Creates the polygon
  58956. * @param depth The depth of the mesh created
  58957. * @returns the created VertexData
  58958. */
  58959. buildVertexData(depth?: number): VertexData;
  58960. /**
  58961. * Adds a side to the polygon
  58962. * @param positions points that make the polygon
  58963. * @param normals normals of the polygon
  58964. * @param uvs uvs of the polygon
  58965. * @param indices indices of the polygon
  58966. * @param bounds bounds of the polygon
  58967. * @param points points of the polygon
  58968. * @param depth depth of the polygon
  58969. * @param flip flip of the polygon
  58970. */
  58971. private addSide;
  58972. }
  58973. }
  58974. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58975. import { Scene } from "babylonjs/scene";
  58976. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58977. import { Color4 } from "babylonjs/Maths/math.color";
  58978. import { Mesh } from "babylonjs/Meshes/mesh";
  58979. import { Nullable } from "babylonjs/types";
  58980. /**
  58981. * Class containing static functions to help procedurally build meshes
  58982. */
  58983. export class PolygonBuilder {
  58984. /**
  58985. * Creates a polygon mesh
  58986. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58987. * * 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
  58988. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58991. * * Remember you can only change the shape positions, not their number when updating a polygon
  58992. * @param name defines the name of the mesh
  58993. * @param options defines the options used to create the mesh
  58994. * @param scene defines the hosting scene
  58995. * @param earcutInjection can be used to inject your own earcut reference
  58996. * @returns the polygon mesh
  58997. */
  58998. static CreatePolygon(name: string, options: {
  58999. shape: Vector3[];
  59000. holes?: Vector3[][];
  59001. depth?: number;
  59002. faceUV?: Vector4[];
  59003. faceColors?: Color4[];
  59004. updatable?: boolean;
  59005. sideOrientation?: number;
  59006. frontUVs?: Vector4;
  59007. backUVs?: Vector4;
  59008. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59009. /**
  59010. * Creates an extruded polygon mesh, with depth in the Y direction.
  59011. * * 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)
  59012. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59013. * @param name defines the name of the mesh
  59014. * @param options defines the options used to create the mesh
  59015. * @param scene defines the hosting scene
  59016. * @param earcutInjection can be used to inject your own earcut reference
  59017. * @returns the polygon mesh
  59018. */
  59019. static ExtrudePolygon(name: string, options: {
  59020. shape: Vector3[];
  59021. holes?: Vector3[][];
  59022. depth?: number;
  59023. faceUV?: Vector4[];
  59024. faceColors?: Color4[];
  59025. updatable?: boolean;
  59026. sideOrientation?: number;
  59027. frontUVs?: Vector4;
  59028. backUVs?: Vector4;
  59029. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59030. }
  59031. }
  59032. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59033. import { Scene } from "babylonjs/scene";
  59034. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59035. import { Mesh } from "babylonjs/Meshes/mesh";
  59036. import { Nullable } from "babylonjs/types";
  59037. /**
  59038. * Class containing static functions to help procedurally build meshes
  59039. */
  59040. export class LatheBuilder {
  59041. /**
  59042. * Creates lathe mesh.
  59043. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59044. * * 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
  59045. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59046. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59047. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59048. * * 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
  59049. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59050. * * 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
  59051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59053. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59055. * @param name defines the name of the mesh
  59056. * @param options defines the options used to create the mesh
  59057. * @param scene defines the hosting scene
  59058. * @returns the lathe mesh
  59059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59060. */
  59061. static CreateLathe(name: string, options: {
  59062. shape: Vector3[];
  59063. radius?: number;
  59064. tessellation?: number;
  59065. clip?: number;
  59066. arc?: number;
  59067. closed?: boolean;
  59068. updatable?: boolean;
  59069. sideOrientation?: number;
  59070. frontUVs?: Vector4;
  59071. backUVs?: Vector4;
  59072. cap?: number;
  59073. invertUV?: boolean;
  59074. }, scene?: Nullable<Scene>): Mesh;
  59075. }
  59076. }
  59077. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59078. import { Nullable } from "babylonjs/types";
  59079. import { Scene } from "babylonjs/scene";
  59080. import { Vector4 } from "babylonjs/Maths/math.vector";
  59081. import { Mesh } from "babylonjs/Meshes/mesh";
  59082. /**
  59083. * Class containing static functions to help procedurally build meshes
  59084. */
  59085. export class TiledPlaneBuilder {
  59086. /**
  59087. * Creates a tiled plane mesh
  59088. * * The parameter `pattern` will, depending on value, do nothing or
  59089. * * * flip (reflect about central vertical) alternate tiles across and up
  59090. * * * flip every tile on alternate rows
  59091. * * * rotate (180 degs) alternate tiles across and up
  59092. * * * rotate every tile on alternate rows
  59093. * * * flip and rotate alternate tiles across and up
  59094. * * * flip and rotate every tile on alternate rows
  59095. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59096. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59098. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59099. * * 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)
  59100. * * 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)
  59101. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59102. * @param name defines the name of the mesh
  59103. * @param options defines the options used to create the mesh
  59104. * @param scene defines the hosting scene
  59105. * @returns the box mesh
  59106. */
  59107. static CreateTiledPlane(name: string, options: {
  59108. pattern?: number;
  59109. tileSize?: number;
  59110. tileWidth?: number;
  59111. tileHeight?: number;
  59112. size?: number;
  59113. width?: number;
  59114. height?: number;
  59115. alignHorizontal?: number;
  59116. alignVertical?: number;
  59117. sideOrientation?: number;
  59118. frontUVs?: Vector4;
  59119. backUVs?: Vector4;
  59120. updatable?: boolean;
  59121. }, scene?: Nullable<Scene>): Mesh;
  59122. }
  59123. }
  59124. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59125. import { Nullable } from "babylonjs/types";
  59126. import { Scene } from "babylonjs/scene";
  59127. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59128. import { Mesh } from "babylonjs/Meshes/mesh";
  59129. /**
  59130. * Class containing static functions to help procedurally build meshes
  59131. */
  59132. export class TubeBuilder {
  59133. /**
  59134. * Creates a tube mesh.
  59135. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59136. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59137. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59138. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59139. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59140. * * 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)
  59141. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59142. * * 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
  59143. * * 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
  59144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59148. * @param name defines the name of the mesh
  59149. * @param options defines the options used to create the mesh
  59150. * @param scene defines the hosting scene
  59151. * @returns the tube mesh
  59152. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59153. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59154. */
  59155. static CreateTube(name: string, options: {
  59156. path: Vector3[];
  59157. radius?: number;
  59158. tessellation?: number;
  59159. radiusFunction?: {
  59160. (i: number, distance: number): number;
  59161. };
  59162. cap?: number;
  59163. arc?: number;
  59164. updatable?: boolean;
  59165. sideOrientation?: number;
  59166. frontUVs?: Vector4;
  59167. backUVs?: Vector4;
  59168. instance?: Mesh;
  59169. invertUV?: boolean;
  59170. }, scene?: Nullable<Scene>): Mesh;
  59171. }
  59172. }
  59173. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59174. import { Scene } from "babylonjs/scene";
  59175. import { Vector4 } from "babylonjs/Maths/math.vector";
  59176. import { Mesh } from "babylonjs/Meshes/mesh";
  59177. import { Nullable } from "babylonjs/types";
  59178. /**
  59179. * Class containing static functions to help procedurally build meshes
  59180. */
  59181. export class IcoSphereBuilder {
  59182. /**
  59183. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59184. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59185. * * 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`)
  59186. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59187. * * 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
  59188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59191. * @param name defines the name of the mesh
  59192. * @param options defines the options used to create the mesh
  59193. * @param scene defines the hosting scene
  59194. * @returns the icosahedron mesh
  59195. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59196. */
  59197. static CreateIcoSphere(name: string, options: {
  59198. radius?: number;
  59199. radiusX?: number;
  59200. radiusY?: number;
  59201. radiusZ?: number;
  59202. flat?: boolean;
  59203. subdivisions?: number;
  59204. sideOrientation?: number;
  59205. frontUVs?: Vector4;
  59206. backUVs?: Vector4;
  59207. updatable?: boolean;
  59208. }, scene?: Nullable<Scene>): Mesh;
  59209. }
  59210. }
  59211. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59212. import { Vector3 } from "babylonjs/Maths/math.vector";
  59213. import { Mesh } from "babylonjs/Meshes/mesh";
  59214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59215. /**
  59216. * Class containing static functions to help procedurally build meshes
  59217. */
  59218. export class DecalBuilder {
  59219. /**
  59220. * Creates a decal mesh.
  59221. * 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
  59222. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59223. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59224. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59225. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59226. * @param name defines the name of the mesh
  59227. * @param sourceMesh defines the mesh where the decal must be applied
  59228. * @param options defines the options used to create the mesh
  59229. * @param scene defines the hosting scene
  59230. * @returns the decal mesh
  59231. * @see https://doc.babylonjs.com/how_to/decals
  59232. */
  59233. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59234. position?: Vector3;
  59235. normal?: Vector3;
  59236. size?: Vector3;
  59237. angle?: number;
  59238. }): Mesh;
  59239. }
  59240. }
  59241. declare module "babylonjs/Meshes/meshBuilder" {
  59242. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59243. import { Nullable } from "babylonjs/types";
  59244. import { Scene } from "babylonjs/scene";
  59245. import { Mesh } from "babylonjs/Meshes/mesh";
  59246. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59247. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59249. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59250. import { Plane } from "babylonjs/Maths/math.plane";
  59251. /**
  59252. * Class containing static functions to help procedurally build meshes
  59253. */
  59254. export class MeshBuilder {
  59255. /**
  59256. * Creates a box mesh
  59257. * * The parameter `size` sets the size (float) of each box side (default 1)
  59258. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59259. * * 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)
  59260. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59264. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59265. * @param name defines the name of the mesh
  59266. * @param options defines the options used to create the mesh
  59267. * @param scene defines the hosting scene
  59268. * @returns the box mesh
  59269. */
  59270. static CreateBox(name: string, options: {
  59271. size?: number;
  59272. width?: number;
  59273. height?: number;
  59274. depth?: number;
  59275. faceUV?: Vector4[];
  59276. faceColors?: Color4[];
  59277. sideOrientation?: number;
  59278. frontUVs?: Vector4;
  59279. backUVs?: Vector4;
  59280. updatable?: boolean;
  59281. }, scene?: Nullable<Scene>): Mesh;
  59282. /**
  59283. * Creates a tiled box mesh
  59284. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59286. * @param name defines the name of the mesh
  59287. * @param options defines the options used to create the mesh
  59288. * @param scene defines the hosting scene
  59289. * @returns the tiled box mesh
  59290. */
  59291. static CreateTiledBox(name: string, options: {
  59292. pattern?: number;
  59293. size?: number;
  59294. width?: number;
  59295. height?: number;
  59296. depth: number;
  59297. tileSize?: number;
  59298. tileWidth?: number;
  59299. tileHeight?: number;
  59300. faceUV?: Vector4[];
  59301. faceColors?: Color4[];
  59302. alignHorizontal?: number;
  59303. alignVertical?: number;
  59304. sideOrientation?: number;
  59305. updatable?: boolean;
  59306. }, scene?: Nullable<Scene>): Mesh;
  59307. /**
  59308. * Creates a sphere mesh
  59309. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59310. * * 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`)
  59311. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59312. * * 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
  59313. * * 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)
  59314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 sphere mesh
  59321. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59322. */
  59323. static CreateSphere(name: string, options: {
  59324. segments?: number;
  59325. diameter?: number;
  59326. diameterX?: number;
  59327. diameterY?: number;
  59328. diameterZ?: number;
  59329. arc?: number;
  59330. slice?: number;
  59331. sideOrientation?: number;
  59332. frontUVs?: Vector4;
  59333. backUVs?: Vector4;
  59334. updatable?: boolean;
  59335. }, scene?: Nullable<Scene>): Mesh;
  59336. /**
  59337. * Creates a plane polygonal mesh. By default, this is a disc
  59338. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59339. * * 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
  59340. * * 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
  59341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59344. * @param name defines the name of the mesh
  59345. * @param options defines the options used to create the mesh
  59346. * @param scene defines the hosting scene
  59347. * @returns the plane polygonal mesh
  59348. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59349. */
  59350. static CreateDisc(name: string, options: {
  59351. radius?: number;
  59352. tessellation?: number;
  59353. arc?: number;
  59354. updatable?: boolean;
  59355. sideOrientation?: number;
  59356. frontUVs?: Vector4;
  59357. backUVs?: Vector4;
  59358. }, scene?: Nullable<Scene>): Mesh;
  59359. /**
  59360. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59361. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59362. * * 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`)
  59363. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59364. * * 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
  59365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59368. * @param name defines the name of the mesh
  59369. * @param options defines the options used to create the mesh
  59370. * @param scene defines the hosting scene
  59371. * @returns the icosahedron mesh
  59372. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59373. */
  59374. static CreateIcoSphere(name: string, options: {
  59375. radius?: number;
  59376. radiusX?: number;
  59377. radiusY?: number;
  59378. radiusZ?: number;
  59379. flat?: boolean;
  59380. subdivisions?: number;
  59381. sideOrientation?: number;
  59382. frontUVs?: Vector4;
  59383. backUVs?: Vector4;
  59384. updatable?: boolean;
  59385. }, scene?: Nullable<Scene>): Mesh;
  59386. /**
  59387. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59388. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59389. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59390. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59391. * * 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
  59392. * * 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
  59393. * * 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
  59394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59397. * * 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
  59398. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59399. * * 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
  59400. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59402. * @param name defines the name of the mesh
  59403. * @param options defines the options used to create the mesh
  59404. * @param scene defines the hosting scene
  59405. * @returns the ribbon mesh
  59406. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59408. */
  59409. static CreateRibbon(name: string, options: {
  59410. pathArray: Vector3[][];
  59411. closeArray?: boolean;
  59412. closePath?: boolean;
  59413. offset?: number;
  59414. updatable?: boolean;
  59415. sideOrientation?: number;
  59416. frontUVs?: Vector4;
  59417. backUVs?: Vector4;
  59418. instance?: Mesh;
  59419. invertUV?: boolean;
  59420. uvs?: Vector2[];
  59421. colors?: Color4[];
  59422. }, scene?: Nullable<Scene>): Mesh;
  59423. /**
  59424. * Creates a cylinder or a cone mesh
  59425. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59426. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59427. * * 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.
  59428. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59429. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59430. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59431. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59432. * * 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).
  59433. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59434. * * 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).
  59435. * * 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
  59436. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59437. * * 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
  59438. * * 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.
  59439. * * If `enclose` is false, a ring surface is one element.
  59440. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59441. * * 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
  59442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59445. * @param name defines the name of the mesh
  59446. * @param options defines the options used to create the mesh
  59447. * @param scene defines the hosting scene
  59448. * @returns the cylinder mesh
  59449. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59450. */
  59451. static CreateCylinder(name: string, options: {
  59452. height?: number;
  59453. diameterTop?: number;
  59454. diameterBottom?: number;
  59455. diameter?: number;
  59456. tessellation?: number;
  59457. subdivisions?: number;
  59458. arc?: number;
  59459. faceColors?: Color4[];
  59460. faceUV?: Vector4[];
  59461. updatable?: boolean;
  59462. hasRings?: boolean;
  59463. enclose?: boolean;
  59464. cap?: number;
  59465. sideOrientation?: number;
  59466. frontUVs?: Vector4;
  59467. backUVs?: Vector4;
  59468. }, scene?: Nullable<Scene>): Mesh;
  59469. /**
  59470. * Creates a torus mesh
  59471. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59472. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59473. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59477. * @param name defines the name of the mesh
  59478. * @param options defines the options used to create the mesh
  59479. * @param scene defines the hosting scene
  59480. * @returns the torus mesh
  59481. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59482. */
  59483. static CreateTorus(name: string, options: {
  59484. diameter?: number;
  59485. thickness?: number;
  59486. tessellation?: number;
  59487. updatable?: boolean;
  59488. sideOrientation?: number;
  59489. frontUVs?: Vector4;
  59490. backUVs?: Vector4;
  59491. }, scene?: Nullable<Scene>): Mesh;
  59492. /**
  59493. * Creates a torus knot mesh
  59494. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59495. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59496. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59497. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59501. * @param name defines the name of the mesh
  59502. * @param options defines the options used to create the mesh
  59503. * @param scene defines the hosting scene
  59504. * @returns the torus knot mesh
  59505. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59506. */
  59507. static CreateTorusKnot(name: string, options: {
  59508. radius?: number;
  59509. tube?: number;
  59510. radialSegments?: number;
  59511. tubularSegments?: number;
  59512. p?: number;
  59513. q?: number;
  59514. updatable?: boolean;
  59515. sideOrientation?: number;
  59516. frontUVs?: Vector4;
  59517. backUVs?: Vector4;
  59518. }, scene?: Nullable<Scene>): Mesh;
  59519. /**
  59520. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59521. * * 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
  59522. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59523. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59524. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59525. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59526. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59527. * * 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
  59528. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59531. * @param name defines the name of the new line system
  59532. * @param options defines the options used to create the line system
  59533. * @param scene defines the hosting scene
  59534. * @returns a new line system mesh
  59535. */
  59536. static CreateLineSystem(name: string, options: {
  59537. lines: Vector3[][];
  59538. updatable?: boolean;
  59539. instance?: Nullable<LinesMesh>;
  59540. colors?: Nullable<Color4[][]>;
  59541. useVertexAlpha?: boolean;
  59542. }, scene: Nullable<Scene>): LinesMesh;
  59543. /**
  59544. * Creates a line mesh
  59545. * 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
  59546. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59547. * * The parameter `points` is an array successive Vector3
  59548. * * 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
  59549. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59550. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59551. * * When updating an instance, remember that only point positions can change, not the number of points
  59552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59554. * @param name defines the name of the new line system
  59555. * @param options defines the options used to create the line system
  59556. * @param scene defines the hosting scene
  59557. * @returns a new line mesh
  59558. */
  59559. static CreateLines(name: string, options: {
  59560. points: Vector3[];
  59561. updatable?: boolean;
  59562. instance?: Nullable<LinesMesh>;
  59563. colors?: Color4[];
  59564. useVertexAlpha?: boolean;
  59565. }, scene?: Nullable<Scene>): LinesMesh;
  59566. /**
  59567. * Creates a dashed line mesh
  59568. * * 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
  59569. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59570. * * The parameter `points` is an array successive Vector3
  59571. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59572. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59573. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59574. * * 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
  59575. * * When updating an instance, remember that only point positions can change, not the number of points
  59576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59577. * @param name defines the name of the mesh
  59578. * @param options defines the options used to create the mesh
  59579. * @param scene defines the hosting scene
  59580. * @returns the dashed line mesh
  59581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59582. */
  59583. static CreateDashedLines(name: string, options: {
  59584. points: Vector3[];
  59585. dashSize?: number;
  59586. gapSize?: number;
  59587. dashNb?: number;
  59588. updatable?: boolean;
  59589. instance?: LinesMesh;
  59590. }, scene?: Nullable<Scene>): LinesMesh;
  59591. /**
  59592. * 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.
  59593. * * 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.
  59594. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59595. * * 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.
  59596. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59597. * * 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
  59598. * * 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
  59599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59604. * @param name defines the name of the mesh
  59605. * @param options defines the options used to create the mesh
  59606. * @param scene defines the hosting scene
  59607. * @returns the extruded shape mesh
  59608. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59610. */
  59611. static ExtrudeShape(name: string, options: {
  59612. shape: Vector3[];
  59613. path: Vector3[];
  59614. scale?: number;
  59615. rotation?: number;
  59616. cap?: number;
  59617. updatable?: boolean;
  59618. sideOrientation?: number;
  59619. frontUVs?: Vector4;
  59620. backUVs?: Vector4;
  59621. instance?: Mesh;
  59622. invertUV?: boolean;
  59623. }, scene?: Nullable<Scene>): Mesh;
  59624. /**
  59625. * Creates an custom extruded shape mesh.
  59626. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59627. * * 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.
  59628. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59629. * * 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
  59630. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59631. * * 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
  59632. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59633. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59634. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59635. * * 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
  59636. * * 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
  59637. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59640. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59642. * @param name defines the name of the mesh
  59643. * @param options defines the options used to create the mesh
  59644. * @param scene defines the hosting scene
  59645. * @returns the custom extruded shape mesh
  59646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59649. */
  59650. static ExtrudeShapeCustom(name: string, options: {
  59651. shape: Vector3[];
  59652. path: Vector3[];
  59653. scaleFunction?: any;
  59654. rotationFunction?: any;
  59655. ribbonCloseArray?: boolean;
  59656. ribbonClosePath?: boolean;
  59657. cap?: number;
  59658. updatable?: boolean;
  59659. sideOrientation?: number;
  59660. frontUVs?: Vector4;
  59661. backUVs?: Vector4;
  59662. instance?: Mesh;
  59663. invertUV?: boolean;
  59664. }, scene?: Nullable<Scene>): Mesh;
  59665. /**
  59666. * Creates lathe mesh.
  59667. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59668. * * 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
  59669. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59670. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59671. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59672. * * 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
  59673. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59674. * * 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
  59675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59679. * @param name defines the name of the mesh
  59680. * @param options defines the options used to create the mesh
  59681. * @param scene defines the hosting scene
  59682. * @returns the lathe mesh
  59683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59684. */
  59685. static CreateLathe(name: string, options: {
  59686. shape: Vector3[];
  59687. radius?: number;
  59688. tessellation?: number;
  59689. clip?: number;
  59690. arc?: number;
  59691. closed?: boolean;
  59692. updatable?: boolean;
  59693. sideOrientation?: number;
  59694. frontUVs?: Vector4;
  59695. backUVs?: Vector4;
  59696. cap?: number;
  59697. invertUV?: boolean;
  59698. }, scene?: Nullable<Scene>): Mesh;
  59699. /**
  59700. * Creates a tiled plane mesh
  59701. * * You can set a limited pattern arrangement with the tiles
  59702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59705. * @param name defines the name of the mesh
  59706. * @param options defines the options used to create the mesh
  59707. * @param scene defines the hosting scene
  59708. * @returns the plane mesh
  59709. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59710. */
  59711. static CreateTiledPlane(name: string, options: {
  59712. pattern?: number;
  59713. tileSize?: number;
  59714. tileWidth?: number;
  59715. tileHeight?: number;
  59716. size?: number;
  59717. width?: number;
  59718. height?: number;
  59719. alignHorizontal?: number;
  59720. alignVertical?: number;
  59721. sideOrientation?: number;
  59722. frontUVs?: Vector4;
  59723. backUVs?: Vector4;
  59724. updatable?: boolean;
  59725. }, scene?: Nullable<Scene>): Mesh;
  59726. /**
  59727. * Creates a plane mesh
  59728. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59729. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59730. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59734. * @param name defines the name of the mesh
  59735. * @param options defines the options used to create the mesh
  59736. * @param scene defines the hosting scene
  59737. * @returns the plane mesh
  59738. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59739. */
  59740. static CreatePlane(name: string, options: {
  59741. size?: number;
  59742. width?: number;
  59743. height?: number;
  59744. sideOrientation?: number;
  59745. frontUVs?: Vector4;
  59746. backUVs?: Vector4;
  59747. updatable?: boolean;
  59748. sourcePlane?: Plane;
  59749. }, scene?: Nullable<Scene>): Mesh;
  59750. /**
  59751. * Creates a ground mesh
  59752. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59753. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59755. * @param name defines the name of the mesh
  59756. * @param options defines the options used to create the mesh
  59757. * @param scene defines the hosting scene
  59758. * @returns the ground mesh
  59759. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59760. */
  59761. static CreateGround(name: string, options: {
  59762. width?: number;
  59763. height?: number;
  59764. subdivisions?: number;
  59765. subdivisionsX?: number;
  59766. subdivisionsY?: number;
  59767. updatable?: boolean;
  59768. }, scene?: Nullable<Scene>): Mesh;
  59769. /**
  59770. * Creates a tiled ground mesh
  59771. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59772. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59773. * * 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
  59774. * * 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
  59775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59776. * @param name defines the name of the mesh
  59777. * @param options defines the options used to create the mesh
  59778. * @param scene defines the hosting scene
  59779. * @returns the tiled ground mesh
  59780. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59781. */
  59782. static CreateTiledGround(name: string, options: {
  59783. xmin: number;
  59784. zmin: number;
  59785. xmax: number;
  59786. zmax: number;
  59787. subdivisions?: {
  59788. w: number;
  59789. h: number;
  59790. };
  59791. precision?: {
  59792. w: number;
  59793. h: number;
  59794. };
  59795. updatable?: boolean;
  59796. }, scene?: Nullable<Scene>): Mesh;
  59797. /**
  59798. * Creates a ground mesh from a height map
  59799. * * The parameter `url` sets the URL of the height map image resource.
  59800. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59801. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59802. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59803. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59804. * * 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.
  59805. * * 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).
  59806. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59808. * @param name defines the name of the mesh
  59809. * @param url defines the url to the height map
  59810. * @param options defines the options used to create the mesh
  59811. * @param scene defines the hosting scene
  59812. * @returns the ground mesh
  59813. * @see https://doc.babylonjs.com/babylon101/height_map
  59814. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59815. */
  59816. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59817. width?: number;
  59818. height?: number;
  59819. subdivisions?: number;
  59820. minHeight?: number;
  59821. maxHeight?: number;
  59822. colorFilter?: Color3;
  59823. alphaFilter?: number;
  59824. updatable?: boolean;
  59825. onReady?: (mesh: GroundMesh) => void;
  59826. }, scene?: Nullable<Scene>): GroundMesh;
  59827. /**
  59828. * Creates a polygon mesh
  59829. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59830. * * 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
  59831. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59834. * * Remember you can only change the shape positions, not their number when updating a polygon
  59835. * @param name defines the name of the mesh
  59836. * @param options defines the options used to create the mesh
  59837. * @param scene defines the hosting scene
  59838. * @param earcutInjection can be used to inject your own earcut reference
  59839. * @returns the polygon mesh
  59840. */
  59841. static CreatePolygon(name: string, options: {
  59842. shape: Vector3[];
  59843. holes?: Vector3[][];
  59844. depth?: number;
  59845. faceUV?: Vector4[];
  59846. faceColors?: Color4[];
  59847. updatable?: boolean;
  59848. sideOrientation?: number;
  59849. frontUVs?: Vector4;
  59850. backUVs?: Vector4;
  59851. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59852. /**
  59853. * Creates an extruded polygon mesh, with depth in the Y direction.
  59854. * * 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)
  59855. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59856. * @param name defines the name of the mesh
  59857. * @param options defines the options used to create the mesh
  59858. * @param scene defines the hosting scene
  59859. * @param earcutInjection can be used to inject your own earcut reference
  59860. * @returns the polygon mesh
  59861. */
  59862. static ExtrudePolygon(name: string, options: {
  59863. shape: Vector3[];
  59864. holes?: Vector3[][];
  59865. depth?: number;
  59866. faceUV?: Vector4[];
  59867. faceColors?: Color4[];
  59868. updatable?: boolean;
  59869. sideOrientation?: number;
  59870. frontUVs?: Vector4;
  59871. backUVs?: Vector4;
  59872. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59873. /**
  59874. * Creates a tube mesh.
  59875. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59876. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59877. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59878. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59879. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59880. * * 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)
  59881. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59882. * * 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
  59883. * * 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
  59884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59886. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59888. * @param name defines the name of the mesh
  59889. * @param options defines the options used to create the mesh
  59890. * @param scene defines the hosting scene
  59891. * @returns the tube mesh
  59892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59893. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59894. */
  59895. static CreateTube(name: string, options: {
  59896. path: Vector3[];
  59897. radius?: number;
  59898. tessellation?: number;
  59899. radiusFunction?: {
  59900. (i: number, distance: number): number;
  59901. };
  59902. cap?: number;
  59903. arc?: number;
  59904. updatable?: boolean;
  59905. sideOrientation?: number;
  59906. frontUVs?: Vector4;
  59907. backUVs?: Vector4;
  59908. instance?: Mesh;
  59909. invertUV?: boolean;
  59910. }, scene?: Nullable<Scene>): Mesh;
  59911. /**
  59912. * Creates a polyhedron mesh
  59913. * * 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
  59914. * * The parameter `size` (positive float, default 1) sets the polygon size
  59915. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59916. * * 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`
  59917. * * 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
  59918. * * 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)`)
  59919. * * 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
  59920. * * 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
  59921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59924. * @param name defines the name of the mesh
  59925. * @param options defines the options used to create the mesh
  59926. * @param scene defines the hosting scene
  59927. * @returns the polyhedron mesh
  59928. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59929. */
  59930. static CreatePolyhedron(name: string, options: {
  59931. type?: number;
  59932. size?: number;
  59933. sizeX?: number;
  59934. sizeY?: number;
  59935. sizeZ?: number;
  59936. custom?: any;
  59937. faceUV?: Vector4[];
  59938. faceColors?: Color4[];
  59939. flat?: boolean;
  59940. updatable?: boolean;
  59941. sideOrientation?: number;
  59942. frontUVs?: Vector4;
  59943. backUVs?: Vector4;
  59944. }, scene?: Nullable<Scene>): Mesh;
  59945. /**
  59946. * Creates a decal mesh.
  59947. * 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
  59948. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59949. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59950. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59951. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59952. * @param name defines the name of the mesh
  59953. * @param sourceMesh defines the mesh where the decal must be applied
  59954. * @param options defines the options used to create the mesh
  59955. * @param scene defines the hosting scene
  59956. * @returns the decal mesh
  59957. * @see https://doc.babylonjs.com/how_to/decals
  59958. */
  59959. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59960. position?: Vector3;
  59961. normal?: Vector3;
  59962. size?: Vector3;
  59963. angle?: number;
  59964. }): Mesh;
  59965. }
  59966. }
  59967. declare module "babylonjs/Meshes/meshSimplification" {
  59968. import { Mesh } from "babylonjs/Meshes/mesh";
  59969. /**
  59970. * A simplifier interface for future simplification implementations
  59971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59972. */
  59973. export interface ISimplifier {
  59974. /**
  59975. * Simplification of a given mesh according to the given settings.
  59976. * Since this requires computation, it is assumed that the function runs async.
  59977. * @param settings The settings of the simplification, including quality and distance
  59978. * @param successCallback A callback that will be called after the mesh was simplified.
  59979. * @param errorCallback in case of an error, this callback will be called. optional.
  59980. */
  59981. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59982. }
  59983. /**
  59984. * Expected simplification settings.
  59985. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59986. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59987. */
  59988. export interface ISimplificationSettings {
  59989. /**
  59990. * Gets or sets the expected quality
  59991. */
  59992. quality: number;
  59993. /**
  59994. * Gets or sets the distance when this optimized version should be used
  59995. */
  59996. distance: number;
  59997. /**
  59998. * Gets an already optimized mesh
  59999. */
  60000. optimizeMesh?: boolean;
  60001. }
  60002. /**
  60003. * Class used to specify simplification options
  60004. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60005. */
  60006. export class SimplificationSettings implements ISimplificationSettings {
  60007. /** expected quality */
  60008. quality: number;
  60009. /** distance when this optimized version should be used */
  60010. distance: number;
  60011. /** already optimized mesh */
  60012. optimizeMesh?: boolean | undefined;
  60013. /**
  60014. * Creates a SimplificationSettings
  60015. * @param quality expected quality
  60016. * @param distance distance when this optimized version should be used
  60017. * @param optimizeMesh already optimized mesh
  60018. */
  60019. constructor(
  60020. /** expected quality */
  60021. quality: number,
  60022. /** distance when this optimized version should be used */
  60023. distance: number,
  60024. /** already optimized mesh */
  60025. optimizeMesh?: boolean | undefined);
  60026. }
  60027. /**
  60028. * Interface used to define a simplification task
  60029. */
  60030. export interface ISimplificationTask {
  60031. /**
  60032. * Array of settings
  60033. */
  60034. settings: Array<ISimplificationSettings>;
  60035. /**
  60036. * Simplification type
  60037. */
  60038. simplificationType: SimplificationType;
  60039. /**
  60040. * Mesh to simplify
  60041. */
  60042. mesh: Mesh;
  60043. /**
  60044. * Callback called on success
  60045. */
  60046. successCallback?: () => void;
  60047. /**
  60048. * Defines if parallel processing can be used
  60049. */
  60050. parallelProcessing: boolean;
  60051. }
  60052. /**
  60053. * Queue used to order the simplification tasks
  60054. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60055. */
  60056. export class SimplificationQueue {
  60057. private _simplificationArray;
  60058. /**
  60059. * Gets a boolean indicating that the process is still running
  60060. */
  60061. running: boolean;
  60062. /**
  60063. * Creates a new queue
  60064. */
  60065. constructor();
  60066. /**
  60067. * Adds a new simplification task
  60068. * @param task defines a task to add
  60069. */
  60070. addTask(task: ISimplificationTask): void;
  60071. /**
  60072. * Execute next task
  60073. */
  60074. executeNext(): void;
  60075. /**
  60076. * Execute a simplification task
  60077. * @param task defines the task to run
  60078. */
  60079. runSimplification(task: ISimplificationTask): void;
  60080. private getSimplifier;
  60081. }
  60082. /**
  60083. * The implemented types of simplification
  60084. * At the moment only Quadratic Error Decimation is implemented
  60085. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60086. */
  60087. export enum SimplificationType {
  60088. /** Quadratic error decimation */
  60089. QUADRATIC = 0
  60090. }
  60091. }
  60092. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60093. import { Scene } from "babylonjs/scene";
  60094. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60095. import { ISceneComponent } from "babylonjs/sceneComponent";
  60096. module "babylonjs/scene" {
  60097. interface Scene {
  60098. /** @hidden (Backing field) */
  60099. _simplificationQueue: SimplificationQueue;
  60100. /**
  60101. * Gets or sets the simplification queue attached to the scene
  60102. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60103. */
  60104. simplificationQueue: SimplificationQueue;
  60105. }
  60106. }
  60107. module "babylonjs/Meshes/mesh" {
  60108. interface Mesh {
  60109. /**
  60110. * Simplify the mesh according to the given array of settings.
  60111. * Function will return immediately and will simplify async
  60112. * @param settings a collection of simplification settings
  60113. * @param parallelProcessing should all levels calculate parallel or one after the other
  60114. * @param simplificationType the type of simplification to run
  60115. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60116. * @returns the current mesh
  60117. */
  60118. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60119. }
  60120. }
  60121. /**
  60122. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60123. * created in a scene
  60124. */
  60125. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60126. /**
  60127. * The component name helpfull to identify the component in the list of scene components.
  60128. */
  60129. readonly name: string;
  60130. /**
  60131. * The scene the component belongs to.
  60132. */
  60133. scene: Scene;
  60134. /**
  60135. * Creates a new instance of the component for the given scene
  60136. * @param scene Defines the scene to register the component in
  60137. */
  60138. constructor(scene: Scene);
  60139. /**
  60140. * Registers the component in a given scene
  60141. */
  60142. register(): void;
  60143. /**
  60144. * Rebuilds the elements related to this component in case of
  60145. * context lost for instance.
  60146. */
  60147. rebuild(): void;
  60148. /**
  60149. * Disposes the component and the associated ressources
  60150. */
  60151. dispose(): void;
  60152. private _beforeCameraUpdate;
  60153. }
  60154. }
  60155. declare module "babylonjs/Meshes/Builders/index" {
  60156. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60157. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60158. export * from "babylonjs/Meshes/Builders/discBuilder";
  60159. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60160. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60161. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60162. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60163. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60164. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60165. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60166. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60167. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60168. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60169. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60170. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60171. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60172. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60173. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60174. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60175. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60176. }
  60177. declare module "babylonjs/Meshes/index" {
  60178. export * from "babylonjs/Meshes/abstractMesh";
  60179. export * from "babylonjs/Meshes/buffer";
  60180. export * from "babylonjs/Meshes/Compression/index";
  60181. export * from "babylonjs/Meshes/csg";
  60182. export * from "babylonjs/Meshes/geometry";
  60183. export * from "babylonjs/Meshes/groundMesh";
  60184. export * from "babylonjs/Meshes/trailMesh";
  60185. export * from "babylonjs/Meshes/instancedMesh";
  60186. export * from "babylonjs/Meshes/linesMesh";
  60187. export * from "babylonjs/Meshes/mesh";
  60188. export * from "babylonjs/Meshes/mesh.vertexData";
  60189. export * from "babylonjs/Meshes/meshBuilder";
  60190. export * from "babylonjs/Meshes/meshSimplification";
  60191. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60192. export * from "babylonjs/Meshes/polygonMesh";
  60193. export * from "babylonjs/Meshes/subMesh";
  60194. export * from "babylonjs/Meshes/meshLODLevel";
  60195. export * from "babylonjs/Meshes/transformNode";
  60196. export * from "babylonjs/Meshes/Builders/index";
  60197. export * from "babylonjs/Meshes/dataBuffer";
  60198. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60199. }
  60200. declare module "babylonjs/Morph/index" {
  60201. export * from "babylonjs/Morph/morphTarget";
  60202. export * from "babylonjs/Morph/morphTargetManager";
  60203. }
  60204. declare module "babylonjs/Navigation/INavigationEngine" {
  60205. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60206. import { Vector3 } from "babylonjs/Maths/math";
  60207. import { Mesh } from "babylonjs/Meshes/mesh";
  60208. import { Scene } from "babylonjs/scene";
  60209. /**
  60210. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60211. */
  60212. export interface INavigationEnginePlugin {
  60213. /**
  60214. * plugin name
  60215. */
  60216. name: string;
  60217. /**
  60218. * Creates a navigation mesh
  60219. * @param meshes array of all the geometry used to compute the navigatio mesh
  60220. * @param parameters bunch of parameters used to filter geometry
  60221. */
  60222. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60223. /**
  60224. * Create a navigation mesh debug mesh
  60225. * @param scene is where the mesh will be added
  60226. * @returns debug display mesh
  60227. */
  60228. createDebugNavMesh(scene: Scene): Mesh;
  60229. /**
  60230. * Get a navigation mesh constrained position, closest to the parameter position
  60231. * @param position world position
  60232. * @returns the closest point to position constrained by the navigation mesh
  60233. */
  60234. getClosestPoint(position: Vector3): Vector3;
  60235. /**
  60236. * Get a navigation mesh constrained position, within a particular radius
  60237. * @param position world position
  60238. * @param maxRadius the maximum distance to the constrained world position
  60239. * @returns the closest point to position constrained by the navigation mesh
  60240. */
  60241. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60242. /**
  60243. * Compute the final position from a segment made of destination-position
  60244. * @param position world position
  60245. * @param destination world position
  60246. * @returns the resulting point along the navmesh
  60247. */
  60248. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60249. /**
  60250. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60251. * @param start world position
  60252. * @param end world position
  60253. * @returns array containing world position composing the path
  60254. */
  60255. computePath(start: Vector3, end: Vector3): Vector3[];
  60256. /**
  60257. * If this plugin is supported
  60258. * @returns true if plugin is supported
  60259. */
  60260. isSupported(): boolean;
  60261. /**
  60262. * Create a new Crowd so you can add agents
  60263. * @param maxAgents the maximum agent count in the crowd
  60264. * @param maxAgentRadius the maximum radius an agent can have
  60265. * @param scene to attach the crowd to
  60266. * @returns the crowd you can add agents to
  60267. */
  60268. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60269. /**
  60270. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60271. * The queries will try to find a solution within those bounds
  60272. * default is (1,1,1)
  60273. * @param extent x,y,z value that define the extent around the queries point of reference
  60274. */
  60275. setDefaultQueryExtent(extent: Vector3): void;
  60276. /**
  60277. * Get the Bounding box extent specified by setDefaultQueryExtent
  60278. * @returns the box extent values
  60279. */
  60280. getDefaultQueryExtent(): Vector3;
  60281. /**
  60282. * Release all resources
  60283. */
  60284. dispose(): void;
  60285. }
  60286. /**
  60287. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60288. */
  60289. export interface ICrowd {
  60290. /**
  60291. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60292. * You can attach anything to that node. The node position is updated in the scene update tick.
  60293. * @param pos world position that will be constrained by the navigation mesh
  60294. * @param parameters agent parameters
  60295. * @param transform hooked to the agent that will be update by the scene
  60296. * @returns agent index
  60297. */
  60298. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60299. /**
  60300. * Returns the agent position in world space
  60301. * @param index agent index returned by addAgent
  60302. * @returns world space position
  60303. */
  60304. getAgentPosition(index: number): Vector3;
  60305. /**
  60306. * Gets the agent velocity in world space
  60307. * @param index agent index returned by addAgent
  60308. * @returns world space velocity
  60309. */
  60310. getAgentVelocity(index: number): Vector3;
  60311. /**
  60312. * remove a particular agent previously created
  60313. * @param index agent index returned by addAgent
  60314. */
  60315. removeAgent(index: number): void;
  60316. /**
  60317. * get the list of all agents attached to this crowd
  60318. * @returns list of agent indices
  60319. */
  60320. getAgents(): number[];
  60321. /**
  60322. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60323. * @param deltaTime in seconds
  60324. */
  60325. update(deltaTime: number): void;
  60326. /**
  60327. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60328. * @param index agent index returned by addAgent
  60329. * @param destination targeted world position
  60330. */
  60331. agentGoto(index: number, destination: Vector3): void;
  60332. /**
  60333. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60334. * The queries will try to find a solution within those bounds
  60335. * default is (1,1,1)
  60336. * @param extent x,y,z value that define the extent around the queries point of reference
  60337. */
  60338. setDefaultQueryExtent(extent: Vector3): void;
  60339. /**
  60340. * Get the Bounding box extent specified by setDefaultQueryExtent
  60341. * @returns the box extent values
  60342. */
  60343. getDefaultQueryExtent(): Vector3;
  60344. /**
  60345. * Release all resources
  60346. */
  60347. dispose(): void;
  60348. }
  60349. /**
  60350. * Configures an agent
  60351. */
  60352. export interface IAgentParameters {
  60353. /**
  60354. * Agent radius. [Limit: >= 0]
  60355. */
  60356. radius: number;
  60357. /**
  60358. * Agent height. [Limit: > 0]
  60359. */
  60360. height: number;
  60361. /**
  60362. * Maximum allowed acceleration. [Limit: >= 0]
  60363. */
  60364. maxAcceleration: number;
  60365. /**
  60366. * Maximum allowed speed. [Limit: >= 0]
  60367. */
  60368. maxSpeed: number;
  60369. /**
  60370. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60371. */
  60372. collisionQueryRange: number;
  60373. /**
  60374. * The path visibility optimization range. [Limit: > 0]
  60375. */
  60376. pathOptimizationRange: number;
  60377. /**
  60378. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60379. */
  60380. separationWeight: number;
  60381. }
  60382. /**
  60383. * Configures the navigation mesh creation
  60384. */
  60385. export interface INavMeshParameters {
  60386. /**
  60387. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60388. */
  60389. cs: number;
  60390. /**
  60391. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60392. */
  60393. ch: number;
  60394. /**
  60395. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60396. */
  60397. walkableSlopeAngle: number;
  60398. /**
  60399. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60400. * be considered walkable. [Limit: >= 3] [Units: vx]
  60401. */
  60402. walkableHeight: number;
  60403. /**
  60404. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60405. */
  60406. walkableClimb: number;
  60407. /**
  60408. * The distance to erode/shrink the walkable area of the heightfield away from
  60409. * obstructions. [Limit: >=0] [Units: vx]
  60410. */
  60411. walkableRadius: number;
  60412. /**
  60413. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60414. */
  60415. maxEdgeLen: number;
  60416. /**
  60417. * The maximum distance a simplfied contour's border edges should deviate
  60418. * the original raw contour. [Limit: >=0] [Units: vx]
  60419. */
  60420. maxSimplificationError: number;
  60421. /**
  60422. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60423. */
  60424. minRegionArea: number;
  60425. /**
  60426. * Any regions with a span count smaller than this value will, if possible,
  60427. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60428. */
  60429. mergeRegionArea: number;
  60430. /**
  60431. * The maximum number of vertices allowed for polygons generated during the
  60432. * contour to polygon conversion process. [Limit: >= 3]
  60433. */
  60434. maxVertsPerPoly: number;
  60435. /**
  60436. * Sets the sampling distance to use when generating the detail mesh.
  60437. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60438. */
  60439. detailSampleDist: number;
  60440. /**
  60441. * The maximum distance the detail mesh surface should deviate from heightfield
  60442. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60443. */
  60444. detailSampleMaxError: number;
  60445. }
  60446. }
  60447. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60448. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60449. import { Mesh } from "babylonjs/Meshes/mesh";
  60450. import { Scene } from "babylonjs/scene";
  60451. import { Vector3 } from "babylonjs/Maths/math";
  60452. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60453. /**
  60454. * RecastJS navigation plugin
  60455. */
  60456. export class RecastJSPlugin implements INavigationEnginePlugin {
  60457. /**
  60458. * Reference to the Recast library
  60459. */
  60460. bjsRECAST: any;
  60461. /**
  60462. * plugin name
  60463. */
  60464. name: string;
  60465. /**
  60466. * the first navmesh created. We might extend this to support multiple navmeshes
  60467. */
  60468. navMesh: any;
  60469. /**
  60470. * Initializes the recastJS plugin
  60471. * @param recastInjection can be used to inject your own recast reference
  60472. */
  60473. constructor(recastInjection?: any);
  60474. /**
  60475. * Creates a navigation mesh
  60476. * @param meshes array of all the geometry used to compute the navigatio mesh
  60477. * @param parameters bunch of parameters used to filter geometry
  60478. */
  60479. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60480. /**
  60481. * Create a navigation mesh debug mesh
  60482. * @param scene is where the mesh will be added
  60483. * @returns debug display mesh
  60484. */
  60485. createDebugNavMesh(scene: Scene): Mesh;
  60486. /**
  60487. * Get a navigation mesh constrained position, closest to the parameter position
  60488. * @param position world position
  60489. * @returns the closest point to position constrained by the navigation mesh
  60490. */
  60491. getClosestPoint(position: Vector3): Vector3;
  60492. /**
  60493. * Get a navigation mesh constrained position, within a particular radius
  60494. * @param position world position
  60495. * @param maxRadius the maximum distance to the constrained world position
  60496. * @returns the closest point to position constrained by the navigation mesh
  60497. */
  60498. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60499. /**
  60500. * Compute the final position from a segment made of destination-position
  60501. * @param position world position
  60502. * @param destination world position
  60503. * @returns the resulting point along the navmesh
  60504. */
  60505. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60506. /**
  60507. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60508. * @param start world position
  60509. * @param end world position
  60510. * @returns array containing world position composing the path
  60511. */
  60512. computePath(start: Vector3, end: Vector3): Vector3[];
  60513. /**
  60514. * Create a new Crowd so you can add agents
  60515. * @param maxAgents the maximum agent count in the crowd
  60516. * @param maxAgentRadius the maximum radius an agent can have
  60517. * @param scene to attach the crowd to
  60518. * @returns the crowd you can add agents to
  60519. */
  60520. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60521. /**
  60522. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60523. * The queries will try to find a solution within those bounds
  60524. * default is (1,1,1)
  60525. * @param extent x,y,z value that define the extent around the queries point of reference
  60526. */
  60527. setDefaultQueryExtent(extent: Vector3): void;
  60528. /**
  60529. * Get the Bounding box extent specified by setDefaultQueryExtent
  60530. * @returns the box extent values
  60531. */
  60532. getDefaultQueryExtent(): Vector3;
  60533. /**
  60534. * Disposes
  60535. */
  60536. dispose(): void;
  60537. /**
  60538. * If this plugin is supported
  60539. * @returns true if plugin is supported
  60540. */
  60541. isSupported(): boolean;
  60542. }
  60543. /**
  60544. * Recast detour crowd implementation
  60545. */
  60546. export class RecastJSCrowd implements ICrowd {
  60547. /**
  60548. * Recast/detour plugin
  60549. */
  60550. bjsRECASTPlugin: RecastJSPlugin;
  60551. /**
  60552. * Link to the detour crowd
  60553. */
  60554. recastCrowd: any;
  60555. /**
  60556. * One transform per agent
  60557. */
  60558. transforms: TransformNode[];
  60559. /**
  60560. * All agents created
  60561. */
  60562. agents: number[];
  60563. /**
  60564. * Link to the scene is kept to unregister the crowd from the scene
  60565. */
  60566. private _scene;
  60567. /**
  60568. * Observer for crowd updates
  60569. */
  60570. private _onBeforeAnimationsObserver;
  60571. /**
  60572. * Constructor
  60573. * @param plugin recastJS plugin
  60574. * @param maxAgents the maximum agent count in the crowd
  60575. * @param maxAgentRadius the maximum radius an agent can have
  60576. * @param scene to attach the crowd to
  60577. * @returns the crowd you can add agents to
  60578. */
  60579. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60580. /**
  60581. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60582. * You can attach anything to that node. The node position is updated in the scene update tick.
  60583. * @param pos world position that will be constrained by the navigation mesh
  60584. * @param parameters agent parameters
  60585. * @param transform hooked to the agent that will be update by the scene
  60586. * @returns agent index
  60587. */
  60588. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60589. /**
  60590. * Returns the agent position in world space
  60591. * @param index agent index returned by addAgent
  60592. * @returns world space position
  60593. */
  60594. getAgentPosition(index: number): Vector3;
  60595. /**
  60596. * Returns the agent velocity in world space
  60597. * @param index agent index returned by addAgent
  60598. * @returns world space velocity
  60599. */
  60600. getAgentVelocity(index: number): Vector3;
  60601. /**
  60602. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60603. * @param index agent index returned by addAgent
  60604. * @param destination targeted world position
  60605. */
  60606. agentGoto(index: number, destination: Vector3): void;
  60607. /**
  60608. * remove a particular agent previously created
  60609. * @param index agent index returned by addAgent
  60610. */
  60611. removeAgent(index: number): void;
  60612. /**
  60613. * get the list of all agents attached to this crowd
  60614. * @returns list of agent indices
  60615. */
  60616. getAgents(): number[];
  60617. /**
  60618. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60619. * @param deltaTime in seconds
  60620. */
  60621. update(deltaTime: number): void;
  60622. /**
  60623. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60624. * The queries will try to find a solution within those bounds
  60625. * default is (1,1,1)
  60626. * @param extent x,y,z value that define the extent around the queries point of reference
  60627. */
  60628. setDefaultQueryExtent(extent: Vector3): void;
  60629. /**
  60630. * Get the Bounding box extent specified by setDefaultQueryExtent
  60631. * @returns the box extent values
  60632. */
  60633. getDefaultQueryExtent(): Vector3;
  60634. /**
  60635. * Release all resources
  60636. */
  60637. dispose(): void;
  60638. }
  60639. }
  60640. declare module "babylonjs/Navigation/Plugins/index" {
  60641. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60642. }
  60643. declare module "babylonjs/Navigation/index" {
  60644. export * from "babylonjs/Navigation/INavigationEngine";
  60645. export * from "babylonjs/Navigation/Plugins/index";
  60646. }
  60647. declare module "babylonjs/Offline/database" {
  60648. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60649. /**
  60650. * Class used to enable access to IndexedDB
  60651. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60652. */
  60653. export class Database implements IOfflineProvider {
  60654. private _callbackManifestChecked;
  60655. private _currentSceneUrl;
  60656. private _db;
  60657. private _enableSceneOffline;
  60658. private _enableTexturesOffline;
  60659. private _manifestVersionFound;
  60660. private _mustUpdateRessources;
  60661. private _hasReachedQuota;
  60662. private _isSupported;
  60663. private _idbFactory;
  60664. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60665. private static IsUASupportingBlobStorage;
  60666. /**
  60667. * Gets a boolean indicating if Database storate is enabled (off by default)
  60668. */
  60669. static IDBStorageEnabled: boolean;
  60670. /**
  60671. * Gets a boolean indicating if scene must be saved in the database
  60672. */
  60673. readonly enableSceneOffline: boolean;
  60674. /**
  60675. * Gets a boolean indicating if textures must be saved in the database
  60676. */
  60677. readonly enableTexturesOffline: boolean;
  60678. /**
  60679. * Creates a new Database
  60680. * @param urlToScene defines the url to load the scene
  60681. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60682. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60683. */
  60684. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60685. private static _ParseURL;
  60686. private static _ReturnFullUrlLocation;
  60687. private _checkManifestFile;
  60688. /**
  60689. * Open the database and make it available
  60690. * @param successCallback defines the callback to call on success
  60691. * @param errorCallback defines the callback to call on error
  60692. */
  60693. open(successCallback: () => void, errorCallback: () => void): void;
  60694. /**
  60695. * Loads an image from the database
  60696. * @param url defines the url to load from
  60697. * @param image defines the target DOM image
  60698. */
  60699. loadImage(url: string, image: HTMLImageElement): void;
  60700. private _loadImageFromDBAsync;
  60701. private _saveImageIntoDBAsync;
  60702. private _checkVersionFromDB;
  60703. private _loadVersionFromDBAsync;
  60704. private _saveVersionIntoDBAsync;
  60705. /**
  60706. * Loads a file from database
  60707. * @param url defines the URL to load from
  60708. * @param sceneLoaded defines a callback to call on success
  60709. * @param progressCallBack defines a callback to call when progress changed
  60710. * @param errorCallback defines a callback to call on error
  60711. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60712. */
  60713. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60714. private _loadFileAsync;
  60715. private _saveFileAsync;
  60716. /**
  60717. * Validates if xhr data is correct
  60718. * @param xhr defines the request to validate
  60719. * @param dataType defines the expected data type
  60720. * @returns true if data is correct
  60721. */
  60722. private static _ValidateXHRData;
  60723. }
  60724. }
  60725. declare module "babylonjs/Offline/index" {
  60726. export * from "babylonjs/Offline/database";
  60727. export * from "babylonjs/Offline/IOfflineProvider";
  60728. }
  60729. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60730. /** @hidden */
  60731. export var gpuUpdateParticlesPixelShader: {
  60732. name: string;
  60733. shader: string;
  60734. };
  60735. }
  60736. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60737. /** @hidden */
  60738. export var gpuUpdateParticlesVertexShader: {
  60739. name: string;
  60740. shader: string;
  60741. };
  60742. }
  60743. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60744. /** @hidden */
  60745. export var clipPlaneFragmentDeclaration2: {
  60746. name: string;
  60747. shader: string;
  60748. };
  60749. }
  60750. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60751. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60752. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60753. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60754. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60755. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60756. /** @hidden */
  60757. export var gpuRenderParticlesPixelShader: {
  60758. name: string;
  60759. shader: string;
  60760. };
  60761. }
  60762. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60763. /** @hidden */
  60764. export var clipPlaneVertexDeclaration2: {
  60765. name: string;
  60766. shader: string;
  60767. };
  60768. }
  60769. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60770. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60771. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60772. /** @hidden */
  60773. export var gpuRenderParticlesVertexShader: {
  60774. name: string;
  60775. shader: string;
  60776. };
  60777. }
  60778. declare module "babylonjs/Particles/gpuParticleSystem" {
  60779. import { Nullable } from "babylonjs/types";
  60780. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60781. import { Observable } from "babylonjs/Misc/observable";
  60782. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60783. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60784. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60785. import { Scene, IDisposable } from "babylonjs/scene";
  60786. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60787. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60788. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60789. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60790. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60791. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60792. /**
  60793. * This represents a GPU particle system in Babylon
  60794. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60795. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60796. */
  60797. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60798. /**
  60799. * The layer mask we are rendering the particles through.
  60800. */
  60801. layerMask: number;
  60802. private _capacity;
  60803. private _activeCount;
  60804. private _currentActiveCount;
  60805. private _accumulatedCount;
  60806. private _renderEffect;
  60807. private _updateEffect;
  60808. private _buffer0;
  60809. private _buffer1;
  60810. private _spriteBuffer;
  60811. private _updateVAO;
  60812. private _renderVAO;
  60813. private _targetIndex;
  60814. private _sourceBuffer;
  60815. private _targetBuffer;
  60816. private _engine;
  60817. private _currentRenderId;
  60818. private _started;
  60819. private _stopped;
  60820. private _timeDelta;
  60821. private _randomTexture;
  60822. private _randomTexture2;
  60823. private _attributesStrideSize;
  60824. private _updateEffectOptions;
  60825. private _randomTextureSize;
  60826. private _actualFrame;
  60827. private readonly _rawTextureWidth;
  60828. /**
  60829. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60830. */
  60831. static readonly IsSupported: boolean;
  60832. /**
  60833. * An event triggered when the system is disposed.
  60834. */
  60835. onDisposeObservable: Observable<GPUParticleSystem>;
  60836. /**
  60837. * Gets the maximum number of particles active at the same time.
  60838. * @returns The max number of active particles.
  60839. */
  60840. getCapacity(): number;
  60841. /**
  60842. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60843. * to override the particles.
  60844. */
  60845. forceDepthWrite: boolean;
  60846. /**
  60847. * Gets or set the number of active particles
  60848. */
  60849. activeParticleCount: number;
  60850. private _preWarmDone;
  60851. /**
  60852. * Is this system ready to be used/rendered
  60853. * @return true if the system is ready
  60854. */
  60855. isReady(): boolean;
  60856. /**
  60857. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60858. * @returns True if it has been started, otherwise false.
  60859. */
  60860. isStarted(): boolean;
  60861. /**
  60862. * Starts the particle system and begins to emit
  60863. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60864. */
  60865. start(delay?: number): void;
  60866. /**
  60867. * Stops the particle system.
  60868. */
  60869. stop(): void;
  60870. /**
  60871. * Remove all active particles
  60872. */
  60873. reset(): void;
  60874. /**
  60875. * Returns the string "GPUParticleSystem"
  60876. * @returns a string containing the class name
  60877. */
  60878. getClassName(): string;
  60879. private _colorGradientsTexture;
  60880. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60881. /**
  60882. * Adds a new color gradient
  60883. * @param gradient defines the gradient to use (between 0 and 1)
  60884. * @param color1 defines the color to affect to the specified gradient
  60885. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60886. * @returns the current particle system
  60887. */
  60888. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60889. /**
  60890. * Remove a specific color gradient
  60891. * @param gradient defines the gradient to remove
  60892. * @returns the current particle system
  60893. */
  60894. removeColorGradient(gradient: number): GPUParticleSystem;
  60895. private _angularSpeedGradientsTexture;
  60896. private _sizeGradientsTexture;
  60897. private _velocityGradientsTexture;
  60898. private _limitVelocityGradientsTexture;
  60899. private _dragGradientsTexture;
  60900. private _addFactorGradient;
  60901. /**
  60902. * Adds a new size gradient
  60903. * @param gradient defines the gradient to use (between 0 and 1)
  60904. * @param factor defines the size factor to affect to the specified gradient
  60905. * @returns the current particle system
  60906. */
  60907. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60908. /**
  60909. * Remove a specific size gradient
  60910. * @param gradient defines the gradient to remove
  60911. * @returns the current particle system
  60912. */
  60913. removeSizeGradient(gradient: number): GPUParticleSystem;
  60914. /**
  60915. * Adds a new angular speed gradient
  60916. * @param gradient defines the gradient to use (between 0 and 1)
  60917. * @param factor defines the angular speed to affect to the specified gradient
  60918. * @returns the current particle system
  60919. */
  60920. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60921. /**
  60922. * Remove a specific angular speed gradient
  60923. * @param gradient defines the gradient to remove
  60924. * @returns the current particle system
  60925. */
  60926. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60927. /**
  60928. * Adds a new velocity gradient
  60929. * @param gradient defines the gradient to use (between 0 and 1)
  60930. * @param factor defines the velocity to affect to the specified gradient
  60931. * @returns the current particle system
  60932. */
  60933. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60934. /**
  60935. * Remove a specific velocity gradient
  60936. * @param gradient defines the gradient to remove
  60937. * @returns the current particle system
  60938. */
  60939. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60940. /**
  60941. * Adds a new limit velocity gradient
  60942. * @param gradient defines the gradient to use (between 0 and 1)
  60943. * @param factor defines the limit velocity value to affect to the specified gradient
  60944. * @returns the current particle system
  60945. */
  60946. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60947. /**
  60948. * Remove a specific limit velocity gradient
  60949. * @param gradient defines the gradient to remove
  60950. * @returns the current particle system
  60951. */
  60952. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60953. /**
  60954. * Adds a new drag gradient
  60955. * @param gradient defines the gradient to use (between 0 and 1)
  60956. * @param factor defines the drag value to affect to the specified gradient
  60957. * @returns the current particle system
  60958. */
  60959. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60960. /**
  60961. * Remove a specific drag gradient
  60962. * @param gradient defines the gradient to remove
  60963. * @returns the current particle system
  60964. */
  60965. removeDragGradient(gradient: number): GPUParticleSystem;
  60966. /**
  60967. * Not supported by GPUParticleSystem
  60968. * @param gradient defines the gradient to use (between 0 and 1)
  60969. * @param factor defines the emit rate value to affect to the specified gradient
  60970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60971. * @returns the current particle system
  60972. */
  60973. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60974. /**
  60975. * Not supported by GPUParticleSystem
  60976. * @param gradient defines the gradient to remove
  60977. * @returns the current particle system
  60978. */
  60979. removeEmitRateGradient(gradient: number): IParticleSystem;
  60980. /**
  60981. * Not supported by GPUParticleSystem
  60982. * @param gradient defines the gradient to use (between 0 and 1)
  60983. * @param factor defines the start size value to affect to the specified gradient
  60984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60985. * @returns the current particle system
  60986. */
  60987. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60988. /**
  60989. * Not supported by GPUParticleSystem
  60990. * @param gradient defines the gradient to remove
  60991. * @returns the current particle system
  60992. */
  60993. removeStartSizeGradient(gradient: number): IParticleSystem;
  60994. /**
  60995. * Not supported by GPUParticleSystem
  60996. * @param gradient defines the gradient to use (between 0 and 1)
  60997. * @param min defines the color remap minimal range
  60998. * @param max defines the color remap maximal range
  60999. * @returns the current particle system
  61000. */
  61001. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61002. /**
  61003. * Not supported by GPUParticleSystem
  61004. * @param gradient defines the gradient to remove
  61005. * @returns the current particle system
  61006. */
  61007. removeColorRemapGradient(): IParticleSystem;
  61008. /**
  61009. * Not supported by GPUParticleSystem
  61010. * @param gradient defines the gradient to use (between 0 and 1)
  61011. * @param min defines the alpha remap minimal range
  61012. * @param max defines the alpha remap maximal range
  61013. * @returns the current particle system
  61014. */
  61015. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61016. /**
  61017. * Not supported by GPUParticleSystem
  61018. * @param gradient defines the gradient to remove
  61019. * @returns the current particle system
  61020. */
  61021. removeAlphaRemapGradient(): IParticleSystem;
  61022. /**
  61023. * Not supported by GPUParticleSystem
  61024. * @param gradient defines the gradient to use (between 0 and 1)
  61025. * @param color defines the color to affect to the specified gradient
  61026. * @returns the current particle system
  61027. */
  61028. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61029. /**
  61030. * Not supported by GPUParticleSystem
  61031. * @param gradient defines the gradient to remove
  61032. * @returns the current particle system
  61033. */
  61034. removeRampGradient(): IParticleSystem;
  61035. /**
  61036. * Not supported by GPUParticleSystem
  61037. * @returns the list of ramp gradients
  61038. */
  61039. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61040. /**
  61041. * Not supported by GPUParticleSystem
  61042. * Gets or sets a boolean indicating that ramp gradients must be used
  61043. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61044. */
  61045. useRampGradients: boolean;
  61046. /**
  61047. * Not supported by GPUParticleSystem
  61048. * @param gradient defines the gradient to use (between 0 and 1)
  61049. * @param factor defines the life time factor to affect to the specified gradient
  61050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61051. * @returns the current particle system
  61052. */
  61053. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61054. /**
  61055. * Not supported by GPUParticleSystem
  61056. * @param gradient defines the gradient to remove
  61057. * @returns the current particle system
  61058. */
  61059. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61060. /**
  61061. * Instantiates a GPU particle system.
  61062. * 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.
  61063. * @param name The name of the particle system
  61064. * @param options The options used to create the system
  61065. * @param scene The scene the particle system belongs to
  61066. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61067. */
  61068. constructor(name: string, options: Partial<{
  61069. capacity: number;
  61070. randomTextureSize: number;
  61071. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61072. protected _reset(): void;
  61073. private _createUpdateVAO;
  61074. private _createRenderVAO;
  61075. private _initialize;
  61076. /** @hidden */
  61077. _recreateUpdateEffect(): void;
  61078. /** @hidden */
  61079. _recreateRenderEffect(): void;
  61080. /**
  61081. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61082. * @param preWarm defines if we are in the pre-warmimg phase
  61083. */
  61084. animate(preWarm?: boolean): void;
  61085. private _createFactorGradientTexture;
  61086. private _createSizeGradientTexture;
  61087. private _createAngularSpeedGradientTexture;
  61088. private _createVelocityGradientTexture;
  61089. private _createLimitVelocityGradientTexture;
  61090. private _createDragGradientTexture;
  61091. private _createColorGradientTexture;
  61092. /**
  61093. * Renders the particle system in its current state
  61094. * @param preWarm defines if the system should only update the particles but not render them
  61095. * @returns the current number of particles
  61096. */
  61097. render(preWarm?: boolean): number;
  61098. /**
  61099. * Rebuilds the particle system
  61100. */
  61101. rebuild(): void;
  61102. private _releaseBuffers;
  61103. private _releaseVAOs;
  61104. /**
  61105. * Disposes the particle system and free the associated resources
  61106. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61107. */
  61108. dispose(disposeTexture?: boolean): void;
  61109. /**
  61110. * Clones the particle system.
  61111. * @param name The name of the cloned object
  61112. * @param newEmitter The new emitter to use
  61113. * @returns the cloned particle system
  61114. */
  61115. clone(name: string, newEmitter: any): GPUParticleSystem;
  61116. /**
  61117. * Serializes the particle system to a JSON object.
  61118. * @returns the JSON object
  61119. */
  61120. serialize(): any;
  61121. /**
  61122. * Parses a JSON object to create a GPU particle system.
  61123. * @param parsedParticleSystem The JSON object to parse
  61124. * @param scene The scene to create the particle system in
  61125. * @param rootUrl The root url to use to load external dependencies like texture
  61126. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61127. * @returns the parsed GPU particle system
  61128. */
  61129. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61130. }
  61131. }
  61132. declare module "babylonjs/Particles/particleSystemSet" {
  61133. import { Nullable } from "babylonjs/types";
  61134. import { Color3 } from "babylonjs/Maths/math.color";
  61135. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61137. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61138. import { Scene, IDisposable } from "babylonjs/scene";
  61139. /**
  61140. * Represents a set of particle systems working together to create a specific effect
  61141. */
  61142. export class ParticleSystemSet implements IDisposable {
  61143. private _emitterCreationOptions;
  61144. private _emitterNode;
  61145. /**
  61146. * Gets the particle system list
  61147. */
  61148. systems: IParticleSystem[];
  61149. /**
  61150. * Gets the emitter node used with this set
  61151. */
  61152. readonly emitterNode: Nullable<TransformNode>;
  61153. /**
  61154. * Creates a new emitter mesh as a sphere
  61155. * @param options defines the options used to create the sphere
  61156. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61157. * @param scene defines the hosting scene
  61158. */
  61159. setEmitterAsSphere(options: {
  61160. diameter: number;
  61161. segments: number;
  61162. color: Color3;
  61163. }, renderingGroupId: number, scene: Scene): void;
  61164. /**
  61165. * Starts all particle systems of the set
  61166. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61167. */
  61168. start(emitter?: AbstractMesh): void;
  61169. /**
  61170. * Release all associated resources
  61171. */
  61172. dispose(): void;
  61173. /**
  61174. * Serialize the set into a JSON compatible object
  61175. * @returns a JSON compatible representation of the set
  61176. */
  61177. serialize(): any;
  61178. /**
  61179. * Parse a new ParticleSystemSet from a serialized source
  61180. * @param data defines a JSON compatible representation of the set
  61181. * @param scene defines the hosting scene
  61182. * @param gpu defines if we want GPU particles or CPU particles
  61183. * @returns a new ParticleSystemSet
  61184. */
  61185. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61186. }
  61187. }
  61188. declare module "babylonjs/Particles/particleHelper" {
  61189. import { Nullable } from "babylonjs/types";
  61190. import { Scene } from "babylonjs/scene";
  61191. import { Vector3 } from "babylonjs/Maths/math.vector";
  61192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61193. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61194. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61195. /**
  61196. * This class is made for on one-liner static method to help creating particle system set.
  61197. */
  61198. export class ParticleHelper {
  61199. /**
  61200. * Gets or sets base Assets URL
  61201. */
  61202. static BaseAssetsUrl: string;
  61203. /**
  61204. * Create a default particle system that you can tweak
  61205. * @param emitter defines the emitter to use
  61206. * @param capacity defines the system capacity (default is 500 particles)
  61207. * @param scene defines the hosting scene
  61208. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61209. * @returns the new Particle system
  61210. */
  61211. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61212. /**
  61213. * This is the main static method (one-liner) of this helper to create different particle systems
  61214. * @param type This string represents the type to the particle system to create
  61215. * @param scene The scene where the particle system should live
  61216. * @param gpu If the system will use gpu
  61217. * @returns the ParticleSystemSet created
  61218. */
  61219. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61220. /**
  61221. * Static function used to export a particle system to a ParticleSystemSet variable.
  61222. * Please note that the emitter shape is not exported
  61223. * @param systems defines the particle systems to export
  61224. * @returns the created particle system set
  61225. */
  61226. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61227. }
  61228. }
  61229. declare module "babylonjs/Particles/particleSystemComponent" {
  61230. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61231. import { Effect } from "babylonjs/Materials/effect";
  61232. import "babylonjs/Shaders/particles.vertex";
  61233. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61234. module "babylonjs/Engines/engine" {
  61235. interface Engine {
  61236. /**
  61237. * Create an effect to use with particle systems.
  61238. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61239. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61240. * @param uniformsNames defines a list of attribute names
  61241. * @param samplers defines an array of string used to represent textures
  61242. * @param defines defines the string containing the defines to use to compile the shaders
  61243. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61244. * @param onCompiled defines a function to call when the effect creation is successful
  61245. * @param onError defines a function to call when the effect creation has failed
  61246. * @returns the new Effect
  61247. */
  61248. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61249. }
  61250. }
  61251. module "babylonjs/Meshes/mesh" {
  61252. interface Mesh {
  61253. /**
  61254. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61255. * @returns an array of IParticleSystem
  61256. */
  61257. getEmittedParticleSystems(): IParticleSystem[];
  61258. /**
  61259. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61260. * @returns an array of IParticleSystem
  61261. */
  61262. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61263. }
  61264. }
  61265. /**
  61266. * @hidden
  61267. */
  61268. export var _IDoNeedToBeInTheBuild: number;
  61269. }
  61270. declare module "babylonjs/Particles/index" {
  61271. export * from "babylonjs/Particles/baseParticleSystem";
  61272. export * from "babylonjs/Particles/EmitterTypes/index";
  61273. export * from "babylonjs/Particles/gpuParticleSystem";
  61274. export * from "babylonjs/Particles/IParticleSystem";
  61275. export * from "babylonjs/Particles/particle";
  61276. export * from "babylonjs/Particles/particleHelper";
  61277. export * from "babylonjs/Particles/particleSystem";
  61278. export * from "babylonjs/Particles/particleSystemComponent";
  61279. export * from "babylonjs/Particles/particleSystemSet";
  61280. export * from "babylonjs/Particles/solidParticle";
  61281. export * from "babylonjs/Particles/solidParticleSystem";
  61282. export * from "babylonjs/Particles/subEmitter";
  61283. }
  61284. declare module "babylonjs/Physics/physicsEngineComponent" {
  61285. import { Nullable } from "babylonjs/types";
  61286. import { Observable, Observer } from "babylonjs/Misc/observable";
  61287. import { Vector3 } from "babylonjs/Maths/math.vector";
  61288. import { Mesh } from "babylonjs/Meshes/mesh";
  61289. import { ISceneComponent } from "babylonjs/sceneComponent";
  61290. import { Scene } from "babylonjs/scene";
  61291. import { Node } from "babylonjs/node";
  61292. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61293. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61294. module "babylonjs/scene" {
  61295. interface Scene {
  61296. /** @hidden (Backing field) */
  61297. _physicsEngine: Nullable<IPhysicsEngine>;
  61298. /**
  61299. * Gets the current physics engine
  61300. * @returns a IPhysicsEngine or null if none attached
  61301. */
  61302. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61303. /**
  61304. * Enables physics to the current scene
  61305. * @param gravity defines the scene's gravity for the physics engine
  61306. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61307. * @return a boolean indicating if the physics engine was initialized
  61308. */
  61309. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61310. /**
  61311. * Disables and disposes the physics engine associated with the scene
  61312. */
  61313. disablePhysicsEngine(): void;
  61314. /**
  61315. * Gets a boolean indicating if there is an active physics engine
  61316. * @returns a boolean indicating if there is an active physics engine
  61317. */
  61318. isPhysicsEnabled(): boolean;
  61319. /**
  61320. * Deletes a physics compound impostor
  61321. * @param compound defines the compound to delete
  61322. */
  61323. deleteCompoundImpostor(compound: any): void;
  61324. /**
  61325. * An event triggered when physic simulation is about to be run
  61326. */
  61327. onBeforePhysicsObservable: Observable<Scene>;
  61328. /**
  61329. * An event triggered when physic simulation has been done
  61330. */
  61331. onAfterPhysicsObservable: Observable<Scene>;
  61332. }
  61333. }
  61334. module "babylonjs/Meshes/abstractMesh" {
  61335. interface AbstractMesh {
  61336. /** @hidden */
  61337. _physicsImpostor: Nullable<PhysicsImpostor>;
  61338. /**
  61339. * Gets or sets impostor used for physic simulation
  61340. * @see http://doc.babylonjs.com/features/physics_engine
  61341. */
  61342. physicsImpostor: Nullable<PhysicsImpostor>;
  61343. /**
  61344. * Gets the current physics impostor
  61345. * @see http://doc.babylonjs.com/features/physics_engine
  61346. * @returns a physics impostor or null
  61347. */
  61348. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61349. /** Apply a physic impulse to the mesh
  61350. * @param force defines the force to apply
  61351. * @param contactPoint defines where to apply the force
  61352. * @returns the current mesh
  61353. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61354. */
  61355. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61356. /**
  61357. * Creates a physic joint between two meshes
  61358. * @param otherMesh defines the other mesh to use
  61359. * @param pivot1 defines the pivot to use on this mesh
  61360. * @param pivot2 defines the pivot to use on the other mesh
  61361. * @param options defines additional options (can be plugin dependent)
  61362. * @returns the current mesh
  61363. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61364. */
  61365. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61366. /** @hidden */
  61367. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61368. }
  61369. }
  61370. /**
  61371. * Defines the physics engine scene component responsible to manage a physics engine
  61372. */
  61373. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61374. /**
  61375. * The component name helpful to identify the component in the list of scene components.
  61376. */
  61377. readonly name: string;
  61378. /**
  61379. * The scene the component belongs to.
  61380. */
  61381. scene: Scene;
  61382. /**
  61383. * Creates a new instance of the component for the given scene
  61384. * @param scene Defines the scene to register the component in
  61385. */
  61386. constructor(scene: Scene);
  61387. /**
  61388. * Registers the component in a given scene
  61389. */
  61390. register(): void;
  61391. /**
  61392. * Rebuilds the elements related to this component in case of
  61393. * context lost for instance.
  61394. */
  61395. rebuild(): void;
  61396. /**
  61397. * Disposes the component and the associated ressources
  61398. */
  61399. dispose(): void;
  61400. }
  61401. }
  61402. declare module "babylonjs/Physics/physicsHelper" {
  61403. import { Nullable } from "babylonjs/types";
  61404. import { Vector3 } from "babylonjs/Maths/math.vector";
  61405. import { Mesh } from "babylonjs/Meshes/mesh";
  61406. import { Scene } from "babylonjs/scene";
  61407. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61408. /**
  61409. * A helper for physics simulations
  61410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61411. */
  61412. export class PhysicsHelper {
  61413. private _scene;
  61414. private _physicsEngine;
  61415. /**
  61416. * Initializes the Physics helper
  61417. * @param scene Babylon.js scene
  61418. */
  61419. constructor(scene: Scene);
  61420. /**
  61421. * Applies a radial explosion impulse
  61422. * @param origin the origin of the explosion
  61423. * @param radiusOrEventOptions the radius or the options of radial explosion
  61424. * @param strength the explosion strength
  61425. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61426. * @returns A physics radial explosion event, or null
  61427. */
  61428. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61429. /**
  61430. * Applies a radial explosion force
  61431. * @param origin the origin of the explosion
  61432. * @param radiusOrEventOptions the radius or the options of radial explosion
  61433. * @param strength the explosion strength
  61434. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61435. * @returns A physics radial explosion event, or null
  61436. */
  61437. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61438. /**
  61439. * Creates a gravitational field
  61440. * @param origin the origin of the explosion
  61441. * @param radiusOrEventOptions the radius or the options of radial explosion
  61442. * @param strength the explosion strength
  61443. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61444. * @returns A physics gravitational field event, or null
  61445. */
  61446. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61447. /**
  61448. * Creates a physics updraft event
  61449. * @param origin the origin of the updraft
  61450. * @param radiusOrEventOptions the radius or the options of the updraft
  61451. * @param strength the strength of the updraft
  61452. * @param height the height of the updraft
  61453. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61454. * @returns A physics updraft event, or null
  61455. */
  61456. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61457. /**
  61458. * Creates a physics vortex event
  61459. * @param origin the of the vortex
  61460. * @param radiusOrEventOptions the radius or the options of the vortex
  61461. * @param strength the strength of the vortex
  61462. * @param height the height of the vortex
  61463. * @returns a Physics vortex event, or null
  61464. * A physics vortex event or null
  61465. */
  61466. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61467. }
  61468. /**
  61469. * Represents a physics radial explosion event
  61470. */
  61471. class PhysicsRadialExplosionEvent {
  61472. private _scene;
  61473. private _options;
  61474. private _sphere;
  61475. private _dataFetched;
  61476. /**
  61477. * Initializes a radial explosioin event
  61478. * @param _scene BabylonJS scene
  61479. * @param _options The options for the vortex event
  61480. */
  61481. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61482. /**
  61483. * Returns the data related to the radial explosion event (sphere).
  61484. * @returns The radial explosion event data
  61485. */
  61486. getData(): PhysicsRadialExplosionEventData;
  61487. /**
  61488. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61489. * @param impostor A physics imposter
  61490. * @param origin the origin of the explosion
  61491. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61492. */
  61493. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61494. /**
  61495. * Triggers affecterd impostors callbacks
  61496. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61497. */
  61498. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61499. /**
  61500. * Disposes the sphere.
  61501. * @param force Specifies if the sphere should be disposed by force
  61502. */
  61503. dispose(force?: boolean): void;
  61504. /*** Helpers ***/
  61505. private _prepareSphere;
  61506. private _intersectsWithSphere;
  61507. }
  61508. /**
  61509. * Represents a gravitational field event
  61510. */
  61511. class PhysicsGravitationalFieldEvent {
  61512. private _physicsHelper;
  61513. private _scene;
  61514. private _origin;
  61515. private _options;
  61516. private _tickCallback;
  61517. private _sphere;
  61518. private _dataFetched;
  61519. /**
  61520. * Initializes the physics gravitational field event
  61521. * @param _physicsHelper A physics helper
  61522. * @param _scene BabylonJS scene
  61523. * @param _origin The origin position of the gravitational field event
  61524. * @param _options The options for the vortex event
  61525. */
  61526. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61527. /**
  61528. * Returns the data related to the gravitational field event (sphere).
  61529. * @returns A gravitational field event
  61530. */
  61531. getData(): PhysicsGravitationalFieldEventData;
  61532. /**
  61533. * Enables the gravitational field.
  61534. */
  61535. enable(): void;
  61536. /**
  61537. * Disables the gravitational field.
  61538. */
  61539. disable(): void;
  61540. /**
  61541. * Disposes the sphere.
  61542. * @param force The force to dispose from the gravitational field event
  61543. */
  61544. dispose(force?: boolean): void;
  61545. private _tick;
  61546. }
  61547. /**
  61548. * Represents a physics updraft event
  61549. */
  61550. class PhysicsUpdraftEvent {
  61551. private _scene;
  61552. private _origin;
  61553. private _options;
  61554. private _physicsEngine;
  61555. private _originTop;
  61556. private _originDirection;
  61557. private _tickCallback;
  61558. private _cylinder;
  61559. private _cylinderPosition;
  61560. private _dataFetched;
  61561. /**
  61562. * Initializes the physics updraft event
  61563. * @param _scene BabylonJS scene
  61564. * @param _origin The origin position of the updraft
  61565. * @param _options The options for the updraft event
  61566. */
  61567. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61568. /**
  61569. * Returns the data related to the updraft event (cylinder).
  61570. * @returns A physics updraft event
  61571. */
  61572. getData(): PhysicsUpdraftEventData;
  61573. /**
  61574. * Enables the updraft.
  61575. */
  61576. enable(): void;
  61577. /**
  61578. * Disables the updraft.
  61579. */
  61580. disable(): void;
  61581. /**
  61582. * Disposes the cylinder.
  61583. * @param force Specifies if the updraft should be disposed by force
  61584. */
  61585. dispose(force?: boolean): void;
  61586. private getImpostorHitData;
  61587. private _tick;
  61588. /*** Helpers ***/
  61589. private _prepareCylinder;
  61590. private _intersectsWithCylinder;
  61591. }
  61592. /**
  61593. * Represents a physics vortex event
  61594. */
  61595. class PhysicsVortexEvent {
  61596. private _scene;
  61597. private _origin;
  61598. private _options;
  61599. private _physicsEngine;
  61600. private _originTop;
  61601. private _tickCallback;
  61602. private _cylinder;
  61603. private _cylinderPosition;
  61604. private _dataFetched;
  61605. /**
  61606. * Initializes the physics vortex event
  61607. * @param _scene The BabylonJS scene
  61608. * @param _origin The origin position of the vortex
  61609. * @param _options The options for the vortex event
  61610. */
  61611. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61612. /**
  61613. * Returns the data related to the vortex event (cylinder).
  61614. * @returns The physics vortex event data
  61615. */
  61616. getData(): PhysicsVortexEventData;
  61617. /**
  61618. * Enables the vortex.
  61619. */
  61620. enable(): void;
  61621. /**
  61622. * Disables the cortex.
  61623. */
  61624. disable(): void;
  61625. /**
  61626. * Disposes the sphere.
  61627. * @param force
  61628. */
  61629. dispose(force?: boolean): void;
  61630. private getImpostorHitData;
  61631. private _tick;
  61632. /*** Helpers ***/
  61633. private _prepareCylinder;
  61634. private _intersectsWithCylinder;
  61635. }
  61636. /**
  61637. * Options fot the radial explosion event
  61638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61639. */
  61640. export class PhysicsRadialExplosionEventOptions {
  61641. /**
  61642. * The radius of the sphere for the radial explosion.
  61643. */
  61644. radius: number;
  61645. /**
  61646. * The strenth of the explosion.
  61647. */
  61648. strength: number;
  61649. /**
  61650. * The strenght of the force in correspondence to the distance of the affected object
  61651. */
  61652. falloff: PhysicsRadialImpulseFalloff;
  61653. /**
  61654. * Sphere options for the radial explosion.
  61655. */
  61656. sphere: {
  61657. segments: number;
  61658. diameter: number;
  61659. };
  61660. /**
  61661. * Sphere options for the radial explosion.
  61662. */
  61663. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61664. }
  61665. /**
  61666. * Options fot the updraft event
  61667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61668. */
  61669. export class PhysicsUpdraftEventOptions {
  61670. /**
  61671. * The radius of the cylinder for the vortex
  61672. */
  61673. radius: number;
  61674. /**
  61675. * The strenth of the updraft.
  61676. */
  61677. strength: number;
  61678. /**
  61679. * The height of the cylinder for the updraft.
  61680. */
  61681. height: number;
  61682. /**
  61683. * The mode for the the updraft.
  61684. */
  61685. updraftMode: PhysicsUpdraftMode;
  61686. }
  61687. /**
  61688. * Options fot the vortex event
  61689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61690. */
  61691. export class PhysicsVortexEventOptions {
  61692. /**
  61693. * The radius of the cylinder for the vortex
  61694. */
  61695. radius: number;
  61696. /**
  61697. * The strenth of the vortex.
  61698. */
  61699. strength: number;
  61700. /**
  61701. * The height of the cylinder for the vortex.
  61702. */
  61703. height: number;
  61704. /**
  61705. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61706. */
  61707. centripetalForceThreshold: number;
  61708. /**
  61709. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61710. */
  61711. centripetalForceMultiplier: number;
  61712. /**
  61713. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61714. */
  61715. centrifugalForceMultiplier: number;
  61716. /**
  61717. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61718. */
  61719. updraftForceMultiplier: number;
  61720. }
  61721. /**
  61722. * The strenght of the force in correspondence to the distance of the affected object
  61723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61724. */
  61725. export enum PhysicsRadialImpulseFalloff {
  61726. /** Defines that impulse is constant in strength across it's whole radius */
  61727. Constant = 0,
  61728. /** Defines that impulse gets weaker if it's further from the origin */
  61729. Linear = 1
  61730. }
  61731. /**
  61732. * The strength of the force in correspondence to the distance of the affected object
  61733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61734. */
  61735. export enum PhysicsUpdraftMode {
  61736. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61737. Center = 0,
  61738. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61739. Perpendicular = 1
  61740. }
  61741. /**
  61742. * Interface for a physics hit data
  61743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61744. */
  61745. export interface PhysicsHitData {
  61746. /**
  61747. * The force applied at the contact point
  61748. */
  61749. force: Vector3;
  61750. /**
  61751. * The contact point
  61752. */
  61753. contactPoint: Vector3;
  61754. /**
  61755. * The distance from the origin to the contact point
  61756. */
  61757. distanceFromOrigin: number;
  61758. }
  61759. /**
  61760. * Interface for radial explosion event data
  61761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61762. */
  61763. export interface PhysicsRadialExplosionEventData {
  61764. /**
  61765. * A sphere used for the radial explosion event
  61766. */
  61767. sphere: Mesh;
  61768. }
  61769. /**
  61770. * Interface for gravitational field event data
  61771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61772. */
  61773. export interface PhysicsGravitationalFieldEventData {
  61774. /**
  61775. * A sphere mesh used for the gravitational field event
  61776. */
  61777. sphere: Mesh;
  61778. }
  61779. /**
  61780. * Interface for updraft event data
  61781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61782. */
  61783. export interface PhysicsUpdraftEventData {
  61784. /**
  61785. * A cylinder used for the updraft event
  61786. */
  61787. cylinder: Mesh;
  61788. }
  61789. /**
  61790. * Interface for vortex event data
  61791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61792. */
  61793. export interface PhysicsVortexEventData {
  61794. /**
  61795. * A cylinder used for the vortex event
  61796. */
  61797. cylinder: Mesh;
  61798. }
  61799. /**
  61800. * Interface for an affected physics impostor
  61801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61802. */
  61803. export interface PhysicsAffectedImpostorWithData {
  61804. /**
  61805. * The impostor affected by the effect
  61806. */
  61807. impostor: PhysicsImpostor;
  61808. /**
  61809. * The data about the hit/horce from the explosion
  61810. */
  61811. hitData: PhysicsHitData;
  61812. }
  61813. }
  61814. declare module "babylonjs/Physics/Plugins/index" {
  61815. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61816. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61817. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61818. }
  61819. declare module "babylonjs/Physics/index" {
  61820. export * from "babylonjs/Physics/IPhysicsEngine";
  61821. export * from "babylonjs/Physics/physicsEngine";
  61822. export * from "babylonjs/Physics/physicsEngineComponent";
  61823. export * from "babylonjs/Physics/physicsHelper";
  61824. export * from "babylonjs/Physics/physicsImpostor";
  61825. export * from "babylonjs/Physics/physicsJoint";
  61826. export * from "babylonjs/Physics/Plugins/index";
  61827. }
  61828. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61829. /** @hidden */
  61830. export var blackAndWhitePixelShader: {
  61831. name: string;
  61832. shader: string;
  61833. };
  61834. }
  61835. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61837. import { Camera } from "babylonjs/Cameras/camera";
  61838. import { Engine } from "babylonjs/Engines/engine";
  61839. import "babylonjs/Shaders/blackAndWhite.fragment";
  61840. /**
  61841. * Post process used to render in black and white
  61842. */
  61843. export class BlackAndWhitePostProcess extends PostProcess {
  61844. /**
  61845. * Linear about to convert he result to black and white (default: 1)
  61846. */
  61847. degree: number;
  61848. /**
  61849. * Creates a black and white post process
  61850. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61851. * @param name The name of the effect.
  61852. * @param options The required width/height ratio to downsize to before computing the render pass.
  61853. * @param camera The camera to apply the render pass to.
  61854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61855. * @param engine The engine which the post process will be applied. (default: current engine)
  61856. * @param reusable If the post process can be reused on the same frame. (default: false)
  61857. */
  61858. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61859. }
  61860. }
  61861. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61862. import { Nullable } from "babylonjs/types";
  61863. import { Camera } from "babylonjs/Cameras/camera";
  61864. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61865. import { Engine } from "babylonjs/Engines/engine";
  61866. /**
  61867. * This represents a set of one or more post processes in Babylon.
  61868. * A post process can be used to apply a shader to a texture after it is rendered.
  61869. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61870. */
  61871. export class PostProcessRenderEffect {
  61872. private _postProcesses;
  61873. private _getPostProcesses;
  61874. private _singleInstance;
  61875. private _cameras;
  61876. private _indicesForCamera;
  61877. /**
  61878. * Name of the effect
  61879. * @hidden
  61880. */
  61881. _name: string;
  61882. /**
  61883. * Instantiates a post process render effect.
  61884. * A post process can be used to apply a shader to a texture after it is rendered.
  61885. * @param engine The engine the effect is tied to
  61886. * @param name The name of the effect
  61887. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61888. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61889. */
  61890. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61891. /**
  61892. * Checks if all the post processes in the effect are supported.
  61893. */
  61894. readonly isSupported: boolean;
  61895. /**
  61896. * Updates the current state of the effect
  61897. * @hidden
  61898. */
  61899. _update(): void;
  61900. /**
  61901. * Attaches the effect on cameras
  61902. * @param cameras The camera to attach to.
  61903. * @hidden
  61904. */
  61905. _attachCameras(cameras: Camera): void;
  61906. /**
  61907. * Attaches the effect on cameras
  61908. * @param cameras The camera to attach to.
  61909. * @hidden
  61910. */
  61911. _attachCameras(cameras: Camera[]): void;
  61912. /**
  61913. * Detaches the effect on cameras
  61914. * @param cameras The camera to detatch from.
  61915. * @hidden
  61916. */
  61917. _detachCameras(cameras: Camera): void;
  61918. /**
  61919. * Detatches the effect on cameras
  61920. * @param cameras The camera to detatch from.
  61921. * @hidden
  61922. */
  61923. _detachCameras(cameras: Camera[]): void;
  61924. /**
  61925. * Enables the effect on given cameras
  61926. * @param cameras The camera to enable.
  61927. * @hidden
  61928. */
  61929. _enable(cameras: Camera): void;
  61930. /**
  61931. * Enables the effect on given cameras
  61932. * @param cameras The camera to enable.
  61933. * @hidden
  61934. */
  61935. _enable(cameras: Nullable<Camera[]>): void;
  61936. /**
  61937. * Disables the effect on the given cameras
  61938. * @param cameras The camera to disable.
  61939. * @hidden
  61940. */
  61941. _disable(cameras: Camera): void;
  61942. /**
  61943. * Disables the effect on the given cameras
  61944. * @param cameras The camera to disable.
  61945. * @hidden
  61946. */
  61947. _disable(cameras: Nullable<Camera[]>): void;
  61948. /**
  61949. * Gets a list of the post processes contained in the effect.
  61950. * @param camera The camera to get the post processes on.
  61951. * @returns The list of the post processes in the effect.
  61952. */
  61953. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61954. }
  61955. }
  61956. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61957. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61958. /** @hidden */
  61959. export var extractHighlightsPixelShader: {
  61960. name: string;
  61961. shader: string;
  61962. };
  61963. }
  61964. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61965. import { Nullable } from "babylonjs/types";
  61966. import { Camera } from "babylonjs/Cameras/camera";
  61967. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61968. import { Engine } from "babylonjs/Engines/engine";
  61969. import "babylonjs/Shaders/extractHighlights.fragment";
  61970. /**
  61971. * 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.
  61972. */
  61973. export class ExtractHighlightsPostProcess extends PostProcess {
  61974. /**
  61975. * The luminance threshold, pixels below this value will be set to black.
  61976. */
  61977. threshold: number;
  61978. /** @hidden */
  61979. _exposure: number;
  61980. /**
  61981. * Post process which has the input texture to be used when performing highlight extraction
  61982. * @hidden
  61983. */
  61984. _inputPostProcess: Nullable<PostProcess>;
  61985. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61986. }
  61987. }
  61988. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61989. /** @hidden */
  61990. export var bloomMergePixelShader: {
  61991. name: string;
  61992. shader: string;
  61993. };
  61994. }
  61995. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61996. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61997. import { Nullable } from "babylonjs/types";
  61998. import { Engine } from "babylonjs/Engines/engine";
  61999. import { Camera } from "babylonjs/Cameras/camera";
  62000. import "babylonjs/Shaders/bloomMerge.fragment";
  62001. /**
  62002. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62003. */
  62004. export class BloomMergePostProcess extends PostProcess {
  62005. /** Weight of the bloom to be added to the original input. */
  62006. weight: number;
  62007. /**
  62008. * Creates a new instance of @see BloomMergePostProcess
  62009. * @param name The name of the effect.
  62010. * @param originalFromInput Post process which's input will be used for the merge.
  62011. * @param blurred Blurred highlights post process which's output will be used.
  62012. * @param weight Weight of the bloom to be added to the original input.
  62013. * @param options The required width/height ratio to downsize to before computing the render pass.
  62014. * @param camera The camera to apply the render pass to.
  62015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62016. * @param engine The engine which the post process will be applied. (default: current engine)
  62017. * @param reusable If the post process can be reused on the same frame. (default: false)
  62018. * @param textureType Type of textures used when performing the post process. (default: 0)
  62019. * @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)
  62020. */
  62021. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62022. /** Weight of the bloom to be added to the original input. */
  62023. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62024. }
  62025. }
  62026. declare module "babylonjs/PostProcesses/bloomEffect" {
  62027. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62028. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62029. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62030. import { Camera } from "babylonjs/Cameras/camera";
  62031. import { Scene } from "babylonjs/scene";
  62032. /**
  62033. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62034. */
  62035. export class BloomEffect extends PostProcessRenderEffect {
  62036. private bloomScale;
  62037. /**
  62038. * @hidden Internal
  62039. */
  62040. _effects: Array<PostProcess>;
  62041. /**
  62042. * @hidden Internal
  62043. */
  62044. _downscale: ExtractHighlightsPostProcess;
  62045. private _blurX;
  62046. private _blurY;
  62047. private _merge;
  62048. /**
  62049. * The luminance threshold to find bright areas of the image to bloom.
  62050. */
  62051. threshold: number;
  62052. /**
  62053. * The strength of the bloom.
  62054. */
  62055. weight: number;
  62056. /**
  62057. * Specifies the size of the bloom blur kernel, relative to the final output size
  62058. */
  62059. kernel: number;
  62060. /**
  62061. * Creates a new instance of @see BloomEffect
  62062. * @param scene The scene the effect belongs to.
  62063. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62064. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62065. * @param bloomWeight The the strength of bloom.
  62066. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62067. * @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)
  62068. */
  62069. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62070. /**
  62071. * Disposes each of the internal effects for a given camera.
  62072. * @param camera The camera to dispose the effect on.
  62073. */
  62074. disposeEffects(camera: Camera): void;
  62075. /**
  62076. * @hidden Internal
  62077. */
  62078. _updateEffects(): void;
  62079. /**
  62080. * Internal
  62081. * @returns if all the contained post processes are ready.
  62082. * @hidden
  62083. */
  62084. _isReady(): boolean;
  62085. }
  62086. }
  62087. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62088. /** @hidden */
  62089. export var chromaticAberrationPixelShader: {
  62090. name: string;
  62091. shader: string;
  62092. };
  62093. }
  62094. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62095. import { Vector2 } from "babylonjs/Maths/math.vector";
  62096. import { Nullable } from "babylonjs/types";
  62097. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62098. import { Camera } from "babylonjs/Cameras/camera";
  62099. import { Engine } from "babylonjs/Engines/engine";
  62100. import "babylonjs/Shaders/chromaticAberration.fragment";
  62101. /**
  62102. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62103. */
  62104. export class ChromaticAberrationPostProcess extends PostProcess {
  62105. /**
  62106. * The amount of seperation of rgb channels (default: 30)
  62107. */
  62108. aberrationAmount: number;
  62109. /**
  62110. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62111. */
  62112. radialIntensity: number;
  62113. /**
  62114. * 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))
  62115. */
  62116. direction: Vector2;
  62117. /**
  62118. * 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))
  62119. */
  62120. centerPosition: Vector2;
  62121. /**
  62122. * Creates a new instance ChromaticAberrationPostProcess
  62123. * @param name The name of the effect.
  62124. * @param screenWidth The width of the screen to apply the effect on.
  62125. * @param screenHeight The height of the screen to apply the effect on.
  62126. * @param options The required width/height ratio to downsize to before computing the render pass.
  62127. * @param camera The camera to apply the render pass to.
  62128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62129. * @param engine The engine which the post process will be applied. (default: current engine)
  62130. * @param reusable If the post process can be reused on the same frame. (default: false)
  62131. * @param textureType Type of textures used when performing the post process. (default: 0)
  62132. * @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)
  62133. */
  62134. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62135. }
  62136. }
  62137. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62138. /** @hidden */
  62139. export var circleOfConfusionPixelShader: {
  62140. name: string;
  62141. shader: string;
  62142. };
  62143. }
  62144. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62145. import { Nullable } from "babylonjs/types";
  62146. import { Engine } from "babylonjs/Engines/engine";
  62147. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62148. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62149. import { Camera } from "babylonjs/Cameras/camera";
  62150. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62151. /**
  62152. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62153. */
  62154. export class CircleOfConfusionPostProcess extends PostProcess {
  62155. /**
  62156. * 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.
  62157. */
  62158. lensSize: number;
  62159. /**
  62160. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62161. */
  62162. fStop: number;
  62163. /**
  62164. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62165. */
  62166. focusDistance: number;
  62167. /**
  62168. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62169. */
  62170. focalLength: number;
  62171. private _depthTexture;
  62172. /**
  62173. * Creates a new instance CircleOfConfusionPostProcess
  62174. * @param name The name of the effect.
  62175. * @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.
  62176. * @param options The required width/height ratio to downsize to before computing the render pass.
  62177. * @param camera The camera to apply the render pass to.
  62178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62179. * @param engine The engine which the post process will be applied. (default: current engine)
  62180. * @param reusable If the post process can be reused on the same frame. (default: false)
  62181. * @param textureType Type of textures used when performing the post process. (default: 0)
  62182. * @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)
  62183. */
  62184. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62185. /**
  62186. * 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.
  62187. */
  62188. depthTexture: RenderTargetTexture;
  62189. }
  62190. }
  62191. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62192. /** @hidden */
  62193. export var colorCorrectionPixelShader: {
  62194. name: string;
  62195. shader: string;
  62196. };
  62197. }
  62198. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62199. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62200. import { Engine } from "babylonjs/Engines/engine";
  62201. import { Camera } from "babylonjs/Cameras/camera";
  62202. import "babylonjs/Shaders/colorCorrection.fragment";
  62203. /**
  62204. *
  62205. * This post-process allows the modification of rendered colors by using
  62206. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62207. *
  62208. * The object needs to be provided an url to a texture containing the color
  62209. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62210. * Use an image editing software to tweak the LUT to match your needs.
  62211. *
  62212. * For an example of a color LUT, see here:
  62213. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62214. * For explanations on color grading, see here:
  62215. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62216. *
  62217. */
  62218. export class ColorCorrectionPostProcess extends PostProcess {
  62219. private _colorTableTexture;
  62220. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62221. }
  62222. }
  62223. declare module "babylonjs/Shaders/convolution.fragment" {
  62224. /** @hidden */
  62225. export var convolutionPixelShader: {
  62226. name: string;
  62227. shader: string;
  62228. };
  62229. }
  62230. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62231. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62232. import { Nullable } from "babylonjs/types";
  62233. import { Camera } from "babylonjs/Cameras/camera";
  62234. import { Engine } from "babylonjs/Engines/engine";
  62235. import "babylonjs/Shaders/convolution.fragment";
  62236. /**
  62237. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62238. * input texture to perform effects such as edge detection or sharpening
  62239. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62240. */
  62241. export class ConvolutionPostProcess extends PostProcess {
  62242. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62243. kernel: number[];
  62244. /**
  62245. * Creates a new instance ConvolutionPostProcess
  62246. * @param name The name of the effect.
  62247. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62248. * @param options The required width/height ratio to downsize to before computing the render pass.
  62249. * @param camera The camera to apply the render pass to.
  62250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62251. * @param engine The engine which the post process will be applied. (default: current engine)
  62252. * @param reusable If the post process can be reused on the same frame. (default: false)
  62253. * @param textureType Type of textures used when performing the post process. (default: 0)
  62254. */
  62255. constructor(name: string,
  62256. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62257. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62258. /**
  62259. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62260. */
  62261. static EdgeDetect0Kernel: number[];
  62262. /**
  62263. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62264. */
  62265. static EdgeDetect1Kernel: number[];
  62266. /**
  62267. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62268. */
  62269. static EdgeDetect2Kernel: number[];
  62270. /**
  62271. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62272. */
  62273. static SharpenKernel: number[];
  62274. /**
  62275. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62276. */
  62277. static EmbossKernel: number[];
  62278. /**
  62279. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62280. */
  62281. static GaussianKernel: number[];
  62282. }
  62283. }
  62284. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62285. import { Nullable } from "babylonjs/types";
  62286. import { Vector2 } from "babylonjs/Maths/math.vector";
  62287. import { Camera } from "babylonjs/Cameras/camera";
  62288. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62289. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62290. import { Engine } from "babylonjs/Engines/engine";
  62291. import { Scene } from "babylonjs/scene";
  62292. /**
  62293. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62294. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62295. * based on samples that have a large difference in distance than the center pixel.
  62296. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62297. */
  62298. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62299. direction: Vector2;
  62300. /**
  62301. * Creates a new instance CircleOfConfusionPostProcess
  62302. * @param name The name of the effect.
  62303. * @param scene The scene the effect belongs to.
  62304. * @param direction The direction the blur should be applied.
  62305. * @param kernel The size of the kernel used to blur.
  62306. * @param options The required width/height ratio to downsize to before computing the render pass.
  62307. * @param camera The camera to apply the render pass to.
  62308. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62309. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62311. * @param engine The engine which the post process will be applied. (default: current engine)
  62312. * @param reusable If the post process can be reused on the same frame. (default: false)
  62313. * @param textureType Type of textures used when performing the post process. (default: 0)
  62314. * @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)
  62315. */
  62316. 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);
  62317. }
  62318. }
  62319. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62320. /** @hidden */
  62321. export var depthOfFieldMergePixelShader: {
  62322. name: string;
  62323. shader: string;
  62324. };
  62325. }
  62326. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62327. import { Nullable } from "babylonjs/types";
  62328. import { Camera } from "babylonjs/Cameras/camera";
  62329. import { Effect } from "babylonjs/Materials/effect";
  62330. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62331. import { Engine } from "babylonjs/Engines/engine";
  62332. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62333. /**
  62334. * Options to be set when merging outputs from the default pipeline.
  62335. */
  62336. export class DepthOfFieldMergePostProcessOptions {
  62337. /**
  62338. * The original image to merge on top of
  62339. */
  62340. originalFromInput: PostProcess;
  62341. /**
  62342. * Parameters to perform the merge of the depth of field effect
  62343. */
  62344. depthOfField?: {
  62345. circleOfConfusion: PostProcess;
  62346. blurSteps: Array<PostProcess>;
  62347. };
  62348. /**
  62349. * Parameters to perform the merge of bloom effect
  62350. */
  62351. bloom?: {
  62352. blurred: PostProcess;
  62353. weight: number;
  62354. };
  62355. }
  62356. /**
  62357. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62358. */
  62359. export class DepthOfFieldMergePostProcess extends PostProcess {
  62360. private blurSteps;
  62361. /**
  62362. * Creates a new instance of DepthOfFieldMergePostProcess
  62363. * @param name The name of the effect.
  62364. * @param originalFromInput Post process which's input will be used for the merge.
  62365. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62366. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62367. * @param options The required width/height ratio to downsize to before computing the render pass.
  62368. * @param camera The camera to apply the render pass to.
  62369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62370. * @param engine The engine which the post process will be applied. (default: current engine)
  62371. * @param reusable If the post process can be reused on the same frame. (default: false)
  62372. * @param textureType Type of textures used when performing the post process. (default: 0)
  62373. * @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)
  62374. */
  62375. 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);
  62376. /**
  62377. * Updates the effect with the current post process compile time values and recompiles the shader.
  62378. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62379. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62380. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62381. * @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
  62382. * @param onCompiled Called when the shader has been compiled.
  62383. * @param onError Called if there is an error when compiling a shader.
  62384. */
  62385. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62386. }
  62387. }
  62388. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62389. import { Nullable } from "babylonjs/types";
  62390. import { Camera } from "babylonjs/Cameras/camera";
  62391. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62392. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62393. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62394. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62395. import { Scene } from "babylonjs/scene";
  62396. /**
  62397. * Specifies the level of max blur that should be applied when using the depth of field effect
  62398. */
  62399. export enum DepthOfFieldEffectBlurLevel {
  62400. /**
  62401. * Subtle blur
  62402. */
  62403. Low = 0,
  62404. /**
  62405. * Medium blur
  62406. */
  62407. Medium = 1,
  62408. /**
  62409. * Large blur
  62410. */
  62411. High = 2
  62412. }
  62413. /**
  62414. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62415. */
  62416. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62417. private _circleOfConfusion;
  62418. /**
  62419. * @hidden Internal, blurs from high to low
  62420. */
  62421. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62422. private _depthOfFieldBlurY;
  62423. private _dofMerge;
  62424. /**
  62425. * @hidden Internal post processes in depth of field effect
  62426. */
  62427. _effects: Array<PostProcess>;
  62428. /**
  62429. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62430. */
  62431. focalLength: number;
  62432. /**
  62433. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62434. */
  62435. fStop: number;
  62436. /**
  62437. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62438. */
  62439. focusDistance: number;
  62440. /**
  62441. * 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.
  62442. */
  62443. lensSize: number;
  62444. /**
  62445. * Creates a new instance DepthOfFieldEffect
  62446. * @param scene The scene the effect belongs to.
  62447. * @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.
  62448. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62449. * @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)
  62450. */
  62451. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62452. /**
  62453. * Get the current class name of the current effet
  62454. * @returns "DepthOfFieldEffect"
  62455. */
  62456. getClassName(): string;
  62457. /**
  62458. * 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.
  62459. */
  62460. depthTexture: RenderTargetTexture;
  62461. /**
  62462. * Disposes each of the internal effects for a given camera.
  62463. * @param camera The camera to dispose the effect on.
  62464. */
  62465. disposeEffects(camera: Camera): void;
  62466. /**
  62467. * @hidden Internal
  62468. */
  62469. _updateEffects(): void;
  62470. /**
  62471. * Internal
  62472. * @returns if all the contained post processes are ready.
  62473. * @hidden
  62474. */
  62475. _isReady(): boolean;
  62476. }
  62477. }
  62478. declare module "babylonjs/Shaders/displayPass.fragment" {
  62479. /** @hidden */
  62480. export var displayPassPixelShader: {
  62481. name: string;
  62482. shader: string;
  62483. };
  62484. }
  62485. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62486. import { Nullable } from "babylonjs/types";
  62487. import { Camera } from "babylonjs/Cameras/camera";
  62488. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62489. import { Engine } from "babylonjs/Engines/engine";
  62490. import "babylonjs/Shaders/displayPass.fragment";
  62491. /**
  62492. * DisplayPassPostProcess which produces an output the same as it's input
  62493. */
  62494. export class DisplayPassPostProcess extends PostProcess {
  62495. /**
  62496. * Creates the DisplayPassPostProcess
  62497. * @param name The name of the effect.
  62498. * @param options The required width/height ratio to downsize to before computing the render pass.
  62499. * @param camera The camera to apply the render pass to.
  62500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62501. * @param engine The engine which the post process will be applied. (default: current engine)
  62502. * @param reusable If the post process can be reused on the same frame. (default: false)
  62503. */
  62504. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62505. }
  62506. }
  62507. declare module "babylonjs/Shaders/filter.fragment" {
  62508. /** @hidden */
  62509. export var filterPixelShader: {
  62510. name: string;
  62511. shader: string;
  62512. };
  62513. }
  62514. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62515. import { Nullable } from "babylonjs/types";
  62516. import { Matrix } from "babylonjs/Maths/math.vector";
  62517. import { Camera } from "babylonjs/Cameras/camera";
  62518. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62519. import { Engine } from "babylonjs/Engines/engine";
  62520. import "babylonjs/Shaders/filter.fragment";
  62521. /**
  62522. * Applies a kernel filter to the image
  62523. */
  62524. export class FilterPostProcess extends PostProcess {
  62525. /** The matrix to be applied to the image */
  62526. kernelMatrix: Matrix;
  62527. /**
  62528. *
  62529. * @param name The name of the effect.
  62530. * @param kernelMatrix The matrix to be applied to the image
  62531. * @param options The required width/height ratio to downsize to before computing the render pass.
  62532. * @param camera The camera to apply the render pass to.
  62533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62534. * @param engine The engine which the post process will be applied. (default: current engine)
  62535. * @param reusable If the post process can be reused on the same frame. (default: false)
  62536. */
  62537. constructor(name: string,
  62538. /** The matrix to be applied to the image */
  62539. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62540. }
  62541. }
  62542. declare module "babylonjs/Shaders/fxaa.fragment" {
  62543. /** @hidden */
  62544. export var fxaaPixelShader: {
  62545. name: string;
  62546. shader: string;
  62547. };
  62548. }
  62549. declare module "babylonjs/Shaders/fxaa.vertex" {
  62550. /** @hidden */
  62551. export var fxaaVertexShader: {
  62552. name: string;
  62553. shader: string;
  62554. };
  62555. }
  62556. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62557. import { Nullable } from "babylonjs/types";
  62558. import { Camera } from "babylonjs/Cameras/camera";
  62559. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62560. import { Engine } from "babylonjs/Engines/engine";
  62561. import "babylonjs/Shaders/fxaa.fragment";
  62562. import "babylonjs/Shaders/fxaa.vertex";
  62563. /**
  62564. * Fxaa post process
  62565. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62566. */
  62567. export class FxaaPostProcess extends PostProcess {
  62568. /** @hidden */
  62569. texelWidth: number;
  62570. /** @hidden */
  62571. texelHeight: number;
  62572. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62573. private _getDefines;
  62574. }
  62575. }
  62576. declare module "babylonjs/Shaders/grain.fragment" {
  62577. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62578. /** @hidden */
  62579. export var grainPixelShader: {
  62580. name: string;
  62581. shader: string;
  62582. };
  62583. }
  62584. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62585. import { Nullable } from "babylonjs/types";
  62586. import { Camera } from "babylonjs/Cameras/camera";
  62587. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62588. import { Engine } from "babylonjs/Engines/engine";
  62589. import "babylonjs/Shaders/grain.fragment";
  62590. /**
  62591. * The GrainPostProcess adds noise to the image at mid luminance levels
  62592. */
  62593. export class GrainPostProcess extends PostProcess {
  62594. /**
  62595. * The intensity of the grain added (default: 30)
  62596. */
  62597. intensity: number;
  62598. /**
  62599. * If the grain should be randomized on every frame
  62600. */
  62601. animated: boolean;
  62602. /**
  62603. * Creates a new instance of @see GrainPostProcess
  62604. * @param name The name of the effect.
  62605. * @param options The required width/height ratio to downsize to before computing the render pass.
  62606. * @param camera The camera to apply the render pass to.
  62607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62608. * @param engine The engine which the post process will be applied. (default: current engine)
  62609. * @param reusable If the post process can be reused on the same frame. (default: false)
  62610. * @param textureType Type of textures used when performing the post process. (default: 0)
  62611. * @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)
  62612. */
  62613. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62614. }
  62615. }
  62616. declare module "babylonjs/Shaders/highlights.fragment" {
  62617. /** @hidden */
  62618. export var highlightsPixelShader: {
  62619. name: string;
  62620. shader: string;
  62621. };
  62622. }
  62623. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62624. import { Nullable } from "babylonjs/types";
  62625. import { Camera } from "babylonjs/Cameras/camera";
  62626. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62627. import { Engine } from "babylonjs/Engines/engine";
  62628. import "babylonjs/Shaders/highlights.fragment";
  62629. /**
  62630. * Extracts highlights from the image
  62631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62632. */
  62633. export class HighlightsPostProcess extends PostProcess {
  62634. /**
  62635. * Extracts highlights from the image
  62636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62637. * @param name The name of the effect.
  62638. * @param options The required width/height ratio to downsize to before computing the render pass.
  62639. * @param camera The camera to apply the render pass to.
  62640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62641. * @param engine The engine which the post process will be applied. (default: current engine)
  62642. * @param reusable If the post process can be reused on the same frame. (default: false)
  62643. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62644. */
  62645. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62646. }
  62647. }
  62648. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62649. /** @hidden */
  62650. export var mrtFragmentDeclaration: {
  62651. name: string;
  62652. shader: string;
  62653. };
  62654. }
  62655. declare module "babylonjs/Shaders/geometry.fragment" {
  62656. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62657. /** @hidden */
  62658. export var geometryPixelShader: {
  62659. name: string;
  62660. shader: string;
  62661. };
  62662. }
  62663. declare module "babylonjs/Shaders/geometry.vertex" {
  62664. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62665. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62666. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62667. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62668. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62669. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62670. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62671. /** @hidden */
  62672. export var geometryVertexShader: {
  62673. name: string;
  62674. shader: string;
  62675. };
  62676. }
  62677. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62678. import { Matrix } from "babylonjs/Maths/math.vector";
  62679. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62680. import { Mesh } from "babylonjs/Meshes/mesh";
  62681. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62682. import { Effect } from "babylonjs/Materials/effect";
  62683. import { Scene } from "babylonjs/scene";
  62684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62685. import "babylonjs/Shaders/geometry.fragment";
  62686. import "babylonjs/Shaders/geometry.vertex";
  62687. /** @hidden */
  62688. interface ISavedTransformationMatrix {
  62689. world: Matrix;
  62690. viewProjection: Matrix;
  62691. }
  62692. /**
  62693. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62694. */
  62695. export class GeometryBufferRenderer {
  62696. /**
  62697. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62698. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62699. */
  62700. static readonly POSITION_TEXTURE_TYPE: number;
  62701. /**
  62702. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62703. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62704. */
  62705. static readonly VELOCITY_TEXTURE_TYPE: number;
  62706. /**
  62707. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62708. * in order to compute objects velocities when enableVelocity is set to "true"
  62709. * @hidden
  62710. */
  62711. _previousTransformationMatrices: {
  62712. [index: number]: ISavedTransformationMatrix;
  62713. };
  62714. /**
  62715. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62716. * in order to compute objects velocities when enableVelocity is set to "true"
  62717. * @hidden
  62718. */
  62719. _previousBonesTransformationMatrices: {
  62720. [index: number]: Float32Array;
  62721. };
  62722. /**
  62723. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62724. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62725. */
  62726. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62727. private _scene;
  62728. private _multiRenderTarget;
  62729. private _ratio;
  62730. private _enablePosition;
  62731. private _enableVelocity;
  62732. private _positionIndex;
  62733. private _velocityIndex;
  62734. protected _effect: Effect;
  62735. protected _cachedDefines: string;
  62736. /**
  62737. * Set the render list (meshes to be rendered) used in the G buffer.
  62738. */
  62739. renderList: Mesh[];
  62740. /**
  62741. * Gets wether or not G buffer are supported by the running hardware.
  62742. * This requires draw buffer supports
  62743. */
  62744. readonly isSupported: boolean;
  62745. /**
  62746. * Returns the index of the given texture type in the G-Buffer textures array
  62747. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62748. * @returns the index of the given texture type in the G-Buffer textures array
  62749. */
  62750. getTextureIndex(textureType: number): number;
  62751. /**
  62752. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62753. */
  62754. /**
  62755. * Sets whether or not objects positions are enabled for the G buffer.
  62756. */
  62757. enablePosition: boolean;
  62758. /**
  62759. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62760. */
  62761. /**
  62762. * Sets wether or not objects velocities are enabled for the G buffer.
  62763. */
  62764. enableVelocity: boolean;
  62765. /**
  62766. * Gets the scene associated with the buffer.
  62767. */
  62768. readonly scene: Scene;
  62769. /**
  62770. * Gets the ratio used by the buffer during its creation.
  62771. * How big is the buffer related to the main canvas.
  62772. */
  62773. readonly ratio: number;
  62774. /** @hidden */
  62775. static _SceneComponentInitialization: (scene: Scene) => void;
  62776. /**
  62777. * Creates a new G Buffer for the scene
  62778. * @param scene The scene the buffer belongs to
  62779. * @param ratio How big is the buffer related to the main canvas.
  62780. */
  62781. constructor(scene: Scene, ratio?: number);
  62782. /**
  62783. * Checks wether everything is ready to render a submesh to the G buffer.
  62784. * @param subMesh the submesh to check readiness for
  62785. * @param useInstances is the mesh drawn using instance or not
  62786. * @returns true if ready otherwise false
  62787. */
  62788. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62789. /**
  62790. * Gets the current underlying G Buffer.
  62791. * @returns the buffer
  62792. */
  62793. getGBuffer(): MultiRenderTarget;
  62794. /**
  62795. * Gets the number of samples used to render the buffer (anti aliasing).
  62796. */
  62797. /**
  62798. * Sets the number of samples used to render the buffer (anti aliasing).
  62799. */
  62800. samples: number;
  62801. /**
  62802. * Disposes the renderer and frees up associated resources.
  62803. */
  62804. dispose(): void;
  62805. protected _createRenderTargets(): void;
  62806. private _copyBonesTransformationMatrices;
  62807. }
  62808. }
  62809. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62810. import { Nullable } from "babylonjs/types";
  62811. import { Scene } from "babylonjs/scene";
  62812. import { ISceneComponent } from "babylonjs/sceneComponent";
  62813. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62814. module "babylonjs/scene" {
  62815. interface Scene {
  62816. /** @hidden (Backing field) */
  62817. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62818. /**
  62819. * Gets or Sets the current geometry buffer associated to the scene.
  62820. */
  62821. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62822. /**
  62823. * Enables a GeometryBufferRender and associates it with the scene
  62824. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62825. * @returns the GeometryBufferRenderer
  62826. */
  62827. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62828. /**
  62829. * Disables the GeometryBufferRender associated with the scene
  62830. */
  62831. disableGeometryBufferRenderer(): void;
  62832. }
  62833. }
  62834. /**
  62835. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62836. * in several rendering techniques.
  62837. */
  62838. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62839. /**
  62840. * The component name helpful to identify the component in the list of scene components.
  62841. */
  62842. readonly name: string;
  62843. /**
  62844. * The scene the component belongs to.
  62845. */
  62846. scene: Scene;
  62847. /**
  62848. * Creates a new instance of the component for the given scene
  62849. * @param scene Defines the scene to register the component in
  62850. */
  62851. constructor(scene: Scene);
  62852. /**
  62853. * Registers the component in a given scene
  62854. */
  62855. register(): void;
  62856. /**
  62857. * Rebuilds the elements related to this component in case of
  62858. * context lost for instance.
  62859. */
  62860. rebuild(): void;
  62861. /**
  62862. * Disposes the component and the associated ressources
  62863. */
  62864. dispose(): void;
  62865. private _gatherRenderTargets;
  62866. }
  62867. }
  62868. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62869. /** @hidden */
  62870. export var motionBlurPixelShader: {
  62871. name: string;
  62872. shader: string;
  62873. };
  62874. }
  62875. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62876. import { Nullable } from "babylonjs/types";
  62877. import { Camera } from "babylonjs/Cameras/camera";
  62878. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62879. import { Scene } from "babylonjs/scene";
  62880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62881. import "babylonjs/Animations/animatable";
  62882. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62883. import "babylonjs/Shaders/motionBlur.fragment";
  62884. import { Engine } from "babylonjs/Engines/engine";
  62885. /**
  62886. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62887. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62888. * As an example, all you have to do is to create the post-process:
  62889. * var mb = new BABYLON.MotionBlurPostProcess(
  62890. * 'mb', // The name of the effect.
  62891. * scene, // The scene containing the objects to blur according to their velocity.
  62892. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62893. * camera // The camera to apply the render pass to.
  62894. * );
  62895. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62896. */
  62897. export class MotionBlurPostProcess extends PostProcess {
  62898. /**
  62899. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62900. */
  62901. motionStrength: number;
  62902. /**
  62903. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62904. */
  62905. /**
  62906. * Sets the number of iterations to be used for motion blur quality
  62907. */
  62908. motionBlurSamples: number;
  62909. private _motionBlurSamples;
  62910. private _geometryBufferRenderer;
  62911. /**
  62912. * Creates a new instance MotionBlurPostProcess
  62913. * @param name The name of the effect.
  62914. * @param scene The scene containing the objects to blur according to their velocity.
  62915. * @param options The required width/height ratio to downsize to before computing the render pass.
  62916. * @param camera The camera to apply the render pass to.
  62917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62918. * @param engine The engine which the post process will be applied. (default: current engine)
  62919. * @param reusable If the post process can be reused on the same frame. (default: false)
  62920. * @param textureType Type of textures used when performing the post process. (default: 0)
  62921. * @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)
  62922. */
  62923. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62924. /**
  62925. * Excludes the given skinned mesh from computing bones velocities.
  62926. * 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.
  62927. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62928. */
  62929. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62930. /**
  62931. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62932. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62933. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62934. */
  62935. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62936. /**
  62937. * Disposes the post process.
  62938. * @param camera The camera to dispose the post process on.
  62939. */
  62940. dispose(camera?: Camera): void;
  62941. }
  62942. }
  62943. declare module "babylonjs/Shaders/refraction.fragment" {
  62944. /** @hidden */
  62945. export var refractionPixelShader: {
  62946. name: string;
  62947. shader: string;
  62948. };
  62949. }
  62950. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62951. import { Color3 } from "babylonjs/Maths/math.color";
  62952. import { Camera } from "babylonjs/Cameras/camera";
  62953. import { Texture } from "babylonjs/Materials/Textures/texture";
  62954. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62955. import { Engine } from "babylonjs/Engines/engine";
  62956. import "babylonjs/Shaders/refraction.fragment";
  62957. /**
  62958. * Post process which applies a refractin texture
  62959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62960. */
  62961. export class RefractionPostProcess extends PostProcess {
  62962. /** the base color of the refraction (used to taint the rendering) */
  62963. color: Color3;
  62964. /** simulated refraction depth */
  62965. depth: number;
  62966. /** the coefficient of the base color (0 to remove base color tainting) */
  62967. colorLevel: number;
  62968. private _refTexture;
  62969. private _ownRefractionTexture;
  62970. /**
  62971. * Gets or sets the refraction texture
  62972. * Please note that you are responsible for disposing the texture if you set it manually
  62973. */
  62974. refractionTexture: Texture;
  62975. /**
  62976. * Initializes the RefractionPostProcess
  62977. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62978. * @param name The name of the effect.
  62979. * @param refractionTextureUrl Url of the refraction texture to use
  62980. * @param color the base color of the refraction (used to taint the rendering)
  62981. * @param depth simulated refraction depth
  62982. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62983. * @param camera The camera to apply the render pass to.
  62984. * @param options The required width/height ratio to downsize to before computing the render pass.
  62985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62986. * @param engine The engine which the post process will be applied. (default: current engine)
  62987. * @param reusable If the post process can be reused on the same frame. (default: false)
  62988. */
  62989. constructor(name: string, refractionTextureUrl: string,
  62990. /** the base color of the refraction (used to taint the rendering) */
  62991. color: Color3,
  62992. /** simulated refraction depth */
  62993. depth: number,
  62994. /** the coefficient of the base color (0 to remove base color tainting) */
  62995. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62996. /**
  62997. * Disposes of the post process
  62998. * @param camera Camera to dispose post process on
  62999. */
  63000. dispose(camera: Camera): void;
  63001. }
  63002. }
  63003. declare module "babylonjs/Shaders/sharpen.fragment" {
  63004. /** @hidden */
  63005. export var sharpenPixelShader: {
  63006. name: string;
  63007. shader: string;
  63008. };
  63009. }
  63010. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63011. import { Nullable } from "babylonjs/types";
  63012. import { Camera } from "babylonjs/Cameras/camera";
  63013. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63014. import "babylonjs/Shaders/sharpen.fragment";
  63015. import { Engine } from "babylonjs/Engines/engine";
  63016. /**
  63017. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63018. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63019. */
  63020. export class SharpenPostProcess extends PostProcess {
  63021. /**
  63022. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63023. */
  63024. colorAmount: number;
  63025. /**
  63026. * How much sharpness should be applied (default: 0.3)
  63027. */
  63028. edgeAmount: number;
  63029. /**
  63030. * Creates a new instance ConvolutionPostProcess
  63031. * @param name The name of the effect.
  63032. * @param options The required width/height ratio to downsize to before computing the render pass.
  63033. * @param camera The camera to apply the render pass to.
  63034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63035. * @param engine The engine which the post process will be applied. (default: current engine)
  63036. * @param reusable If the post process can be reused on the same frame. (default: false)
  63037. * @param textureType Type of textures used when performing the post process. (default: 0)
  63038. * @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)
  63039. */
  63040. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63041. }
  63042. }
  63043. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63044. import { Nullable } from "babylonjs/types";
  63045. import { Camera } from "babylonjs/Cameras/camera";
  63046. import { Engine } from "babylonjs/Engines/engine";
  63047. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63048. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63049. /**
  63050. * PostProcessRenderPipeline
  63051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63052. */
  63053. export class PostProcessRenderPipeline {
  63054. private engine;
  63055. private _renderEffects;
  63056. private _renderEffectsForIsolatedPass;
  63057. /**
  63058. * List of inspectable custom properties (used by the Inspector)
  63059. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63060. */
  63061. inspectableCustomProperties: IInspectable[];
  63062. /**
  63063. * @hidden
  63064. */
  63065. protected _cameras: Camera[];
  63066. /** @hidden */
  63067. _name: string;
  63068. /**
  63069. * Gets pipeline name
  63070. */
  63071. readonly name: string;
  63072. /**
  63073. * Initializes a PostProcessRenderPipeline
  63074. * @param engine engine to add the pipeline to
  63075. * @param name name of the pipeline
  63076. */
  63077. constructor(engine: Engine, name: string);
  63078. /**
  63079. * Gets the class name
  63080. * @returns "PostProcessRenderPipeline"
  63081. */
  63082. getClassName(): string;
  63083. /**
  63084. * If all the render effects in the pipeline are supported
  63085. */
  63086. readonly isSupported: boolean;
  63087. /**
  63088. * Adds an effect to the pipeline
  63089. * @param renderEffect the effect to add
  63090. */
  63091. addEffect(renderEffect: PostProcessRenderEffect): void;
  63092. /** @hidden */
  63093. _rebuild(): void;
  63094. /** @hidden */
  63095. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63096. /** @hidden */
  63097. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63098. /** @hidden */
  63099. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63100. /** @hidden */
  63101. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63102. /** @hidden */
  63103. _attachCameras(cameras: Camera, unique: boolean): void;
  63104. /** @hidden */
  63105. _attachCameras(cameras: Camera[], unique: boolean): void;
  63106. /** @hidden */
  63107. _detachCameras(cameras: Camera): void;
  63108. /** @hidden */
  63109. _detachCameras(cameras: Nullable<Camera[]>): void;
  63110. /** @hidden */
  63111. _update(): void;
  63112. /** @hidden */
  63113. _reset(): void;
  63114. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63115. /**
  63116. * Disposes of the pipeline
  63117. */
  63118. dispose(): void;
  63119. }
  63120. }
  63121. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63122. import { Camera } from "babylonjs/Cameras/camera";
  63123. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63124. /**
  63125. * PostProcessRenderPipelineManager class
  63126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63127. */
  63128. export class PostProcessRenderPipelineManager {
  63129. private _renderPipelines;
  63130. /**
  63131. * Initializes a PostProcessRenderPipelineManager
  63132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63133. */
  63134. constructor();
  63135. /**
  63136. * Gets the list of supported render pipelines
  63137. */
  63138. readonly supportedPipelines: PostProcessRenderPipeline[];
  63139. /**
  63140. * Adds a pipeline to the manager
  63141. * @param renderPipeline The pipeline to add
  63142. */
  63143. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63144. /**
  63145. * Attaches a camera to the pipeline
  63146. * @param renderPipelineName The name of the pipeline to attach to
  63147. * @param cameras the camera to attach
  63148. * @param unique if the camera can be attached multiple times to the pipeline
  63149. */
  63150. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63151. /**
  63152. * Detaches a camera from the pipeline
  63153. * @param renderPipelineName The name of the pipeline to detach from
  63154. * @param cameras the camera to detach
  63155. */
  63156. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63157. /**
  63158. * Enables an effect by name on a pipeline
  63159. * @param renderPipelineName the name of the pipeline to enable the effect in
  63160. * @param renderEffectName the name of the effect to enable
  63161. * @param cameras the cameras that the effect should be enabled on
  63162. */
  63163. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63164. /**
  63165. * Disables an effect by name on a pipeline
  63166. * @param renderPipelineName the name of the pipeline to disable the effect in
  63167. * @param renderEffectName the name of the effect to disable
  63168. * @param cameras the cameras that the effect should be disabled on
  63169. */
  63170. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63171. /**
  63172. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63173. */
  63174. update(): void;
  63175. /** @hidden */
  63176. _rebuild(): void;
  63177. /**
  63178. * Disposes of the manager and pipelines
  63179. */
  63180. dispose(): void;
  63181. }
  63182. }
  63183. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63184. import { ISceneComponent } from "babylonjs/sceneComponent";
  63185. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63186. import { Scene } from "babylonjs/scene";
  63187. module "babylonjs/scene" {
  63188. interface Scene {
  63189. /** @hidden (Backing field) */
  63190. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63191. /**
  63192. * Gets the postprocess render pipeline manager
  63193. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63194. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63195. */
  63196. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63197. }
  63198. }
  63199. /**
  63200. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63201. */
  63202. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63203. /**
  63204. * The component name helpfull to identify the component in the list of scene components.
  63205. */
  63206. readonly name: string;
  63207. /**
  63208. * The scene the component belongs to.
  63209. */
  63210. scene: Scene;
  63211. /**
  63212. * Creates a new instance of the component for the given scene
  63213. * @param scene Defines the scene to register the component in
  63214. */
  63215. constructor(scene: Scene);
  63216. /**
  63217. * Registers the component in a given scene
  63218. */
  63219. register(): void;
  63220. /**
  63221. * Rebuilds the elements related to this component in case of
  63222. * context lost for instance.
  63223. */
  63224. rebuild(): void;
  63225. /**
  63226. * Disposes the component and the associated ressources
  63227. */
  63228. dispose(): void;
  63229. private _gatherRenderTargets;
  63230. }
  63231. }
  63232. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63233. import { Nullable } from "babylonjs/types";
  63234. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63235. import { Camera } from "babylonjs/Cameras/camera";
  63236. import { IDisposable } from "babylonjs/scene";
  63237. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63238. import { Scene } from "babylonjs/scene";
  63239. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63240. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63241. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63242. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63243. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63244. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63245. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63246. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63247. import { Animation } from "babylonjs/Animations/animation";
  63248. /**
  63249. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63250. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63251. */
  63252. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63253. private _scene;
  63254. private _camerasToBeAttached;
  63255. /**
  63256. * ID of the sharpen post process,
  63257. */
  63258. private readonly SharpenPostProcessId;
  63259. /**
  63260. * @ignore
  63261. * ID of the image processing post process;
  63262. */
  63263. readonly ImageProcessingPostProcessId: string;
  63264. /**
  63265. * @ignore
  63266. * ID of the Fast Approximate Anti-Aliasing post process;
  63267. */
  63268. readonly FxaaPostProcessId: string;
  63269. /**
  63270. * ID of the chromatic aberration post process,
  63271. */
  63272. private readonly ChromaticAberrationPostProcessId;
  63273. /**
  63274. * ID of the grain post process
  63275. */
  63276. private readonly GrainPostProcessId;
  63277. /**
  63278. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63279. */
  63280. sharpen: SharpenPostProcess;
  63281. private _sharpenEffect;
  63282. private bloom;
  63283. /**
  63284. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63285. */
  63286. depthOfField: DepthOfFieldEffect;
  63287. /**
  63288. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63289. */
  63290. fxaa: FxaaPostProcess;
  63291. /**
  63292. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63293. */
  63294. imageProcessing: ImageProcessingPostProcess;
  63295. /**
  63296. * Chromatic aberration post process which will shift rgb colors in the image
  63297. */
  63298. chromaticAberration: ChromaticAberrationPostProcess;
  63299. private _chromaticAberrationEffect;
  63300. /**
  63301. * Grain post process which add noise to the image
  63302. */
  63303. grain: GrainPostProcess;
  63304. private _grainEffect;
  63305. /**
  63306. * Glow post process which adds a glow to emissive areas of the image
  63307. */
  63308. private _glowLayer;
  63309. /**
  63310. * Animations which can be used to tweak settings over a period of time
  63311. */
  63312. animations: Animation[];
  63313. private _imageProcessingConfigurationObserver;
  63314. private _sharpenEnabled;
  63315. private _bloomEnabled;
  63316. private _depthOfFieldEnabled;
  63317. private _depthOfFieldBlurLevel;
  63318. private _fxaaEnabled;
  63319. private _imageProcessingEnabled;
  63320. private _defaultPipelineTextureType;
  63321. private _bloomScale;
  63322. private _chromaticAberrationEnabled;
  63323. private _grainEnabled;
  63324. private _buildAllowed;
  63325. /**
  63326. * Gets active scene
  63327. */
  63328. readonly scene: Scene;
  63329. /**
  63330. * Enable or disable the sharpen process from the pipeline
  63331. */
  63332. sharpenEnabled: boolean;
  63333. private _resizeObserver;
  63334. private _hardwareScaleLevel;
  63335. private _bloomKernel;
  63336. /**
  63337. * Specifies the size of the bloom blur kernel, relative to the final output size
  63338. */
  63339. bloomKernel: number;
  63340. /**
  63341. * Specifies the weight of the bloom in the final rendering
  63342. */
  63343. private _bloomWeight;
  63344. /**
  63345. * Specifies the luma threshold for the area that will be blurred by the bloom
  63346. */
  63347. private _bloomThreshold;
  63348. private _hdr;
  63349. /**
  63350. * The strength of the bloom.
  63351. */
  63352. bloomWeight: number;
  63353. /**
  63354. * The strength of the bloom.
  63355. */
  63356. bloomThreshold: number;
  63357. /**
  63358. * The scale of the bloom, lower value will provide better performance.
  63359. */
  63360. bloomScale: number;
  63361. /**
  63362. * Enable or disable the bloom from the pipeline
  63363. */
  63364. bloomEnabled: boolean;
  63365. private _rebuildBloom;
  63366. /**
  63367. * If the depth of field is enabled.
  63368. */
  63369. depthOfFieldEnabled: boolean;
  63370. /**
  63371. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63372. */
  63373. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63374. /**
  63375. * If the anti aliasing is enabled.
  63376. */
  63377. fxaaEnabled: boolean;
  63378. private _samples;
  63379. /**
  63380. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63381. */
  63382. samples: number;
  63383. /**
  63384. * If image processing is enabled.
  63385. */
  63386. imageProcessingEnabled: boolean;
  63387. /**
  63388. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63389. */
  63390. glowLayerEnabled: boolean;
  63391. /**
  63392. * Gets the glow layer (or null if not defined)
  63393. */
  63394. readonly glowLayer: Nullable<GlowLayer>;
  63395. /**
  63396. * Enable or disable the chromaticAberration process from the pipeline
  63397. */
  63398. chromaticAberrationEnabled: boolean;
  63399. /**
  63400. * Enable or disable the grain process from the pipeline
  63401. */
  63402. grainEnabled: boolean;
  63403. /**
  63404. * @constructor
  63405. * @param name - The rendering pipeline name (default: "")
  63406. * @param hdr - If high dynamic range textures should be used (default: true)
  63407. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63408. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63409. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63410. */
  63411. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63412. /**
  63413. * Get the class name
  63414. * @returns "DefaultRenderingPipeline"
  63415. */
  63416. getClassName(): string;
  63417. /**
  63418. * Force the compilation of the entire pipeline.
  63419. */
  63420. prepare(): void;
  63421. private _hasCleared;
  63422. private _prevPostProcess;
  63423. private _prevPrevPostProcess;
  63424. private _setAutoClearAndTextureSharing;
  63425. private _depthOfFieldSceneObserver;
  63426. private _buildPipeline;
  63427. private _disposePostProcesses;
  63428. /**
  63429. * Adds a camera to the pipeline
  63430. * @param camera the camera to be added
  63431. */
  63432. addCamera(camera: Camera): void;
  63433. /**
  63434. * Removes a camera from the pipeline
  63435. * @param camera the camera to remove
  63436. */
  63437. removeCamera(camera: Camera): void;
  63438. /**
  63439. * Dispose of the pipeline and stop all post processes
  63440. */
  63441. dispose(): void;
  63442. /**
  63443. * Serialize the rendering pipeline (Used when exporting)
  63444. * @returns the serialized object
  63445. */
  63446. serialize(): any;
  63447. /**
  63448. * Parse the serialized pipeline
  63449. * @param source Source pipeline.
  63450. * @param scene The scene to load the pipeline to.
  63451. * @param rootUrl The URL of the serialized pipeline.
  63452. * @returns An instantiated pipeline from the serialized object.
  63453. */
  63454. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63455. }
  63456. }
  63457. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63458. /** @hidden */
  63459. export var lensHighlightsPixelShader: {
  63460. name: string;
  63461. shader: string;
  63462. };
  63463. }
  63464. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63465. /** @hidden */
  63466. export var depthOfFieldPixelShader: {
  63467. name: string;
  63468. shader: string;
  63469. };
  63470. }
  63471. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63472. import { Camera } from "babylonjs/Cameras/camera";
  63473. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63474. import { Scene } from "babylonjs/scene";
  63475. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63476. import "babylonjs/Shaders/chromaticAberration.fragment";
  63477. import "babylonjs/Shaders/lensHighlights.fragment";
  63478. import "babylonjs/Shaders/depthOfField.fragment";
  63479. /**
  63480. * BABYLON.JS Chromatic Aberration GLSL Shader
  63481. * Author: Olivier Guyot
  63482. * Separates very slightly R, G and B colors on the edges of the screen
  63483. * Inspired by Francois Tarlier & Martins Upitis
  63484. */
  63485. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63486. /**
  63487. * @ignore
  63488. * The chromatic aberration PostProcess id in the pipeline
  63489. */
  63490. LensChromaticAberrationEffect: string;
  63491. /**
  63492. * @ignore
  63493. * The highlights enhancing PostProcess id in the pipeline
  63494. */
  63495. HighlightsEnhancingEffect: string;
  63496. /**
  63497. * @ignore
  63498. * The depth-of-field PostProcess id in the pipeline
  63499. */
  63500. LensDepthOfFieldEffect: string;
  63501. private _scene;
  63502. private _depthTexture;
  63503. private _grainTexture;
  63504. private _chromaticAberrationPostProcess;
  63505. private _highlightsPostProcess;
  63506. private _depthOfFieldPostProcess;
  63507. private _edgeBlur;
  63508. private _grainAmount;
  63509. private _chromaticAberration;
  63510. private _distortion;
  63511. private _highlightsGain;
  63512. private _highlightsThreshold;
  63513. private _dofDistance;
  63514. private _dofAperture;
  63515. private _dofDarken;
  63516. private _dofPentagon;
  63517. private _blurNoise;
  63518. /**
  63519. * @constructor
  63520. *
  63521. * Effect parameters are as follow:
  63522. * {
  63523. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63524. * edge_blur: number; // from 0 to x (1 for realism)
  63525. * distortion: number; // from 0 to x (1 for realism)
  63526. * grain_amount: number; // from 0 to 1
  63527. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63528. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63529. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63530. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63531. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63532. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63533. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63534. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63535. * }
  63536. * Note: if an effect parameter is unset, effect is disabled
  63537. *
  63538. * @param name The rendering pipeline name
  63539. * @param parameters - An object containing all parameters (see above)
  63540. * @param scene The scene linked to this pipeline
  63541. * @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)
  63542. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63543. */
  63544. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63545. /**
  63546. * Get the class name
  63547. * @returns "LensRenderingPipeline"
  63548. */
  63549. getClassName(): string;
  63550. /**
  63551. * Gets associated scene
  63552. */
  63553. readonly scene: Scene;
  63554. /**
  63555. * Gets or sets the edge blur
  63556. */
  63557. edgeBlur: number;
  63558. /**
  63559. * Gets or sets the grain amount
  63560. */
  63561. grainAmount: number;
  63562. /**
  63563. * Gets or sets the chromatic aberration amount
  63564. */
  63565. chromaticAberration: number;
  63566. /**
  63567. * Gets or sets the depth of field aperture
  63568. */
  63569. dofAperture: number;
  63570. /**
  63571. * Gets or sets the edge distortion
  63572. */
  63573. edgeDistortion: number;
  63574. /**
  63575. * Gets or sets the depth of field distortion
  63576. */
  63577. dofDistortion: number;
  63578. /**
  63579. * Gets or sets the darken out of focus amount
  63580. */
  63581. darkenOutOfFocus: number;
  63582. /**
  63583. * Gets or sets a boolean indicating if blur noise is enabled
  63584. */
  63585. blurNoise: boolean;
  63586. /**
  63587. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63588. */
  63589. pentagonBokeh: boolean;
  63590. /**
  63591. * Gets or sets the highlight grain amount
  63592. */
  63593. highlightsGain: number;
  63594. /**
  63595. * Gets or sets the highlight threshold
  63596. */
  63597. highlightsThreshold: number;
  63598. /**
  63599. * Sets the amount of blur at the edges
  63600. * @param amount blur amount
  63601. */
  63602. setEdgeBlur(amount: number): void;
  63603. /**
  63604. * Sets edge blur to 0
  63605. */
  63606. disableEdgeBlur(): void;
  63607. /**
  63608. * Sets the amout of grain
  63609. * @param amount Amount of grain
  63610. */
  63611. setGrainAmount(amount: number): void;
  63612. /**
  63613. * Set grain amount to 0
  63614. */
  63615. disableGrain(): void;
  63616. /**
  63617. * Sets the chromatic aberration amount
  63618. * @param amount amount of chromatic aberration
  63619. */
  63620. setChromaticAberration(amount: number): void;
  63621. /**
  63622. * Sets chromatic aberration amount to 0
  63623. */
  63624. disableChromaticAberration(): void;
  63625. /**
  63626. * Sets the EdgeDistortion amount
  63627. * @param amount amount of EdgeDistortion
  63628. */
  63629. setEdgeDistortion(amount: number): void;
  63630. /**
  63631. * Sets edge distortion to 0
  63632. */
  63633. disableEdgeDistortion(): void;
  63634. /**
  63635. * Sets the FocusDistance amount
  63636. * @param amount amount of FocusDistance
  63637. */
  63638. setFocusDistance(amount: number): void;
  63639. /**
  63640. * Disables depth of field
  63641. */
  63642. disableDepthOfField(): void;
  63643. /**
  63644. * Sets the Aperture amount
  63645. * @param amount amount of Aperture
  63646. */
  63647. setAperture(amount: number): void;
  63648. /**
  63649. * Sets the DarkenOutOfFocus amount
  63650. * @param amount amount of DarkenOutOfFocus
  63651. */
  63652. setDarkenOutOfFocus(amount: number): void;
  63653. private _pentagonBokehIsEnabled;
  63654. /**
  63655. * Creates a pentagon bokeh effect
  63656. */
  63657. enablePentagonBokeh(): void;
  63658. /**
  63659. * Disables the pentagon bokeh effect
  63660. */
  63661. disablePentagonBokeh(): void;
  63662. /**
  63663. * Enables noise blur
  63664. */
  63665. enableNoiseBlur(): void;
  63666. /**
  63667. * Disables noise blur
  63668. */
  63669. disableNoiseBlur(): void;
  63670. /**
  63671. * Sets the HighlightsGain amount
  63672. * @param amount amount of HighlightsGain
  63673. */
  63674. setHighlightsGain(amount: number): void;
  63675. /**
  63676. * Sets the HighlightsThreshold amount
  63677. * @param amount amount of HighlightsThreshold
  63678. */
  63679. setHighlightsThreshold(amount: number): void;
  63680. /**
  63681. * Disables highlights
  63682. */
  63683. disableHighlights(): void;
  63684. /**
  63685. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63686. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63687. */
  63688. dispose(disableDepthRender?: boolean): void;
  63689. private _createChromaticAberrationPostProcess;
  63690. private _createHighlightsPostProcess;
  63691. private _createDepthOfFieldPostProcess;
  63692. private _createGrainTexture;
  63693. }
  63694. }
  63695. declare module "babylonjs/Shaders/ssao2.fragment" {
  63696. /** @hidden */
  63697. export var ssao2PixelShader: {
  63698. name: string;
  63699. shader: string;
  63700. };
  63701. }
  63702. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63703. /** @hidden */
  63704. export var ssaoCombinePixelShader: {
  63705. name: string;
  63706. shader: string;
  63707. };
  63708. }
  63709. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63710. import { Camera } from "babylonjs/Cameras/camera";
  63711. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63712. import { Scene } from "babylonjs/scene";
  63713. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63714. import "babylonjs/Shaders/ssao2.fragment";
  63715. import "babylonjs/Shaders/ssaoCombine.fragment";
  63716. /**
  63717. * Render pipeline to produce ssao effect
  63718. */
  63719. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63720. /**
  63721. * @ignore
  63722. * The PassPostProcess id in the pipeline that contains the original scene color
  63723. */
  63724. SSAOOriginalSceneColorEffect: string;
  63725. /**
  63726. * @ignore
  63727. * The SSAO PostProcess id in the pipeline
  63728. */
  63729. SSAORenderEffect: string;
  63730. /**
  63731. * @ignore
  63732. * The horizontal blur PostProcess id in the pipeline
  63733. */
  63734. SSAOBlurHRenderEffect: string;
  63735. /**
  63736. * @ignore
  63737. * The vertical blur PostProcess id in the pipeline
  63738. */
  63739. SSAOBlurVRenderEffect: string;
  63740. /**
  63741. * @ignore
  63742. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63743. */
  63744. SSAOCombineRenderEffect: string;
  63745. /**
  63746. * The output strength of the SSAO post-process. Default value is 1.0.
  63747. */
  63748. totalStrength: number;
  63749. /**
  63750. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63751. */
  63752. maxZ: number;
  63753. /**
  63754. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63755. */
  63756. minZAspect: number;
  63757. private _samples;
  63758. /**
  63759. * Number of samples used for the SSAO calculations. Default value is 8
  63760. */
  63761. samples: number;
  63762. private _textureSamples;
  63763. /**
  63764. * Number of samples to use for antialiasing
  63765. */
  63766. textureSamples: number;
  63767. /**
  63768. * Ratio object used for SSAO ratio and blur ratio
  63769. */
  63770. private _ratio;
  63771. /**
  63772. * Dynamically generated sphere sampler.
  63773. */
  63774. private _sampleSphere;
  63775. /**
  63776. * Blur filter offsets
  63777. */
  63778. private _samplerOffsets;
  63779. private _expensiveBlur;
  63780. /**
  63781. * If bilateral blur should be used
  63782. */
  63783. expensiveBlur: boolean;
  63784. /**
  63785. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63786. */
  63787. radius: number;
  63788. /**
  63789. * The base color of the SSAO post-process
  63790. * The final result is "base + ssao" between [0, 1]
  63791. */
  63792. base: number;
  63793. /**
  63794. * Support test.
  63795. */
  63796. static readonly IsSupported: boolean;
  63797. private _scene;
  63798. private _depthTexture;
  63799. private _normalTexture;
  63800. private _randomTexture;
  63801. private _originalColorPostProcess;
  63802. private _ssaoPostProcess;
  63803. private _blurHPostProcess;
  63804. private _blurVPostProcess;
  63805. private _ssaoCombinePostProcess;
  63806. private _firstUpdate;
  63807. /**
  63808. * Gets active scene
  63809. */
  63810. readonly scene: Scene;
  63811. /**
  63812. * @constructor
  63813. * @param name The rendering pipeline name
  63814. * @param scene The scene linked to this pipeline
  63815. * @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 }
  63816. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63817. */
  63818. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63819. /**
  63820. * Get the class name
  63821. * @returns "SSAO2RenderingPipeline"
  63822. */
  63823. getClassName(): string;
  63824. /**
  63825. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63826. */
  63827. dispose(disableGeometryBufferRenderer?: boolean): void;
  63828. private _createBlurPostProcess;
  63829. /** @hidden */
  63830. _rebuild(): void;
  63831. private _bits;
  63832. private _radicalInverse_VdC;
  63833. private _hammersley;
  63834. private _hemisphereSample_uniform;
  63835. private _generateHemisphere;
  63836. private _createSSAOPostProcess;
  63837. private _createSSAOCombinePostProcess;
  63838. private _createRandomTexture;
  63839. /**
  63840. * Serialize the rendering pipeline (Used when exporting)
  63841. * @returns the serialized object
  63842. */
  63843. serialize(): any;
  63844. /**
  63845. * Parse the serialized pipeline
  63846. * @param source Source pipeline.
  63847. * @param scene The scene to load the pipeline to.
  63848. * @param rootUrl The URL of the serialized pipeline.
  63849. * @returns An instantiated pipeline from the serialized object.
  63850. */
  63851. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63852. }
  63853. }
  63854. declare module "babylonjs/Shaders/ssao.fragment" {
  63855. /** @hidden */
  63856. export var ssaoPixelShader: {
  63857. name: string;
  63858. shader: string;
  63859. };
  63860. }
  63861. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63862. import { Camera } from "babylonjs/Cameras/camera";
  63863. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63864. import { Scene } from "babylonjs/scene";
  63865. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63866. import "babylonjs/Shaders/ssao.fragment";
  63867. import "babylonjs/Shaders/ssaoCombine.fragment";
  63868. /**
  63869. * Render pipeline to produce ssao effect
  63870. */
  63871. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63872. /**
  63873. * @ignore
  63874. * The PassPostProcess id in the pipeline that contains the original scene color
  63875. */
  63876. SSAOOriginalSceneColorEffect: string;
  63877. /**
  63878. * @ignore
  63879. * The SSAO PostProcess id in the pipeline
  63880. */
  63881. SSAORenderEffect: string;
  63882. /**
  63883. * @ignore
  63884. * The horizontal blur PostProcess id in the pipeline
  63885. */
  63886. SSAOBlurHRenderEffect: string;
  63887. /**
  63888. * @ignore
  63889. * The vertical blur PostProcess id in the pipeline
  63890. */
  63891. SSAOBlurVRenderEffect: string;
  63892. /**
  63893. * @ignore
  63894. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63895. */
  63896. SSAOCombineRenderEffect: string;
  63897. /**
  63898. * The output strength of the SSAO post-process. Default value is 1.0.
  63899. */
  63900. totalStrength: number;
  63901. /**
  63902. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63903. */
  63904. radius: number;
  63905. /**
  63906. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63907. * Must not be equal to fallOff and superior to fallOff.
  63908. * Default value is 0.0075
  63909. */
  63910. area: number;
  63911. /**
  63912. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63913. * Must not be equal to area and inferior to area.
  63914. * Default value is 0.000001
  63915. */
  63916. fallOff: number;
  63917. /**
  63918. * The base color of the SSAO post-process
  63919. * The final result is "base + ssao" between [0, 1]
  63920. */
  63921. base: number;
  63922. private _scene;
  63923. private _depthTexture;
  63924. private _randomTexture;
  63925. private _originalColorPostProcess;
  63926. private _ssaoPostProcess;
  63927. private _blurHPostProcess;
  63928. private _blurVPostProcess;
  63929. private _ssaoCombinePostProcess;
  63930. private _firstUpdate;
  63931. /**
  63932. * Gets active scene
  63933. */
  63934. readonly scene: Scene;
  63935. /**
  63936. * @constructor
  63937. * @param name - The rendering pipeline name
  63938. * @param scene - The scene linked to this pipeline
  63939. * @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 }
  63940. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63941. */
  63942. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63943. /**
  63944. * Get the class name
  63945. * @returns "SSAORenderingPipeline"
  63946. */
  63947. getClassName(): string;
  63948. /**
  63949. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63950. */
  63951. dispose(disableDepthRender?: boolean): void;
  63952. private _createBlurPostProcess;
  63953. /** @hidden */
  63954. _rebuild(): void;
  63955. private _createSSAOPostProcess;
  63956. private _createSSAOCombinePostProcess;
  63957. private _createRandomTexture;
  63958. }
  63959. }
  63960. declare module "babylonjs/Shaders/standard.fragment" {
  63961. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63962. /** @hidden */
  63963. export var standardPixelShader: {
  63964. name: string;
  63965. shader: string;
  63966. };
  63967. }
  63968. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63969. import { Nullable } from "babylonjs/types";
  63970. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63971. import { Camera } from "babylonjs/Cameras/camera";
  63972. import { Texture } from "babylonjs/Materials/Textures/texture";
  63973. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63974. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63975. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63976. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63977. import { IDisposable } from "babylonjs/scene";
  63978. import { SpotLight } from "babylonjs/Lights/spotLight";
  63979. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63980. import { Scene } from "babylonjs/scene";
  63981. import { Animation } from "babylonjs/Animations/animation";
  63982. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63983. import "babylonjs/Shaders/standard.fragment";
  63984. /**
  63985. * Standard rendering pipeline
  63986. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63987. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63988. */
  63989. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63990. /**
  63991. * Public members
  63992. */
  63993. /**
  63994. * Post-process which contains the original scene color before the pipeline applies all the effects
  63995. */
  63996. originalPostProcess: Nullable<PostProcess>;
  63997. /**
  63998. * Post-process used to down scale an image x4
  63999. */
  64000. downSampleX4PostProcess: Nullable<PostProcess>;
  64001. /**
  64002. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64003. */
  64004. brightPassPostProcess: Nullable<PostProcess>;
  64005. /**
  64006. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64007. */
  64008. blurHPostProcesses: PostProcess[];
  64009. /**
  64010. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64011. */
  64012. blurVPostProcesses: PostProcess[];
  64013. /**
  64014. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64015. */
  64016. textureAdderPostProcess: Nullable<PostProcess>;
  64017. /**
  64018. * Post-process used to create volumetric lighting effect
  64019. */
  64020. volumetricLightPostProcess: Nullable<PostProcess>;
  64021. /**
  64022. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64023. */
  64024. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64025. /**
  64026. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64027. */
  64028. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64029. /**
  64030. * Post-process used to merge the volumetric light effect and the real scene color
  64031. */
  64032. volumetricLightMergePostProces: Nullable<PostProcess>;
  64033. /**
  64034. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64035. */
  64036. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64037. /**
  64038. * Base post-process used to calculate the average luminance of the final image for HDR
  64039. */
  64040. luminancePostProcess: Nullable<PostProcess>;
  64041. /**
  64042. * Post-processes used to create down sample post-processes in order to get
  64043. * the average luminance of the final image for HDR
  64044. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64045. */
  64046. luminanceDownSamplePostProcesses: PostProcess[];
  64047. /**
  64048. * Post-process used to create a HDR effect (light adaptation)
  64049. */
  64050. hdrPostProcess: Nullable<PostProcess>;
  64051. /**
  64052. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64053. */
  64054. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64055. /**
  64056. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64057. */
  64058. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64059. /**
  64060. * Post-process used to merge the final HDR post-process and the real scene color
  64061. */
  64062. hdrFinalPostProcess: Nullable<PostProcess>;
  64063. /**
  64064. * Post-process used to create a lens flare effect
  64065. */
  64066. lensFlarePostProcess: Nullable<PostProcess>;
  64067. /**
  64068. * Post-process that merges the result of the lens flare post-process and the real scene color
  64069. */
  64070. lensFlareComposePostProcess: Nullable<PostProcess>;
  64071. /**
  64072. * Post-process used to create a motion blur effect
  64073. */
  64074. motionBlurPostProcess: Nullable<PostProcess>;
  64075. /**
  64076. * Post-process used to create a depth of field effect
  64077. */
  64078. depthOfFieldPostProcess: Nullable<PostProcess>;
  64079. /**
  64080. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64081. */
  64082. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64083. /**
  64084. * Represents the brightness threshold in order to configure the illuminated surfaces
  64085. */
  64086. brightThreshold: number;
  64087. /**
  64088. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64089. */
  64090. blurWidth: number;
  64091. /**
  64092. * Sets if the blur for highlighted surfaces must be only horizontal
  64093. */
  64094. horizontalBlur: boolean;
  64095. /**
  64096. * Gets the overall exposure used by the pipeline
  64097. */
  64098. /**
  64099. * Sets the overall exposure used by the pipeline
  64100. */
  64101. exposure: number;
  64102. /**
  64103. * Texture used typically to simulate "dirty" on camera lens
  64104. */
  64105. lensTexture: Nullable<Texture>;
  64106. /**
  64107. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64108. */
  64109. volumetricLightCoefficient: number;
  64110. /**
  64111. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64112. */
  64113. volumetricLightPower: number;
  64114. /**
  64115. * Used the set the blur intensity to smooth the volumetric lights
  64116. */
  64117. volumetricLightBlurScale: number;
  64118. /**
  64119. * Light (spot or directional) used to generate the volumetric lights rays
  64120. * The source light must have a shadow generate so the pipeline can get its
  64121. * depth map
  64122. */
  64123. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64124. /**
  64125. * For eye adaptation, represents the minimum luminance the eye can see
  64126. */
  64127. hdrMinimumLuminance: number;
  64128. /**
  64129. * For eye adaptation, represents the decrease luminance speed
  64130. */
  64131. hdrDecreaseRate: number;
  64132. /**
  64133. * For eye adaptation, represents the increase luminance speed
  64134. */
  64135. hdrIncreaseRate: number;
  64136. /**
  64137. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64138. */
  64139. /**
  64140. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64141. */
  64142. hdrAutoExposure: boolean;
  64143. /**
  64144. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64145. */
  64146. lensColorTexture: Nullable<Texture>;
  64147. /**
  64148. * The overall strengh for the lens flare effect
  64149. */
  64150. lensFlareStrength: number;
  64151. /**
  64152. * Dispersion coefficient for lens flare ghosts
  64153. */
  64154. lensFlareGhostDispersal: number;
  64155. /**
  64156. * Main lens flare halo width
  64157. */
  64158. lensFlareHaloWidth: number;
  64159. /**
  64160. * Based on the lens distortion effect, defines how much the lens flare result
  64161. * is distorted
  64162. */
  64163. lensFlareDistortionStrength: number;
  64164. /**
  64165. * Configures the blur intensity used for for lens flare (halo)
  64166. */
  64167. lensFlareBlurWidth: number;
  64168. /**
  64169. * Lens star texture must be used to simulate rays on the flares and is available
  64170. * in the documentation
  64171. */
  64172. lensStarTexture: Nullable<Texture>;
  64173. /**
  64174. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64175. * flare effect by taking account of the dirt texture
  64176. */
  64177. lensFlareDirtTexture: Nullable<Texture>;
  64178. /**
  64179. * Represents the focal length for the depth of field effect
  64180. */
  64181. depthOfFieldDistance: number;
  64182. /**
  64183. * Represents the blur intensity for the blurred part of the depth of field effect
  64184. */
  64185. depthOfFieldBlurWidth: number;
  64186. /**
  64187. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64188. */
  64189. /**
  64190. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64191. */
  64192. motionStrength: number;
  64193. /**
  64194. * Gets wether or not the motion blur post-process is object based or screen based.
  64195. */
  64196. /**
  64197. * Sets wether or not the motion blur post-process should be object based or screen based
  64198. */
  64199. objectBasedMotionBlur: boolean;
  64200. /**
  64201. * List of animations for the pipeline (IAnimatable implementation)
  64202. */
  64203. animations: Animation[];
  64204. /**
  64205. * Private members
  64206. */
  64207. private _scene;
  64208. private _currentDepthOfFieldSource;
  64209. private _basePostProcess;
  64210. private _fixedExposure;
  64211. private _currentExposure;
  64212. private _hdrAutoExposure;
  64213. private _hdrCurrentLuminance;
  64214. private _motionStrength;
  64215. private _isObjectBasedMotionBlur;
  64216. private _floatTextureType;
  64217. private _camerasToBeAttached;
  64218. private _ratio;
  64219. private _bloomEnabled;
  64220. private _depthOfFieldEnabled;
  64221. private _vlsEnabled;
  64222. private _lensFlareEnabled;
  64223. private _hdrEnabled;
  64224. private _motionBlurEnabled;
  64225. private _fxaaEnabled;
  64226. private _motionBlurSamples;
  64227. private _volumetricLightStepsCount;
  64228. private _samples;
  64229. /**
  64230. * @ignore
  64231. * Specifies if the bloom pipeline is enabled
  64232. */
  64233. BloomEnabled: boolean;
  64234. /**
  64235. * @ignore
  64236. * Specifies if the depth of field pipeline is enabed
  64237. */
  64238. DepthOfFieldEnabled: boolean;
  64239. /**
  64240. * @ignore
  64241. * Specifies if the lens flare pipeline is enabed
  64242. */
  64243. LensFlareEnabled: boolean;
  64244. /**
  64245. * @ignore
  64246. * Specifies if the HDR pipeline is enabled
  64247. */
  64248. HDREnabled: boolean;
  64249. /**
  64250. * @ignore
  64251. * Specifies if the volumetric lights scattering effect is enabled
  64252. */
  64253. VLSEnabled: boolean;
  64254. /**
  64255. * @ignore
  64256. * Specifies if the motion blur effect is enabled
  64257. */
  64258. MotionBlurEnabled: boolean;
  64259. /**
  64260. * Specifies if anti-aliasing is enabled
  64261. */
  64262. fxaaEnabled: boolean;
  64263. /**
  64264. * Specifies the number of steps used to calculate the volumetric lights
  64265. * Typically in interval [50, 200]
  64266. */
  64267. volumetricLightStepsCount: number;
  64268. /**
  64269. * Specifies the number of samples used for the motion blur effect
  64270. * Typically in interval [16, 64]
  64271. */
  64272. motionBlurSamples: number;
  64273. /**
  64274. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64275. */
  64276. samples: number;
  64277. /**
  64278. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64279. * @constructor
  64280. * @param name The rendering pipeline name
  64281. * @param scene The scene linked to this pipeline
  64282. * @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)
  64283. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64284. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64285. */
  64286. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64287. private _buildPipeline;
  64288. private _createDownSampleX4PostProcess;
  64289. private _createBrightPassPostProcess;
  64290. private _createBlurPostProcesses;
  64291. private _createTextureAdderPostProcess;
  64292. private _createVolumetricLightPostProcess;
  64293. private _createLuminancePostProcesses;
  64294. private _createHdrPostProcess;
  64295. private _createLensFlarePostProcess;
  64296. private _createDepthOfFieldPostProcess;
  64297. private _createMotionBlurPostProcess;
  64298. private _getDepthTexture;
  64299. private _disposePostProcesses;
  64300. /**
  64301. * Dispose of the pipeline and stop all post processes
  64302. */
  64303. dispose(): void;
  64304. /**
  64305. * Serialize the rendering pipeline (Used when exporting)
  64306. * @returns the serialized object
  64307. */
  64308. serialize(): any;
  64309. /**
  64310. * Parse the serialized pipeline
  64311. * @param source Source pipeline.
  64312. * @param scene The scene to load the pipeline to.
  64313. * @param rootUrl The URL of the serialized pipeline.
  64314. * @returns An instantiated pipeline from the serialized object.
  64315. */
  64316. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64317. /**
  64318. * Luminance steps
  64319. */
  64320. static LuminanceSteps: number;
  64321. }
  64322. }
  64323. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64324. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64325. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64326. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64327. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64328. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64329. }
  64330. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64331. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64332. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64333. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64334. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64335. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64336. }
  64337. declare module "babylonjs/Shaders/tonemap.fragment" {
  64338. /** @hidden */
  64339. export var tonemapPixelShader: {
  64340. name: string;
  64341. shader: string;
  64342. };
  64343. }
  64344. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64345. import { Camera } from "babylonjs/Cameras/camera";
  64346. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64347. import "babylonjs/Shaders/tonemap.fragment";
  64348. import { Engine } from "babylonjs/Engines/engine";
  64349. /** Defines operator used for tonemapping */
  64350. export enum TonemappingOperator {
  64351. /** Hable */
  64352. Hable = 0,
  64353. /** Reinhard */
  64354. Reinhard = 1,
  64355. /** HejiDawson */
  64356. HejiDawson = 2,
  64357. /** Photographic */
  64358. Photographic = 3
  64359. }
  64360. /**
  64361. * Defines a post process to apply tone mapping
  64362. */
  64363. export class TonemapPostProcess extends PostProcess {
  64364. private _operator;
  64365. /** Defines the required exposure adjustement */
  64366. exposureAdjustment: number;
  64367. /**
  64368. * Creates a new TonemapPostProcess
  64369. * @param name defines the name of the postprocess
  64370. * @param _operator defines the operator to use
  64371. * @param exposureAdjustment defines the required exposure adjustement
  64372. * @param camera defines the camera to use (can be null)
  64373. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64374. * @param engine defines the hosting engine (can be ignore if camera is set)
  64375. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64376. */
  64377. constructor(name: string, _operator: TonemappingOperator,
  64378. /** Defines the required exposure adjustement */
  64379. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64380. }
  64381. }
  64382. declare module "babylonjs/Shaders/depth.vertex" {
  64383. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64384. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64386. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64388. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64389. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64390. /** @hidden */
  64391. export var depthVertexShader: {
  64392. name: string;
  64393. shader: string;
  64394. };
  64395. }
  64396. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64397. /** @hidden */
  64398. export var volumetricLightScatteringPixelShader: {
  64399. name: string;
  64400. shader: string;
  64401. };
  64402. }
  64403. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64404. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64405. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64406. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64407. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64408. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64409. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64410. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64411. /** @hidden */
  64412. export var volumetricLightScatteringPassVertexShader: {
  64413. name: string;
  64414. shader: string;
  64415. };
  64416. }
  64417. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64418. /** @hidden */
  64419. export var volumetricLightScatteringPassPixelShader: {
  64420. name: string;
  64421. shader: string;
  64422. };
  64423. }
  64424. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64425. import { Vector3 } from "babylonjs/Maths/math.vector";
  64426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64427. import { Mesh } from "babylonjs/Meshes/mesh";
  64428. import { Camera } from "babylonjs/Cameras/camera";
  64429. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64430. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64431. import { Scene } from "babylonjs/scene";
  64432. import "babylonjs/Meshes/Builders/planeBuilder";
  64433. import "babylonjs/Shaders/depth.vertex";
  64434. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64435. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64436. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64437. import { Engine } from "babylonjs/Engines/engine";
  64438. /**
  64439. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64440. */
  64441. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64442. private _volumetricLightScatteringPass;
  64443. private _volumetricLightScatteringRTT;
  64444. private _viewPort;
  64445. private _screenCoordinates;
  64446. private _cachedDefines;
  64447. /**
  64448. * If not undefined, the mesh position is computed from the attached node position
  64449. */
  64450. attachedNode: {
  64451. position: Vector3;
  64452. };
  64453. /**
  64454. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64455. */
  64456. customMeshPosition: Vector3;
  64457. /**
  64458. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64459. */
  64460. useCustomMeshPosition: boolean;
  64461. /**
  64462. * If the post-process should inverse the light scattering direction
  64463. */
  64464. invert: boolean;
  64465. /**
  64466. * The internal mesh used by the post-process
  64467. */
  64468. mesh: Mesh;
  64469. /**
  64470. * @hidden
  64471. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64472. */
  64473. useDiffuseColor: boolean;
  64474. /**
  64475. * Array containing the excluded meshes not rendered in the internal pass
  64476. */
  64477. excludedMeshes: AbstractMesh[];
  64478. /**
  64479. * Controls the overall intensity of the post-process
  64480. */
  64481. exposure: number;
  64482. /**
  64483. * Dissipates each sample's contribution in range [0, 1]
  64484. */
  64485. decay: number;
  64486. /**
  64487. * Controls the overall intensity of each sample
  64488. */
  64489. weight: number;
  64490. /**
  64491. * Controls the density of each sample
  64492. */
  64493. density: number;
  64494. /**
  64495. * @constructor
  64496. * @param name The post-process name
  64497. * @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)
  64498. * @param camera The camera that the post-process will be attached to
  64499. * @param mesh The mesh used to create the light scattering
  64500. * @param samples The post-process quality, default 100
  64501. * @param samplingModeThe post-process filtering mode
  64502. * @param engine The babylon engine
  64503. * @param reusable If the post-process is reusable
  64504. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64505. */
  64506. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64507. /**
  64508. * Returns the string "VolumetricLightScatteringPostProcess"
  64509. * @returns "VolumetricLightScatteringPostProcess"
  64510. */
  64511. getClassName(): string;
  64512. private _isReady;
  64513. /**
  64514. * Sets the new light position for light scattering effect
  64515. * @param position The new custom light position
  64516. */
  64517. setCustomMeshPosition(position: Vector3): void;
  64518. /**
  64519. * Returns the light position for light scattering effect
  64520. * @return Vector3 The custom light position
  64521. */
  64522. getCustomMeshPosition(): Vector3;
  64523. /**
  64524. * Disposes the internal assets and detaches the post-process from the camera
  64525. */
  64526. dispose(camera: Camera): void;
  64527. /**
  64528. * Returns the render target texture used by the post-process
  64529. * @return the render target texture used by the post-process
  64530. */
  64531. getPass(): RenderTargetTexture;
  64532. private _meshExcluded;
  64533. private _createPass;
  64534. private _updateMeshScreenCoordinates;
  64535. /**
  64536. * Creates a default mesh for the Volumeric Light Scattering post-process
  64537. * @param name The mesh name
  64538. * @param scene The scene where to create the mesh
  64539. * @return the default mesh
  64540. */
  64541. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64542. }
  64543. }
  64544. declare module "babylonjs/PostProcesses/index" {
  64545. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64546. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64547. export * from "babylonjs/PostProcesses/bloomEffect";
  64548. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64549. export * from "babylonjs/PostProcesses/blurPostProcess";
  64550. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64551. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64552. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64553. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64554. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64555. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64556. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64557. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64558. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64559. export * from "babylonjs/PostProcesses/filterPostProcess";
  64560. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64561. export * from "babylonjs/PostProcesses/grainPostProcess";
  64562. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64563. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64564. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64565. export * from "babylonjs/PostProcesses/passPostProcess";
  64566. export * from "babylonjs/PostProcesses/postProcess";
  64567. export * from "babylonjs/PostProcesses/postProcessManager";
  64568. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64569. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64570. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64571. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64572. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64573. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64574. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64575. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64576. }
  64577. declare module "babylonjs/Probes/index" {
  64578. export * from "babylonjs/Probes/reflectionProbe";
  64579. }
  64580. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64581. import { Scene } from "babylonjs/scene";
  64582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64583. import { SmartArray } from "babylonjs/Misc/smartArray";
  64584. import { ISceneComponent } from "babylonjs/sceneComponent";
  64585. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64586. import "babylonjs/Meshes/Builders/boxBuilder";
  64587. import "babylonjs/Shaders/color.fragment";
  64588. import "babylonjs/Shaders/color.vertex";
  64589. import { Color3 } from "babylonjs/Maths/math.color";
  64590. module "babylonjs/scene" {
  64591. interface Scene {
  64592. /** @hidden (Backing field) */
  64593. _boundingBoxRenderer: BoundingBoxRenderer;
  64594. /** @hidden (Backing field) */
  64595. _forceShowBoundingBoxes: boolean;
  64596. /**
  64597. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64598. */
  64599. forceShowBoundingBoxes: boolean;
  64600. /**
  64601. * Gets the bounding box renderer associated with the scene
  64602. * @returns a BoundingBoxRenderer
  64603. */
  64604. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64605. }
  64606. }
  64607. module "babylonjs/Meshes/abstractMesh" {
  64608. interface AbstractMesh {
  64609. /** @hidden (Backing field) */
  64610. _showBoundingBox: boolean;
  64611. /**
  64612. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64613. */
  64614. showBoundingBox: boolean;
  64615. }
  64616. }
  64617. /**
  64618. * Component responsible of rendering the bounding box of the meshes in a scene.
  64619. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64620. */
  64621. export class BoundingBoxRenderer implements ISceneComponent {
  64622. /**
  64623. * The component name helpfull to identify the component in the list of scene components.
  64624. */
  64625. readonly name: string;
  64626. /**
  64627. * The scene the component belongs to.
  64628. */
  64629. scene: Scene;
  64630. /**
  64631. * Color of the bounding box lines placed in front of an object
  64632. */
  64633. frontColor: Color3;
  64634. /**
  64635. * Color of the bounding box lines placed behind an object
  64636. */
  64637. backColor: Color3;
  64638. /**
  64639. * Defines if the renderer should show the back lines or not
  64640. */
  64641. showBackLines: boolean;
  64642. /**
  64643. * @hidden
  64644. */
  64645. renderList: SmartArray<BoundingBox>;
  64646. private _colorShader;
  64647. private _vertexBuffers;
  64648. private _indexBuffer;
  64649. private _fillIndexBuffer;
  64650. private _fillIndexData;
  64651. /**
  64652. * Instantiates a new bounding box renderer in a scene.
  64653. * @param scene the scene the renderer renders in
  64654. */
  64655. constructor(scene: Scene);
  64656. /**
  64657. * Registers the component in a given scene
  64658. */
  64659. register(): void;
  64660. private _evaluateSubMesh;
  64661. private _activeMesh;
  64662. private _prepareRessources;
  64663. private _createIndexBuffer;
  64664. /**
  64665. * Rebuilds the elements related to this component in case of
  64666. * context lost for instance.
  64667. */
  64668. rebuild(): void;
  64669. /**
  64670. * @hidden
  64671. */
  64672. reset(): void;
  64673. /**
  64674. * Render the bounding boxes of a specific rendering group
  64675. * @param renderingGroupId defines the rendering group to render
  64676. */
  64677. render(renderingGroupId: number): void;
  64678. /**
  64679. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64680. * @param mesh Define the mesh to render the occlusion bounding box for
  64681. */
  64682. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64683. /**
  64684. * Dispose and release the resources attached to this renderer.
  64685. */
  64686. dispose(): void;
  64687. }
  64688. }
  64689. declare module "babylonjs/Shaders/depth.fragment" {
  64690. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64691. /** @hidden */
  64692. export var depthPixelShader: {
  64693. name: string;
  64694. shader: string;
  64695. };
  64696. }
  64697. declare module "babylonjs/Rendering/depthRenderer" {
  64698. import { Nullable } from "babylonjs/types";
  64699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64700. import { Scene } from "babylonjs/scene";
  64701. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64702. import { Camera } from "babylonjs/Cameras/camera";
  64703. import "babylonjs/Shaders/depth.fragment";
  64704. import "babylonjs/Shaders/depth.vertex";
  64705. /**
  64706. * This represents a depth renderer in Babylon.
  64707. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64708. */
  64709. export class DepthRenderer {
  64710. private _scene;
  64711. private _depthMap;
  64712. private _effect;
  64713. private readonly _storeNonLinearDepth;
  64714. private readonly _clearColor;
  64715. /** Get if the depth renderer is using packed depth or not */
  64716. readonly isPacked: boolean;
  64717. private _cachedDefines;
  64718. private _camera;
  64719. /**
  64720. * Specifiess that the depth renderer will only be used within
  64721. * the camera it is created for.
  64722. * This can help forcing its rendering during the camera processing.
  64723. */
  64724. useOnlyInActiveCamera: boolean;
  64725. /** @hidden */
  64726. static _SceneComponentInitialization: (scene: Scene) => void;
  64727. /**
  64728. * Instantiates a depth renderer
  64729. * @param scene The scene the renderer belongs to
  64730. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64731. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64732. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64733. */
  64734. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64735. /**
  64736. * Creates the depth rendering effect and checks if the effect is ready.
  64737. * @param subMesh The submesh to be used to render the depth map of
  64738. * @param useInstances If multiple world instances should be used
  64739. * @returns if the depth renderer is ready to render the depth map
  64740. */
  64741. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64742. /**
  64743. * Gets the texture which the depth map will be written to.
  64744. * @returns The depth map texture
  64745. */
  64746. getDepthMap(): RenderTargetTexture;
  64747. /**
  64748. * Disposes of the depth renderer.
  64749. */
  64750. dispose(): void;
  64751. }
  64752. }
  64753. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64754. import { Nullable } from "babylonjs/types";
  64755. import { Scene } from "babylonjs/scene";
  64756. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64757. import { Camera } from "babylonjs/Cameras/camera";
  64758. import { ISceneComponent } from "babylonjs/sceneComponent";
  64759. module "babylonjs/scene" {
  64760. interface Scene {
  64761. /** @hidden (Backing field) */
  64762. _depthRenderer: {
  64763. [id: string]: DepthRenderer;
  64764. };
  64765. /**
  64766. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64767. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64768. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64769. * @returns the created depth renderer
  64770. */
  64771. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64772. /**
  64773. * Disables a depth renderer for a given camera
  64774. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64775. */
  64776. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64777. }
  64778. }
  64779. /**
  64780. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64781. * in several rendering techniques.
  64782. */
  64783. export class DepthRendererSceneComponent implements ISceneComponent {
  64784. /**
  64785. * The component name helpfull to identify the component in the list of scene components.
  64786. */
  64787. readonly name: string;
  64788. /**
  64789. * The scene the component belongs to.
  64790. */
  64791. scene: Scene;
  64792. /**
  64793. * Creates a new instance of the component for the given scene
  64794. * @param scene Defines the scene to register the component in
  64795. */
  64796. constructor(scene: Scene);
  64797. /**
  64798. * Registers the component in a given scene
  64799. */
  64800. register(): void;
  64801. /**
  64802. * Rebuilds the elements related to this component in case of
  64803. * context lost for instance.
  64804. */
  64805. rebuild(): void;
  64806. /**
  64807. * Disposes the component and the associated ressources
  64808. */
  64809. dispose(): void;
  64810. private _gatherRenderTargets;
  64811. private _gatherActiveCameraRenderTargets;
  64812. }
  64813. }
  64814. declare module "babylonjs/Shaders/outline.fragment" {
  64815. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64816. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64817. /** @hidden */
  64818. export var outlinePixelShader: {
  64819. name: string;
  64820. shader: string;
  64821. };
  64822. }
  64823. declare module "babylonjs/Shaders/outline.vertex" {
  64824. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64825. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64826. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64827. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64828. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64829. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64830. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64831. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64832. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64833. /** @hidden */
  64834. export var outlineVertexShader: {
  64835. name: string;
  64836. shader: string;
  64837. };
  64838. }
  64839. declare module "babylonjs/Rendering/outlineRenderer" {
  64840. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64841. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64842. import { Scene } from "babylonjs/scene";
  64843. import { ISceneComponent } from "babylonjs/sceneComponent";
  64844. import "babylonjs/Shaders/outline.fragment";
  64845. import "babylonjs/Shaders/outline.vertex";
  64846. module "babylonjs/scene" {
  64847. interface Scene {
  64848. /** @hidden */
  64849. _outlineRenderer: OutlineRenderer;
  64850. /**
  64851. * Gets the outline renderer associated with the scene
  64852. * @returns a OutlineRenderer
  64853. */
  64854. getOutlineRenderer(): OutlineRenderer;
  64855. }
  64856. }
  64857. module "babylonjs/Meshes/abstractMesh" {
  64858. interface AbstractMesh {
  64859. /** @hidden (Backing field) */
  64860. _renderOutline: boolean;
  64861. /**
  64862. * Gets or sets a boolean indicating if the outline must be rendered as well
  64863. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64864. */
  64865. renderOutline: boolean;
  64866. /** @hidden (Backing field) */
  64867. _renderOverlay: boolean;
  64868. /**
  64869. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64870. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64871. */
  64872. renderOverlay: boolean;
  64873. }
  64874. }
  64875. /**
  64876. * This class is responsible to draw bothe outline/overlay of meshes.
  64877. * It should not be used directly but through the available method on mesh.
  64878. */
  64879. export class OutlineRenderer implements ISceneComponent {
  64880. /**
  64881. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64882. */
  64883. private static _StencilReference;
  64884. /**
  64885. * The name of the component. Each component must have a unique name.
  64886. */
  64887. name: string;
  64888. /**
  64889. * The scene the component belongs to.
  64890. */
  64891. scene: Scene;
  64892. /**
  64893. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64894. */
  64895. zOffset: number;
  64896. private _engine;
  64897. private _effect;
  64898. private _cachedDefines;
  64899. private _savedDepthWrite;
  64900. /**
  64901. * Instantiates a new outline renderer. (There could be only one per scene).
  64902. * @param scene Defines the scene it belongs to
  64903. */
  64904. constructor(scene: Scene);
  64905. /**
  64906. * Register the component to one instance of a scene.
  64907. */
  64908. register(): void;
  64909. /**
  64910. * Rebuilds the elements related to this component in case of
  64911. * context lost for instance.
  64912. */
  64913. rebuild(): void;
  64914. /**
  64915. * Disposes the component and the associated ressources.
  64916. */
  64917. dispose(): void;
  64918. /**
  64919. * Renders the outline in the canvas.
  64920. * @param subMesh Defines the sumesh to render
  64921. * @param batch Defines the batch of meshes in case of instances
  64922. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64923. */
  64924. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64925. /**
  64926. * Returns whether or not the outline renderer is ready for a given submesh.
  64927. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64928. * @param subMesh Defines the submesh to check readyness for
  64929. * @param useInstances Defines wheter wee are trying to render instances or not
  64930. * @returns true if ready otherwise false
  64931. */
  64932. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64933. private _beforeRenderingMesh;
  64934. private _afterRenderingMesh;
  64935. }
  64936. }
  64937. declare module "babylonjs/Rendering/index" {
  64938. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64939. export * from "babylonjs/Rendering/depthRenderer";
  64940. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64941. export * from "babylonjs/Rendering/edgesRenderer";
  64942. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64943. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64944. export * from "babylonjs/Rendering/outlineRenderer";
  64945. export * from "babylonjs/Rendering/renderingGroup";
  64946. export * from "babylonjs/Rendering/renderingManager";
  64947. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64948. }
  64949. declare module "babylonjs/Sprites/spritePackedManager" {
  64950. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64951. import { Scene } from "babylonjs/scene";
  64952. /**
  64953. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64954. * @see http://doc.babylonjs.com/babylon101/sprites
  64955. */
  64956. export class SpritePackedManager extends SpriteManager {
  64957. /** defines the packed manager's name */
  64958. name: string;
  64959. /**
  64960. * Creates a new sprite manager from a packed sprite sheet
  64961. * @param name defines the manager's name
  64962. * @param imgUrl defines the sprite sheet url
  64963. * @param capacity defines the maximum allowed number of sprites
  64964. * @param scene defines the hosting scene
  64965. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64966. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64967. * @param samplingMode defines the smapling mode to use with spritesheet
  64968. * @param fromPacked set to true; do not alter
  64969. */
  64970. constructor(
  64971. /** defines the packed manager's name */
  64972. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64973. }
  64974. }
  64975. declare module "babylonjs/Sprites/index" {
  64976. export * from "babylonjs/Sprites/sprite";
  64977. export * from "babylonjs/Sprites/spriteManager";
  64978. export * from "babylonjs/Sprites/spritePackedManager";
  64979. export * from "babylonjs/Sprites/spriteSceneComponent";
  64980. }
  64981. declare module "babylonjs/States/index" {
  64982. export * from "babylonjs/States/alphaCullingState";
  64983. export * from "babylonjs/States/depthCullingState";
  64984. export * from "babylonjs/States/stencilState";
  64985. }
  64986. declare module "babylonjs/Misc/assetsManager" {
  64987. import { Scene } from "babylonjs/scene";
  64988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64989. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64990. import { Skeleton } from "babylonjs/Bones/skeleton";
  64991. import { Observable } from "babylonjs/Misc/observable";
  64992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64993. import { Texture } from "babylonjs/Materials/Textures/texture";
  64994. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64995. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64996. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64997. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64998. /**
  64999. * Defines the list of states available for a task inside a AssetsManager
  65000. */
  65001. export enum AssetTaskState {
  65002. /**
  65003. * Initialization
  65004. */
  65005. INIT = 0,
  65006. /**
  65007. * Running
  65008. */
  65009. RUNNING = 1,
  65010. /**
  65011. * Done
  65012. */
  65013. DONE = 2,
  65014. /**
  65015. * Error
  65016. */
  65017. ERROR = 3
  65018. }
  65019. /**
  65020. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65021. */
  65022. export abstract class AbstractAssetTask {
  65023. /**
  65024. * Task name
  65025. */ name: string;
  65026. /**
  65027. * Callback called when the task is successful
  65028. */
  65029. onSuccess: (task: any) => void;
  65030. /**
  65031. * Callback called when the task is not successful
  65032. */
  65033. onError: (task: any, message?: string, exception?: any) => void;
  65034. /**
  65035. * Creates a new AssetsManager
  65036. * @param name defines the name of the task
  65037. */
  65038. constructor(
  65039. /**
  65040. * Task name
  65041. */ name: string);
  65042. private _isCompleted;
  65043. private _taskState;
  65044. private _errorObject;
  65045. /**
  65046. * Get if the task is completed
  65047. */
  65048. readonly isCompleted: boolean;
  65049. /**
  65050. * Gets the current state of the task
  65051. */
  65052. readonly taskState: AssetTaskState;
  65053. /**
  65054. * Gets the current error object (if task is in error)
  65055. */
  65056. readonly errorObject: {
  65057. message?: string;
  65058. exception?: any;
  65059. };
  65060. /**
  65061. * Internal only
  65062. * @hidden
  65063. */
  65064. _setErrorObject(message?: string, exception?: any): void;
  65065. /**
  65066. * Execute the current task
  65067. * @param scene defines the scene where you want your assets to be loaded
  65068. * @param onSuccess is a callback called when the task is successfully executed
  65069. * @param onError is a callback called if an error occurs
  65070. */
  65071. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65072. /**
  65073. * Execute the current task
  65074. * @param scene defines the scene where you want your assets to be loaded
  65075. * @param onSuccess is a callback called when the task is successfully executed
  65076. * @param onError is a callback called if an error occurs
  65077. */
  65078. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65079. /**
  65080. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65081. * This can be used with failed tasks that have the reason for failure fixed.
  65082. */
  65083. reset(): void;
  65084. private onErrorCallback;
  65085. private onDoneCallback;
  65086. }
  65087. /**
  65088. * Define the interface used by progress events raised during assets loading
  65089. */
  65090. export interface IAssetsProgressEvent {
  65091. /**
  65092. * Defines the number of remaining tasks to process
  65093. */
  65094. remainingCount: number;
  65095. /**
  65096. * Defines the total number of tasks
  65097. */
  65098. totalCount: number;
  65099. /**
  65100. * Defines the task that was just processed
  65101. */
  65102. task: AbstractAssetTask;
  65103. }
  65104. /**
  65105. * Class used to share progress information about assets loading
  65106. */
  65107. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65108. /**
  65109. * Defines the number of remaining tasks to process
  65110. */
  65111. remainingCount: number;
  65112. /**
  65113. * Defines the total number of tasks
  65114. */
  65115. totalCount: number;
  65116. /**
  65117. * Defines the task that was just processed
  65118. */
  65119. task: AbstractAssetTask;
  65120. /**
  65121. * Creates a AssetsProgressEvent
  65122. * @param remainingCount defines the number of remaining tasks to process
  65123. * @param totalCount defines the total number of tasks
  65124. * @param task defines the task that was just processed
  65125. */
  65126. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65127. }
  65128. /**
  65129. * Define a task used by AssetsManager to load meshes
  65130. */
  65131. export class MeshAssetTask extends AbstractAssetTask {
  65132. /**
  65133. * Defines the name of the task
  65134. */
  65135. name: string;
  65136. /**
  65137. * Defines the list of mesh's names you want to load
  65138. */
  65139. meshesNames: any;
  65140. /**
  65141. * Defines the root url to use as a base to load your meshes and associated resources
  65142. */
  65143. rootUrl: string;
  65144. /**
  65145. * Defines the filename of the scene to load from
  65146. */
  65147. sceneFilename: string;
  65148. /**
  65149. * Gets the list of loaded meshes
  65150. */
  65151. loadedMeshes: Array<AbstractMesh>;
  65152. /**
  65153. * Gets the list of loaded particle systems
  65154. */
  65155. loadedParticleSystems: Array<IParticleSystem>;
  65156. /**
  65157. * Gets the list of loaded skeletons
  65158. */
  65159. loadedSkeletons: Array<Skeleton>;
  65160. /**
  65161. * Gets the list of loaded animation groups
  65162. */
  65163. loadedAnimationGroups: Array<AnimationGroup>;
  65164. /**
  65165. * Callback called when the task is successful
  65166. */
  65167. onSuccess: (task: MeshAssetTask) => void;
  65168. /**
  65169. * Callback called when the task is successful
  65170. */
  65171. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65172. /**
  65173. * Creates a new MeshAssetTask
  65174. * @param name defines the name of the task
  65175. * @param meshesNames defines the list of mesh's names you want to load
  65176. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65177. * @param sceneFilename defines the filename of the scene to load from
  65178. */
  65179. constructor(
  65180. /**
  65181. * Defines the name of the task
  65182. */
  65183. name: string,
  65184. /**
  65185. * Defines the list of mesh's names you want to load
  65186. */
  65187. meshesNames: any,
  65188. /**
  65189. * Defines the root url to use as a base to load your meshes and associated resources
  65190. */
  65191. rootUrl: string,
  65192. /**
  65193. * Defines the filename of the scene to load from
  65194. */
  65195. sceneFilename: string);
  65196. /**
  65197. * Execute the current task
  65198. * @param scene defines the scene where you want your assets to be loaded
  65199. * @param onSuccess is a callback called when the task is successfully executed
  65200. * @param onError is a callback called if an error occurs
  65201. */
  65202. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65203. }
  65204. /**
  65205. * Define a task used by AssetsManager to load text content
  65206. */
  65207. export class TextFileAssetTask extends AbstractAssetTask {
  65208. /**
  65209. * Defines the name of the task
  65210. */
  65211. name: string;
  65212. /**
  65213. * Defines the location of the file to load
  65214. */
  65215. url: string;
  65216. /**
  65217. * Gets the loaded text string
  65218. */
  65219. text: string;
  65220. /**
  65221. * Callback called when the task is successful
  65222. */
  65223. onSuccess: (task: TextFileAssetTask) => void;
  65224. /**
  65225. * Callback called when the task is successful
  65226. */
  65227. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65228. /**
  65229. * Creates a new TextFileAssetTask object
  65230. * @param name defines the name of the task
  65231. * @param url defines the location of the file to load
  65232. */
  65233. constructor(
  65234. /**
  65235. * Defines the name of the task
  65236. */
  65237. name: string,
  65238. /**
  65239. * Defines the location of the file to load
  65240. */
  65241. url: string);
  65242. /**
  65243. * Execute the current task
  65244. * @param scene defines the scene where you want your assets to be loaded
  65245. * @param onSuccess is a callback called when the task is successfully executed
  65246. * @param onError is a callback called if an error occurs
  65247. */
  65248. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65249. }
  65250. /**
  65251. * Define a task used by AssetsManager to load binary data
  65252. */
  65253. export class BinaryFileAssetTask extends AbstractAssetTask {
  65254. /**
  65255. * Defines the name of the task
  65256. */
  65257. name: string;
  65258. /**
  65259. * Defines the location of the file to load
  65260. */
  65261. url: string;
  65262. /**
  65263. * Gets the lodaded data (as an array buffer)
  65264. */
  65265. data: ArrayBuffer;
  65266. /**
  65267. * Callback called when the task is successful
  65268. */
  65269. onSuccess: (task: BinaryFileAssetTask) => void;
  65270. /**
  65271. * Callback called when the task is successful
  65272. */
  65273. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65274. /**
  65275. * Creates a new BinaryFileAssetTask object
  65276. * @param name defines the name of the new task
  65277. * @param url defines the location of the file to load
  65278. */
  65279. constructor(
  65280. /**
  65281. * Defines the name of the task
  65282. */
  65283. name: string,
  65284. /**
  65285. * Defines the location of the file to load
  65286. */
  65287. url: string);
  65288. /**
  65289. * Execute the current task
  65290. * @param scene defines the scene where you want your assets to be loaded
  65291. * @param onSuccess is a callback called when the task is successfully executed
  65292. * @param onError is a callback called if an error occurs
  65293. */
  65294. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65295. }
  65296. /**
  65297. * Define a task used by AssetsManager to load images
  65298. */
  65299. export class ImageAssetTask extends AbstractAssetTask {
  65300. /**
  65301. * Defines the name of the task
  65302. */
  65303. name: string;
  65304. /**
  65305. * Defines the location of the image to load
  65306. */
  65307. url: string;
  65308. /**
  65309. * Gets the loaded images
  65310. */
  65311. image: HTMLImageElement;
  65312. /**
  65313. * Callback called when the task is successful
  65314. */
  65315. onSuccess: (task: ImageAssetTask) => void;
  65316. /**
  65317. * Callback called when the task is successful
  65318. */
  65319. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65320. /**
  65321. * Creates a new ImageAssetTask
  65322. * @param name defines the name of the task
  65323. * @param url defines the location of the image to load
  65324. */
  65325. constructor(
  65326. /**
  65327. * Defines the name of the task
  65328. */
  65329. name: string,
  65330. /**
  65331. * Defines the location of the image to load
  65332. */
  65333. url: string);
  65334. /**
  65335. * Execute the current task
  65336. * @param scene defines the scene where you want your assets to be loaded
  65337. * @param onSuccess is a callback called when the task is successfully executed
  65338. * @param onError is a callback called if an error occurs
  65339. */
  65340. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65341. }
  65342. /**
  65343. * Defines the interface used by texture loading tasks
  65344. */
  65345. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65346. /**
  65347. * Gets the loaded texture
  65348. */
  65349. texture: TEX;
  65350. }
  65351. /**
  65352. * Define a task used by AssetsManager to load 2D textures
  65353. */
  65354. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65355. /**
  65356. * Defines the name of the task
  65357. */
  65358. name: string;
  65359. /**
  65360. * Defines the location of the file to load
  65361. */
  65362. url: string;
  65363. /**
  65364. * Defines if mipmap should not be generated (default is false)
  65365. */
  65366. noMipmap?: boolean | undefined;
  65367. /**
  65368. * Defines if texture must be inverted on Y axis (default is false)
  65369. */
  65370. invertY?: boolean | undefined;
  65371. /**
  65372. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65373. */
  65374. samplingMode: number;
  65375. /**
  65376. * Gets the loaded texture
  65377. */
  65378. texture: Texture;
  65379. /**
  65380. * Callback called when the task is successful
  65381. */
  65382. onSuccess: (task: TextureAssetTask) => void;
  65383. /**
  65384. * Callback called when the task is successful
  65385. */
  65386. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65387. /**
  65388. * Creates a new TextureAssetTask object
  65389. * @param name defines the name of the task
  65390. * @param url defines the location of the file to load
  65391. * @param noMipmap defines if mipmap should not be generated (default is false)
  65392. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65393. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65394. */
  65395. constructor(
  65396. /**
  65397. * Defines the name of the task
  65398. */
  65399. name: string,
  65400. /**
  65401. * Defines the location of the file to load
  65402. */
  65403. url: string,
  65404. /**
  65405. * Defines if mipmap should not be generated (default is false)
  65406. */
  65407. noMipmap?: boolean | undefined,
  65408. /**
  65409. * Defines if texture must be inverted on Y axis (default is false)
  65410. */
  65411. invertY?: boolean | undefined,
  65412. /**
  65413. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65414. */
  65415. samplingMode?: number);
  65416. /**
  65417. * Execute the current task
  65418. * @param scene defines the scene where you want your assets to be loaded
  65419. * @param onSuccess is a callback called when the task is successfully executed
  65420. * @param onError is a callback called if an error occurs
  65421. */
  65422. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65423. }
  65424. /**
  65425. * Define a task used by AssetsManager to load cube textures
  65426. */
  65427. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65428. /**
  65429. * Defines the name of the task
  65430. */
  65431. name: string;
  65432. /**
  65433. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65434. */
  65435. url: string;
  65436. /**
  65437. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65438. */
  65439. extensions?: string[] | undefined;
  65440. /**
  65441. * Defines if mipmaps should not be generated (default is false)
  65442. */
  65443. noMipmap?: boolean | undefined;
  65444. /**
  65445. * Defines the explicit list of files (undefined by default)
  65446. */
  65447. files?: string[] | undefined;
  65448. /**
  65449. * Gets the loaded texture
  65450. */
  65451. texture: CubeTexture;
  65452. /**
  65453. * Callback called when the task is successful
  65454. */
  65455. onSuccess: (task: CubeTextureAssetTask) => void;
  65456. /**
  65457. * Callback called when the task is successful
  65458. */
  65459. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65460. /**
  65461. * Creates a new CubeTextureAssetTask
  65462. * @param name defines the name of the task
  65463. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65464. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65465. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65466. * @param files defines the explicit list of files (undefined by default)
  65467. */
  65468. constructor(
  65469. /**
  65470. * Defines the name of the task
  65471. */
  65472. name: string,
  65473. /**
  65474. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65475. */
  65476. url: string,
  65477. /**
  65478. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65479. */
  65480. extensions?: string[] | undefined,
  65481. /**
  65482. * Defines if mipmaps should not be generated (default is false)
  65483. */
  65484. noMipmap?: boolean | undefined,
  65485. /**
  65486. * Defines the explicit list of files (undefined by default)
  65487. */
  65488. files?: string[] | undefined);
  65489. /**
  65490. * Execute the current task
  65491. * @param scene defines the scene where you want your assets to be loaded
  65492. * @param onSuccess is a callback called when the task is successfully executed
  65493. * @param onError is a callback called if an error occurs
  65494. */
  65495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65496. }
  65497. /**
  65498. * Define a task used by AssetsManager to load HDR cube textures
  65499. */
  65500. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65501. /**
  65502. * Defines the name of the task
  65503. */
  65504. name: string;
  65505. /**
  65506. * Defines the location of the file to load
  65507. */
  65508. url: string;
  65509. /**
  65510. * Defines the desired size (the more it increases the longer the generation will be)
  65511. */
  65512. size: number;
  65513. /**
  65514. * Defines if mipmaps should not be generated (default is false)
  65515. */
  65516. noMipmap: boolean;
  65517. /**
  65518. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65519. */
  65520. generateHarmonics: boolean;
  65521. /**
  65522. * 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)
  65523. */
  65524. gammaSpace: boolean;
  65525. /**
  65526. * Internal Use Only
  65527. */
  65528. reserved: boolean;
  65529. /**
  65530. * Gets the loaded texture
  65531. */
  65532. texture: HDRCubeTexture;
  65533. /**
  65534. * Callback called when the task is successful
  65535. */
  65536. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65537. /**
  65538. * Callback called when the task is successful
  65539. */
  65540. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65541. /**
  65542. * Creates a new HDRCubeTextureAssetTask object
  65543. * @param name defines the name of the task
  65544. * @param url defines the location of the file to load
  65545. * @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.
  65546. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65547. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65548. * @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)
  65549. * @param reserved Internal use only
  65550. */
  65551. constructor(
  65552. /**
  65553. * Defines the name of the task
  65554. */
  65555. name: string,
  65556. /**
  65557. * Defines the location of the file to load
  65558. */
  65559. url: string,
  65560. /**
  65561. * Defines the desired size (the more it increases the longer the generation will be)
  65562. */
  65563. size: number,
  65564. /**
  65565. * Defines if mipmaps should not be generated (default is false)
  65566. */
  65567. noMipmap?: boolean,
  65568. /**
  65569. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65570. */
  65571. generateHarmonics?: boolean,
  65572. /**
  65573. * 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)
  65574. */
  65575. gammaSpace?: boolean,
  65576. /**
  65577. * Internal Use Only
  65578. */
  65579. reserved?: boolean);
  65580. /**
  65581. * Execute the current task
  65582. * @param scene defines the scene where you want your assets to be loaded
  65583. * @param onSuccess is a callback called when the task is successfully executed
  65584. * @param onError is a callback called if an error occurs
  65585. */
  65586. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65587. }
  65588. /**
  65589. * Define a task used by AssetsManager to load Equirectangular cube textures
  65590. */
  65591. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65592. /**
  65593. * Defines the name of the task
  65594. */
  65595. name: string;
  65596. /**
  65597. * Defines the location of the file to load
  65598. */
  65599. url: string;
  65600. /**
  65601. * Defines the desired size (the more it increases the longer the generation will be)
  65602. */
  65603. size: number;
  65604. /**
  65605. * Defines if mipmaps should not be generated (default is false)
  65606. */
  65607. noMipmap: boolean;
  65608. /**
  65609. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65610. * but the standard material would require them in Gamma space) (default is true)
  65611. */
  65612. gammaSpace: boolean;
  65613. /**
  65614. * Gets the loaded texture
  65615. */
  65616. texture: EquiRectangularCubeTexture;
  65617. /**
  65618. * Callback called when the task is successful
  65619. */
  65620. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65621. /**
  65622. * Callback called when the task is successful
  65623. */
  65624. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65625. /**
  65626. * Creates a new EquiRectangularCubeTextureAssetTask object
  65627. * @param name defines the name of the task
  65628. * @param url defines the location of the file to load
  65629. * @param size defines the desired size (the more it increases the longer the generation will be)
  65630. * If the size is omitted this implies you are using a preprocessed cubemap.
  65631. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65632. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65633. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65634. * (default is true)
  65635. */
  65636. constructor(
  65637. /**
  65638. * Defines the name of the task
  65639. */
  65640. name: string,
  65641. /**
  65642. * Defines the location of the file to load
  65643. */
  65644. url: string,
  65645. /**
  65646. * Defines the desired size (the more it increases the longer the generation will be)
  65647. */
  65648. size: number,
  65649. /**
  65650. * Defines if mipmaps should not be generated (default is false)
  65651. */
  65652. noMipmap?: boolean,
  65653. /**
  65654. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65655. * but the standard material would require them in Gamma space) (default is true)
  65656. */
  65657. gammaSpace?: boolean);
  65658. /**
  65659. * Execute the current task
  65660. * @param scene defines the scene where you want your assets to be loaded
  65661. * @param onSuccess is a callback called when the task is successfully executed
  65662. * @param onError is a callback called if an error occurs
  65663. */
  65664. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65665. }
  65666. /**
  65667. * This class can be used to easily import assets into a scene
  65668. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65669. */
  65670. export class AssetsManager {
  65671. private _scene;
  65672. private _isLoading;
  65673. protected _tasks: AbstractAssetTask[];
  65674. protected _waitingTasksCount: number;
  65675. protected _totalTasksCount: number;
  65676. /**
  65677. * Callback called when all tasks are processed
  65678. */
  65679. onFinish: (tasks: AbstractAssetTask[]) => void;
  65680. /**
  65681. * Callback called when a task is successful
  65682. */
  65683. onTaskSuccess: (task: AbstractAssetTask) => void;
  65684. /**
  65685. * Callback called when a task had an error
  65686. */
  65687. onTaskError: (task: AbstractAssetTask) => void;
  65688. /**
  65689. * Callback called when a task is done (whatever the result is)
  65690. */
  65691. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65692. /**
  65693. * Observable called when all tasks are processed
  65694. */
  65695. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65696. /**
  65697. * Observable called when a task had an error
  65698. */
  65699. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65700. /**
  65701. * Observable called when all tasks were executed
  65702. */
  65703. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65704. /**
  65705. * Observable called when a task is done (whatever the result is)
  65706. */
  65707. onProgressObservable: Observable<IAssetsProgressEvent>;
  65708. /**
  65709. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65710. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65711. */
  65712. useDefaultLoadingScreen: boolean;
  65713. /**
  65714. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65715. * when all assets have been downloaded.
  65716. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65717. */
  65718. autoHideLoadingUI: boolean;
  65719. /**
  65720. * Creates a new AssetsManager
  65721. * @param scene defines the scene to work on
  65722. */
  65723. constructor(scene: Scene);
  65724. /**
  65725. * Add a MeshAssetTask to the list of active tasks
  65726. * @param taskName defines the name of the new task
  65727. * @param meshesNames defines the name of meshes to load
  65728. * @param rootUrl defines the root url to use to locate files
  65729. * @param sceneFilename defines the filename of the scene file
  65730. * @returns a new MeshAssetTask object
  65731. */
  65732. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65733. /**
  65734. * Add a TextFileAssetTask to the list of active tasks
  65735. * @param taskName defines the name of the new task
  65736. * @param url defines the url of the file to load
  65737. * @returns a new TextFileAssetTask object
  65738. */
  65739. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65740. /**
  65741. * Add a BinaryFileAssetTask to the list of active tasks
  65742. * @param taskName defines the name of the new task
  65743. * @param url defines the url of the file to load
  65744. * @returns a new BinaryFileAssetTask object
  65745. */
  65746. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65747. /**
  65748. * Add a ImageAssetTask to the list of active tasks
  65749. * @param taskName defines the name of the new task
  65750. * @param url defines the url of the file to load
  65751. * @returns a new ImageAssetTask object
  65752. */
  65753. addImageTask(taskName: string, url: string): ImageAssetTask;
  65754. /**
  65755. * Add a TextureAssetTask to the list of active tasks
  65756. * @param taskName defines the name of the new task
  65757. * @param url defines the url of the file to load
  65758. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65759. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65760. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65761. * @returns a new TextureAssetTask object
  65762. */
  65763. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65764. /**
  65765. * Add a CubeTextureAssetTask 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. * @param extensions defines the extension to use to load the cube map (can be null)
  65769. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65770. * @param files defines the list of files to load (can be null)
  65771. * @returns a new CubeTextureAssetTask object
  65772. */
  65773. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65774. /**
  65775. *
  65776. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65777. * @param taskName defines the name of the new task
  65778. * @param url defines the url of the file to load
  65779. * @param size defines the size you want for the cubemap (can be null)
  65780. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65781. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65782. * @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)
  65783. * @param reserved Internal use only
  65784. * @returns a new HDRCubeTextureAssetTask object
  65785. */
  65786. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65787. /**
  65788. *
  65789. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65790. * @param taskName defines the name of the new task
  65791. * @param url defines the url of the file to load
  65792. * @param size defines the size you want for the cubemap (can be null)
  65793. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65794. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65795. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65796. * @returns a new EquiRectangularCubeTextureAssetTask object
  65797. */
  65798. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65799. /**
  65800. * Remove a task from the assets manager.
  65801. * @param task the task to remove
  65802. */
  65803. removeTask(task: AbstractAssetTask): void;
  65804. private _decreaseWaitingTasksCount;
  65805. private _runTask;
  65806. /**
  65807. * Reset the AssetsManager and remove all tasks
  65808. * @return the current instance of the AssetsManager
  65809. */
  65810. reset(): AssetsManager;
  65811. /**
  65812. * Start the loading process
  65813. * @return the current instance of the AssetsManager
  65814. */
  65815. load(): AssetsManager;
  65816. /**
  65817. * Start the loading process as an async operation
  65818. * @return a promise returning the list of failed tasks
  65819. */
  65820. loadAsync(): Promise<void>;
  65821. }
  65822. }
  65823. declare module "babylonjs/Misc/deferred" {
  65824. /**
  65825. * Wrapper class for promise with external resolve and reject.
  65826. */
  65827. export class Deferred<T> {
  65828. /**
  65829. * The promise associated with this deferred object.
  65830. */
  65831. readonly promise: Promise<T>;
  65832. private _resolve;
  65833. private _reject;
  65834. /**
  65835. * The resolve method of the promise associated with this deferred object.
  65836. */
  65837. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65838. /**
  65839. * The reject method of the promise associated with this deferred object.
  65840. */
  65841. readonly reject: (reason?: any) => void;
  65842. /**
  65843. * Constructor for this deferred object.
  65844. */
  65845. constructor();
  65846. }
  65847. }
  65848. declare module "babylonjs/Misc/meshExploder" {
  65849. import { Mesh } from "babylonjs/Meshes/mesh";
  65850. /**
  65851. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65852. */
  65853. export class MeshExploder {
  65854. private _centerMesh;
  65855. private _meshes;
  65856. private _meshesOrigins;
  65857. private _toCenterVectors;
  65858. private _scaledDirection;
  65859. private _newPosition;
  65860. private _centerPosition;
  65861. /**
  65862. * Explodes meshes from a center mesh.
  65863. * @param meshes The meshes to explode.
  65864. * @param centerMesh The mesh to be center of explosion.
  65865. */
  65866. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65867. private _setCenterMesh;
  65868. /**
  65869. * Get class name
  65870. * @returns "MeshExploder"
  65871. */
  65872. getClassName(): string;
  65873. /**
  65874. * "Exploded meshes"
  65875. * @returns Array of meshes with the centerMesh at index 0.
  65876. */
  65877. getMeshes(): Array<Mesh>;
  65878. /**
  65879. * Explodes meshes giving a specific direction
  65880. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65881. */
  65882. explode(direction?: number): void;
  65883. }
  65884. }
  65885. declare module "babylonjs/Misc/filesInput" {
  65886. import { Engine } from "babylonjs/Engines/engine";
  65887. import { Scene } from "babylonjs/scene";
  65888. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65889. /**
  65890. * Class used to help managing file picking and drag'n'drop
  65891. */
  65892. export class FilesInput {
  65893. /**
  65894. * List of files ready to be loaded
  65895. */
  65896. static readonly FilesToLoad: {
  65897. [key: string]: File;
  65898. };
  65899. /**
  65900. * Callback called when a file is processed
  65901. */
  65902. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65903. private _engine;
  65904. private _currentScene;
  65905. private _sceneLoadedCallback;
  65906. private _progressCallback;
  65907. private _additionalRenderLoopLogicCallback;
  65908. private _textureLoadingCallback;
  65909. private _startingProcessingFilesCallback;
  65910. private _onReloadCallback;
  65911. private _errorCallback;
  65912. private _elementToMonitor;
  65913. private _sceneFileToLoad;
  65914. private _filesToLoad;
  65915. /**
  65916. * Creates a new FilesInput
  65917. * @param engine defines the rendering engine
  65918. * @param scene defines the hosting scene
  65919. * @param sceneLoadedCallback callback called when scene is loaded
  65920. * @param progressCallback callback called to track progress
  65921. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65922. * @param textureLoadingCallback callback called when a texture is loading
  65923. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65924. * @param onReloadCallback callback called when a reload is requested
  65925. * @param errorCallback callback call if an error occurs
  65926. */
  65927. 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);
  65928. private _dragEnterHandler;
  65929. private _dragOverHandler;
  65930. private _dropHandler;
  65931. /**
  65932. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65933. * @param elementToMonitor defines the DOM element to track
  65934. */
  65935. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65936. /**
  65937. * Release all associated resources
  65938. */
  65939. dispose(): void;
  65940. private renderFunction;
  65941. private drag;
  65942. private drop;
  65943. private _traverseFolder;
  65944. private _processFiles;
  65945. /**
  65946. * Load files from a drop event
  65947. * @param event defines the drop event to use as source
  65948. */
  65949. loadFiles(event: any): void;
  65950. private _processReload;
  65951. /**
  65952. * Reload the current scene from the loaded files
  65953. */
  65954. reload(): void;
  65955. }
  65956. }
  65957. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65958. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65959. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65960. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65961. }
  65962. declare module "babylonjs/Misc/sceneOptimizer" {
  65963. import { Scene, IDisposable } from "babylonjs/scene";
  65964. import { Observable } from "babylonjs/Misc/observable";
  65965. /**
  65966. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65968. */
  65969. export class SceneOptimization {
  65970. /**
  65971. * Defines the priority of this optimization (0 by default which means first in the list)
  65972. */
  65973. priority: number;
  65974. /**
  65975. * Gets a string describing the action executed by the current optimization
  65976. * @returns description string
  65977. */
  65978. getDescription(): string;
  65979. /**
  65980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65981. * @param scene defines the current scene where to apply this optimization
  65982. * @param optimizer defines the current optimizer
  65983. * @returns true if everything that can be done was applied
  65984. */
  65985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65986. /**
  65987. * Creates the SceneOptimization object
  65988. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65989. * @param desc defines the description associated with the optimization
  65990. */
  65991. constructor(
  65992. /**
  65993. * Defines the priority of this optimization (0 by default which means first in the list)
  65994. */
  65995. priority?: number);
  65996. }
  65997. /**
  65998. * Defines an optimization used to reduce the size of render target textures
  65999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66000. */
  66001. export class TextureOptimization extends SceneOptimization {
  66002. /**
  66003. * Defines the priority of this optimization (0 by default which means first in the list)
  66004. */
  66005. priority: number;
  66006. /**
  66007. * 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
  66008. */
  66009. maximumSize: number;
  66010. /**
  66011. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66012. */
  66013. step: number;
  66014. /**
  66015. * Gets a string describing the action executed by the current optimization
  66016. * @returns description string
  66017. */
  66018. getDescription(): string;
  66019. /**
  66020. * Creates the TextureOptimization object
  66021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66022. * @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
  66023. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66024. */
  66025. constructor(
  66026. /**
  66027. * Defines the priority of this optimization (0 by default which means first in the list)
  66028. */
  66029. priority?: number,
  66030. /**
  66031. * 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
  66032. */
  66033. maximumSize?: number,
  66034. /**
  66035. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66036. */
  66037. step?: number);
  66038. /**
  66039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66040. * @param scene defines the current scene where to apply this optimization
  66041. * @param optimizer defines the current optimizer
  66042. * @returns true if everything that can be done was applied
  66043. */
  66044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66045. }
  66046. /**
  66047. * Defines an optimization used to increase or decrease the rendering resolution
  66048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66049. */
  66050. export class HardwareScalingOptimization extends SceneOptimization {
  66051. /**
  66052. * Defines the priority of this optimization (0 by default which means first in the list)
  66053. */
  66054. priority: number;
  66055. /**
  66056. * Defines the maximum scale to use (2 by default)
  66057. */
  66058. maximumScale: number;
  66059. /**
  66060. * Defines the step to use between two passes (0.5 by default)
  66061. */
  66062. step: number;
  66063. private _currentScale;
  66064. private _directionOffset;
  66065. /**
  66066. * Gets a string describing the action executed by the current optimization
  66067. * @return description string
  66068. */
  66069. getDescription(): string;
  66070. /**
  66071. * Creates the HardwareScalingOptimization object
  66072. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66073. * @param maximumScale defines the maximum scale to use (2 by default)
  66074. * @param step defines the step to use between two passes (0.5 by default)
  66075. */
  66076. constructor(
  66077. /**
  66078. * Defines the priority of this optimization (0 by default which means first in the list)
  66079. */
  66080. priority?: number,
  66081. /**
  66082. * Defines the maximum scale to use (2 by default)
  66083. */
  66084. maximumScale?: number,
  66085. /**
  66086. * Defines the step to use between two passes (0.5 by default)
  66087. */
  66088. step?: number);
  66089. /**
  66090. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66091. * @param scene defines the current scene where to apply this optimization
  66092. * @param optimizer defines the current optimizer
  66093. * @returns true if everything that can be done was applied
  66094. */
  66095. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66096. }
  66097. /**
  66098. * Defines an optimization used to remove shadows
  66099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66100. */
  66101. export class ShadowsOptimization extends SceneOptimization {
  66102. /**
  66103. * Gets a string describing the action executed by the current optimization
  66104. * @return description string
  66105. */
  66106. getDescription(): string;
  66107. /**
  66108. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66109. * @param scene defines the current scene where to apply this optimization
  66110. * @param optimizer defines the current optimizer
  66111. * @returns true if everything that can be done was applied
  66112. */
  66113. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66114. }
  66115. /**
  66116. * Defines an optimization used to turn post-processes off
  66117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66118. */
  66119. export class PostProcessesOptimization extends SceneOptimization {
  66120. /**
  66121. * Gets a string describing the action executed by the current optimization
  66122. * @return description string
  66123. */
  66124. getDescription(): string;
  66125. /**
  66126. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66127. * @param scene defines the current scene where to apply this optimization
  66128. * @param optimizer defines the current optimizer
  66129. * @returns true if everything that can be done was applied
  66130. */
  66131. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66132. }
  66133. /**
  66134. * Defines an optimization used to turn lens flares off
  66135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66136. */
  66137. export class LensFlaresOptimization extends SceneOptimization {
  66138. /**
  66139. * Gets a string describing the action executed by the current optimization
  66140. * @return description string
  66141. */
  66142. getDescription(): string;
  66143. /**
  66144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66145. * @param scene defines the current scene where to apply this optimization
  66146. * @param optimizer defines the current optimizer
  66147. * @returns true if everything that can be done was applied
  66148. */
  66149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66150. }
  66151. /**
  66152. * Defines an optimization based on user defined callback.
  66153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66154. */
  66155. export class CustomOptimization extends SceneOptimization {
  66156. /**
  66157. * Callback called to apply the custom optimization.
  66158. */
  66159. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66160. /**
  66161. * Callback called to get custom description
  66162. */
  66163. onGetDescription: () => string;
  66164. /**
  66165. * Gets a string describing the action executed by the current optimization
  66166. * @returns description string
  66167. */
  66168. getDescription(): string;
  66169. /**
  66170. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66171. * @param scene defines the current scene where to apply this optimization
  66172. * @param optimizer defines the current optimizer
  66173. * @returns true if everything that can be done was applied
  66174. */
  66175. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66176. }
  66177. /**
  66178. * Defines an optimization used to turn particles off
  66179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66180. */
  66181. export class ParticlesOptimization extends SceneOptimization {
  66182. /**
  66183. * Gets a string describing the action executed by the current optimization
  66184. * @return description string
  66185. */
  66186. getDescription(): string;
  66187. /**
  66188. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66189. * @param scene defines the current scene where to apply this optimization
  66190. * @param optimizer defines the current optimizer
  66191. * @returns true if everything that can be done was applied
  66192. */
  66193. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66194. }
  66195. /**
  66196. * Defines an optimization used to turn render targets off
  66197. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66198. */
  66199. export class RenderTargetsOptimization extends SceneOptimization {
  66200. /**
  66201. * Gets a string describing the action executed by the current optimization
  66202. * @return description string
  66203. */
  66204. getDescription(): string;
  66205. /**
  66206. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66207. * @param scene defines the current scene where to apply this optimization
  66208. * @param optimizer defines the current optimizer
  66209. * @returns true if everything that can be done was applied
  66210. */
  66211. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66212. }
  66213. /**
  66214. * Defines an optimization used to merge meshes with compatible materials
  66215. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66216. */
  66217. export class MergeMeshesOptimization extends SceneOptimization {
  66218. private static _UpdateSelectionTree;
  66219. /**
  66220. * Gets or sets a boolean which defines if optimization octree has to be updated
  66221. */
  66222. /**
  66223. * Gets or sets a boolean which defines if optimization octree has to be updated
  66224. */
  66225. static UpdateSelectionTree: boolean;
  66226. /**
  66227. * Gets a string describing the action executed by the current optimization
  66228. * @return description string
  66229. */
  66230. getDescription(): string;
  66231. private _canBeMerged;
  66232. /**
  66233. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66234. * @param scene defines the current scene where to apply this optimization
  66235. * @param optimizer defines the current optimizer
  66236. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66237. * @returns true if everything that can be done was applied
  66238. */
  66239. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66240. }
  66241. /**
  66242. * Defines a list of options used by SceneOptimizer
  66243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66244. */
  66245. export class SceneOptimizerOptions {
  66246. /**
  66247. * Defines the target frame rate to reach (60 by default)
  66248. */
  66249. targetFrameRate: number;
  66250. /**
  66251. * Defines the interval between two checkes (2000ms by default)
  66252. */
  66253. trackerDuration: number;
  66254. /**
  66255. * Gets the list of optimizations to apply
  66256. */
  66257. optimizations: SceneOptimization[];
  66258. /**
  66259. * Creates a new list of options used by SceneOptimizer
  66260. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66261. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66262. */
  66263. constructor(
  66264. /**
  66265. * Defines the target frame rate to reach (60 by default)
  66266. */
  66267. targetFrameRate?: number,
  66268. /**
  66269. * Defines the interval between two checkes (2000ms by default)
  66270. */
  66271. trackerDuration?: number);
  66272. /**
  66273. * Add a new optimization
  66274. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66275. * @returns the current SceneOptimizerOptions
  66276. */
  66277. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66278. /**
  66279. * Add a new custom optimization
  66280. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66281. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66282. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66283. * @returns the current SceneOptimizerOptions
  66284. */
  66285. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66286. /**
  66287. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66288. * @param targetFrameRate defines the target frame rate (60 by default)
  66289. * @returns a SceneOptimizerOptions object
  66290. */
  66291. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66292. /**
  66293. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66294. * @param targetFrameRate defines the target frame rate (60 by default)
  66295. * @returns a SceneOptimizerOptions object
  66296. */
  66297. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66298. /**
  66299. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66300. * @param targetFrameRate defines the target frame rate (60 by default)
  66301. * @returns a SceneOptimizerOptions object
  66302. */
  66303. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66304. }
  66305. /**
  66306. * Class used to run optimizations in order to reach a target frame rate
  66307. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66308. */
  66309. export class SceneOptimizer implements IDisposable {
  66310. private _isRunning;
  66311. private _options;
  66312. private _scene;
  66313. private _currentPriorityLevel;
  66314. private _targetFrameRate;
  66315. private _trackerDuration;
  66316. private _currentFrameRate;
  66317. private _sceneDisposeObserver;
  66318. private _improvementMode;
  66319. /**
  66320. * Defines an observable called when the optimizer reaches the target frame rate
  66321. */
  66322. onSuccessObservable: Observable<SceneOptimizer>;
  66323. /**
  66324. * Defines an observable called when the optimizer enables an optimization
  66325. */
  66326. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66327. /**
  66328. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66329. */
  66330. onFailureObservable: Observable<SceneOptimizer>;
  66331. /**
  66332. * Gets a boolean indicating if the optimizer is in improvement mode
  66333. */
  66334. readonly isInImprovementMode: boolean;
  66335. /**
  66336. * Gets the current priority level (0 at start)
  66337. */
  66338. readonly currentPriorityLevel: number;
  66339. /**
  66340. * Gets the current frame rate checked by the SceneOptimizer
  66341. */
  66342. readonly currentFrameRate: number;
  66343. /**
  66344. * Gets or sets the current target frame rate (60 by default)
  66345. */
  66346. /**
  66347. * Gets or sets the current target frame rate (60 by default)
  66348. */
  66349. targetFrameRate: number;
  66350. /**
  66351. * Gets or sets the current interval between two checks (every 2000ms by default)
  66352. */
  66353. /**
  66354. * Gets or sets the current interval between two checks (every 2000ms by default)
  66355. */
  66356. trackerDuration: number;
  66357. /**
  66358. * Gets the list of active optimizations
  66359. */
  66360. readonly optimizations: SceneOptimization[];
  66361. /**
  66362. * Creates a new SceneOptimizer
  66363. * @param scene defines the scene to work on
  66364. * @param options defines the options to use with the SceneOptimizer
  66365. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66366. * @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)
  66367. */
  66368. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66369. /**
  66370. * Stops the current optimizer
  66371. */
  66372. stop(): void;
  66373. /**
  66374. * Reset the optimizer to initial step (current priority level = 0)
  66375. */
  66376. reset(): void;
  66377. /**
  66378. * Start the optimizer. By default it will try to reach a specific framerate
  66379. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66380. */
  66381. start(): void;
  66382. private _checkCurrentState;
  66383. /**
  66384. * Release all resources
  66385. */
  66386. dispose(): void;
  66387. /**
  66388. * Helper function to create a SceneOptimizer with one single line of code
  66389. * @param scene defines the scene to work on
  66390. * @param options defines the options to use with the SceneOptimizer
  66391. * @param onSuccess defines a callback to call on success
  66392. * @param onFailure defines a callback to call on failure
  66393. * @returns the new SceneOptimizer object
  66394. */
  66395. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66396. }
  66397. }
  66398. declare module "babylonjs/Misc/sceneSerializer" {
  66399. import { Scene } from "babylonjs/scene";
  66400. /**
  66401. * Class used to serialize a scene into a string
  66402. */
  66403. export class SceneSerializer {
  66404. /**
  66405. * Clear cache used by a previous serialization
  66406. */
  66407. static ClearCache(): void;
  66408. /**
  66409. * Serialize a scene into a JSON compatible object
  66410. * @param scene defines the scene to serialize
  66411. * @returns a JSON compatible object
  66412. */
  66413. static Serialize(scene: Scene): any;
  66414. /**
  66415. * Serialize a mesh into a JSON compatible object
  66416. * @param toSerialize defines the mesh to serialize
  66417. * @param withParents defines if parents must be serialized as well
  66418. * @param withChildren defines if children must be serialized as well
  66419. * @returns a JSON compatible object
  66420. */
  66421. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66422. }
  66423. }
  66424. declare module "babylonjs/Misc/textureTools" {
  66425. import { Texture } from "babylonjs/Materials/Textures/texture";
  66426. /**
  66427. * Class used to host texture specific utilities
  66428. */
  66429. export class TextureTools {
  66430. /**
  66431. * Uses the GPU to create a copy texture rescaled at a given size
  66432. * @param texture Texture to copy from
  66433. * @param width defines the desired width
  66434. * @param height defines the desired height
  66435. * @param useBilinearMode defines if bilinear mode has to be used
  66436. * @return the generated texture
  66437. */
  66438. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66439. }
  66440. }
  66441. declare module "babylonjs/Misc/videoRecorder" {
  66442. import { Nullable } from "babylonjs/types";
  66443. import { Engine } from "babylonjs/Engines/engine";
  66444. /**
  66445. * This represents the different options available for the video capture.
  66446. */
  66447. export interface VideoRecorderOptions {
  66448. /** Defines the mime type of the video. */
  66449. mimeType: string;
  66450. /** Defines the FPS the video should be recorded at. */
  66451. fps: number;
  66452. /** Defines the chunk size for the recording data. */
  66453. recordChunckSize: number;
  66454. /** The audio tracks to attach to the recording. */
  66455. audioTracks?: MediaStreamTrack[];
  66456. }
  66457. /**
  66458. * This can help with recording videos from BabylonJS.
  66459. * This is based on the available WebRTC functionalities of the browser.
  66460. *
  66461. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66462. */
  66463. export class VideoRecorder {
  66464. private static readonly _defaultOptions;
  66465. /**
  66466. * Returns whether or not the VideoRecorder is available in your browser.
  66467. * @param engine Defines the Babylon Engine.
  66468. * @returns true if supported otherwise false.
  66469. */
  66470. static IsSupported(engine: Engine): boolean;
  66471. private readonly _options;
  66472. private _canvas;
  66473. private _mediaRecorder;
  66474. private _recordedChunks;
  66475. private _fileName;
  66476. private _resolve;
  66477. private _reject;
  66478. /**
  66479. * True when a recording is already in progress.
  66480. */
  66481. readonly isRecording: boolean;
  66482. /**
  66483. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66484. * @param engine Defines the BabylonJS Engine you wish to record.
  66485. * @param options Defines options that can be used to customize the capture.
  66486. */
  66487. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66488. /**
  66489. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66490. */
  66491. stopRecording(): void;
  66492. /**
  66493. * Starts recording the canvas for a max duration specified in parameters.
  66494. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66495. * If null no automatic download will start and you can rely on the promise to get the data back.
  66496. * @param maxDuration Defines the maximum recording time in seconds.
  66497. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66498. * @return A promise callback at the end of the recording with the video data in Blob.
  66499. */
  66500. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66501. /**
  66502. * Releases internal resources used during the recording.
  66503. */
  66504. dispose(): void;
  66505. private _handleDataAvailable;
  66506. private _handleError;
  66507. private _handleStop;
  66508. }
  66509. }
  66510. declare module "babylonjs/Misc/screenshotTools" {
  66511. import { Camera } from "babylonjs/Cameras/camera";
  66512. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66513. import { Engine } from "babylonjs/Engines/engine";
  66514. /**
  66515. * Class containing a set of static utilities functions for screenshots
  66516. */
  66517. export class ScreenshotTools {
  66518. /**
  66519. * Captures a screenshot of the current rendering
  66520. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66521. * @param engine defines the rendering engine
  66522. * @param camera defines the source camera
  66523. * @param size This parameter can be set to a single number or to an object with the
  66524. * following (optional) properties: precision, width, height. If a single number is passed,
  66525. * it will be used for both width and height. If an object is passed, the screenshot size
  66526. * will be derived from the parameters. The precision property is a multiplier allowing
  66527. * rendering at a higher or lower resolution
  66528. * @param successCallback defines the callback receives a single parameter which contains the
  66529. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66530. * src parameter of an <img> to display it
  66531. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66532. * Check your browser for supported MIME types
  66533. */
  66534. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66535. /**
  66536. * Captures a screenshot of the current rendering
  66537. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66538. * @param engine defines the rendering engine
  66539. * @param camera defines the source camera
  66540. * @param size This parameter can be set to a single number or to an object with the
  66541. * following (optional) properties: precision, width, height. If a single number is passed,
  66542. * it will be used for both width and height. If an object is passed, the screenshot size
  66543. * will be derived from the parameters. The precision property is a multiplier allowing
  66544. * rendering at a higher or lower resolution
  66545. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66546. * Check your browser for supported MIME types
  66547. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66548. * to the src parameter of an <img> to display it
  66549. */
  66550. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66551. /**
  66552. * Generates an image screenshot from the specified camera.
  66553. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66554. * @param engine The engine to use for rendering
  66555. * @param camera The camera to use for rendering
  66556. * @param size This parameter can be set to a single number or to an object with the
  66557. * following (optional) properties: precision, width, height. If a single number is passed,
  66558. * it will be used for both width and height. If an object is passed, the screenshot size
  66559. * will be derived from the parameters. The precision property is a multiplier allowing
  66560. * rendering at a higher or lower resolution
  66561. * @param successCallback The callback receives a single parameter which contains the
  66562. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66563. * src parameter of an <img> to display it
  66564. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66565. * Check your browser for supported MIME types
  66566. * @param samples Texture samples (default: 1)
  66567. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66568. * @param fileName A name for for the downloaded file.
  66569. */
  66570. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66571. /**
  66572. * Generates an image screenshot from the specified camera.
  66573. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66574. * @param engine The engine to use for rendering
  66575. * @param camera The camera to use for rendering
  66576. * @param size This parameter can be set to a single number or to an object with the
  66577. * following (optional) properties: precision, width, height. If a single number is passed,
  66578. * it will be used for both width and height. If an object is passed, the screenshot size
  66579. * will be derived from the parameters. The precision property is a multiplier allowing
  66580. * rendering at a higher or lower resolution
  66581. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66582. * Check your browser for supported MIME types
  66583. * @param samples Texture samples (default: 1)
  66584. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66585. * @param fileName A name for for the downloaded file.
  66586. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66587. * to the src parameter of an <img> to display it
  66588. */
  66589. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66590. /**
  66591. * Gets height and width for screenshot size
  66592. * @private
  66593. */
  66594. private static _getScreenshotSize;
  66595. }
  66596. }
  66597. declare module "babylonjs/Misc/index" {
  66598. export * from "babylonjs/Misc/andOrNotEvaluator";
  66599. export * from "babylonjs/Misc/assetsManager";
  66600. export * from "babylonjs/Misc/dds";
  66601. export * from "babylonjs/Misc/decorators";
  66602. export * from "babylonjs/Misc/deferred";
  66603. export * from "babylonjs/Misc/environmentTextureTools";
  66604. export * from "babylonjs/Misc/meshExploder";
  66605. export * from "babylonjs/Misc/filesInput";
  66606. export * from "babylonjs/Misc/HighDynamicRange/index";
  66607. export * from "babylonjs/Misc/khronosTextureContainer";
  66608. export * from "babylonjs/Misc/observable";
  66609. export * from "babylonjs/Misc/performanceMonitor";
  66610. export * from "babylonjs/Misc/promise";
  66611. export * from "babylonjs/Misc/sceneOptimizer";
  66612. export * from "babylonjs/Misc/sceneSerializer";
  66613. export * from "babylonjs/Misc/smartArray";
  66614. export * from "babylonjs/Misc/stringDictionary";
  66615. export * from "babylonjs/Misc/tags";
  66616. export * from "babylonjs/Misc/textureTools";
  66617. export * from "babylonjs/Misc/tga";
  66618. export * from "babylonjs/Misc/tools";
  66619. export * from "babylonjs/Misc/videoRecorder";
  66620. export * from "babylonjs/Misc/virtualJoystick";
  66621. export * from "babylonjs/Misc/workerPool";
  66622. export * from "babylonjs/Misc/logger";
  66623. export * from "babylonjs/Misc/typeStore";
  66624. export * from "babylonjs/Misc/filesInputStore";
  66625. export * from "babylonjs/Misc/deepCopier";
  66626. export * from "babylonjs/Misc/pivotTools";
  66627. export * from "babylonjs/Misc/precisionDate";
  66628. export * from "babylonjs/Misc/screenshotTools";
  66629. export * from "babylonjs/Misc/typeStore";
  66630. export * from "babylonjs/Misc/webRequest";
  66631. export * from "babylonjs/Misc/iInspectable";
  66632. export * from "babylonjs/Misc/brdfTextureTools";
  66633. export * from "babylonjs/Misc/rgbdTextureTools";
  66634. export * from "babylonjs/Misc/gradients";
  66635. export * from "babylonjs/Misc/perfCounter";
  66636. export * from "babylonjs/Misc/fileRequest";
  66637. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66638. export * from "babylonjs/Misc/retryStrategy";
  66639. export * from "babylonjs/Misc/loadFileError";
  66640. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66641. }
  66642. declare module "babylonjs/index" {
  66643. export * from "babylonjs/abstractScene";
  66644. export * from "babylonjs/Actions/index";
  66645. export * from "babylonjs/Animations/index";
  66646. export * from "babylonjs/assetContainer";
  66647. export * from "babylonjs/Audio/index";
  66648. export * from "babylonjs/Behaviors/index";
  66649. export * from "babylonjs/Bones/index";
  66650. export * from "babylonjs/Cameras/index";
  66651. export * from "babylonjs/Collisions/index";
  66652. export * from "babylonjs/Culling/index";
  66653. export * from "babylonjs/Debug/index";
  66654. export * from "babylonjs/Engines/index";
  66655. export * from "babylonjs/Events/index";
  66656. export * from "babylonjs/Gamepads/index";
  66657. export * from "babylonjs/Gizmos/index";
  66658. export * from "babylonjs/Helpers/index";
  66659. export * from "babylonjs/Instrumentation/index";
  66660. export * from "babylonjs/Layers/index";
  66661. export * from "babylonjs/LensFlares/index";
  66662. export * from "babylonjs/Lights/index";
  66663. export * from "babylonjs/Loading/index";
  66664. export * from "babylonjs/Materials/index";
  66665. export * from "babylonjs/Maths/index";
  66666. export * from "babylonjs/Meshes/index";
  66667. export * from "babylonjs/Morph/index";
  66668. export * from "babylonjs/Navigation/index";
  66669. export * from "babylonjs/node";
  66670. export * from "babylonjs/Offline/index";
  66671. export * from "babylonjs/Particles/index";
  66672. export * from "babylonjs/Physics/index";
  66673. export * from "babylonjs/PostProcesses/index";
  66674. export * from "babylonjs/Probes/index";
  66675. export * from "babylonjs/Rendering/index";
  66676. export * from "babylonjs/scene";
  66677. export * from "babylonjs/sceneComponent";
  66678. export * from "babylonjs/Sprites/index";
  66679. export * from "babylonjs/States/index";
  66680. export * from "babylonjs/Misc/index";
  66681. export * from "babylonjs/types";
  66682. }
  66683. declare module "babylonjs/Animations/pathCursor" {
  66684. import { Vector3 } from "babylonjs/Maths/math.vector";
  66685. import { Path2 } from "babylonjs/Maths/math.path";
  66686. /**
  66687. * A cursor which tracks a point on a path
  66688. */
  66689. export class PathCursor {
  66690. private path;
  66691. /**
  66692. * Stores path cursor callbacks for when an onchange event is triggered
  66693. */
  66694. private _onchange;
  66695. /**
  66696. * The value of the path cursor
  66697. */
  66698. value: number;
  66699. /**
  66700. * The animation array of the path cursor
  66701. */
  66702. animations: Animation[];
  66703. /**
  66704. * Initializes the path cursor
  66705. * @param path The path to track
  66706. */
  66707. constructor(path: Path2);
  66708. /**
  66709. * Gets the cursor point on the path
  66710. * @returns A point on the path cursor at the cursor location
  66711. */
  66712. getPoint(): Vector3;
  66713. /**
  66714. * Moves the cursor ahead by the step amount
  66715. * @param step The amount to move the cursor forward
  66716. * @returns This path cursor
  66717. */
  66718. moveAhead(step?: number): PathCursor;
  66719. /**
  66720. * Moves the cursor behind by the step amount
  66721. * @param step The amount to move the cursor back
  66722. * @returns This path cursor
  66723. */
  66724. moveBack(step?: number): PathCursor;
  66725. /**
  66726. * Moves the cursor by the step amount
  66727. * If the step amount is greater than one, an exception is thrown
  66728. * @param step The amount to move the cursor
  66729. * @returns This path cursor
  66730. */
  66731. move(step: number): PathCursor;
  66732. /**
  66733. * Ensures that the value is limited between zero and one
  66734. * @returns This path cursor
  66735. */
  66736. private ensureLimits;
  66737. /**
  66738. * Runs onchange callbacks on change (used by the animation engine)
  66739. * @returns This path cursor
  66740. */
  66741. private raiseOnChange;
  66742. /**
  66743. * Executes a function on change
  66744. * @param f A path cursor onchange callback
  66745. * @returns This path cursor
  66746. */
  66747. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66748. }
  66749. }
  66750. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66751. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66752. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66753. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66754. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66755. }
  66756. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66757. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66758. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66759. }
  66760. declare module "babylonjs/Engines/Processors/index" {
  66761. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66762. export * from "babylonjs/Engines/Processors/Expressions/index";
  66763. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66764. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66765. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66766. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66767. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66768. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66769. }
  66770. declare module "babylonjs/Legacy/legacy" {
  66771. import * as Babylon from "babylonjs/index";
  66772. export * from "babylonjs/index";
  66773. }
  66774. declare module "babylonjs/Shaders/blur.fragment" {
  66775. /** @hidden */
  66776. export var blurPixelShader: {
  66777. name: string;
  66778. shader: string;
  66779. };
  66780. }
  66781. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66782. /** @hidden */
  66783. export var pointCloudVertexDeclaration: {
  66784. name: string;
  66785. shader: string;
  66786. };
  66787. }
  66788. declare module "babylonjs" {
  66789. export * from "babylonjs/Legacy/legacy";
  66790. }
  66791. declare module BABYLON {
  66792. /** Alias type for value that can be null */
  66793. export type Nullable<T> = T | null;
  66794. /**
  66795. * Alias type for number that are floats
  66796. * @ignorenaming
  66797. */
  66798. export type float = number;
  66799. /**
  66800. * Alias type for number that are doubles.
  66801. * @ignorenaming
  66802. */
  66803. export type double = number;
  66804. /**
  66805. * Alias type for number that are integer
  66806. * @ignorenaming
  66807. */
  66808. export type int = number;
  66809. /** Alias type for number array or Float32Array */
  66810. export type FloatArray = number[] | Float32Array;
  66811. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66812. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66813. /**
  66814. * Alias for types that can be used by a Buffer or VertexBuffer.
  66815. */
  66816. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66817. /**
  66818. * Alias type for primitive types
  66819. * @ignorenaming
  66820. */
  66821. type Primitive = undefined | null | boolean | string | number | Function;
  66822. /**
  66823. * Type modifier to make all the properties of an object Readonly
  66824. */
  66825. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66826. /**
  66827. * Type modifier to make all the properties of an object Readonly recursively
  66828. */
  66829. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66830. /**
  66831. * Type modifier to make object properties readonly.
  66832. */
  66833. export type DeepImmutableObject<T> = {
  66834. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66835. };
  66836. /** @hidden */
  66837. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66838. }
  66839. }
  66840. declare module BABYLON {
  66841. /**
  66842. * A class serves as a medium between the observable and its observers
  66843. */
  66844. export class EventState {
  66845. /**
  66846. * Create a new EventState
  66847. * @param mask defines the mask associated with this state
  66848. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66849. * @param target defines the original target of the state
  66850. * @param currentTarget defines the current target of the state
  66851. */
  66852. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66853. /**
  66854. * Initialize the current event state
  66855. * @param mask defines the mask associated with this state
  66856. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66857. * @param target defines the original target of the state
  66858. * @param currentTarget defines the current target of the state
  66859. * @returns the current event state
  66860. */
  66861. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66862. /**
  66863. * An Observer can set this property to true to prevent subsequent observers of being notified
  66864. */
  66865. skipNextObservers: boolean;
  66866. /**
  66867. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66868. */
  66869. mask: number;
  66870. /**
  66871. * The object that originally notified the event
  66872. */
  66873. target?: any;
  66874. /**
  66875. * The current object in the bubbling phase
  66876. */
  66877. currentTarget?: any;
  66878. /**
  66879. * This will be populated with the return value of the last function that was executed.
  66880. * If it is the first function in the callback chain it will be the event data.
  66881. */
  66882. lastReturnValue?: any;
  66883. }
  66884. /**
  66885. * Represent an Observer registered to a given Observable object.
  66886. */
  66887. export class Observer<T> {
  66888. /**
  66889. * Defines the callback to call when the observer is notified
  66890. */
  66891. callback: (eventData: T, eventState: EventState) => void;
  66892. /**
  66893. * Defines the mask of the observer (used to filter notifications)
  66894. */
  66895. mask: number;
  66896. /**
  66897. * Defines the current scope used to restore the JS context
  66898. */
  66899. scope: any;
  66900. /** @hidden */
  66901. _willBeUnregistered: boolean;
  66902. /**
  66903. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66904. */
  66905. unregisterOnNextCall: boolean;
  66906. /**
  66907. * Creates a new observer
  66908. * @param callback defines the callback to call when the observer is notified
  66909. * @param mask defines the mask of the observer (used to filter notifications)
  66910. * @param scope defines the current scope used to restore the JS context
  66911. */
  66912. constructor(
  66913. /**
  66914. * Defines the callback to call when the observer is notified
  66915. */
  66916. callback: (eventData: T, eventState: EventState) => void,
  66917. /**
  66918. * Defines the mask of the observer (used to filter notifications)
  66919. */
  66920. mask: number,
  66921. /**
  66922. * Defines the current scope used to restore the JS context
  66923. */
  66924. scope?: any);
  66925. }
  66926. /**
  66927. * Represent a list of observers registered to multiple Observables object.
  66928. */
  66929. export class MultiObserver<T> {
  66930. private _observers;
  66931. private _observables;
  66932. /**
  66933. * Release associated resources
  66934. */
  66935. dispose(): void;
  66936. /**
  66937. * Raise a callback when one of the observable will notify
  66938. * @param observables defines a list of observables to watch
  66939. * @param callback defines the callback to call on notification
  66940. * @param mask defines the mask used to filter notifications
  66941. * @param scope defines the current scope used to restore the JS context
  66942. * @returns the new MultiObserver
  66943. */
  66944. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66945. }
  66946. /**
  66947. * The Observable class is a simple implementation of the Observable pattern.
  66948. *
  66949. * 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.
  66950. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66951. * 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).
  66952. * 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.
  66953. */
  66954. export class Observable<T> {
  66955. private _observers;
  66956. private _eventState;
  66957. private _onObserverAdded;
  66958. /**
  66959. * Gets the list of observers
  66960. */
  66961. readonly observers: Array<Observer<T>>;
  66962. /**
  66963. * Creates a new observable
  66964. * @param onObserverAdded defines a callback to call when a new observer is added
  66965. */
  66966. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66967. /**
  66968. * Create a new Observer with the specified callback
  66969. * @param callback the callback that will be executed for that Observer
  66970. * @param mask the mask used to filter observers
  66971. * @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.
  66972. * @param scope optional scope for the callback to be called from
  66973. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66974. * @returns the new observer created for the callback
  66975. */
  66976. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66977. /**
  66978. * Create a new Observer with the specified callback and unregisters after the next notification
  66979. * @param callback the callback that will be executed for that Observer
  66980. * @returns the new observer created for the callback
  66981. */
  66982. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66983. /**
  66984. * Remove an Observer from the Observable object
  66985. * @param observer the instance of the Observer to remove
  66986. * @returns false if it doesn't belong to this Observable
  66987. */
  66988. remove(observer: Nullable<Observer<T>>): boolean;
  66989. /**
  66990. * Remove a callback from the Observable object
  66991. * @param callback the callback to remove
  66992. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66993. * @returns false if it doesn't belong to this Observable
  66994. */
  66995. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66996. private _deferUnregister;
  66997. private _remove;
  66998. /**
  66999. * Moves the observable to the top of the observer list making it get called first when notified
  67000. * @param observer the observer to move
  67001. */
  67002. makeObserverTopPriority(observer: Observer<T>): void;
  67003. /**
  67004. * Moves the observable to the bottom of the observer list making it get called last when notified
  67005. * @param observer the observer to move
  67006. */
  67007. makeObserverBottomPriority(observer: Observer<T>): void;
  67008. /**
  67009. * Notify all Observers by calling their respective callback with the given data
  67010. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67011. * @param eventData defines the data to send to all observers
  67012. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67013. * @param target defines the original target of the state
  67014. * @param currentTarget defines the current target of the state
  67015. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67016. */
  67017. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67018. /**
  67019. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67020. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67021. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67022. * and it is crucial that all callbacks will be executed.
  67023. * The order of the callbacks is kept, callbacks are not executed parallel.
  67024. *
  67025. * @param eventData The data to be sent to each callback
  67026. * @param mask is used to filter observers defaults to -1
  67027. * @param target defines the callback target (see EventState)
  67028. * @param currentTarget defines he current object in the bubbling phase
  67029. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67030. */
  67031. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67032. /**
  67033. * Notify a specific observer
  67034. * @param observer defines the observer to notify
  67035. * @param eventData defines the data to be sent to each callback
  67036. * @param mask is used to filter observers defaults to -1
  67037. */
  67038. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67039. /**
  67040. * Gets a boolean indicating if the observable has at least one observer
  67041. * @returns true is the Observable has at least one Observer registered
  67042. */
  67043. hasObservers(): boolean;
  67044. /**
  67045. * Clear the list of observers
  67046. */
  67047. clear(): void;
  67048. /**
  67049. * Clone the current observable
  67050. * @returns a new observable
  67051. */
  67052. clone(): Observable<T>;
  67053. /**
  67054. * Does this observable handles observer registered with a given mask
  67055. * @param mask defines the mask to be tested
  67056. * @return whether or not one observer registered with the given mask is handeled
  67057. **/
  67058. hasSpecificMask(mask?: number): boolean;
  67059. }
  67060. }
  67061. declare module BABYLON {
  67062. /**
  67063. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67064. * Babylon.js
  67065. */
  67066. export class DomManagement {
  67067. /**
  67068. * Checks if the window object exists
  67069. * @returns true if the window object exists
  67070. */
  67071. static IsWindowObjectExist(): boolean;
  67072. /**
  67073. * Checks if the navigator object exists
  67074. * @returns true if the navigator object exists
  67075. */
  67076. static IsNavigatorAvailable(): boolean;
  67077. /**
  67078. * Extracts text content from a DOM element hierarchy
  67079. * @param element defines the root element
  67080. * @returns a string
  67081. */
  67082. static GetDOMTextContent(element: HTMLElement): string;
  67083. }
  67084. }
  67085. declare module BABYLON {
  67086. /**
  67087. * Logger used througouht the application to allow configuration of
  67088. * the log level required for the messages.
  67089. */
  67090. export class Logger {
  67091. /**
  67092. * No log
  67093. */
  67094. static readonly NoneLogLevel: number;
  67095. /**
  67096. * Only message logs
  67097. */
  67098. static readonly MessageLogLevel: number;
  67099. /**
  67100. * Only warning logs
  67101. */
  67102. static readonly WarningLogLevel: number;
  67103. /**
  67104. * Only error logs
  67105. */
  67106. static readonly ErrorLogLevel: number;
  67107. /**
  67108. * All logs
  67109. */
  67110. static readonly AllLogLevel: number;
  67111. private static _LogCache;
  67112. /**
  67113. * Gets a value indicating the number of loading errors
  67114. * @ignorenaming
  67115. */
  67116. static errorsCount: number;
  67117. /**
  67118. * Callback called when a new log is added
  67119. */
  67120. static OnNewCacheEntry: (entry: string) => void;
  67121. private static _AddLogEntry;
  67122. private static _FormatMessage;
  67123. private static _LogDisabled;
  67124. private static _LogEnabled;
  67125. private static _WarnDisabled;
  67126. private static _WarnEnabled;
  67127. private static _ErrorDisabled;
  67128. private static _ErrorEnabled;
  67129. /**
  67130. * Log a message to the console
  67131. */
  67132. static Log: (message: string) => void;
  67133. /**
  67134. * Write a warning message to the console
  67135. */
  67136. static Warn: (message: string) => void;
  67137. /**
  67138. * Write an error message to the console
  67139. */
  67140. static Error: (message: string) => void;
  67141. /**
  67142. * Gets current log cache (list of logs)
  67143. */
  67144. static readonly LogCache: string;
  67145. /**
  67146. * Clears the log cache
  67147. */
  67148. static ClearLogCache(): void;
  67149. /**
  67150. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67151. */
  67152. static LogLevels: number;
  67153. }
  67154. }
  67155. declare module BABYLON {
  67156. /** @hidden */
  67157. export class _TypeStore {
  67158. /** @hidden */
  67159. static RegisteredTypes: {
  67160. [key: string]: Object;
  67161. };
  67162. /** @hidden */
  67163. static GetClass(fqdn: string): any;
  67164. }
  67165. }
  67166. declare module BABYLON {
  67167. /**
  67168. * Class containing a set of static utilities functions for deep copy.
  67169. */
  67170. export class DeepCopier {
  67171. /**
  67172. * Tries to copy an object by duplicating every property
  67173. * @param source defines the source object
  67174. * @param destination defines the target object
  67175. * @param doNotCopyList defines a list of properties to avoid
  67176. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67177. */
  67178. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67179. }
  67180. }
  67181. declare module BABYLON {
  67182. /**
  67183. * Class containing a set of static utilities functions for precision date
  67184. */
  67185. export class PrecisionDate {
  67186. /**
  67187. * Gets either window.performance.now() if supported or Date.now() else
  67188. */
  67189. static readonly Now: number;
  67190. }
  67191. }
  67192. declare module BABYLON {
  67193. /** @hidden */
  67194. export class _DevTools {
  67195. static WarnImport(name: string): string;
  67196. }
  67197. }
  67198. declare module BABYLON {
  67199. /**
  67200. * Interface used to define the mechanism to get data from the network
  67201. */
  67202. export interface IWebRequest {
  67203. /**
  67204. * Returns client's response url
  67205. */
  67206. responseURL: string;
  67207. /**
  67208. * Returns client's status
  67209. */
  67210. status: number;
  67211. /**
  67212. * Returns client's status as a text
  67213. */
  67214. statusText: string;
  67215. }
  67216. }
  67217. declare module BABYLON {
  67218. /**
  67219. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67220. */
  67221. export class WebRequest implements IWebRequest {
  67222. private _xhr;
  67223. /**
  67224. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67225. * i.e. when loading files, where the server/service expects an Authorization header
  67226. */
  67227. static CustomRequestHeaders: {
  67228. [key: string]: string;
  67229. };
  67230. /**
  67231. * Add callback functions in this array to update all the requests before they get sent to the network
  67232. */
  67233. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67234. private _injectCustomRequestHeaders;
  67235. /**
  67236. * Gets or sets a function to be called when loading progress changes
  67237. */
  67238. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67239. /**
  67240. * Returns client's state
  67241. */
  67242. readonly readyState: number;
  67243. /**
  67244. * Returns client's status
  67245. */
  67246. readonly status: number;
  67247. /**
  67248. * Returns client's status as a text
  67249. */
  67250. readonly statusText: string;
  67251. /**
  67252. * Returns client's response
  67253. */
  67254. readonly response: any;
  67255. /**
  67256. * Returns client's response url
  67257. */
  67258. readonly responseURL: string;
  67259. /**
  67260. * Returns client's response as text
  67261. */
  67262. readonly responseText: string;
  67263. /**
  67264. * Gets or sets the expected response type
  67265. */
  67266. responseType: XMLHttpRequestResponseType;
  67267. /** @hidden */
  67268. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67269. /** @hidden */
  67270. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67271. /**
  67272. * Cancels any network activity
  67273. */
  67274. abort(): void;
  67275. /**
  67276. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67277. * @param body defines an optional request body
  67278. */
  67279. send(body?: Document | BodyInit | null): void;
  67280. /**
  67281. * Sets the request method, request URL
  67282. * @param method defines the method to use (GET, POST, etc..)
  67283. * @param url defines the url to connect with
  67284. */
  67285. open(method: string, url: string): void;
  67286. }
  67287. }
  67288. declare module BABYLON {
  67289. /**
  67290. * File request interface
  67291. */
  67292. export interface IFileRequest {
  67293. /**
  67294. * Raised when the request is complete (success or error).
  67295. */
  67296. onCompleteObservable: Observable<IFileRequest>;
  67297. /**
  67298. * Aborts the request for a file.
  67299. */
  67300. abort: () => void;
  67301. }
  67302. }
  67303. declare module BABYLON {
  67304. /**
  67305. * Scalar computation library
  67306. */
  67307. export class Scalar {
  67308. /**
  67309. * Two pi constants convenient for computation.
  67310. */
  67311. static TwoPi: number;
  67312. /**
  67313. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67314. * @param a number
  67315. * @param b number
  67316. * @param epsilon (default = 1.401298E-45)
  67317. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67318. */
  67319. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  67320. /**
  67321. * Returns a string : the upper case translation of the number i to hexadecimal.
  67322. * @param i number
  67323. * @returns the upper case translation of the number i to hexadecimal.
  67324. */
  67325. static ToHex(i: number): string;
  67326. /**
  67327. * Returns -1 if value is negative and +1 is value is positive.
  67328. * @param value the value
  67329. * @returns the value itself if it's equal to zero.
  67330. */
  67331. static Sign(value: number): number;
  67332. /**
  67333. * Returns the value itself if it's between min and max.
  67334. * Returns min if the value is lower than min.
  67335. * Returns max if the value is greater than max.
  67336. * @param value the value to clmap
  67337. * @param min the min value to clamp to (default: 0)
  67338. * @param max the max value to clamp to (default: 1)
  67339. * @returns the clamped value
  67340. */
  67341. static Clamp(value: number, min?: number, max?: number): number;
  67342. /**
  67343. * the log2 of value.
  67344. * @param value the value to compute log2 of
  67345. * @returns the log2 of value.
  67346. */
  67347. static Log2(value: number): number;
  67348. /**
  67349. * Loops the value, so that it is never larger than length and never smaller than 0.
  67350. *
  67351. * This is similar to the modulo operator but it works with floating point numbers.
  67352. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67353. * With t = 5 and length = 2.5, the result would be 0.0.
  67354. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67355. * @param value the value
  67356. * @param length the length
  67357. * @returns the looped value
  67358. */
  67359. static Repeat(value: number, length: number): number;
  67360. /**
  67361. * Normalize the value between 0.0 and 1.0 using min and max values
  67362. * @param value value to normalize
  67363. * @param min max to normalize between
  67364. * @param max min to normalize between
  67365. * @returns the normalized value
  67366. */
  67367. static Normalize(value: number, min: number, max: number): number;
  67368. /**
  67369. * Denormalize the value from 0.0 and 1.0 using min and max values
  67370. * @param normalized value to denormalize
  67371. * @param min max to denormalize between
  67372. * @param max min to denormalize between
  67373. * @returns the denormalized value
  67374. */
  67375. static Denormalize(normalized: number, min: number, max: number): number;
  67376. /**
  67377. * Calculates the shortest difference between two given angles given in degrees.
  67378. * @param current current angle in degrees
  67379. * @param target target angle in degrees
  67380. * @returns the delta
  67381. */
  67382. static DeltaAngle(current: number, target: number): number;
  67383. /**
  67384. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67385. * @param tx value
  67386. * @param length length
  67387. * @returns The returned value will move back and forth between 0 and length
  67388. */
  67389. static PingPong(tx: number, length: number): number;
  67390. /**
  67391. * Interpolates between min and max with smoothing at the limits.
  67392. *
  67393. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67394. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67395. * @param from from
  67396. * @param to to
  67397. * @param tx value
  67398. * @returns the smooth stepped value
  67399. */
  67400. static SmoothStep(from: number, to: number, tx: number): number;
  67401. /**
  67402. * Moves a value current towards target.
  67403. *
  67404. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67405. * Negative values of maxDelta pushes the value away from target.
  67406. * @param current current value
  67407. * @param target target value
  67408. * @param maxDelta max distance to move
  67409. * @returns resulting value
  67410. */
  67411. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67412. /**
  67413. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67414. *
  67415. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67416. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67417. * @param current current value
  67418. * @param target target value
  67419. * @param maxDelta max distance to move
  67420. * @returns resulting angle
  67421. */
  67422. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67423. /**
  67424. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67425. * @param start start value
  67426. * @param end target value
  67427. * @param amount amount to lerp between
  67428. * @returns the lerped value
  67429. */
  67430. static Lerp(start: number, end: number, amount: number): number;
  67431. /**
  67432. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67433. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67434. * @param start start value
  67435. * @param end target value
  67436. * @param amount amount to lerp between
  67437. * @returns the lerped value
  67438. */
  67439. static LerpAngle(start: number, end: number, amount: number): number;
  67440. /**
  67441. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67442. * @param a start value
  67443. * @param b target value
  67444. * @param value value between a and b
  67445. * @returns the inverseLerp value
  67446. */
  67447. static InverseLerp(a: number, b: number, value: number): number;
  67448. /**
  67449. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67450. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67451. * @param value1 spline value
  67452. * @param tangent1 spline value
  67453. * @param value2 spline value
  67454. * @param tangent2 spline value
  67455. * @param amount input value
  67456. * @returns hermite result
  67457. */
  67458. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67459. /**
  67460. * Returns a random float number between and min and max values
  67461. * @param min min value of random
  67462. * @param max max value of random
  67463. * @returns random value
  67464. */
  67465. static RandomRange(min: number, max: number): number;
  67466. /**
  67467. * This function returns percentage of a number in a given range.
  67468. *
  67469. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67470. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67471. * @param number to convert to percentage
  67472. * @param min min range
  67473. * @param max max range
  67474. * @returns the percentage
  67475. */
  67476. static RangeToPercent(number: number, min: number, max: number): number;
  67477. /**
  67478. * This function returns number that corresponds to the percentage in a given range.
  67479. *
  67480. * PercentToRange(0.34,0,100) will return 34.
  67481. * @param percent to convert to number
  67482. * @param min min range
  67483. * @param max max range
  67484. * @returns the number
  67485. */
  67486. static PercentToRange(percent: number, min: number, max: number): number;
  67487. /**
  67488. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67489. * @param angle The angle to normalize in radian.
  67490. * @return The converted angle.
  67491. */
  67492. static NormalizeRadians(angle: number): number;
  67493. }
  67494. }
  67495. declare module BABYLON {
  67496. /**
  67497. * Constant used to convert a value to gamma space
  67498. * @ignorenaming
  67499. */
  67500. export const ToGammaSpace: number;
  67501. /**
  67502. * Constant used to convert a value to linear space
  67503. * @ignorenaming
  67504. */
  67505. export const ToLinearSpace = 2.2;
  67506. /**
  67507. * Constant used to define the minimal number value in Babylon.js
  67508. * @ignorenaming
  67509. */
  67510. let Epsilon: number;
  67511. }
  67512. declare module BABYLON {
  67513. /**
  67514. * Class used to represent a viewport on screen
  67515. */
  67516. export class Viewport {
  67517. /** viewport left coordinate */
  67518. x: number;
  67519. /** viewport top coordinate */
  67520. y: number;
  67521. /**viewport width */
  67522. width: number;
  67523. /** viewport height */
  67524. height: number;
  67525. /**
  67526. * Creates a Viewport object located at (x, y) and sized (width, height)
  67527. * @param x defines viewport left coordinate
  67528. * @param y defines viewport top coordinate
  67529. * @param width defines the viewport width
  67530. * @param height defines the viewport height
  67531. */
  67532. constructor(
  67533. /** viewport left coordinate */
  67534. x: number,
  67535. /** viewport top coordinate */
  67536. y: number,
  67537. /**viewport width */
  67538. width: number,
  67539. /** viewport height */
  67540. height: number);
  67541. /**
  67542. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67543. * @param renderWidth defines the rendering width
  67544. * @param renderHeight defines the rendering height
  67545. * @returns a new Viewport
  67546. */
  67547. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67548. /**
  67549. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67550. * @param renderWidth defines the rendering width
  67551. * @param renderHeight defines the rendering height
  67552. * @param ref defines the target viewport
  67553. * @returns the current viewport
  67554. */
  67555. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67556. /**
  67557. * Returns a new Viewport copied from the current one
  67558. * @returns a new Viewport
  67559. */
  67560. clone(): Viewport;
  67561. }
  67562. }
  67563. declare module BABYLON {
  67564. /**
  67565. * Class containing a set of static utilities functions for arrays.
  67566. */
  67567. export class ArrayTools {
  67568. /**
  67569. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67570. * @param size the number of element to construct and put in the array
  67571. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67572. * @returns a new array filled with new objects
  67573. */
  67574. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67575. }
  67576. }
  67577. declare module BABYLON {
  67578. /**
  67579. * @hidden
  67580. */
  67581. export interface IColor4Like {
  67582. r: float;
  67583. g: float;
  67584. b: float;
  67585. a: float;
  67586. }
  67587. /**
  67588. * @hidden
  67589. */
  67590. export interface IColor3Like {
  67591. r: float;
  67592. g: float;
  67593. b: float;
  67594. }
  67595. /**
  67596. * @hidden
  67597. */
  67598. export interface IVector4Like {
  67599. x: float;
  67600. y: float;
  67601. z: float;
  67602. w: float;
  67603. }
  67604. /**
  67605. * @hidden
  67606. */
  67607. export interface IVector3Like {
  67608. x: float;
  67609. y: float;
  67610. z: float;
  67611. }
  67612. /**
  67613. * @hidden
  67614. */
  67615. export interface IVector2Like {
  67616. x: float;
  67617. y: float;
  67618. }
  67619. /**
  67620. * @hidden
  67621. */
  67622. export interface IMatrixLike {
  67623. toArray(): DeepImmutable<Float32Array>;
  67624. updateFlag: int;
  67625. }
  67626. /**
  67627. * @hidden
  67628. */
  67629. export interface IViewportLike {
  67630. x: float;
  67631. y: float;
  67632. width: float;
  67633. height: float;
  67634. }
  67635. /**
  67636. * @hidden
  67637. */
  67638. export interface IPlaneLike {
  67639. normal: IVector3Like;
  67640. d: float;
  67641. normalize(): void;
  67642. }
  67643. }
  67644. declare module BABYLON {
  67645. /**
  67646. * Class representing a vector containing 2 coordinates
  67647. */
  67648. export class Vector2 {
  67649. /** defines the first coordinate */
  67650. x: number;
  67651. /** defines the second coordinate */
  67652. y: number;
  67653. /**
  67654. * Creates a new Vector2 from the given x and y coordinates
  67655. * @param x defines the first coordinate
  67656. * @param y defines the second coordinate
  67657. */
  67658. constructor(
  67659. /** defines the first coordinate */
  67660. x?: number,
  67661. /** defines the second coordinate */
  67662. y?: number);
  67663. /**
  67664. * Gets a string with the Vector2 coordinates
  67665. * @returns a string with the Vector2 coordinates
  67666. */
  67667. toString(): string;
  67668. /**
  67669. * Gets class name
  67670. * @returns the string "Vector2"
  67671. */
  67672. getClassName(): string;
  67673. /**
  67674. * Gets current vector hash code
  67675. * @returns the Vector2 hash code as a number
  67676. */
  67677. getHashCode(): number;
  67678. /**
  67679. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67680. * @param array defines the source array
  67681. * @param index defines the offset in source array
  67682. * @returns the current Vector2
  67683. */
  67684. toArray(array: FloatArray, index?: number): Vector2;
  67685. /**
  67686. * Copy the current vector to an array
  67687. * @returns a new array with 2 elements: the Vector2 coordinates.
  67688. */
  67689. asArray(): number[];
  67690. /**
  67691. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67692. * @param source defines the source Vector2
  67693. * @returns the current updated Vector2
  67694. */
  67695. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67696. /**
  67697. * Sets the Vector2 coordinates with the given floats
  67698. * @param x defines the first coordinate
  67699. * @param y defines the second coordinate
  67700. * @returns the current updated Vector2
  67701. */
  67702. copyFromFloats(x: number, y: number): Vector2;
  67703. /**
  67704. * Sets the Vector2 coordinates with the given floats
  67705. * @param x defines the first coordinate
  67706. * @param y defines the second coordinate
  67707. * @returns the current updated Vector2
  67708. */
  67709. set(x: number, y: number): Vector2;
  67710. /**
  67711. * Add another vector with the current one
  67712. * @param otherVector defines the other vector
  67713. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67714. */
  67715. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67716. /**
  67717. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67718. * @param otherVector defines the other vector
  67719. * @param result defines the target vector
  67720. * @returns the unmodified current Vector2
  67721. */
  67722. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67723. /**
  67724. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67725. * @param otherVector defines the other vector
  67726. * @returns the current updated Vector2
  67727. */
  67728. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67729. /**
  67730. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67731. * @param otherVector defines the other vector
  67732. * @returns a new Vector2
  67733. */
  67734. addVector3(otherVector: Vector3): Vector2;
  67735. /**
  67736. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67737. * @param otherVector defines the other vector
  67738. * @returns a new Vector2
  67739. */
  67740. subtract(otherVector: Vector2): Vector2;
  67741. /**
  67742. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67743. * @param otherVector defines the other vector
  67744. * @param result defines the target vector
  67745. * @returns the unmodified current Vector2
  67746. */
  67747. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67748. /**
  67749. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67750. * @param otherVector defines the other vector
  67751. * @returns the current updated Vector2
  67752. */
  67753. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67754. /**
  67755. * Multiplies in place the current Vector2 coordinates by the given ones
  67756. * @param otherVector defines the other vector
  67757. * @returns the current updated Vector2
  67758. */
  67759. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67760. /**
  67761. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67762. * @param otherVector defines the other vector
  67763. * @returns a new Vector2
  67764. */
  67765. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67766. /**
  67767. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67768. * @param otherVector defines the other vector
  67769. * @param result defines the target vector
  67770. * @returns the unmodified current Vector2
  67771. */
  67772. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67773. /**
  67774. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67775. * @param x defines the first coordinate
  67776. * @param y defines the second coordinate
  67777. * @returns a new Vector2
  67778. */
  67779. multiplyByFloats(x: number, y: number): Vector2;
  67780. /**
  67781. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67782. * @param otherVector defines the other vector
  67783. * @returns a new Vector2
  67784. */
  67785. divide(otherVector: Vector2): Vector2;
  67786. /**
  67787. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67788. * @param otherVector defines the other vector
  67789. * @param result defines the target vector
  67790. * @returns the unmodified current Vector2
  67791. */
  67792. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67793. /**
  67794. * Divides the current Vector2 coordinates by the given ones
  67795. * @param otherVector defines the other vector
  67796. * @returns the current updated Vector2
  67797. */
  67798. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67799. /**
  67800. * Gets a new Vector2 with current Vector2 negated coordinates
  67801. * @returns a new Vector2
  67802. */
  67803. negate(): Vector2;
  67804. /**
  67805. * Multiply the Vector2 coordinates by scale
  67806. * @param scale defines the scaling factor
  67807. * @returns the current updated Vector2
  67808. */
  67809. scaleInPlace(scale: number): Vector2;
  67810. /**
  67811. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67812. * @param scale defines the scaling factor
  67813. * @returns a new Vector2
  67814. */
  67815. scale(scale: number): Vector2;
  67816. /**
  67817. * Scale the current Vector2 values by a factor to a given Vector2
  67818. * @param scale defines the scale factor
  67819. * @param result defines the Vector2 object where to store the result
  67820. * @returns the unmodified current Vector2
  67821. */
  67822. scaleToRef(scale: number, result: Vector2): Vector2;
  67823. /**
  67824. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67825. * @param scale defines the scale factor
  67826. * @param result defines the Vector2 object where to store the result
  67827. * @returns the unmodified current Vector2
  67828. */
  67829. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67830. /**
  67831. * Gets a boolean if two vectors are equals
  67832. * @param otherVector defines the other vector
  67833. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67834. */
  67835. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67836. /**
  67837. * Gets a boolean if two vectors are equals (using an epsilon value)
  67838. * @param otherVector defines the other vector
  67839. * @param epsilon defines the minimal distance to consider equality
  67840. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67841. */
  67842. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67843. /**
  67844. * Gets a new Vector2 from current Vector2 floored values
  67845. * @returns a new Vector2
  67846. */
  67847. floor(): Vector2;
  67848. /**
  67849. * Gets a new Vector2 from current Vector2 floored values
  67850. * @returns a new Vector2
  67851. */
  67852. fract(): Vector2;
  67853. /**
  67854. * Gets the length of the vector
  67855. * @returns the vector length (float)
  67856. */
  67857. length(): number;
  67858. /**
  67859. * Gets the vector squared length
  67860. * @returns the vector squared length (float)
  67861. */
  67862. lengthSquared(): number;
  67863. /**
  67864. * Normalize the vector
  67865. * @returns the current updated Vector2
  67866. */
  67867. normalize(): Vector2;
  67868. /**
  67869. * Gets a new Vector2 copied from the Vector2
  67870. * @returns a new Vector2
  67871. */
  67872. clone(): Vector2;
  67873. /**
  67874. * Gets a new Vector2(0, 0)
  67875. * @returns a new Vector2
  67876. */
  67877. static Zero(): Vector2;
  67878. /**
  67879. * Gets a new Vector2(1, 1)
  67880. * @returns a new Vector2
  67881. */
  67882. static One(): Vector2;
  67883. /**
  67884. * Gets a new Vector2 set from the given index element of the given array
  67885. * @param array defines the data source
  67886. * @param offset defines the offset in the data source
  67887. * @returns a new Vector2
  67888. */
  67889. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67890. /**
  67891. * Sets "result" from the given index element of the given array
  67892. * @param array defines the data source
  67893. * @param offset defines the offset in the data source
  67894. * @param result defines the target vector
  67895. */
  67896. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67897. /**
  67898. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67899. * @param value1 defines 1st point of control
  67900. * @param value2 defines 2nd point of control
  67901. * @param value3 defines 3rd point of control
  67902. * @param value4 defines 4th point of control
  67903. * @param amount defines the interpolation factor
  67904. * @returns a new Vector2
  67905. */
  67906. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67907. /**
  67908. * 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".
  67909. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67910. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67911. * @param value defines the value to clamp
  67912. * @param min defines the lower limit
  67913. * @param max defines the upper limit
  67914. * @returns a new Vector2
  67915. */
  67916. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67917. /**
  67918. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67919. * @param value1 defines the 1st control point
  67920. * @param tangent1 defines the outgoing tangent
  67921. * @param value2 defines the 2nd control point
  67922. * @param tangent2 defines the incoming tangent
  67923. * @param amount defines the interpolation factor
  67924. * @returns a new Vector2
  67925. */
  67926. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67927. /**
  67928. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67929. * @param start defines the start vector
  67930. * @param end defines the end vector
  67931. * @param amount defines the interpolation factor
  67932. * @returns a new Vector2
  67933. */
  67934. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67935. /**
  67936. * Gets the dot product of the vector "left" and the vector "right"
  67937. * @param left defines first vector
  67938. * @param right defines second vector
  67939. * @returns the dot product (float)
  67940. */
  67941. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67942. /**
  67943. * Returns a new Vector2 equal to the normalized given vector
  67944. * @param vector defines the vector to normalize
  67945. * @returns a new Vector2
  67946. */
  67947. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67948. /**
  67949. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67950. * @param left defines 1st vector
  67951. * @param right defines 2nd vector
  67952. * @returns a new Vector2
  67953. */
  67954. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67955. /**
  67956. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67957. * @param left defines 1st vector
  67958. * @param right defines 2nd vector
  67959. * @returns a new Vector2
  67960. */
  67961. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67962. /**
  67963. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67964. * @param vector defines the vector to transform
  67965. * @param transformation defines the matrix to apply
  67966. * @returns a new Vector2
  67967. */
  67968. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67969. /**
  67970. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67971. * @param vector defines the vector to transform
  67972. * @param transformation defines the matrix to apply
  67973. * @param result defines the target vector
  67974. */
  67975. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67976. /**
  67977. * Determines if a given vector is included in a triangle
  67978. * @param p defines the vector to test
  67979. * @param p0 defines 1st triangle point
  67980. * @param p1 defines 2nd triangle point
  67981. * @param p2 defines 3rd triangle point
  67982. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67983. */
  67984. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67985. /**
  67986. * Gets the distance between the vectors "value1" and "value2"
  67987. * @param value1 defines first vector
  67988. * @param value2 defines second vector
  67989. * @returns the distance between vectors
  67990. */
  67991. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67992. /**
  67993. * Returns the squared distance between the vectors "value1" and "value2"
  67994. * @param value1 defines first vector
  67995. * @param value2 defines second vector
  67996. * @returns the squared distance between vectors
  67997. */
  67998. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67999. /**
  68000. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  68001. * @param value1 defines first vector
  68002. * @param value2 defines second vector
  68003. * @returns a new Vector2
  68004. */
  68005. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  68006. /**
  68007. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  68008. * @param p defines the middle point
  68009. * @param segA defines one point of the segment
  68010. * @param segB defines the other point of the segment
  68011. * @returns the shortest distance
  68012. */
  68013. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  68014. }
  68015. /**
  68016. * Classed used to store (x,y,z) vector representation
  68017. * A Vector3 is the main object used in 3D geometry
  68018. * It can represent etiher the coordinates of a point the space, either a direction
  68019. * Reminder: js uses a left handed forward facing system
  68020. */
  68021. export class Vector3 {
  68022. /**
  68023. * Defines the first coordinates (on X axis)
  68024. */
  68025. x: number;
  68026. /**
  68027. * Defines the second coordinates (on Y axis)
  68028. */
  68029. y: number;
  68030. /**
  68031. * Defines the third coordinates (on Z axis)
  68032. */
  68033. z: number;
  68034. private static _UpReadOnly;
  68035. private static _ZeroReadOnly;
  68036. /**
  68037. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  68038. * @param x defines the first coordinates (on X axis)
  68039. * @param y defines the second coordinates (on Y axis)
  68040. * @param z defines the third coordinates (on Z axis)
  68041. */
  68042. constructor(
  68043. /**
  68044. * Defines the first coordinates (on X axis)
  68045. */
  68046. x?: number,
  68047. /**
  68048. * Defines the second coordinates (on Y axis)
  68049. */
  68050. y?: number,
  68051. /**
  68052. * Defines the third coordinates (on Z axis)
  68053. */
  68054. z?: number);
  68055. /**
  68056. * Creates a string representation of the Vector3
  68057. * @returns a string with the Vector3 coordinates.
  68058. */
  68059. toString(): string;
  68060. /**
  68061. * Gets the class name
  68062. * @returns the string "Vector3"
  68063. */
  68064. getClassName(): string;
  68065. /**
  68066. * Creates the Vector3 hash code
  68067. * @returns a number which tends to be unique between Vector3 instances
  68068. */
  68069. getHashCode(): number;
  68070. /**
  68071. * Creates an array containing three elements : the coordinates of the Vector3
  68072. * @returns a new array of numbers
  68073. */
  68074. asArray(): number[];
  68075. /**
  68076. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  68077. * @param array defines the destination array
  68078. * @param index defines the offset in the destination array
  68079. * @returns the current Vector3
  68080. */
  68081. toArray(array: FloatArray, index?: number): Vector3;
  68082. /**
  68083. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  68084. * @returns a new Quaternion object, computed from the Vector3 coordinates
  68085. */
  68086. toQuaternion(): Quaternion;
  68087. /**
  68088. * Adds the given vector to the current Vector3
  68089. * @param otherVector defines the second operand
  68090. * @returns the current updated Vector3
  68091. */
  68092. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68093. /**
  68094. * Adds the given coordinates to the current Vector3
  68095. * @param x defines the x coordinate of the operand
  68096. * @param y defines the y coordinate of the operand
  68097. * @param z defines the z coordinate of the operand
  68098. * @returns the current updated Vector3
  68099. */
  68100. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68101. /**
  68102. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  68103. * @param otherVector defines the second operand
  68104. * @returns the resulting Vector3
  68105. */
  68106. add(otherVector: DeepImmutable<Vector3>): Vector3;
  68107. /**
  68108. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  68109. * @param otherVector defines the second operand
  68110. * @param result defines the Vector3 object where to store the result
  68111. * @returns the current Vector3
  68112. */
  68113. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68114. /**
  68115. * Subtract the given vector from the current Vector3
  68116. * @param otherVector defines the second operand
  68117. * @returns the current updated Vector3
  68118. */
  68119. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68120. /**
  68121. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  68122. * @param otherVector defines the second operand
  68123. * @returns the resulting Vector3
  68124. */
  68125. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  68126. /**
  68127. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  68128. * @param otherVector defines the second operand
  68129. * @param result defines the Vector3 object where to store the result
  68130. * @returns the current Vector3
  68131. */
  68132. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68133. /**
  68134. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  68135. * @param x defines the x coordinate of the operand
  68136. * @param y defines the y coordinate of the operand
  68137. * @param z defines the z coordinate of the operand
  68138. * @returns the resulting Vector3
  68139. */
  68140. subtractFromFloats(x: number, y: number, z: number): Vector3;
  68141. /**
  68142. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  68143. * @param x defines the x coordinate of the operand
  68144. * @param y defines the y coordinate of the operand
  68145. * @param z defines the z coordinate of the operand
  68146. * @param result defines the Vector3 object where to store the result
  68147. * @returns the current Vector3
  68148. */
  68149. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  68150. /**
  68151. * Gets a new Vector3 set with the current Vector3 negated coordinates
  68152. * @returns a new Vector3
  68153. */
  68154. negate(): Vector3;
  68155. /**
  68156. * Multiplies the Vector3 coordinates by the float "scale"
  68157. * @param scale defines the multiplier factor
  68158. * @returns the current updated Vector3
  68159. */
  68160. scaleInPlace(scale: number): Vector3;
  68161. /**
  68162. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  68163. * @param scale defines the multiplier factor
  68164. * @returns a new Vector3
  68165. */
  68166. scale(scale: number): Vector3;
  68167. /**
  68168. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  68169. * @param scale defines the multiplier factor
  68170. * @param result defines the Vector3 object where to store the result
  68171. * @returns the current Vector3
  68172. */
  68173. scaleToRef(scale: number, result: Vector3): Vector3;
  68174. /**
  68175. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68176. * @param scale defines the scale factor
  68177. * @param result defines the Vector3 object where to store the result
  68178. * @returns the unmodified current Vector3
  68179. */
  68180. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  68181. /**
  68182. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68183. * @param otherVector defines the second operand
  68184. * @returns true if both vectors are equals
  68185. */
  68186. equals(otherVector: DeepImmutable<Vector3>): boolean;
  68187. /**
  68188. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68189. * @param otherVector defines the second operand
  68190. * @param epsilon defines the minimal distance to define values as equals
  68191. * @returns true if both vectors are distant less than epsilon
  68192. */
  68193. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  68194. /**
  68195. * Returns true if the current Vector3 coordinates equals the given floats
  68196. * @param x defines the x coordinate of the operand
  68197. * @param y defines the y coordinate of the operand
  68198. * @param z defines the z coordinate of the operand
  68199. * @returns true if both vectors are equals
  68200. */
  68201. equalsToFloats(x: number, y: number, z: number): boolean;
  68202. /**
  68203. * Multiplies the current Vector3 coordinates by the given ones
  68204. * @param otherVector defines the second operand
  68205. * @returns the current updated Vector3
  68206. */
  68207. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68208. /**
  68209. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68210. * @param otherVector defines the second operand
  68211. * @returns the new Vector3
  68212. */
  68213. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  68214. /**
  68215. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68216. * @param otherVector defines the second operand
  68217. * @param result defines the Vector3 object where to store the result
  68218. * @returns the current Vector3
  68219. */
  68220. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68221. /**
  68222. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68223. * @param x defines the x coordinate of the operand
  68224. * @param y defines the y coordinate of the operand
  68225. * @param z defines the z coordinate of the operand
  68226. * @returns the new Vector3
  68227. */
  68228. multiplyByFloats(x: number, y: number, z: number): Vector3;
  68229. /**
  68230. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68231. * @param otherVector defines the second operand
  68232. * @returns the new Vector3
  68233. */
  68234. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  68235. /**
  68236. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68237. * @param otherVector defines the second operand
  68238. * @param result defines the Vector3 object where to store the result
  68239. * @returns the current Vector3
  68240. */
  68241. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68242. /**
  68243. * Divides the current Vector3 coordinates by the given ones.
  68244. * @param otherVector defines the second operand
  68245. * @returns the current updated Vector3
  68246. */
  68247. divideInPlace(otherVector: Vector3): Vector3;
  68248. /**
  68249. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68250. * @param other defines the second operand
  68251. * @returns the current updated Vector3
  68252. */
  68253. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68254. /**
  68255. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68256. * @param other defines the second operand
  68257. * @returns the current updated Vector3
  68258. */
  68259. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68260. /**
  68261. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68262. * @param x defines the x coordinate of the operand
  68263. * @param y defines the y coordinate of the operand
  68264. * @param z defines the z coordinate of the operand
  68265. * @returns the current updated Vector3
  68266. */
  68267. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68268. /**
  68269. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68270. * @param x defines the x coordinate of the operand
  68271. * @param y defines the y coordinate of the operand
  68272. * @param z defines the z coordinate of the operand
  68273. * @returns the current updated Vector3
  68274. */
  68275. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68276. /**
  68277. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68278. * Check if is non uniform within a certain amount of decimal places to account for this
  68279. * @param epsilon the amount the values can differ
  68280. * @returns if the the vector is non uniform to a certain number of decimal places
  68281. */
  68282. isNonUniformWithinEpsilon(epsilon: number): boolean;
  68283. /**
  68284. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68285. */
  68286. readonly isNonUniform: boolean;
  68287. /**
  68288. * Gets a new Vector3 from current Vector3 floored values
  68289. * @returns a new Vector3
  68290. */
  68291. floor(): Vector3;
  68292. /**
  68293. * Gets a new Vector3 from current Vector3 floored values
  68294. * @returns a new Vector3
  68295. */
  68296. fract(): Vector3;
  68297. /**
  68298. * Gets the length of the Vector3
  68299. * @returns the length of the Vector3
  68300. */
  68301. length(): number;
  68302. /**
  68303. * Gets the squared length of the Vector3
  68304. * @returns squared length of the Vector3
  68305. */
  68306. lengthSquared(): number;
  68307. /**
  68308. * Normalize the current Vector3.
  68309. * Please note that this is an in place operation.
  68310. * @returns the current updated Vector3
  68311. */
  68312. normalize(): Vector3;
  68313. /**
  68314. * Reorders the x y z properties of the vector in place
  68315. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68316. * @returns the current updated vector
  68317. */
  68318. reorderInPlace(order: string): this;
  68319. /**
  68320. * Rotates the vector around 0,0,0 by a quaternion
  68321. * @param quaternion the rotation quaternion
  68322. * @param result vector to store the result
  68323. * @returns the resulting vector
  68324. */
  68325. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  68326. /**
  68327. * Rotates a vector around a given point
  68328. * @param quaternion the rotation quaternion
  68329. * @param point the point to rotate around
  68330. * @param result vector to store the result
  68331. * @returns the resulting vector
  68332. */
  68333. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  68334. /**
  68335. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  68336. * The cross product is then orthogonal to both current and "other"
  68337. * @param other defines the right operand
  68338. * @returns the cross product
  68339. */
  68340. cross(other: Vector3): Vector3;
  68341. /**
  68342. * Normalize the current Vector3 with the given input length.
  68343. * Please note that this is an in place operation.
  68344. * @param len the length of the vector
  68345. * @returns the current updated Vector3
  68346. */
  68347. normalizeFromLength(len: number): Vector3;
  68348. /**
  68349. * Normalize the current Vector3 to a new vector
  68350. * @returns the new Vector3
  68351. */
  68352. normalizeToNew(): Vector3;
  68353. /**
  68354. * Normalize the current Vector3 to the reference
  68355. * @param reference define the Vector3 to update
  68356. * @returns the updated Vector3
  68357. */
  68358. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  68359. /**
  68360. * Creates a new Vector3 copied from the current Vector3
  68361. * @returns the new Vector3
  68362. */
  68363. clone(): Vector3;
  68364. /**
  68365. * Copies the given vector coordinates to the current Vector3 ones
  68366. * @param source defines the source Vector3
  68367. * @returns the current updated Vector3
  68368. */
  68369. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  68370. /**
  68371. * Copies the given floats to the current Vector3 coordinates
  68372. * @param x defines the x coordinate of the operand
  68373. * @param y defines the y coordinate of the operand
  68374. * @param z defines the z coordinate of the operand
  68375. * @returns the current updated Vector3
  68376. */
  68377. copyFromFloats(x: number, y: number, z: number): Vector3;
  68378. /**
  68379. * Copies the given floats to the current Vector3 coordinates
  68380. * @param x defines the x coordinate of the operand
  68381. * @param y defines the y coordinate of the operand
  68382. * @param z defines the z coordinate of the operand
  68383. * @returns the current updated Vector3
  68384. */
  68385. set(x: number, y: number, z: number): Vector3;
  68386. /**
  68387. * Copies the given float to the current Vector3 coordinates
  68388. * @param v defines the x, y and z coordinates of the operand
  68389. * @returns the current updated Vector3
  68390. */
  68391. setAll(v: number): Vector3;
  68392. /**
  68393. * Get the clip factor between two vectors
  68394. * @param vector0 defines the first operand
  68395. * @param vector1 defines the second operand
  68396. * @param axis defines the axis to use
  68397. * @param size defines the size along the axis
  68398. * @returns the clip factor
  68399. */
  68400. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68401. /**
  68402. * Get angle between two vectors
  68403. * @param vector0 angle between vector0 and vector1
  68404. * @param vector1 angle between vector0 and vector1
  68405. * @param normal direction of the normal
  68406. * @return the angle between vector0 and vector1
  68407. */
  68408. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68409. /**
  68410. * Returns a new Vector3 set from the index "offset" of the given array
  68411. * @param array defines the source array
  68412. * @param offset defines the offset in the source array
  68413. * @returns the new Vector3
  68414. */
  68415. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68416. /**
  68417. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68418. * This function is deprecated. Use FromArray instead
  68419. * @param array defines the source array
  68420. * @param offset defines the offset in the source array
  68421. * @returns the new Vector3
  68422. */
  68423. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68424. /**
  68425. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68426. * @param array defines the source array
  68427. * @param offset defines the offset in the source array
  68428. * @param result defines the Vector3 where to store the result
  68429. */
  68430. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68431. /**
  68432. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68433. * This function is deprecated. Use FromArrayToRef instead.
  68434. * @param array defines the source array
  68435. * @param offset defines the offset in the source array
  68436. * @param result defines the Vector3 where to store the result
  68437. */
  68438. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68439. /**
  68440. * Sets the given vector "result" with the given floats.
  68441. * @param x defines the x coordinate of the source
  68442. * @param y defines the y coordinate of the source
  68443. * @param z defines the z coordinate of the source
  68444. * @param result defines the Vector3 where to store the result
  68445. */
  68446. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68447. /**
  68448. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68449. * @returns a new empty Vector3
  68450. */
  68451. static Zero(): Vector3;
  68452. /**
  68453. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68454. * @returns a new unit Vector3
  68455. */
  68456. static One(): Vector3;
  68457. /**
  68458. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68459. * @returns a new up Vector3
  68460. */
  68461. static Up(): Vector3;
  68462. /**
  68463. * Gets a up Vector3 that must not be updated
  68464. */
  68465. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68466. /**
  68467. * Gets a zero Vector3 that must not be updated
  68468. */
  68469. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68470. /**
  68471. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68472. * @returns a new down Vector3
  68473. */
  68474. static Down(): Vector3;
  68475. /**
  68476. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68477. * @returns a new forward Vector3
  68478. */
  68479. static Forward(): Vector3;
  68480. /**
  68481. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68482. * @returns a new forward Vector3
  68483. */
  68484. static Backward(): Vector3;
  68485. /**
  68486. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68487. * @returns a new right Vector3
  68488. */
  68489. static Right(): Vector3;
  68490. /**
  68491. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68492. * @returns a new left Vector3
  68493. */
  68494. static Left(): Vector3;
  68495. /**
  68496. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68497. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68498. * @param vector defines the Vector3 to transform
  68499. * @param transformation defines the transformation matrix
  68500. * @returns the transformed Vector3
  68501. */
  68502. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68503. /**
  68504. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68505. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68506. * @param vector defines the Vector3 to transform
  68507. * @param transformation defines the transformation matrix
  68508. * @param result defines the Vector3 where to store the result
  68509. */
  68510. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68511. /**
  68512. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68513. * This method computes tranformed coordinates only, not transformed direction vectors
  68514. * @param x define the x coordinate of the source vector
  68515. * @param y define the y coordinate of the source vector
  68516. * @param z define the z coordinate of the source vector
  68517. * @param transformation defines the transformation matrix
  68518. * @param result defines the Vector3 where to store the result
  68519. */
  68520. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68521. /**
  68522. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68523. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68524. * @param vector defines the Vector3 to transform
  68525. * @param transformation defines the transformation matrix
  68526. * @returns the new Vector3
  68527. */
  68528. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68529. /**
  68530. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68531. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68532. * @param vector defines the Vector3 to transform
  68533. * @param transformation defines the transformation matrix
  68534. * @param result defines the Vector3 where to store the result
  68535. */
  68536. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68537. /**
  68538. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68539. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68540. * @param x define the x coordinate of the source vector
  68541. * @param y define the y coordinate of the source vector
  68542. * @param z define the z coordinate of the source vector
  68543. * @param transformation defines the transformation matrix
  68544. * @param result defines the Vector3 where to store the result
  68545. */
  68546. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68547. /**
  68548. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68549. * @param value1 defines the first control point
  68550. * @param value2 defines the second control point
  68551. * @param value3 defines the third control point
  68552. * @param value4 defines the fourth control point
  68553. * @param amount defines the amount on the spline to use
  68554. * @returns the new Vector3
  68555. */
  68556. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68557. /**
  68558. * 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"
  68559. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68560. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68561. * @param value defines the current value
  68562. * @param min defines the lower range value
  68563. * @param max defines the upper range value
  68564. * @returns the new Vector3
  68565. */
  68566. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68567. /**
  68568. * 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"
  68569. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68570. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68571. * @param value defines the current value
  68572. * @param min defines the lower range value
  68573. * @param max defines the upper range value
  68574. * @param result defines the Vector3 where to store the result
  68575. */
  68576. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68577. /**
  68578. * Checks if a given vector is inside a specific range
  68579. * @param v defines the vector to test
  68580. * @param min defines the minimum range
  68581. * @param max defines the maximum range
  68582. */
  68583. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68584. /**
  68585. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68586. * @param value1 defines the first control point
  68587. * @param tangent1 defines the first tangent vector
  68588. * @param value2 defines the second control point
  68589. * @param tangent2 defines the second tangent vector
  68590. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68591. * @returns the new Vector3
  68592. */
  68593. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68594. /**
  68595. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68596. * @param start defines the start value
  68597. * @param end defines the end value
  68598. * @param amount max defines amount between both (between 0 and 1)
  68599. * @returns the new Vector3
  68600. */
  68601. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68602. /**
  68603. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68604. * @param start defines the start value
  68605. * @param end defines the end value
  68606. * @param amount max defines amount between both (between 0 and 1)
  68607. * @param result defines the Vector3 where to store the result
  68608. */
  68609. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68610. /**
  68611. * Returns the dot product (float) between the vectors "left" and "right"
  68612. * @param left defines the left operand
  68613. * @param right defines the right operand
  68614. * @returns the dot product
  68615. */
  68616. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68617. /**
  68618. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68619. * The cross product is then orthogonal to both "left" and "right"
  68620. * @param left defines the left operand
  68621. * @param right defines the right operand
  68622. * @returns the cross product
  68623. */
  68624. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68625. /**
  68626. * Sets the given vector "result" with the cross product of "left" and "right"
  68627. * The cross product is then orthogonal to both "left" and "right"
  68628. * @param left defines the left operand
  68629. * @param right defines the right operand
  68630. * @param result defines the Vector3 where to store the result
  68631. */
  68632. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68633. /**
  68634. * Returns a new Vector3 as the normalization of the given vector
  68635. * @param vector defines the Vector3 to normalize
  68636. * @returns the new Vector3
  68637. */
  68638. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68639. /**
  68640. * Sets the given vector "result" with the normalization of the given first vector
  68641. * @param vector defines the Vector3 to normalize
  68642. * @param result defines the Vector3 where to store the result
  68643. */
  68644. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68645. /**
  68646. * Project a Vector3 onto screen space
  68647. * @param vector defines the Vector3 to project
  68648. * @param world defines the world matrix to use
  68649. * @param transform defines the transform (view x projection) matrix to use
  68650. * @param viewport defines the screen viewport to use
  68651. * @returns the new Vector3
  68652. */
  68653. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68654. /** @hidden */
  68655. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68656. /**
  68657. * Unproject from screen space to object space
  68658. * @param source defines the screen space Vector3 to use
  68659. * @param viewportWidth defines the current width of the viewport
  68660. * @param viewportHeight defines the current height of the viewport
  68661. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68662. * @param transform defines the transform (view x projection) matrix to use
  68663. * @returns the new Vector3
  68664. */
  68665. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68666. /**
  68667. * Unproject from screen space to object space
  68668. * @param source defines the screen space Vector3 to use
  68669. * @param viewportWidth defines the current width of the viewport
  68670. * @param viewportHeight defines the current height of the viewport
  68671. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68672. * @param view defines the view matrix to use
  68673. * @param projection defines the projection matrix to use
  68674. * @returns the new Vector3
  68675. */
  68676. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68677. /**
  68678. * Unproject from screen space to object space
  68679. * @param source defines the screen space Vector3 to use
  68680. * @param viewportWidth defines the current width of the viewport
  68681. * @param viewportHeight defines the current height of the viewport
  68682. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68683. * @param view defines the view matrix to use
  68684. * @param projection defines the projection matrix to use
  68685. * @param result defines the Vector3 where to store the result
  68686. */
  68687. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68688. /**
  68689. * Unproject from screen space to object space
  68690. * @param sourceX defines the screen space x coordinate to use
  68691. * @param sourceY defines the screen space y coordinate to use
  68692. * @param sourceZ defines the screen space z coordinate to use
  68693. * @param viewportWidth defines the current width of the viewport
  68694. * @param viewportHeight defines the current height of the viewport
  68695. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68696. * @param view defines the view matrix to use
  68697. * @param projection defines the projection matrix to use
  68698. * @param result defines the Vector3 where to store the result
  68699. */
  68700. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68701. /**
  68702. * Gets the minimal coordinate values between two Vector3
  68703. * @param left defines the first operand
  68704. * @param right defines the second operand
  68705. * @returns the new Vector3
  68706. */
  68707. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68708. /**
  68709. * Gets the maximal coordinate values between two Vector3
  68710. * @param left defines the first operand
  68711. * @param right defines the second operand
  68712. * @returns the new Vector3
  68713. */
  68714. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68715. /**
  68716. * Returns the distance between the vectors "value1" and "value2"
  68717. * @param value1 defines the first operand
  68718. * @param value2 defines the second operand
  68719. * @returns the distance
  68720. */
  68721. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68722. /**
  68723. * Returns the squared distance between the vectors "value1" and "value2"
  68724. * @param value1 defines the first operand
  68725. * @param value2 defines the second operand
  68726. * @returns the squared distance
  68727. */
  68728. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68729. /**
  68730. * Returns a new Vector3 located at the center between "value1" and "value2"
  68731. * @param value1 defines the first operand
  68732. * @param value2 defines the second operand
  68733. * @returns the new Vector3
  68734. */
  68735. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68736. /**
  68737. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68738. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68739. * to something in order to rotate it from its local system to the given target system
  68740. * Note: axis1, axis2 and axis3 are normalized during this operation
  68741. * @param axis1 defines the first axis
  68742. * @param axis2 defines the second axis
  68743. * @param axis3 defines the third axis
  68744. * @returns a new Vector3
  68745. */
  68746. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68747. /**
  68748. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68749. * @param axis1 defines the first axis
  68750. * @param axis2 defines the second axis
  68751. * @param axis3 defines the third axis
  68752. * @param ref defines the Vector3 where to store the result
  68753. */
  68754. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68755. }
  68756. /**
  68757. * Vector4 class created for EulerAngle class conversion to Quaternion
  68758. */
  68759. export class Vector4 {
  68760. /** x value of the vector */
  68761. x: number;
  68762. /** y value of the vector */
  68763. y: number;
  68764. /** z value of the vector */
  68765. z: number;
  68766. /** w value of the vector */
  68767. w: number;
  68768. /**
  68769. * Creates a Vector4 object from the given floats.
  68770. * @param x x value of the vector
  68771. * @param y y value of the vector
  68772. * @param z z value of the vector
  68773. * @param w w value of the vector
  68774. */
  68775. constructor(
  68776. /** x value of the vector */
  68777. x: number,
  68778. /** y value of the vector */
  68779. y: number,
  68780. /** z value of the vector */
  68781. z: number,
  68782. /** w value of the vector */
  68783. w: number);
  68784. /**
  68785. * Returns the string with the Vector4 coordinates.
  68786. * @returns a string containing all the vector values
  68787. */
  68788. toString(): string;
  68789. /**
  68790. * Returns the string "Vector4".
  68791. * @returns "Vector4"
  68792. */
  68793. getClassName(): string;
  68794. /**
  68795. * Returns the Vector4 hash code.
  68796. * @returns a unique hash code
  68797. */
  68798. getHashCode(): number;
  68799. /**
  68800. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68801. * @returns the resulting array
  68802. */
  68803. asArray(): number[];
  68804. /**
  68805. * Populates the given array from the given index with the Vector4 coordinates.
  68806. * @param array array to populate
  68807. * @param index index of the array to start at (default: 0)
  68808. * @returns the Vector4.
  68809. */
  68810. toArray(array: FloatArray, index?: number): Vector4;
  68811. /**
  68812. * Adds the given vector to the current Vector4.
  68813. * @param otherVector the vector to add
  68814. * @returns the updated Vector4.
  68815. */
  68816. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68817. /**
  68818. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68819. * @param otherVector the vector to add
  68820. * @returns the resulting vector
  68821. */
  68822. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68823. /**
  68824. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68825. * @param otherVector the vector to add
  68826. * @param result the vector to store the result
  68827. * @returns the current Vector4.
  68828. */
  68829. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68830. /**
  68831. * Subtract in place the given vector from the current Vector4.
  68832. * @param otherVector the vector to subtract
  68833. * @returns the updated Vector4.
  68834. */
  68835. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68836. /**
  68837. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68838. * @param otherVector the vector to add
  68839. * @returns the new vector with the result
  68840. */
  68841. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68842. /**
  68843. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68844. * @param otherVector the vector to subtract
  68845. * @param result the vector to store the result
  68846. * @returns the current Vector4.
  68847. */
  68848. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68849. /**
  68850. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68851. */
  68852. /**
  68853. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68854. * @param x value to subtract
  68855. * @param y value to subtract
  68856. * @param z value to subtract
  68857. * @param w value to subtract
  68858. * @returns new vector containing the result
  68859. */
  68860. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68861. /**
  68862. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68863. * @param x value to subtract
  68864. * @param y value to subtract
  68865. * @param z value to subtract
  68866. * @param w value to subtract
  68867. * @param result the vector to store the result in
  68868. * @returns the current Vector4.
  68869. */
  68870. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68871. /**
  68872. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68873. * @returns a new vector with the negated values
  68874. */
  68875. negate(): Vector4;
  68876. /**
  68877. * Multiplies the current Vector4 coordinates by scale (float).
  68878. * @param scale the number to scale with
  68879. * @returns the updated Vector4.
  68880. */
  68881. scaleInPlace(scale: number): Vector4;
  68882. /**
  68883. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68884. * @param scale the number to scale with
  68885. * @returns a new vector with the result
  68886. */
  68887. scale(scale: number): Vector4;
  68888. /**
  68889. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68890. * @param scale the number to scale with
  68891. * @param result a vector to store the result in
  68892. * @returns the current Vector4.
  68893. */
  68894. scaleToRef(scale: number, result: Vector4): Vector4;
  68895. /**
  68896. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68897. * @param scale defines the scale factor
  68898. * @param result defines the Vector4 object where to store the result
  68899. * @returns the unmodified current Vector4
  68900. */
  68901. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68902. /**
  68903. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68904. * @param otherVector the vector to compare against
  68905. * @returns true if they are equal
  68906. */
  68907. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68908. /**
  68909. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68910. * @param otherVector vector to compare against
  68911. * @param epsilon (Default: very small number)
  68912. * @returns true if they are equal
  68913. */
  68914. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68915. /**
  68916. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68917. * @param x x value to compare against
  68918. * @param y y value to compare against
  68919. * @param z z value to compare against
  68920. * @param w w value to compare against
  68921. * @returns true if equal
  68922. */
  68923. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68924. /**
  68925. * Multiplies in place the current Vector4 by the given one.
  68926. * @param otherVector vector to multiple with
  68927. * @returns the updated Vector4.
  68928. */
  68929. multiplyInPlace(otherVector: Vector4): Vector4;
  68930. /**
  68931. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68932. * @param otherVector vector to multiple with
  68933. * @returns resulting new vector
  68934. */
  68935. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68936. /**
  68937. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68938. * @param otherVector vector to multiple with
  68939. * @param result vector to store the result
  68940. * @returns the current Vector4.
  68941. */
  68942. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68943. /**
  68944. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68945. * @param x x value multiply with
  68946. * @param y y value multiply with
  68947. * @param z z value multiply with
  68948. * @param w w value multiply with
  68949. * @returns resulting new vector
  68950. */
  68951. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68952. /**
  68953. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68954. * @param otherVector vector to devide with
  68955. * @returns resulting new vector
  68956. */
  68957. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68958. /**
  68959. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68960. * @param otherVector vector to devide with
  68961. * @param result vector to store the result
  68962. * @returns the current Vector4.
  68963. */
  68964. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68965. /**
  68966. * Divides the current Vector3 coordinates by the given ones.
  68967. * @param otherVector vector to devide with
  68968. * @returns the updated Vector3.
  68969. */
  68970. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68971. /**
  68972. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68973. * @param other defines the second operand
  68974. * @returns the current updated Vector4
  68975. */
  68976. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68977. /**
  68978. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68979. * @param other defines the second operand
  68980. * @returns the current updated Vector4
  68981. */
  68982. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68983. /**
  68984. * Gets a new Vector4 from current Vector4 floored values
  68985. * @returns a new Vector4
  68986. */
  68987. floor(): Vector4;
  68988. /**
  68989. * Gets a new Vector4 from current Vector3 floored values
  68990. * @returns a new Vector4
  68991. */
  68992. fract(): Vector4;
  68993. /**
  68994. * Returns the Vector4 length (float).
  68995. * @returns the length
  68996. */
  68997. length(): number;
  68998. /**
  68999. * Returns the Vector4 squared length (float).
  69000. * @returns the length squared
  69001. */
  69002. lengthSquared(): number;
  69003. /**
  69004. * Normalizes in place the Vector4.
  69005. * @returns the updated Vector4.
  69006. */
  69007. normalize(): Vector4;
  69008. /**
  69009. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  69010. * @returns this converted to a new vector3
  69011. */
  69012. toVector3(): Vector3;
  69013. /**
  69014. * Returns a new Vector4 copied from the current one.
  69015. * @returns the new cloned vector
  69016. */
  69017. clone(): Vector4;
  69018. /**
  69019. * Updates the current Vector4 with the given one coordinates.
  69020. * @param source the source vector to copy from
  69021. * @returns the updated Vector4.
  69022. */
  69023. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  69024. /**
  69025. * Updates the current Vector4 coordinates with the given floats.
  69026. * @param x float to copy from
  69027. * @param y float to copy from
  69028. * @param z float to copy from
  69029. * @param w float to copy from
  69030. * @returns the updated Vector4.
  69031. */
  69032. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  69033. /**
  69034. * Updates the current Vector4 coordinates with the given floats.
  69035. * @param x float to set from
  69036. * @param y float to set from
  69037. * @param z float to set from
  69038. * @param w float to set from
  69039. * @returns the updated Vector4.
  69040. */
  69041. set(x: number, y: number, z: number, w: number): Vector4;
  69042. /**
  69043. * Copies the given float to the current Vector3 coordinates
  69044. * @param v defines the x, y, z and w coordinates of the operand
  69045. * @returns the current updated Vector3
  69046. */
  69047. setAll(v: number): Vector4;
  69048. /**
  69049. * Returns a new Vector4 set from the starting index of the given array.
  69050. * @param array the array to pull values from
  69051. * @param offset the offset into the array to start at
  69052. * @returns the new vector
  69053. */
  69054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  69055. /**
  69056. * Updates the given vector "result" from the starting index of the given array.
  69057. * @param array the array to pull values from
  69058. * @param offset the offset into the array to start at
  69059. * @param result the vector to store the result in
  69060. */
  69061. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  69062. /**
  69063. * Updates the given vector "result" from the starting index of the given Float32Array.
  69064. * @param array the array to pull values from
  69065. * @param offset the offset into the array to start at
  69066. * @param result the vector to store the result in
  69067. */
  69068. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  69069. /**
  69070. * Updates the given vector "result" coordinates from the given floats.
  69071. * @param x float to set from
  69072. * @param y float to set from
  69073. * @param z float to set from
  69074. * @param w float to set from
  69075. * @param result the vector to the floats in
  69076. */
  69077. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  69078. /**
  69079. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  69080. * @returns the new vector
  69081. */
  69082. static Zero(): Vector4;
  69083. /**
  69084. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  69085. * @returns the new vector
  69086. */
  69087. static One(): Vector4;
  69088. /**
  69089. * Returns a new normalized Vector4 from the given one.
  69090. * @param vector the vector to normalize
  69091. * @returns the vector
  69092. */
  69093. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  69094. /**
  69095. * Updates the given vector "result" from the normalization of the given one.
  69096. * @param vector the vector to normalize
  69097. * @param result the vector to store the result in
  69098. */
  69099. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  69100. /**
  69101. * Returns a vector with the minimum values from the left and right vectors
  69102. * @param left left vector to minimize
  69103. * @param right right vector to minimize
  69104. * @returns a new vector with the minimum of the left and right vector values
  69105. */
  69106. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69107. /**
  69108. * Returns a vector with the maximum values from the left and right vectors
  69109. * @param left left vector to maximize
  69110. * @param right right vector to maximize
  69111. * @returns a new vector with the maximum of the left and right vector values
  69112. */
  69113. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69114. /**
  69115. * Returns the distance (float) between the vectors "value1" and "value2".
  69116. * @param value1 value to calulate the distance between
  69117. * @param value2 value to calulate the distance between
  69118. * @return the distance between the two vectors
  69119. */
  69120. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69121. /**
  69122. * Returns the squared distance (float) between the vectors "value1" and "value2".
  69123. * @param value1 value to calulate the distance between
  69124. * @param value2 value to calulate the distance between
  69125. * @return the distance between the two vectors squared
  69126. */
  69127. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69128. /**
  69129. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  69130. * @param value1 value to calulate the center between
  69131. * @param value2 value to calulate the center between
  69132. * @return the center between the two vectors
  69133. */
  69134. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  69135. /**
  69136. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  69137. * This methods computes transformed normalized direction vectors only.
  69138. * @param vector the vector to transform
  69139. * @param transformation the transformation matrix to apply
  69140. * @returns the new vector
  69141. */
  69142. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  69143. /**
  69144. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  69145. * This methods computes transformed normalized direction vectors only.
  69146. * @param vector the vector to transform
  69147. * @param transformation the transformation matrix to apply
  69148. * @param result the vector to store the result in
  69149. */
  69150. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69151. /**
  69152. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  69153. * This methods computes transformed normalized direction vectors only.
  69154. * @param x value to transform
  69155. * @param y value to transform
  69156. * @param z value to transform
  69157. * @param w value to transform
  69158. * @param transformation the transformation matrix to apply
  69159. * @param result the vector to store the results in
  69160. */
  69161. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69162. /**
  69163. * Creates a new Vector4 from a Vector3
  69164. * @param source defines the source data
  69165. * @param w defines the 4th component (default is 0)
  69166. * @returns a new Vector4
  69167. */
  69168. static FromVector3(source: Vector3, w?: number): Vector4;
  69169. }
  69170. /**
  69171. * Class used to store quaternion data
  69172. * @see https://en.wikipedia.org/wiki/Quaternion
  69173. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  69174. */
  69175. export class Quaternion {
  69176. /** defines the first component (0 by default) */
  69177. x: number;
  69178. /** defines the second component (0 by default) */
  69179. y: number;
  69180. /** defines the third component (0 by default) */
  69181. z: number;
  69182. /** defines the fourth component (1.0 by default) */
  69183. w: number;
  69184. /**
  69185. * Creates a new Quaternion from the given floats
  69186. * @param x defines the first component (0 by default)
  69187. * @param y defines the second component (0 by default)
  69188. * @param z defines the third component (0 by default)
  69189. * @param w defines the fourth component (1.0 by default)
  69190. */
  69191. constructor(
  69192. /** defines the first component (0 by default) */
  69193. x?: number,
  69194. /** defines the second component (0 by default) */
  69195. y?: number,
  69196. /** defines the third component (0 by default) */
  69197. z?: number,
  69198. /** defines the fourth component (1.0 by default) */
  69199. w?: number);
  69200. /**
  69201. * Gets a string representation for the current quaternion
  69202. * @returns a string with the Quaternion coordinates
  69203. */
  69204. toString(): string;
  69205. /**
  69206. * Gets the class name of the quaternion
  69207. * @returns the string "Quaternion"
  69208. */
  69209. getClassName(): string;
  69210. /**
  69211. * Gets a hash code for this quaternion
  69212. * @returns the quaternion hash code
  69213. */
  69214. getHashCode(): number;
  69215. /**
  69216. * Copy the quaternion to an array
  69217. * @returns a new array populated with 4 elements from the quaternion coordinates
  69218. */
  69219. asArray(): number[];
  69220. /**
  69221. * Check if two quaternions are equals
  69222. * @param otherQuaternion defines the second operand
  69223. * @return true if the current quaternion and the given one coordinates are strictly equals
  69224. */
  69225. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  69226. /**
  69227. * Clone the current quaternion
  69228. * @returns a new quaternion copied from the current one
  69229. */
  69230. clone(): Quaternion;
  69231. /**
  69232. * Copy a quaternion to the current one
  69233. * @param other defines the other quaternion
  69234. * @returns the updated current quaternion
  69235. */
  69236. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  69237. /**
  69238. * Updates the current quaternion with the given float coordinates
  69239. * @param x defines the x coordinate
  69240. * @param y defines the y coordinate
  69241. * @param z defines the z coordinate
  69242. * @param w defines the w coordinate
  69243. * @returns the updated current quaternion
  69244. */
  69245. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  69246. /**
  69247. * Updates the current quaternion from the given float coordinates
  69248. * @param x defines the x coordinate
  69249. * @param y defines the y coordinate
  69250. * @param z defines the z coordinate
  69251. * @param w defines the w coordinate
  69252. * @returns the updated current quaternion
  69253. */
  69254. set(x: number, y: number, z: number, w: number): Quaternion;
  69255. /**
  69256. * Adds two quaternions
  69257. * @param other defines the second operand
  69258. * @returns a new quaternion as the addition result of the given one and the current quaternion
  69259. */
  69260. add(other: DeepImmutable<Quaternion>): Quaternion;
  69261. /**
  69262. * Add a quaternion to the current one
  69263. * @param other defines the quaternion to add
  69264. * @returns the current quaternion
  69265. */
  69266. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  69267. /**
  69268. * Subtract two quaternions
  69269. * @param other defines the second operand
  69270. * @returns a new quaternion as the subtraction result of the given one from the current one
  69271. */
  69272. subtract(other: Quaternion): Quaternion;
  69273. /**
  69274. * Multiplies the current quaternion by a scale factor
  69275. * @param value defines the scale factor
  69276. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  69277. */
  69278. scale(value: number): Quaternion;
  69279. /**
  69280. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  69281. * @param scale defines the scale factor
  69282. * @param result defines the Quaternion object where to store the result
  69283. * @returns the unmodified current quaternion
  69284. */
  69285. scaleToRef(scale: number, result: Quaternion): Quaternion;
  69286. /**
  69287. * Multiplies in place the current quaternion by a scale factor
  69288. * @param value defines the scale factor
  69289. * @returns the current modified quaternion
  69290. */
  69291. scaleInPlace(value: number): Quaternion;
  69292. /**
  69293. * Scale the current quaternion values by a factor and add the result to a given quaternion
  69294. * @param scale defines the scale factor
  69295. * @param result defines the Quaternion object where to store the result
  69296. * @returns the unmodified current quaternion
  69297. */
  69298. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  69299. /**
  69300. * Multiplies two quaternions
  69301. * @param q1 defines the second operand
  69302. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  69303. */
  69304. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  69305. /**
  69306. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  69307. * @param q1 defines the second operand
  69308. * @param result defines the target quaternion
  69309. * @returns the current quaternion
  69310. */
  69311. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  69312. /**
  69313. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  69314. * @param q1 defines the second operand
  69315. * @returns the currentupdated quaternion
  69316. */
  69317. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  69318. /**
  69319. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  69320. * @param ref defines the target quaternion
  69321. * @returns the current quaternion
  69322. */
  69323. conjugateToRef(ref: Quaternion): Quaternion;
  69324. /**
  69325. * Conjugates in place (1-q) the current quaternion
  69326. * @returns the current updated quaternion
  69327. */
  69328. conjugateInPlace(): Quaternion;
  69329. /**
  69330. * Conjugates in place (1-q) the current quaternion
  69331. * @returns a new quaternion
  69332. */
  69333. conjugate(): Quaternion;
  69334. /**
  69335. * Gets length of current quaternion
  69336. * @returns the quaternion length (float)
  69337. */
  69338. length(): number;
  69339. /**
  69340. * Normalize in place the current quaternion
  69341. * @returns the current updated quaternion
  69342. */
  69343. normalize(): Quaternion;
  69344. /**
  69345. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  69346. * @param order is a reserved parameter and is ignore for now
  69347. * @returns a new Vector3 containing the Euler angles
  69348. */
  69349. toEulerAngles(order?: string): Vector3;
  69350. /**
  69351. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  69352. * @param result defines the vector which will be filled with the Euler angles
  69353. * @param order is a reserved parameter and is ignore for now
  69354. * @returns the current unchanged quaternion
  69355. */
  69356. toEulerAnglesToRef(result: Vector3): Quaternion;
  69357. /**
  69358. * Updates the given rotation matrix with the current quaternion values
  69359. * @param result defines the target matrix
  69360. * @returns the current unchanged quaternion
  69361. */
  69362. toRotationMatrix(result: Matrix): Quaternion;
  69363. /**
  69364. * Updates the current quaternion from the given rotation matrix values
  69365. * @param matrix defines the source matrix
  69366. * @returns the current updated quaternion
  69367. */
  69368. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69369. /**
  69370. * Creates a new quaternion from a rotation matrix
  69371. * @param matrix defines the source matrix
  69372. * @returns a new quaternion created from the given rotation matrix values
  69373. */
  69374. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69375. /**
  69376. * Updates the given quaternion with the given rotation matrix values
  69377. * @param matrix defines the source matrix
  69378. * @param result defines the target quaternion
  69379. */
  69380. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69381. /**
  69382. * Returns the dot product (float) between the quaternions "left" and "right"
  69383. * @param left defines the left operand
  69384. * @param right defines the right operand
  69385. * @returns the dot product
  69386. */
  69387. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69388. /**
  69389. * Checks if the two quaternions are close to each other
  69390. * @param quat0 defines the first quaternion to check
  69391. * @param quat1 defines the second quaternion to check
  69392. * @returns true if the two quaternions are close to each other
  69393. */
  69394. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69395. /**
  69396. * Creates an empty quaternion
  69397. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69398. */
  69399. static Zero(): Quaternion;
  69400. /**
  69401. * Inverse a given quaternion
  69402. * @param q defines the source quaternion
  69403. * @returns a new quaternion as the inverted current quaternion
  69404. */
  69405. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69406. /**
  69407. * Inverse a given quaternion
  69408. * @param q defines the source quaternion
  69409. * @param result the quaternion the result will be stored in
  69410. * @returns the result quaternion
  69411. */
  69412. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69413. /**
  69414. * Creates an identity quaternion
  69415. * @returns the identity quaternion
  69416. */
  69417. static Identity(): Quaternion;
  69418. /**
  69419. * Gets a boolean indicating if the given quaternion is identity
  69420. * @param quaternion defines the quaternion to check
  69421. * @returns true if the quaternion is identity
  69422. */
  69423. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69424. /**
  69425. * Creates a quaternion from a rotation around an axis
  69426. * @param axis defines the axis to use
  69427. * @param angle defines the angle to use
  69428. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69429. */
  69430. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69431. /**
  69432. * Creates a rotation around an axis and stores it into the given quaternion
  69433. * @param axis defines the axis to use
  69434. * @param angle defines the angle to use
  69435. * @param result defines the target quaternion
  69436. * @returns the target quaternion
  69437. */
  69438. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69439. /**
  69440. * Creates a new quaternion from data stored into an array
  69441. * @param array defines the data source
  69442. * @param offset defines the offset in the source array where the data starts
  69443. * @returns a new quaternion
  69444. */
  69445. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69446. /**
  69447. * Create a quaternion from Euler rotation angles
  69448. * @param x Pitch
  69449. * @param y Yaw
  69450. * @param z Roll
  69451. * @returns the new Quaternion
  69452. */
  69453. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69454. /**
  69455. * Updates a quaternion from Euler rotation angles
  69456. * @param x Pitch
  69457. * @param y Yaw
  69458. * @param z Roll
  69459. * @param result the quaternion to store the result
  69460. * @returns the updated quaternion
  69461. */
  69462. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69463. /**
  69464. * Create a quaternion from Euler rotation vector
  69465. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69466. * @returns the new Quaternion
  69467. */
  69468. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69469. /**
  69470. * Updates a quaternion from Euler rotation vector
  69471. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69472. * @param result the quaternion to store the result
  69473. * @returns the updated quaternion
  69474. */
  69475. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69476. /**
  69477. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69478. * @param yaw defines the rotation around Y axis
  69479. * @param pitch defines the rotation around X axis
  69480. * @param roll defines the rotation around Z axis
  69481. * @returns the new quaternion
  69482. */
  69483. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69484. /**
  69485. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69486. * @param yaw defines the rotation around Y axis
  69487. * @param pitch defines the rotation around X axis
  69488. * @param roll defines the rotation around Z axis
  69489. * @param result defines the target quaternion
  69490. */
  69491. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69492. /**
  69493. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69494. * @param alpha defines the rotation around first axis
  69495. * @param beta defines the rotation around second axis
  69496. * @param gamma defines the rotation around third axis
  69497. * @returns the new quaternion
  69498. */
  69499. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69500. /**
  69501. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69502. * @param alpha defines the rotation around first axis
  69503. * @param beta defines the rotation around second axis
  69504. * @param gamma defines the rotation around third axis
  69505. * @param result defines the target quaternion
  69506. */
  69507. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69508. /**
  69509. * 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)
  69510. * @param axis1 defines the first axis
  69511. * @param axis2 defines the second axis
  69512. * @param axis3 defines the third axis
  69513. * @returns the new quaternion
  69514. */
  69515. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69516. /**
  69517. * 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
  69518. * @param axis1 defines the first axis
  69519. * @param axis2 defines the second axis
  69520. * @param axis3 defines the third axis
  69521. * @param ref defines the target quaternion
  69522. */
  69523. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69524. /**
  69525. * Interpolates between two quaternions
  69526. * @param left defines first quaternion
  69527. * @param right defines second quaternion
  69528. * @param amount defines the gradient to use
  69529. * @returns the new interpolated quaternion
  69530. */
  69531. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69532. /**
  69533. * Interpolates between two quaternions and stores it into a target quaternion
  69534. * @param left defines first quaternion
  69535. * @param right defines second quaternion
  69536. * @param amount defines the gradient to use
  69537. * @param result defines the target quaternion
  69538. */
  69539. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69540. /**
  69541. * Interpolate between two quaternions using Hermite interpolation
  69542. * @param value1 defines first quaternion
  69543. * @param tangent1 defines the incoming tangent
  69544. * @param value2 defines second quaternion
  69545. * @param tangent2 defines the outgoing tangent
  69546. * @param amount defines the target quaternion
  69547. * @returns the new interpolated quaternion
  69548. */
  69549. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69550. }
  69551. /**
  69552. * Class used to store matrix data (4x4)
  69553. */
  69554. export class Matrix {
  69555. private static _updateFlagSeed;
  69556. private static _identityReadOnly;
  69557. private _isIdentity;
  69558. private _isIdentityDirty;
  69559. private _isIdentity3x2;
  69560. private _isIdentity3x2Dirty;
  69561. /**
  69562. * Gets the update flag of the matrix which is an unique number for the matrix.
  69563. * It will be incremented every time the matrix data change.
  69564. * You can use it to speed the comparison between two versions of the same matrix.
  69565. */
  69566. updateFlag: number;
  69567. private readonly _m;
  69568. /**
  69569. * Gets the internal data of the matrix
  69570. */
  69571. readonly m: DeepImmutable<Float32Array>;
  69572. /** @hidden */
  69573. _markAsUpdated(): void;
  69574. /** @hidden */
  69575. private _updateIdentityStatus;
  69576. /**
  69577. * Creates an empty matrix (filled with zeros)
  69578. */
  69579. constructor();
  69580. /**
  69581. * Check if the current matrix is identity
  69582. * @returns true is the matrix is the identity matrix
  69583. */
  69584. isIdentity(): boolean;
  69585. /**
  69586. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69587. * @returns true is the matrix is the identity matrix
  69588. */
  69589. isIdentityAs3x2(): boolean;
  69590. /**
  69591. * Gets the determinant of the matrix
  69592. * @returns the matrix determinant
  69593. */
  69594. determinant(): number;
  69595. /**
  69596. * Returns the matrix as a Float32Array
  69597. * @returns the matrix underlying array
  69598. */
  69599. toArray(): DeepImmutable<Float32Array>;
  69600. /**
  69601. * Returns the matrix as a Float32Array
  69602. * @returns the matrix underlying array.
  69603. */
  69604. asArray(): DeepImmutable<Float32Array>;
  69605. /**
  69606. * Inverts the current matrix in place
  69607. * @returns the current inverted matrix
  69608. */
  69609. invert(): Matrix;
  69610. /**
  69611. * Sets all the matrix elements to zero
  69612. * @returns the current matrix
  69613. */
  69614. reset(): Matrix;
  69615. /**
  69616. * Adds the current matrix with a second one
  69617. * @param other defines the matrix to add
  69618. * @returns a new matrix as the addition of the current matrix and the given one
  69619. */
  69620. add(other: DeepImmutable<Matrix>): Matrix;
  69621. /**
  69622. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69623. * @param other defines the matrix to add
  69624. * @param result defines the target matrix
  69625. * @returns the current matrix
  69626. */
  69627. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69628. /**
  69629. * Adds in place the given matrix to the current matrix
  69630. * @param other defines the second operand
  69631. * @returns the current updated matrix
  69632. */
  69633. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69634. /**
  69635. * Sets the given matrix to the current inverted Matrix
  69636. * @param other defines the target matrix
  69637. * @returns the unmodified current matrix
  69638. */
  69639. invertToRef(other: Matrix): Matrix;
  69640. /**
  69641. * add a value at the specified position in the current Matrix
  69642. * @param index the index of the value within the matrix. between 0 and 15.
  69643. * @param value the value to be added
  69644. * @returns the current updated matrix
  69645. */
  69646. addAtIndex(index: number, value: number): Matrix;
  69647. /**
  69648. * mutiply the specified position in the current Matrix by a value
  69649. * @param index the index of the value within the matrix. between 0 and 15.
  69650. * @param value the value to be added
  69651. * @returns the current updated matrix
  69652. */
  69653. multiplyAtIndex(index: number, value: number): Matrix;
  69654. /**
  69655. * Inserts the translation vector (using 3 floats) in the current matrix
  69656. * @param x defines the 1st component of the translation
  69657. * @param y defines the 2nd component of the translation
  69658. * @param z defines the 3rd component of the translation
  69659. * @returns the current updated matrix
  69660. */
  69661. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69662. /**
  69663. * Adds the translation vector (using 3 floats) in the current matrix
  69664. * @param x defines the 1st component of the translation
  69665. * @param y defines the 2nd component of the translation
  69666. * @param z defines the 3rd component of the translation
  69667. * @returns the current updated matrix
  69668. */
  69669. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69670. /**
  69671. * Inserts the translation vector in the current matrix
  69672. * @param vector3 defines the translation to insert
  69673. * @returns the current updated matrix
  69674. */
  69675. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69676. /**
  69677. * Gets the translation value of the current matrix
  69678. * @returns a new Vector3 as the extracted translation from the matrix
  69679. */
  69680. getTranslation(): Vector3;
  69681. /**
  69682. * Fill a Vector3 with the extracted translation from the matrix
  69683. * @param result defines the Vector3 where to store the translation
  69684. * @returns the current matrix
  69685. */
  69686. getTranslationToRef(result: Vector3): Matrix;
  69687. /**
  69688. * Remove rotation and scaling part from the matrix
  69689. * @returns the updated matrix
  69690. */
  69691. removeRotationAndScaling(): Matrix;
  69692. /**
  69693. * Multiply two matrices
  69694. * @param other defines the second operand
  69695. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69696. */
  69697. multiply(other: DeepImmutable<Matrix>): Matrix;
  69698. /**
  69699. * Copy the current matrix from the given one
  69700. * @param other defines the source matrix
  69701. * @returns the current updated matrix
  69702. */
  69703. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69704. /**
  69705. * Populates the given array from the starting index with the current matrix values
  69706. * @param array defines the target array
  69707. * @param offset defines the offset in the target array where to start storing values
  69708. * @returns the current matrix
  69709. */
  69710. copyToArray(array: Float32Array, offset?: number): Matrix;
  69711. /**
  69712. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69713. * @param other defines the second operand
  69714. * @param result defines the matrix where to store the multiplication
  69715. * @returns the current matrix
  69716. */
  69717. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69718. /**
  69719. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69720. * @param other defines the second operand
  69721. * @param result defines the array where to store the multiplication
  69722. * @param offset defines the offset in the target array where to start storing values
  69723. * @returns the current matrix
  69724. */
  69725. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69726. /**
  69727. * Check equality between this matrix and a second one
  69728. * @param value defines the second matrix to compare
  69729. * @returns true is the current matrix and the given one values are strictly equal
  69730. */
  69731. equals(value: DeepImmutable<Matrix>): boolean;
  69732. /**
  69733. * Clone the current matrix
  69734. * @returns a new matrix from the current matrix
  69735. */
  69736. clone(): Matrix;
  69737. /**
  69738. * Returns the name of the current matrix class
  69739. * @returns the string "Matrix"
  69740. */
  69741. getClassName(): string;
  69742. /**
  69743. * Gets the hash code of the current matrix
  69744. * @returns the hash code
  69745. */
  69746. getHashCode(): number;
  69747. /**
  69748. * Decomposes the current Matrix into a translation, rotation and scaling components
  69749. * @param scale defines the scale vector3 given as a reference to update
  69750. * @param rotation defines the rotation quaternion given as a reference to update
  69751. * @param translation defines the translation vector3 given as a reference to update
  69752. * @returns true if operation was successful
  69753. */
  69754. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69755. /**
  69756. * Gets specific row of the matrix
  69757. * @param index defines the number of the row to get
  69758. * @returns the index-th row of the current matrix as a new Vector4
  69759. */
  69760. getRow(index: number): Nullable<Vector4>;
  69761. /**
  69762. * Sets the index-th row of the current matrix to the vector4 values
  69763. * @param index defines the number of the row to set
  69764. * @param row defines the target vector4
  69765. * @returns the updated current matrix
  69766. */
  69767. setRow(index: number, row: Vector4): Matrix;
  69768. /**
  69769. * Compute the transpose of the matrix
  69770. * @returns the new transposed matrix
  69771. */
  69772. transpose(): Matrix;
  69773. /**
  69774. * Compute the transpose of the matrix and store it in a given matrix
  69775. * @param result defines the target matrix
  69776. * @returns the current matrix
  69777. */
  69778. transposeToRef(result: Matrix): Matrix;
  69779. /**
  69780. * Sets the index-th row of the current matrix with the given 4 x float values
  69781. * @param index defines the row index
  69782. * @param x defines the x component to set
  69783. * @param y defines the y component to set
  69784. * @param z defines the z component to set
  69785. * @param w defines the w component to set
  69786. * @returns the updated current matrix
  69787. */
  69788. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69789. /**
  69790. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69791. * @param scale defines the scale factor
  69792. * @returns a new matrix
  69793. */
  69794. scale(scale: number): Matrix;
  69795. /**
  69796. * Scale the current matrix values by a factor to a given result matrix
  69797. * @param scale defines the scale factor
  69798. * @param result defines the matrix to store the result
  69799. * @returns the current matrix
  69800. */
  69801. scaleToRef(scale: number, result: Matrix): Matrix;
  69802. /**
  69803. * Scale the current matrix values by a factor and add the result to a given matrix
  69804. * @param scale defines the scale factor
  69805. * @param result defines the Matrix to store the result
  69806. * @returns the current matrix
  69807. */
  69808. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69809. /**
  69810. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69811. * @param ref matrix to store the result
  69812. */
  69813. toNormalMatrix(ref: Matrix): void;
  69814. /**
  69815. * Gets only rotation part of the current matrix
  69816. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69817. */
  69818. getRotationMatrix(): Matrix;
  69819. /**
  69820. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69821. * @param result defines the target matrix to store data to
  69822. * @returns the current matrix
  69823. */
  69824. getRotationMatrixToRef(result: Matrix): Matrix;
  69825. /**
  69826. * Toggles model matrix from being right handed to left handed in place and vice versa
  69827. */
  69828. toggleModelMatrixHandInPlace(): void;
  69829. /**
  69830. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69831. */
  69832. toggleProjectionMatrixHandInPlace(): void;
  69833. /**
  69834. * Creates a matrix from an array
  69835. * @param array defines the source array
  69836. * @param offset defines an offset in the source array
  69837. * @returns a new Matrix set from the starting index of the given array
  69838. */
  69839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69840. /**
  69841. * Copy the content of an array into a given matrix
  69842. * @param array defines the source array
  69843. * @param offset defines an offset in the source array
  69844. * @param result defines the target matrix
  69845. */
  69846. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69847. /**
  69848. * Stores an array into a matrix after having multiplied each component by a given factor
  69849. * @param array defines the source array
  69850. * @param offset defines the offset in the source array
  69851. * @param scale defines the scaling factor
  69852. * @param result defines the target matrix
  69853. */
  69854. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69855. /**
  69856. * Gets an identity matrix that must not be updated
  69857. */
  69858. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69859. /**
  69860. * Stores a list of values (16) inside a given matrix
  69861. * @param initialM11 defines 1st value of 1st row
  69862. * @param initialM12 defines 2nd value of 1st row
  69863. * @param initialM13 defines 3rd value of 1st row
  69864. * @param initialM14 defines 4th value of 1st row
  69865. * @param initialM21 defines 1st value of 2nd row
  69866. * @param initialM22 defines 2nd value of 2nd row
  69867. * @param initialM23 defines 3rd value of 2nd row
  69868. * @param initialM24 defines 4th value of 2nd row
  69869. * @param initialM31 defines 1st value of 3rd row
  69870. * @param initialM32 defines 2nd value of 3rd row
  69871. * @param initialM33 defines 3rd value of 3rd row
  69872. * @param initialM34 defines 4th value of 3rd row
  69873. * @param initialM41 defines 1st value of 4th row
  69874. * @param initialM42 defines 2nd value of 4th row
  69875. * @param initialM43 defines 3rd value of 4th row
  69876. * @param initialM44 defines 4th value of 4th row
  69877. * @param result defines the target matrix
  69878. */
  69879. 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;
  69880. /**
  69881. * Creates new matrix from a list of values (16)
  69882. * @param initialM11 defines 1st value of 1st row
  69883. * @param initialM12 defines 2nd value of 1st row
  69884. * @param initialM13 defines 3rd value of 1st row
  69885. * @param initialM14 defines 4th value of 1st row
  69886. * @param initialM21 defines 1st value of 2nd row
  69887. * @param initialM22 defines 2nd value of 2nd row
  69888. * @param initialM23 defines 3rd value of 2nd row
  69889. * @param initialM24 defines 4th value of 2nd row
  69890. * @param initialM31 defines 1st value of 3rd row
  69891. * @param initialM32 defines 2nd value of 3rd row
  69892. * @param initialM33 defines 3rd value of 3rd row
  69893. * @param initialM34 defines 4th value of 3rd row
  69894. * @param initialM41 defines 1st value of 4th row
  69895. * @param initialM42 defines 2nd value of 4th row
  69896. * @param initialM43 defines 3rd value of 4th row
  69897. * @param initialM44 defines 4th value of 4th row
  69898. * @returns the new matrix
  69899. */
  69900. 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;
  69901. /**
  69902. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69903. * @param scale defines the scale vector3
  69904. * @param rotation defines the rotation quaternion
  69905. * @param translation defines the translation vector3
  69906. * @returns a new matrix
  69907. */
  69908. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69909. /**
  69910. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69911. * @param scale defines the scale vector3
  69912. * @param rotation defines the rotation quaternion
  69913. * @param translation defines the translation vector3
  69914. * @param result defines the target matrix
  69915. */
  69916. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69917. /**
  69918. * Creates a new identity matrix
  69919. * @returns a new identity matrix
  69920. */
  69921. static Identity(): Matrix;
  69922. /**
  69923. * Creates a new identity matrix and stores the result in a given matrix
  69924. * @param result defines the target matrix
  69925. */
  69926. static IdentityToRef(result: Matrix): void;
  69927. /**
  69928. * Creates a new zero matrix
  69929. * @returns a new zero matrix
  69930. */
  69931. static Zero(): Matrix;
  69932. /**
  69933. * Creates a new rotation matrix for "angle" radians around the X axis
  69934. * @param angle defines the angle (in radians) to use
  69935. * @return the new matrix
  69936. */
  69937. static RotationX(angle: number): Matrix;
  69938. /**
  69939. * Creates a new matrix as the invert of a given matrix
  69940. * @param source defines the source matrix
  69941. * @returns the new matrix
  69942. */
  69943. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69944. /**
  69945. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69946. * @param angle defines the angle (in radians) to use
  69947. * @param result defines the target matrix
  69948. */
  69949. static RotationXToRef(angle: number, result: Matrix): void;
  69950. /**
  69951. * Creates a new rotation matrix for "angle" radians around the Y axis
  69952. * @param angle defines the angle (in radians) to use
  69953. * @return the new matrix
  69954. */
  69955. static RotationY(angle: number): Matrix;
  69956. /**
  69957. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69958. * @param angle defines the angle (in radians) to use
  69959. * @param result defines the target matrix
  69960. */
  69961. static RotationYToRef(angle: number, result: Matrix): void;
  69962. /**
  69963. * Creates a new rotation matrix for "angle" radians around the Z axis
  69964. * @param angle defines the angle (in radians) to use
  69965. * @return the new matrix
  69966. */
  69967. static RotationZ(angle: number): Matrix;
  69968. /**
  69969. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69970. * @param angle defines the angle (in radians) to use
  69971. * @param result defines the target matrix
  69972. */
  69973. static RotationZToRef(angle: number, result: Matrix): void;
  69974. /**
  69975. * Creates a new rotation matrix for "angle" radians around the given axis
  69976. * @param axis defines the axis to use
  69977. * @param angle defines the angle (in radians) to use
  69978. * @return the new matrix
  69979. */
  69980. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69981. /**
  69982. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69983. * @param axis defines the axis to use
  69984. * @param angle defines the angle (in radians) to use
  69985. * @param result defines the target matrix
  69986. */
  69987. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69988. /**
  69989. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69990. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69991. * @param from defines the vector to align
  69992. * @param to defines the vector to align to
  69993. * @param result defines the target matrix
  69994. */
  69995. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69996. /**
  69997. * Creates a rotation matrix
  69998. * @param yaw defines the yaw angle in radians (Y axis)
  69999. * @param pitch defines the pitch angle in radians (X axis)
  70000. * @param roll defines the roll angle in radians (X axis)
  70001. * @returns the new rotation matrix
  70002. */
  70003. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  70004. /**
  70005. * Creates a rotation matrix and stores it in a given matrix
  70006. * @param yaw defines the yaw angle in radians (Y axis)
  70007. * @param pitch defines the pitch angle in radians (X axis)
  70008. * @param roll defines the roll angle in radians (X axis)
  70009. * @param result defines the target matrix
  70010. */
  70011. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  70012. /**
  70013. * Creates a scaling matrix
  70014. * @param x defines the scale factor on X axis
  70015. * @param y defines the scale factor on Y axis
  70016. * @param z defines the scale factor on Z axis
  70017. * @returns the new matrix
  70018. */
  70019. static Scaling(x: number, y: number, z: number): Matrix;
  70020. /**
  70021. * Creates a scaling matrix and stores it in a given matrix
  70022. * @param x defines the scale factor on X axis
  70023. * @param y defines the scale factor on Y axis
  70024. * @param z defines the scale factor on Z axis
  70025. * @param result defines the target matrix
  70026. */
  70027. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  70028. /**
  70029. * Creates a translation matrix
  70030. * @param x defines the translation on X axis
  70031. * @param y defines the translation on Y axis
  70032. * @param z defines the translationon Z axis
  70033. * @returns the new matrix
  70034. */
  70035. static Translation(x: number, y: number, z: number): Matrix;
  70036. /**
  70037. * Creates a translation matrix and stores it in a given matrix
  70038. * @param x defines the translation on X axis
  70039. * @param y defines the translation on Y axis
  70040. * @param z defines the translationon Z axis
  70041. * @param result defines the target matrix
  70042. */
  70043. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  70044. /**
  70045. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  70046. * @param startValue defines the start value
  70047. * @param endValue defines the end value
  70048. * @param gradient defines the gradient factor
  70049. * @returns the new matrix
  70050. */
  70051. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  70052. /**
  70053. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  70054. * @param startValue defines the start value
  70055. * @param endValue defines the end value
  70056. * @param gradient defines the gradient factor
  70057. * @param result defines the Matrix object where to store data
  70058. */
  70059. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  70060. /**
  70061. * Builds a new matrix whose values are computed by:
  70062. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  70063. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  70064. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  70065. * @param startValue defines the first matrix
  70066. * @param endValue defines the second matrix
  70067. * @param gradient defines the gradient between the two matrices
  70068. * @returns the new matrix
  70069. */
  70070. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  70071. /**
  70072. * Update a matrix to values which are computed by:
  70073. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  70074. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  70075. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  70076. * @param startValue defines the first matrix
  70077. * @param endValue defines the second matrix
  70078. * @param gradient defines the gradient between the two matrices
  70079. * @param result defines the target matrix
  70080. */
  70081. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  70082. /**
  70083. * 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"
  70084. * This function works in left handed mode
  70085. * @param eye defines the final position of the entity
  70086. * @param target defines where the entity should look at
  70087. * @param up defines the up vector for the entity
  70088. * @returns the new matrix
  70089. */
  70090. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  70091. /**
  70092. * 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".
  70093. * This function works in left handed mode
  70094. * @param eye defines the final position of the entity
  70095. * @param target defines where the entity should look at
  70096. * @param up defines the up vector for the entity
  70097. * @param result defines the target matrix
  70098. */
  70099. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  70100. /**
  70101. * 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"
  70102. * This function works in right handed mode
  70103. * @param eye defines the final position of the entity
  70104. * @param target defines where the entity should look at
  70105. * @param up defines the up vector for the entity
  70106. * @returns the new matrix
  70107. */
  70108. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  70109. /**
  70110. * 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".
  70111. * This function works in right handed mode
  70112. * @param eye defines the final position of the entity
  70113. * @param target defines where the entity should look at
  70114. * @param up defines the up vector for the entity
  70115. * @param result defines the target matrix
  70116. */
  70117. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  70118. /**
  70119. * Create a left-handed orthographic projection matrix
  70120. * @param width defines the viewport width
  70121. * @param height defines the viewport height
  70122. * @param znear defines the near clip plane
  70123. * @param zfar defines the far clip plane
  70124. * @returns a new matrix as a left-handed orthographic projection matrix
  70125. */
  70126. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70127. /**
  70128. * Store a left-handed orthographic projection to a given matrix
  70129. * @param width defines the viewport width
  70130. * @param height defines the viewport height
  70131. * @param znear defines the near clip plane
  70132. * @param zfar defines the far clip plane
  70133. * @param result defines the target matrix
  70134. */
  70135. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  70136. /**
  70137. * Create a left-handed orthographic projection matrix
  70138. * @param left defines the viewport left coordinate
  70139. * @param right defines the viewport right coordinate
  70140. * @param bottom defines the viewport bottom coordinate
  70141. * @param top defines the viewport top coordinate
  70142. * @param znear defines the near clip plane
  70143. * @param zfar defines the far clip plane
  70144. * @returns a new matrix as a left-handed orthographic projection matrix
  70145. */
  70146. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70147. /**
  70148. * Stores a left-handed orthographic projection into a given matrix
  70149. * @param left defines the viewport left coordinate
  70150. * @param right defines the viewport right coordinate
  70151. * @param bottom defines the viewport bottom coordinate
  70152. * @param top defines the viewport top coordinate
  70153. * @param znear defines the near clip plane
  70154. * @param zfar defines the far clip plane
  70155. * @param result defines the target matrix
  70156. */
  70157. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70158. /**
  70159. * Creates a right-handed orthographic projection matrix
  70160. * @param left defines the viewport left coordinate
  70161. * @param right defines the viewport right coordinate
  70162. * @param bottom defines the viewport bottom coordinate
  70163. * @param top defines the viewport top coordinate
  70164. * @param znear defines the near clip plane
  70165. * @param zfar defines the far clip plane
  70166. * @returns a new matrix as a right-handed orthographic projection matrix
  70167. */
  70168. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70169. /**
  70170. * Stores a right-handed orthographic projection into a given matrix
  70171. * @param left defines the viewport left coordinate
  70172. * @param right defines the viewport right coordinate
  70173. * @param bottom defines the viewport bottom coordinate
  70174. * @param top defines the viewport top coordinate
  70175. * @param znear defines the near clip plane
  70176. * @param zfar defines the far clip plane
  70177. * @param result defines the target matrix
  70178. */
  70179. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70180. /**
  70181. * Creates a left-handed perspective projection matrix
  70182. * @param width defines the viewport width
  70183. * @param height defines the viewport height
  70184. * @param znear defines the near clip plane
  70185. * @param zfar defines the far clip plane
  70186. * @returns a new matrix as a left-handed perspective projection matrix
  70187. */
  70188. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70189. /**
  70190. * Creates a left-handed perspective projection matrix
  70191. * @param fov defines the horizontal field of view
  70192. * @param aspect defines the aspect ratio
  70193. * @param znear defines the near clip plane
  70194. * @param zfar defines the far clip plane
  70195. * @returns a new matrix as a left-handed perspective projection matrix
  70196. */
  70197. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70198. /**
  70199. * Stores a left-handed perspective projection into a given matrix
  70200. * @param fov defines the horizontal field of view
  70201. * @param aspect defines the aspect ratio
  70202. * @param znear defines the near clip plane
  70203. * @param zfar defines the far clip plane
  70204. * @param result defines the target matrix
  70205. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70206. */
  70207. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70208. /**
  70209. * Creates a right-handed perspective projection matrix
  70210. * @param fov defines the horizontal field of view
  70211. * @param aspect defines the aspect ratio
  70212. * @param znear defines the near clip plane
  70213. * @param zfar defines the far clip plane
  70214. * @returns a new matrix as a right-handed perspective projection matrix
  70215. */
  70216. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70217. /**
  70218. * Stores a right-handed perspective projection into a given matrix
  70219. * @param fov defines the horizontal field of view
  70220. * @param aspect defines the aspect ratio
  70221. * @param znear defines the near clip plane
  70222. * @param zfar defines the far clip plane
  70223. * @param result defines the target matrix
  70224. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70225. */
  70226. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70227. /**
  70228. * Stores a perspective projection for WebVR info a given matrix
  70229. * @param fov defines the field of view
  70230. * @param znear defines the near clip plane
  70231. * @param zfar defines the far clip plane
  70232. * @param result defines the target matrix
  70233. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  70234. */
  70235. static PerspectiveFovWebVRToRef(fov: {
  70236. upDegrees: number;
  70237. downDegrees: number;
  70238. leftDegrees: number;
  70239. rightDegrees: number;
  70240. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  70241. /**
  70242. * Computes a complete transformation matrix
  70243. * @param viewport defines the viewport to use
  70244. * @param world defines the world matrix
  70245. * @param view defines the view matrix
  70246. * @param projection defines the projection matrix
  70247. * @param zmin defines the near clip plane
  70248. * @param zmax defines the far clip plane
  70249. * @returns the transformation matrix
  70250. */
  70251. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  70252. /**
  70253. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  70254. * @param matrix defines the matrix to use
  70255. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  70256. */
  70257. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  70258. /**
  70259. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  70260. * @param matrix defines the matrix to use
  70261. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  70262. */
  70263. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  70264. /**
  70265. * Compute the transpose of a given matrix
  70266. * @param matrix defines the matrix to transpose
  70267. * @returns the new matrix
  70268. */
  70269. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  70270. /**
  70271. * Compute the transpose of a matrix and store it in a target matrix
  70272. * @param matrix defines the matrix to transpose
  70273. * @param result defines the target matrix
  70274. */
  70275. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  70276. /**
  70277. * Computes a reflection matrix from a plane
  70278. * @param plane defines the reflection plane
  70279. * @returns a new matrix
  70280. */
  70281. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  70282. /**
  70283. * Computes a reflection matrix from a plane
  70284. * @param plane defines the reflection plane
  70285. * @param result defines the target matrix
  70286. */
  70287. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  70288. /**
  70289. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  70290. * @param xaxis defines the value of the 1st axis
  70291. * @param yaxis defines the value of the 2nd axis
  70292. * @param zaxis defines the value of the 3rd axis
  70293. * @param result defines the target matrix
  70294. */
  70295. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  70296. /**
  70297. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  70298. * @param quat defines the quaternion to use
  70299. * @param result defines the target matrix
  70300. */
  70301. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  70302. }
  70303. /**
  70304. * @hidden
  70305. */
  70306. export class TmpVectors {
  70307. static Vector2: Vector2[];
  70308. static Vector3: Vector3[];
  70309. static Vector4: Vector4[];
  70310. static Quaternion: Quaternion[];
  70311. static Matrix: Matrix[];
  70312. }
  70313. }
  70314. declare module BABYLON {
  70315. /**
  70316. * Class used to hold a RBG color
  70317. */
  70318. export class Color3 {
  70319. /**
  70320. * Defines the red component (between 0 and 1, default is 0)
  70321. */
  70322. r: number;
  70323. /**
  70324. * Defines the green component (between 0 and 1, default is 0)
  70325. */
  70326. g: number;
  70327. /**
  70328. * Defines the blue component (between 0 and 1, default is 0)
  70329. */
  70330. b: number;
  70331. /**
  70332. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70333. * @param r defines the red component (between 0 and 1, default is 0)
  70334. * @param g defines the green component (between 0 and 1, default is 0)
  70335. * @param b defines the blue component (between 0 and 1, default is 0)
  70336. */
  70337. constructor(
  70338. /**
  70339. * Defines the red component (between 0 and 1, default is 0)
  70340. */
  70341. r?: number,
  70342. /**
  70343. * Defines the green component (between 0 and 1, default is 0)
  70344. */
  70345. g?: number,
  70346. /**
  70347. * Defines the blue component (between 0 and 1, default is 0)
  70348. */
  70349. b?: number);
  70350. /**
  70351. * Creates a string with the Color3 current values
  70352. * @returns the string representation of the Color3 object
  70353. */
  70354. toString(): string;
  70355. /**
  70356. * Returns the string "Color3"
  70357. * @returns "Color3"
  70358. */
  70359. getClassName(): string;
  70360. /**
  70361. * Compute the Color3 hash code
  70362. * @returns an unique number that can be used to hash Color3 objects
  70363. */
  70364. getHashCode(): number;
  70365. /**
  70366. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70367. * @param array defines the array where to store the r,g,b components
  70368. * @param index defines an optional index in the target array to define where to start storing values
  70369. * @returns the current Color3 object
  70370. */
  70371. toArray(array: FloatArray, index?: number): Color3;
  70372. /**
  70373. * Returns a new Color4 object from the current Color3 and the given alpha
  70374. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70375. * @returns a new Color4 object
  70376. */
  70377. toColor4(alpha?: number): Color4;
  70378. /**
  70379. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70380. * @returns the new array
  70381. */
  70382. asArray(): number[];
  70383. /**
  70384. * Returns the luminance value
  70385. * @returns a float value
  70386. */
  70387. toLuminance(): number;
  70388. /**
  70389. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70390. * @param otherColor defines the second operand
  70391. * @returns the new Color3 object
  70392. */
  70393. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70394. /**
  70395. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70396. * @param otherColor defines the second operand
  70397. * @param result defines the Color3 object where to store the result
  70398. * @returns the current Color3
  70399. */
  70400. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70401. /**
  70402. * Determines equality between Color3 objects
  70403. * @param otherColor defines the second operand
  70404. * @returns true if the rgb values are equal to the given ones
  70405. */
  70406. equals(otherColor: DeepImmutable<Color3>): boolean;
  70407. /**
  70408. * Determines equality between the current Color3 object and a set of r,b,g values
  70409. * @param r defines the red component to check
  70410. * @param g defines the green component to check
  70411. * @param b defines the blue component to check
  70412. * @returns true if the rgb values are equal to the given ones
  70413. */
  70414. equalsFloats(r: number, g: number, b: number): boolean;
  70415. /**
  70416. * Multiplies in place each rgb value by scale
  70417. * @param scale defines the scaling factor
  70418. * @returns the updated Color3
  70419. */
  70420. scale(scale: number): Color3;
  70421. /**
  70422. * Multiplies the rgb values by scale and stores the result into "result"
  70423. * @param scale defines the scaling factor
  70424. * @param result defines the Color3 object where to store the result
  70425. * @returns the unmodified current Color3
  70426. */
  70427. scaleToRef(scale: number, result: Color3): Color3;
  70428. /**
  70429. * Scale the current Color3 values by a factor and add the result to a given Color3
  70430. * @param scale defines the scale factor
  70431. * @param result defines color to store the result into
  70432. * @returns the unmodified current Color3
  70433. */
  70434. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70435. /**
  70436. * Clamps the rgb values by the min and max values and stores the result into "result"
  70437. * @param min defines minimum clamping value (default is 0)
  70438. * @param max defines maximum clamping value (default is 1)
  70439. * @param result defines color to store the result into
  70440. * @returns the original Color3
  70441. */
  70442. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70443. /**
  70444. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70445. * @param otherColor defines the second operand
  70446. * @returns the new Color3
  70447. */
  70448. add(otherColor: DeepImmutable<Color3>): Color3;
  70449. /**
  70450. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70451. * @param otherColor defines the second operand
  70452. * @param result defines Color3 object to store the result into
  70453. * @returns the unmodified current Color3
  70454. */
  70455. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70456. /**
  70457. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70458. * @param otherColor defines the second operand
  70459. * @returns the new Color3
  70460. */
  70461. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70462. /**
  70463. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70464. * @param otherColor defines the second operand
  70465. * @param result defines Color3 object to store the result into
  70466. * @returns the unmodified current Color3
  70467. */
  70468. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70469. /**
  70470. * Copy the current object
  70471. * @returns a new Color3 copied the current one
  70472. */
  70473. clone(): Color3;
  70474. /**
  70475. * Copies the rgb values from the source in the current Color3
  70476. * @param source defines the source Color3 object
  70477. * @returns the updated Color3 object
  70478. */
  70479. copyFrom(source: DeepImmutable<Color3>): Color3;
  70480. /**
  70481. * Updates the Color3 rgb values from the given floats
  70482. * @param r defines the red component to read from
  70483. * @param g defines the green component to read from
  70484. * @param b defines the blue component to read from
  70485. * @returns the current Color3 object
  70486. */
  70487. copyFromFloats(r: number, g: number, b: number): Color3;
  70488. /**
  70489. * Updates the Color3 rgb values from the given floats
  70490. * @param r defines the red component to read from
  70491. * @param g defines the green component to read from
  70492. * @param b defines the blue component to read from
  70493. * @returns the current Color3 object
  70494. */
  70495. set(r: number, g: number, b: number): Color3;
  70496. /**
  70497. * Compute the Color3 hexadecimal code as a string
  70498. * @returns a string containing the hexadecimal representation of the Color3 object
  70499. */
  70500. toHexString(): string;
  70501. /**
  70502. * Computes a new Color3 converted from the current one to linear space
  70503. * @returns a new Color3 object
  70504. */
  70505. toLinearSpace(): Color3;
  70506. /**
  70507. * Converts current color in rgb space to HSV values
  70508. * @returns a new color3 representing the HSV values
  70509. */
  70510. toHSV(): Color3;
  70511. /**
  70512. * Converts current color in rgb space to HSV values
  70513. * @param result defines the Color3 where to store the HSV values
  70514. */
  70515. toHSVToRef(result: Color3): void;
  70516. /**
  70517. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70518. * @param convertedColor defines the Color3 object where to store the linear space version
  70519. * @returns the unmodified Color3
  70520. */
  70521. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70522. /**
  70523. * Computes a new Color3 converted from the current one to gamma space
  70524. * @returns a new Color3 object
  70525. */
  70526. toGammaSpace(): Color3;
  70527. /**
  70528. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70529. * @param convertedColor defines the Color3 object where to store the gamma space version
  70530. * @returns the unmodified Color3
  70531. */
  70532. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70533. private static _BlackReadOnly;
  70534. /**
  70535. * Convert Hue, saturation and value to a Color3 (RGB)
  70536. * @param hue defines the hue
  70537. * @param saturation defines the saturation
  70538. * @param value defines the value
  70539. * @param result defines the Color3 where to store the RGB values
  70540. */
  70541. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70542. /**
  70543. * Creates a new Color3 from the string containing valid hexadecimal values
  70544. * @param hex defines a string containing valid hexadecimal values
  70545. * @returns a new Color3 object
  70546. */
  70547. static FromHexString(hex: string): Color3;
  70548. /**
  70549. * Creates a new Color3 from the starting index of the given array
  70550. * @param array defines the source array
  70551. * @param offset defines an offset in the source array
  70552. * @returns a new Color3 object
  70553. */
  70554. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70555. /**
  70556. * Creates a new Color3 from integer values (< 256)
  70557. * @param r defines the red component to read from (value between 0 and 255)
  70558. * @param g defines the green component to read from (value between 0 and 255)
  70559. * @param b defines the blue component to read from (value between 0 and 255)
  70560. * @returns a new Color3 object
  70561. */
  70562. static FromInts(r: number, g: number, b: number): Color3;
  70563. /**
  70564. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70565. * @param start defines the start Color3 value
  70566. * @param end defines the end Color3 value
  70567. * @param amount defines the gradient value between start and end
  70568. * @returns a new Color3 object
  70569. */
  70570. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70571. /**
  70572. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70573. * @param left defines the start value
  70574. * @param right defines the end value
  70575. * @param amount defines the gradient factor
  70576. * @param result defines the Color3 object where to store the result
  70577. */
  70578. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70579. /**
  70580. * Returns a Color3 value containing a red color
  70581. * @returns a new Color3 object
  70582. */
  70583. static Red(): Color3;
  70584. /**
  70585. * Returns a Color3 value containing a green color
  70586. * @returns a new Color3 object
  70587. */
  70588. static Green(): Color3;
  70589. /**
  70590. * Returns a Color3 value containing a blue color
  70591. * @returns a new Color3 object
  70592. */
  70593. static Blue(): Color3;
  70594. /**
  70595. * Returns a Color3 value containing a black color
  70596. * @returns a new Color3 object
  70597. */
  70598. static Black(): Color3;
  70599. /**
  70600. * Gets a Color3 value containing a black color that must not be updated
  70601. */
  70602. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70603. /**
  70604. * Returns a Color3 value containing a white color
  70605. * @returns a new Color3 object
  70606. */
  70607. static White(): Color3;
  70608. /**
  70609. * Returns a Color3 value containing a purple color
  70610. * @returns a new Color3 object
  70611. */
  70612. static Purple(): Color3;
  70613. /**
  70614. * Returns a Color3 value containing a magenta color
  70615. * @returns a new Color3 object
  70616. */
  70617. static Magenta(): Color3;
  70618. /**
  70619. * Returns a Color3 value containing a yellow color
  70620. * @returns a new Color3 object
  70621. */
  70622. static Yellow(): Color3;
  70623. /**
  70624. * Returns a Color3 value containing a gray color
  70625. * @returns a new Color3 object
  70626. */
  70627. static Gray(): Color3;
  70628. /**
  70629. * Returns a Color3 value containing a teal color
  70630. * @returns a new Color3 object
  70631. */
  70632. static Teal(): Color3;
  70633. /**
  70634. * Returns a Color3 value containing a random color
  70635. * @returns a new Color3 object
  70636. */
  70637. static Random(): Color3;
  70638. }
  70639. /**
  70640. * Class used to hold a RBGA color
  70641. */
  70642. export class Color4 {
  70643. /**
  70644. * Defines the red component (between 0 and 1, default is 0)
  70645. */
  70646. r: number;
  70647. /**
  70648. * Defines the green component (between 0 and 1, default is 0)
  70649. */
  70650. g: number;
  70651. /**
  70652. * Defines the blue component (between 0 and 1, default is 0)
  70653. */
  70654. b: number;
  70655. /**
  70656. * Defines the alpha component (between 0 and 1, default is 1)
  70657. */
  70658. a: number;
  70659. /**
  70660. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70661. * @param r defines the red component (between 0 and 1, default is 0)
  70662. * @param g defines the green component (between 0 and 1, default is 0)
  70663. * @param b defines the blue component (between 0 and 1, default is 0)
  70664. * @param a defines the alpha component (between 0 and 1, default is 1)
  70665. */
  70666. constructor(
  70667. /**
  70668. * Defines the red component (between 0 and 1, default is 0)
  70669. */
  70670. r?: number,
  70671. /**
  70672. * Defines the green component (between 0 and 1, default is 0)
  70673. */
  70674. g?: number,
  70675. /**
  70676. * Defines the blue component (between 0 and 1, default is 0)
  70677. */
  70678. b?: number,
  70679. /**
  70680. * Defines the alpha component (between 0 and 1, default is 1)
  70681. */
  70682. a?: number);
  70683. /**
  70684. * Adds in place the given Color4 values to the current Color4 object
  70685. * @param right defines the second operand
  70686. * @returns the current updated Color4 object
  70687. */
  70688. addInPlace(right: DeepImmutable<Color4>): Color4;
  70689. /**
  70690. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70691. * @returns the new array
  70692. */
  70693. asArray(): number[];
  70694. /**
  70695. * Stores from the starting index in the given array the Color4 successive values
  70696. * @param array defines the array where to store the r,g,b components
  70697. * @param index defines an optional index in the target array to define where to start storing values
  70698. * @returns the current Color4 object
  70699. */
  70700. toArray(array: number[], index?: number): Color4;
  70701. /**
  70702. * Determines equality between Color4 objects
  70703. * @param otherColor defines the second operand
  70704. * @returns true if the rgba values are equal to the given ones
  70705. */
  70706. equals(otherColor: DeepImmutable<Color4>): boolean;
  70707. /**
  70708. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70709. * @param right defines the second operand
  70710. * @returns a new Color4 object
  70711. */
  70712. add(right: DeepImmutable<Color4>): Color4;
  70713. /**
  70714. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70715. * @param right defines the second operand
  70716. * @returns a new Color4 object
  70717. */
  70718. subtract(right: DeepImmutable<Color4>): Color4;
  70719. /**
  70720. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70721. * @param right defines the second operand
  70722. * @param result defines the Color4 object where to store the result
  70723. * @returns the current Color4 object
  70724. */
  70725. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70726. /**
  70727. * Creates a new Color4 with the current Color4 values multiplied by scale
  70728. * @param scale defines the scaling factor to apply
  70729. * @returns a new Color4 object
  70730. */
  70731. scale(scale: number): Color4;
  70732. /**
  70733. * Multiplies the current Color4 values by scale and stores the result in "result"
  70734. * @param scale defines the scaling factor to apply
  70735. * @param result defines the Color4 object where to store the result
  70736. * @returns the current unmodified Color4
  70737. */
  70738. scaleToRef(scale: number, result: Color4): Color4;
  70739. /**
  70740. * Scale the current Color4 values by a factor and add the result to a given Color4
  70741. * @param scale defines the scale factor
  70742. * @param result defines the Color4 object where to store the result
  70743. * @returns the unmodified current Color4
  70744. */
  70745. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70746. /**
  70747. * Clamps the rgb values by the min and max values and stores the result into "result"
  70748. * @param min defines minimum clamping value (default is 0)
  70749. * @param max defines maximum clamping value (default is 1)
  70750. * @param result defines color to store the result into.
  70751. * @returns the cuurent Color4
  70752. */
  70753. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70754. /**
  70755. * Multipy an Color4 value by another and return a new Color4 object
  70756. * @param color defines the Color4 value to multiply by
  70757. * @returns a new Color4 object
  70758. */
  70759. multiply(color: Color4): Color4;
  70760. /**
  70761. * Multipy a Color4 value by another and push the result in a reference value
  70762. * @param color defines the Color4 value to multiply by
  70763. * @param result defines the Color4 to fill the result in
  70764. * @returns the result Color4
  70765. */
  70766. multiplyToRef(color: Color4, result: Color4): Color4;
  70767. /**
  70768. * Creates a string with the Color4 current values
  70769. * @returns the string representation of the Color4 object
  70770. */
  70771. toString(): string;
  70772. /**
  70773. * Returns the string "Color4"
  70774. * @returns "Color4"
  70775. */
  70776. getClassName(): string;
  70777. /**
  70778. * Compute the Color4 hash code
  70779. * @returns an unique number that can be used to hash Color4 objects
  70780. */
  70781. getHashCode(): number;
  70782. /**
  70783. * Creates a new Color4 copied from the current one
  70784. * @returns a new Color4 object
  70785. */
  70786. clone(): Color4;
  70787. /**
  70788. * Copies the given Color4 values into the current one
  70789. * @param source defines the source Color4 object
  70790. * @returns the current updated Color4 object
  70791. */
  70792. copyFrom(source: Color4): Color4;
  70793. /**
  70794. * Copies the given float values into the current one
  70795. * @param r defines the red component to read from
  70796. * @param g defines the green component to read from
  70797. * @param b defines the blue component to read from
  70798. * @param a defines the alpha component to read from
  70799. * @returns the current updated Color4 object
  70800. */
  70801. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70802. /**
  70803. * Copies the given float values into the current one
  70804. * @param r defines the red component to read from
  70805. * @param g defines the green component to read from
  70806. * @param b defines the blue component to read from
  70807. * @param a defines the alpha component to read from
  70808. * @returns the current updated Color4 object
  70809. */
  70810. set(r: number, g: number, b: number, a: number): Color4;
  70811. /**
  70812. * Compute the Color4 hexadecimal code as a string
  70813. * @returns a string containing the hexadecimal representation of the Color4 object
  70814. */
  70815. toHexString(): string;
  70816. /**
  70817. * Computes a new Color4 converted from the current one to linear space
  70818. * @returns a new Color4 object
  70819. */
  70820. toLinearSpace(): Color4;
  70821. /**
  70822. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70823. * @param convertedColor defines the Color4 object where to store the linear space version
  70824. * @returns the unmodified Color4
  70825. */
  70826. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70827. /**
  70828. * Computes a new Color4 converted from the current one to gamma space
  70829. * @returns a new Color4 object
  70830. */
  70831. toGammaSpace(): Color4;
  70832. /**
  70833. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70834. * @param convertedColor defines the Color4 object where to store the gamma space version
  70835. * @returns the unmodified Color4
  70836. */
  70837. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70838. /**
  70839. * Creates a new Color4 from the string containing valid hexadecimal values
  70840. * @param hex defines a string containing valid hexadecimal values
  70841. * @returns a new Color4 object
  70842. */
  70843. static FromHexString(hex: string): Color4;
  70844. /**
  70845. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70846. * @param left defines the start value
  70847. * @param right defines the end value
  70848. * @param amount defines the gradient factor
  70849. * @returns a new Color4 object
  70850. */
  70851. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70852. /**
  70853. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70854. * @param left defines the start value
  70855. * @param right defines the end value
  70856. * @param amount defines the gradient factor
  70857. * @param result defines the Color4 object where to store data
  70858. */
  70859. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70860. /**
  70861. * Creates a new Color4 from a Color3 and an alpha value
  70862. * @param color3 defines the source Color3 to read from
  70863. * @param alpha defines the alpha component (1.0 by default)
  70864. * @returns a new Color4 object
  70865. */
  70866. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70867. /**
  70868. * Creates a new Color4 from the starting index element of the given array
  70869. * @param array defines the source array to read from
  70870. * @param offset defines the offset in the source array
  70871. * @returns a new Color4 object
  70872. */
  70873. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70874. /**
  70875. * Creates a new Color3 from integer values (< 256)
  70876. * @param r defines the red component to read from (value between 0 and 255)
  70877. * @param g defines the green component to read from (value between 0 and 255)
  70878. * @param b defines the blue component to read from (value between 0 and 255)
  70879. * @param a defines the alpha component to read from (value between 0 and 255)
  70880. * @returns a new Color3 object
  70881. */
  70882. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70883. /**
  70884. * Check the content of a given array and convert it to an array containing RGBA data
  70885. * If the original array was already containing count * 4 values then it is returned directly
  70886. * @param colors defines the array to check
  70887. * @param count defines the number of RGBA data to expect
  70888. * @returns an array containing count * 4 values (RGBA)
  70889. */
  70890. static CheckColors4(colors: number[], count: number): number[];
  70891. }
  70892. /**
  70893. * @hidden
  70894. */
  70895. export class TmpColors {
  70896. static Color3: Color3[];
  70897. static Color4: Color4[];
  70898. }
  70899. }
  70900. declare module BABYLON {
  70901. /**
  70902. * Class representing spherical harmonics coefficients to the 3rd degree
  70903. */
  70904. export class SphericalHarmonics {
  70905. /**
  70906. * Defines whether or not the harmonics have been prescaled for rendering.
  70907. */
  70908. preScaled: boolean;
  70909. /**
  70910. * The l0,0 coefficients of the spherical harmonics
  70911. */
  70912. l00: Vector3;
  70913. /**
  70914. * The l1,-1 coefficients of the spherical harmonics
  70915. */
  70916. l1_1: Vector3;
  70917. /**
  70918. * The l1,0 coefficients of the spherical harmonics
  70919. */
  70920. l10: Vector3;
  70921. /**
  70922. * The l1,1 coefficients of the spherical harmonics
  70923. */
  70924. l11: Vector3;
  70925. /**
  70926. * The l2,-2 coefficients of the spherical harmonics
  70927. */
  70928. l2_2: Vector3;
  70929. /**
  70930. * The l2,-1 coefficients of the spherical harmonics
  70931. */
  70932. l2_1: Vector3;
  70933. /**
  70934. * The l2,0 coefficients of the spherical harmonics
  70935. */
  70936. l20: Vector3;
  70937. /**
  70938. * The l2,1 coefficients of the spherical harmonics
  70939. */
  70940. l21: Vector3;
  70941. /**
  70942. * The l2,2 coefficients of the spherical harmonics
  70943. */
  70944. l22: Vector3;
  70945. /**
  70946. * Adds a light to the spherical harmonics
  70947. * @param direction the direction of the light
  70948. * @param color the color of the light
  70949. * @param deltaSolidAngle the delta solid angle of the light
  70950. */
  70951. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70952. /**
  70953. * Scales the spherical harmonics by the given amount
  70954. * @param scale the amount to scale
  70955. */
  70956. scaleInPlace(scale: number): void;
  70957. /**
  70958. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70959. *
  70960. * ```
  70961. * E_lm = A_l * L_lm
  70962. * ```
  70963. *
  70964. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70965. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70966. * the scaling factors are given in equation 9.
  70967. */
  70968. convertIncidentRadianceToIrradiance(): void;
  70969. /**
  70970. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70971. *
  70972. * ```
  70973. * L = (1/pi) * E * rho
  70974. * ```
  70975. *
  70976. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70977. */
  70978. convertIrradianceToLambertianRadiance(): void;
  70979. /**
  70980. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70981. * required operations at run time.
  70982. *
  70983. * This is simply done by scaling back the SH with Ylm constants parameter.
  70984. * The trigonometric part being applied by the shader at run time.
  70985. */
  70986. preScaleForRendering(): void;
  70987. /**
  70988. * Constructs a spherical harmonics from an array.
  70989. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70990. * @returns the spherical harmonics
  70991. */
  70992. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70993. /**
  70994. * Gets the spherical harmonics from polynomial
  70995. * @param polynomial the spherical polynomial
  70996. * @returns the spherical harmonics
  70997. */
  70998. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70999. }
  71000. /**
  71001. * Class representing spherical polynomial coefficients to the 3rd degree
  71002. */
  71003. export class SphericalPolynomial {
  71004. private _harmonics;
  71005. /**
  71006. * The spherical harmonics used to create the polynomials.
  71007. */
  71008. readonly preScaledHarmonics: SphericalHarmonics;
  71009. /**
  71010. * The x coefficients of the spherical polynomial
  71011. */
  71012. x: Vector3;
  71013. /**
  71014. * The y coefficients of the spherical polynomial
  71015. */
  71016. y: Vector3;
  71017. /**
  71018. * The z coefficients of the spherical polynomial
  71019. */
  71020. z: Vector3;
  71021. /**
  71022. * The xx coefficients of the spherical polynomial
  71023. */
  71024. xx: Vector3;
  71025. /**
  71026. * The yy coefficients of the spherical polynomial
  71027. */
  71028. yy: Vector3;
  71029. /**
  71030. * The zz coefficients of the spherical polynomial
  71031. */
  71032. zz: Vector3;
  71033. /**
  71034. * The xy coefficients of the spherical polynomial
  71035. */
  71036. xy: Vector3;
  71037. /**
  71038. * The yz coefficients of the spherical polynomial
  71039. */
  71040. yz: Vector3;
  71041. /**
  71042. * The zx coefficients of the spherical polynomial
  71043. */
  71044. zx: Vector3;
  71045. /**
  71046. * Adds an ambient color to the spherical polynomial
  71047. * @param color the color to add
  71048. */
  71049. addAmbient(color: Color3): void;
  71050. /**
  71051. * Scales the spherical polynomial by the given amount
  71052. * @param scale the amount to scale
  71053. */
  71054. scaleInPlace(scale: number): void;
  71055. /**
  71056. * Gets the spherical polynomial from harmonics
  71057. * @param harmonics the spherical harmonics
  71058. * @returns the spherical polynomial
  71059. */
  71060. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71061. /**
  71062. * Constructs a spherical polynomial from an array.
  71063. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71064. * @returns the spherical polynomial
  71065. */
  71066. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71067. }
  71068. }
  71069. declare module BABYLON {
  71070. /**
  71071. * Define options used to create a render target texture
  71072. */
  71073. export class RenderTargetCreationOptions {
  71074. /**
  71075. * Specifies is mipmaps must be generated
  71076. */
  71077. generateMipMaps?: boolean;
  71078. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71079. generateDepthBuffer?: boolean;
  71080. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71081. generateStencilBuffer?: boolean;
  71082. /** Defines texture type (int by default) */
  71083. type?: number;
  71084. /** Defines sampling mode (trilinear by default) */
  71085. samplingMode?: number;
  71086. /** Defines format (RGBA by default) */
  71087. format?: number;
  71088. }
  71089. }
  71090. declare module BABYLON {
  71091. /**
  71092. * @hidden
  71093. **/
  71094. export class _TimeToken {
  71095. _startTimeQuery: Nullable<WebGLQuery>;
  71096. _endTimeQuery: Nullable<WebGLQuery>;
  71097. _timeElapsedQuery: Nullable<WebGLQuery>;
  71098. _timeElapsedQueryEnded: boolean;
  71099. }
  71100. }
  71101. declare module BABYLON {
  71102. /** Defines the cross module used constants to avoid circular dependncies */
  71103. export class Constants {
  71104. /** Defines that alpha blending is disabled */
  71105. static readonly ALPHA_DISABLE: number;
  71106. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  71107. static readonly ALPHA_ADD: number;
  71108. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71109. static readonly ALPHA_COMBINE: number;
  71110. /** Defines that alpha blending to DEST - SRC * DEST */
  71111. static readonly ALPHA_SUBTRACT: number;
  71112. /** Defines that alpha blending to SRC * DEST */
  71113. static readonly ALPHA_MULTIPLY: number;
  71114. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  71115. static readonly ALPHA_MAXIMIZED: number;
  71116. /** Defines that alpha blending to SRC + DEST */
  71117. static readonly ALPHA_ONEONE: number;
  71118. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  71119. static readonly ALPHA_PREMULTIPLIED: number;
  71120. /**
  71121. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  71122. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71123. */
  71124. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71125. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  71126. static readonly ALPHA_INTERPOLATE: number;
  71127. /**
  71128. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  71129. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71130. */
  71131. static readonly ALPHA_SCREENMODE: number;
  71132. /**
  71133. * Defines that alpha blending to SRC + DST
  71134. * Alpha will be set to SRC ALPHA + DST ALPHA
  71135. */
  71136. static readonly ALPHA_ONEONE_ONEONE: number;
  71137. /**
  71138. * Defines that alpha blending to SRC * DST ALPHA + DST
  71139. * Alpha will be set to 0
  71140. */
  71141. static readonly ALPHA_ALPHATOCOLOR: number;
  71142. /**
  71143. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  71144. */
  71145. static readonly ALPHA_REVERSEONEMINUS: number;
  71146. /**
  71147. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  71148. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71149. */
  71150. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71151. /**
  71152. * Defines that alpha blending to SRC + DST
  71153. * Alpha will be set to SRC ALPHA
  71154. */
  71155. static readonly ALPHA_ONEONE_ONEZERO: number;
  71156. /** Defines that alpha blending equation a SUM */
  71157. static readonly ALPHA_EQUATION_ADD: number;
  71158. /** Defines that alpha blending equation a SUBSTRACTION */
  71159. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71160. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71161. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71162. /** Defines that alpha blending equation a MAX operation */
  71163. static readonly ALPHA_EQUATION_MAX: number;
  71164. /** Defines that alpha blending equation a MIN operation */
  71165. static readonly ALPHA_EQUATION_MIN: number;
  71166. /**
  71167. * Defines that alpha blending equation a DARKEN operation:
  71168. * It takes the min of the src and sums the alpha channels.
  71169. */
  71170. static readonly ALPHA_EQUATION_DARKEN: number;
  71171. /** Defines that the ressource is not delayed*/
  71172. static readonly DELAYLOADSTATE_NONE: number;
  71173. /** Defines that the ressource was successfully delay loaded */
  71174. static readonly DELAYLOADSTATE_LOADED: number;
  71175. /** Defines that the ressource is currently delay loading */
  71176. static readonly DELAYLOADSTATE_LOADING: number;
  71177. /** Defines that the ressource is delayed and has not started loading */
  71178. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71179. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71180. static readonly NEVER: number;
  71181. /** 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 */
  71182. static readonly ALWAYS: number;
  71183. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71184. static readonly LESS: number;
  71185. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71186. static readonly EQUAL: number;
  71187. /** 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 */
  71188. static readonly LEQUAL: number;
  71189. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71190. static readonly GREATER: number;
  71191. /** 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 */
  71192. static readonly GEQUAL: number;
  71193. /** 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 */
  71194. static readonly NOTEQUAL: number;
  71195. /** Passed to stencilOperation to specify that stencil value must be kept */
  71196. static readonly KEEP: number;
  71197. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71198. static readonly REPLACE: number;
  71199. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71200. static readonly INCR: number;
  71201. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71202. static readonly DECR: number;
  71203. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71204. static readonly INVERT: number;
  71205. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71206. static readonly INCR_WRAP: number;
  71207. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71208. static readonly DECR_WRAP: number;
  71209. /** Texture is not repeating outside of 0..1 UVs */
  71210. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71211. /** Texture is repeating outside of 0..1 UVs */
  71212. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71213. /** Texture is repeating and mirrored */
  71214. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71215. /** ALPHA */
  71216. static readonly TEXTUREFORMAT_ALPHA: number;
  71217. /** LUMINANCE */
  71218. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71219. /** LUMINANCE_ALPHA */
  71220. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71221. /** RGB */
  71222. static readonly TEXTUREFORMAT_RGB: number;
  71223. /** RGBA */
  71224. static readonly TEXTUREFORMAT_RGBA: number;
  71225. /** RED */
  71226. static readonly TEXTUREFORMAT_RED: number;
  71227. /** RED (2nd reference) */
  71228. static readonly TEXTUREFORMAT_R: number;
  71229. /** RG */
  71230. static readonly TEXTUREFORMAT_RG: number;
  71231. /** RED_INTEGER */
  71232. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71233. /** RED_INTEGER (2nd reference) */
  71234. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71235. /** RG_INTEGER */
  71236. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71237. /** RGB_INTEGER */
  71238. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71239. /** RGBA_INTEGER */
  71240. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71241. /** UNSIGNED_BYTE */
  71242. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71243. /** UNSIGNED_BYTE (2nd reference) */
  71244. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71245. /** FLOAT */
  71246. static readonly TEXTURETYPE_FLOAT: number;
  71247. /** HALF_FLOAT */
  71248. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71249. /** BYTE */
  71250. static readonly TEXTURETYPE_BYTE: number;
  71251. /** SHORT */
  71252. static readonly TEXTURETYPE_SHORT: number;
  71253. /** UNSIGNED_SHORT */
  71254. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71255. /** INT */
  71256. static readonly TEXTURETYPE_INT: number;
  71257. /** UNSIGNED_INT */
  71258. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71259. /** UNSIGNED_SHORT_4_4_4_4 */
  71260. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71261. /** UNSIGNED_SHORT_5_5_5_1 */
  71262. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71263. /** UNSIGNED_SHORT_5_6_5 */
  71264. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71265. /** UNSIGNED_INT_2_10_10_10_REV */
  71266. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71267. /** UNSIGNED_INT_24_8 */
  71268. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71269. /** UNSIGNED_INT_10F_11F_11F_REV */
  71270. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71271. /** UNSIGNED_INT_5_9_9_9_REV */
  71272. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71273. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71274. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71275. /** nearest is mag = nearest and min = nearest and mip = linear */
  71276. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71277. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71278. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71279. /** Trilinear is mag = linear and min = linear and mip = linear */
  71280. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71281. /** nearest is mag = nearest and min = nearest and mip = linear */
  71282. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71283. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71284. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71285. /** Trilinear is mag = linear and min = linear and mip = linear */
  71286. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71287. /** mag = nearest and min = nearest and mip = nearest */
  71288. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71289. /** mag = nearest and min = linear and mip = nearest */
  71290. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71291. /** mag = nearest and min = linear and mip = linear */
  71292. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71293. /** mag = nearest and min = linear and mip = none */
  71294. static readonly TEXTURE_NEAREST_LINEAR: number;
  71295. /** mag = nearest and min = nearest and mip = none */
  71296. static readonly TEXTURE_NEAREST_NEAREST: number;
  71297. /** mag = linear and min = nearest and mip = nearest */
  71298. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71299. /** mag = linear and min = nearest and mip = linear */
  71300. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71301. /** mag = linear and min = linear and mip = none */
  71302. static readonly TEXTURE_LINEAR_LINEAR: number;
  71303. /** mag = linear and min = nearest and mip = none */
  71304. static readonly TEXTURE_LINEAR_NEAREST: number;
  71305. /** Explicit coordinates mode */
  71306. static readonly TEXTURE_EXPLICIT_MODE: number;
  71307. /** Spherical coordinates mode */
  71308. static readonly TEXTURE_SPHERICAL_MODE: number;
  71309. /** Planar coordinates mode */
  71310. static readonly TEXTURE_PLANAR_MODE: number;
  71311. /** Cubic coordinates mode */
  71312. static readonly TEXTURE_CUBIC_MODE: number;
  71313. /** Projection coordinates mode */
  71314. static readonly TEXTURE_PROJECTION_MODE: number;
  71315. /** Skybox coordinates mode */
  71316. static readonly TEXTURE_SKYBOX_MODE: number;
  71317. /** Inverse Cubic coordinates mode */
  71318. static readonly TEXTURE_INVCUBIC_MODE: number;
  71319. /** Equirectangular coordinates mode */
  71320. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71321. /** Equirectangular Fixed coordinates mode */
  71322. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71323. /** Equirectangular Fixed Mirrored coordinates mode */
  71324. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71325. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71326. static readonly SCALEMODE_FLOOR: number;
  71327. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71328. static readonly SCALEMODE_NEAREST: number;
  71329. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71330. static readonly SCALEMODE_CEILING: number;
  71331. /**
  71332. * The dirty texture flag value
  71333. */
  71334. static readonly MATERIAL_TextureDirtyFlag: number;
  71335. /**
  71336. * The dirty light flag value
  71337. */
  71338. static readonly MATERIAL_LightDirtyFlag: number;
  71339. /**
  71340. * The dirty fresnel flag value
  71341. */
  71342. static readonly MATERIAL_FresnelDirtyFlag: number;
  71343. /**
  71344. * The dirty attribute flag value
  71345. */
  71346. static readonly MATERIAL_AttributesDirtyFlag: number;
  71347. /**
  71348. * The dirty misc flag value
  71349. */
  71350. static readonly MATERIAL_MiscDirtyFlag: number;
  71351. /**
  71352. * The all dirty flag value
  71353. */
  71354. static readonly MATERIAL_AllDirtyFlag: number;
  71355. /**
  71356. * Returns the triangle fill mode
  71357. */
  71358. static readonly MATERIAL_TriangleFillMode: number;
  71359. /**
  71360. * Returns the wireframe mode
  71361. */
  71362. static readonly MATERIAL_WireFrameFillMode: number;
  71363. /**
  71364. * Returns the point fill mode
  71365. */
  71366. static readonly MATERIAL_PointFillMode: number;
  71367. /**
  71368. * Returns the point list draw mode
  71369. */
  71370. static readonly MATERIAL_PointListDrawMode: number;
  71371. /**
  71372. * Returns the line list draw mode
  71373. */
  71374. static readonly MATERIAL_LineListDrawMode: number;
  71375. /**
  71376. * Returns the line loop draw mode
  71377. */
  71378. static readonly MATERIAL_LineLoopDrawMode: number;
  71379. /**
  71380. * Returns the line strip draw mode
  71381. */
  71382. static readonly MATERIAL_LineStripDrawMode: number;
  71383. /**
  71384. * Returns the triangle strip draw mode
  71385. */
  71386. static readonly MATERIAL_TriangleStripDrawMode: number;
  71387. /**
  71388. * Returns the triangle fan draw mode
  71389. */
  71390. static readonly MATERIAL_TriangleFanDrawMode: number;
  71391. /**
  71392. * Stores the clock-wise side orientation
  71393. */
  71394. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71395. /**
  71396. * Stores the counter clock-wise side orientation
  71397. */
  71398. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71399. /**
  71400. * Nothing
  71401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71402. */
  71403. static readonly ACTION_NothingTrigger: number;
  71404. /**
  71405. * On pick
  71406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71407. */
  71408. static readonly ACTION_OnPickTrigger: number;
  71409. /**
  71410. * On left pick
  71411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71412. */
  71413. static readonly ACTION_OnLeftPickTrigger: number;
  71414. /**
  71415. * On right pick
  71416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71417. */
  71418. static readonly ACTION_OnRightPickTrigger: number;
  71419. /**
  71420. * On center pick
  71421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71422. */
  71423. static readonly ACTION_OnCenterPickTrigger: number;
  71424. /**
  71425. * On pick down
  71426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71427. */
  71428. static readonly ACTION_OnPickDownTrigger: number;
  71429. /**
  71430. * On double pick
  71431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71432. */
  71433. static readonly ACTION_OnDoublePickTrigger: number;
  71434. /**
  71435. * On pick up
  71436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71437. */
  71438. static readonly ACTION_OnPickUpTrigger: number;
  71439. /**
  71440. * On pick out.
  71441. * This trigger will only be raised if you also declared a OnPickDown
  71442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71443. */
  71444. static readonly ACTION_OnPickOutTrigger: number;
  71445. /**
  71446. * On long press
  71447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71448. */
  71449. static readonly ACTION_OnLongPressTrigger: number;
  71450. /**
  71451. * On pointer over
  71452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71453. */
  71454. static readonly ACTION_OnPointerOverTrigger: number;
  71455. /**
  71456. * On pointer out
  71457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71458. */
  71459. static readonly ACTION_OnPointerOutTrigger: number;
  71460. /**
  71461. * On every frame
  71462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71463. */
  71464. static readonly ACTION_OnEveryFrameTrigger: number;
  71465. /**
  71466. * On intersection enter
  71467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71468. */
  71469. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71470. /**
  71471. * On intersection exit
  71472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71473. */
  71474. static readonly ACTION_OnIntersectionExitTrigger: number;
  71475. /**
  71476. * On key down
  71477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71478. */
  71479. static readonly ACTION_OnKeyDownTrigger: number;
  71480. /**
  71481. * On key up
  71482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71483. */
  71484. static readonly ACTION_OnKeyUpTrigger: number;
  71485. /**
  71486. * Billboard mode will only apply to Y axis
  71487. */
  71488. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71489. /**
  71490. * Billboard mode will apply to all axes
  71491. */
  71492. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71493. /**
  71494. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71495. */
  71496. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71497. /**
  71498. * Gets or sets base Assets URL
  71499. */
  71500. static PARTICLES_BaseAssetsUrl: string;
  71501. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71502. * Test order :
  71503. * Is the bounding sphere outside the frustum ?
  71504. * If not, are the bounding box vertices outside the frustum ?
  71505. * It not, then the cullable object is in the frustum.
  71506. */
  71507. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71508. /** Culling strategy : Bounding Sphere Only.
  71509. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71510. * It's also less accurate than the standard because some not visible objects can still be selected.
  71511. * Test : is the bounding sphere outside the frustum ?
  71512. * If not, then the cullable object is in the frustum.
  71513. */
  71514. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71515. /** Culling strategy : Optimistic Inclusion.
  71516. * This in an inclusion test first, then the standard exclusion test.
  71517. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71518. * 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.
  71519. * Anyway, it's as accurate as the standard strategy.
  71520. * Test :
  71521. * Is the cullable object bounding sphere center in the frustum ?
  71522. * If not, apply the default culling strategy.
  71523. */
  71524. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71525. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71526. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71527. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71528. * 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.
  71529. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71530. * Test :
  71531. * Is the cullable object bounding sphere center in the frustum ?
  71532. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71533. */
  71534. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71535. /**
  71536. * No logging while loading
  71537. */
  71538. static readonly SCENELOADER_NO_LOGGING: number;
  71539. /**
  71540. * Minimal logging while loading
  71541. */
  71542. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71543. /**
  71544. * Summary logging while loading
  71545. */
  71546. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71547. /**
  71548. * Detailled logging while loading
  71549. */
  71550. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71551. }
  71552. }
  71553. declare module BABYLON {
  71554. /**
  71555. * This represents the required contract to create a new type of texture loader.
  71556. */
  71557. export interface IInternalTextureLoader {
  71558. /**
  71559. * Defines wether the loader supports cascade loading the different faces.
  71560. */
  71561. supportCascades: boolean;
  71562. /**
  71563. * This returns if the loader support the current file information.
  71564. * @param extension defines the file extension of the file being loaded
  71565. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71566. * @param fallback defines the fallback internal texture if any
  71567. * @param isBase64 defines whether the texture is encoded as a base64
  71568. * @param isBuffer defines whether the texture data are stored as a buffer
  71569. * @returns true if the loader can load the specified file
  71570. */
  71571. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71572. /**
  71573. * Transform the url before loading if required.
  71574. * @param rootUrl the url of the texture
  71575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71576. * @returns the transformed texture
  71577. */
  71578. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71579. /**
  71580. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71581. * @param rootUrl the url of the texture
  71582. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71583. * @returns the fallback texture
  71584. */
  71585. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71586. /**
  71587. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71588. * @param data contains the texture data
  71589. * @param texture defines the BabylonJS internal texture
  71590. * @param createPolynomials will be true if polynomials have been requested
  71591. * @param onLoad defines the callback to trigger once the texture is ready
  71592. * @param onError defines the callback to trigger in case of error
  71593. */
  71594. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71595. /**
  71596. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71597. * @param data contains the texture data
  71598. * @param texture defines the BabylonJS internal texture
  71599. * @param callback defines the method to call once ready to upload
  71600. */
  71601. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71602. }
  71603. }
  71604. declare module BABYLON {
  71605. /**
  71606. * Class used to store and describe the pipeline context associated with an effect
  71607. */
  71608. export interface IPipelineContext {
  71609. /**
  71610. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71611. */
  71612. isAsync: boolean;
  71613. /**
  71614. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71615. */
  71616. isReady: boolean;
  71617. /** @hidden */
  71618. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71619. }
  71620. }
  71621. declare module BABYLON {
  71622. /**
  71623. * Class used to store gfx data (like WebGLBuffer)
  71624. */
  71625. export class DataBuffer {
  71626. /**
  71627. * Gets or sets the number of objects referencing this buffer
  71628. */
  71629. references: number;
  71630. /** Gets or sets the size of the underlying buffer */
  71631. capacity: number;
  71632. /**
  71633. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71634. */
  71635. is32Bits: boolean;
  71636. /**
  71637. * Gets the underlying buffer
  71638. */
  71639. readonly underlyingResource: any;
  71640. }
  71641. }
  71642. declare module BABYLON {
  71643. /** @hidden */
  71644. export interface IShaderProcessor {
  71645. attributeProcessor?: (attribute: string) => string;
  71646. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71647. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71648. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71649. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71650. lineProcessor?: (line: string, isFragment: boolean) => string;
  71651. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71652. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71653. }
  71654. }
  71655. declare module BABYLON {
  71656. /** @hidden */
  71657. export interface ProcessingOptions {
  71658. defines: string[];
  71659. indexParameters: any;
  71660. isFragment: boolean;
  71661. shouldUseHighPrecisionShader: boolean;
  71662. supportsUniformBuffers: boolean;
  71663. shadersRepository: string;
  71664. includesShadersStore: {
  71665. [key: string]: string;
  71666. };
  71667. processor?: IShaderProcessor;
  71668. version: string;
  71669. platformName: string;
  71670. lookForClosingBracketForUniformBuffer?: boolean;
  71671. }
  71672. }
  71673. declare module BABYLON {
  71674. /**
  71675. * Helper to manipulate strings
  71676. */
  71677. export class StringTools {
  71678. /**
  71679. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71680. * @param str Source string
  71681. * @param suffix Suffix to search for in the source string
  71682. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71683. */
  71684. static EndsWith(str: string, suffix: string): boolean;
  71685. /**
  71686. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71687. * @param str Source string
  71688. * @param suffix Suffix to search for in the source string
  71689. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71690. */
  71691. static StartsWith(str: string, suffix: string): boolean;
  71692. }
  71693. }
  71694. declare module BABYLON {
  71695. /** @hidden */
  71696. export class ShaderCodeNode {
  71697. line: string;
  71698. children: ShaderCodeNode[];
  71699. additionalDefineKey?: string;
  71700. additionalDefineValue?: string;
  71701. isValid(preprocessors: {
  71702. [key: string]: string;
  71703. }): boolean;
  71704. process(preprocessors: {
  71705. [key: string]: string;
  71706. }, options: ProcessingOptions): string;
  71707. }
  71708. }
  71709. declare module BABYLON {
  71710. /** @hidden */
  71711. export class ShaderCodeCursor {
  71712. private _lines;
  71713. lineIndex: number;
  71714. readonly currentLine: string;
  71715. readonly canRead: boolean;
  71716. lines: string[];
  71717. }
  71718. }
  71719. declare module BABYLON {
  71720. /** @hidden */
  71721. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71722. process(preprocessors: {
  71723. [key: string]: string;
  71724. }, options: ProcessingOptions): string;
  71725. }
  71726. }
  71727. declare module BABYLON {
  71728. /** @hidden */
  71729. export class ShaderDefineExpression {
  71730. isTrue(preprocessors: {
  71731. [key: string]: string;
  71732. }): boolean;
  71733. }
  71734. }
  71735. declare module BABYLON {
  71736. /** @hidden */
  71737. export class ShaderCodeTestNode extends ShaderCodeNode {
  71738. testExpression: ShaderDefineExpression;
  71739. isValid(preprocessors: {
  71740. [key: string]: string;
  71741. }): boolean;
  71742. }
  71743. }
  71744. declare module BABYLON {
  71745. /** @hidden */
  71746. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71747. define: string;
  71748. not: boolean;
  71749. constructor(define: string, not?: boolean);
  71750. isTrue(preprocessors: {
  71751. [key: string]: string;
  71752. }): boolean;
  71753. }
  71754. }
  71755. declare module BABYLON {
  71756. /** @hidden */
  71757. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71758. leftOperand: ShaderDefineExpression;
  71759. rightOperand: ShaderDefineExpression;
  71760. isTrue(preprocessors: {
  71761. [key: string]: string;
  71762. }): boolean;
  71763. }
  71764. }
  71765. declare module BABYLON {
  71766. /** @hidden */
  71767. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71768. leftOperand: ShaderDefineExpression;
  71769. rightOperand: ShaderDefineExpression;
  71770. isTrue(preprocessors: {
  71771. [key: string]: string;
  71772. }): boolean;
  71773. }
  71774. }
  71775. declare module BABYLON {
  71776. /** @hidden */
  71777. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71778. define: string;
  71779. operand: string;
  71780. testValue: string;
  71781. constructor(define: string, operand: string, testValue: string);
  71782. isTrue(preprocessors: {
  71783. [key: string]: string;
  71784. }): boolean;
  71785. }
  71786. }
  71787. declare module BABYLON {
  71788. /**
  71789. * @ignore
  71790. * Application error to support additional information when loading a file
  71791. */
  71792. export class LoadFileError extends Error {
  71793. /** defines the optional web request */
  71794. request?: WebRequest | undefined;
  71795. private static _setPrototypeOf;
  71796. /**
  71797. * Creates a new LoadFileError
  71798. * @param message defines the message of the error
  71799. * @param request defines the optional web request
  71800. */
  71801. constructor(message: string,
  71802. /** defines the optional web request */
  71803. request?: WebRequest | undefined);
  71804. }
  71805. }
  71806. declare module BABYLON {
  71807. /**
  71808. * Class used to enable access to offline support
  71809. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71810. */
  71811. export interface IOfflineProvider {
  71812. /**
  71813. * Gets a boolean indicating if scene must be saved in the database
  71814. */
  71815. enableSceneOffline: boolean;
  71816. /**
  71817. * Gets a boolean indicating if textures must be saved in the database
  71818. */
  71819. enableTexturesOffline: boolean;
  71820. /**
  71821. * Open the offline support and make it available
  71822. * @param successCallback defines the callback to call on success
  71823. * @param errorCallback defines the callback to call on error
  71824. */
  71825. open(successCallback: () => void, errorCallback: () => void): void;
  71826. /**
  71827. * Loads an image from the offline support
  71828. * @param url defines the url to load from
  71829. * @param image defines the target DOM image
  71830. */
  71831. loadImage(url: string, image: HTMLImageElement): void;
  71832. /**
  71833. * Loads a file from offline support
  71834. * @param url defines the URL to load from
  71835. * @param sceneLoaded defines a callback to call on success
  71836. * @param progressCallBack defines a callback to call when progress changed
  71837. * @param errorCallback defines a callback to call on error
  71838. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71839. */
  71840. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71841. }
  71842. }
  71843. declare module BABYLON {
  71844. /**
  71845. * Class used to help managing file picking and drag'n'drop
  71846. * File Storage
  71847. */
  71848. export class FilesInputStore {
  71849. /**
  71850. * List of files ready to be loaded
  71851. */
  71852. static FilesToLoad: {
  71853. [key: string]: File;
  71854. };
  71855. }
  71856. }
  71857. declare module BABYLON {
  71858. /**
  71859. * Class used to define a retry strategy when error happens while loading assets
  71860. */
  71861. export class RetryStrategy {
  71862. /**
  71863. * Function used to defines an exponential back off strategy
  71864. * @param maxRetries defines the maximum number of retries (3 by default)
  71865. * @param baseInterval defines the interval between retries
  71866. * @returns the strategy function to use
  71867. */
  71868. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71869. }
  71870. }
  71871. declare module BABYLON {
  71872. /**
  71873. * @hidden
  71874. */
  71875. export class FileTools {
  71876. /**
  71877. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71878. */
  71879. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71880. /**
  71881. * Gets or sets the base URL to use to load assets
  71882. */
  71883. static BaseUrl: string;
  71884. /**
  71885. * Default behaviour for cors in the application.
  71886. * It can be a string if the expected behavior is identical in the entire app.
  71887. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71888. */
  71889. static CorsBehavior: string | ((url: string | string[]) => string);
  71890. /**
  71891. * Gets or sets a function used to pre-process url before using them to load assets
  71892. */
  71893. static PreprocessUrl: (url: string) => string;
  71894. /**
  71895. * Removes unwanted characters from an url
  71896. * @param url defines the url to clean
  71897. * @returns the cleaned url
  71898. */
  71899. private static _CleanUrl;
  71900. /**
  71901. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71902. * @param url define the url we are trying
  71903. * @param element define the dom element where to configure the cors policy
  71904. */
  71905. static SetCorsBehavior(url: string | string[], element: {
  71906. crossOrigin: string | null;
  71907. }): void;
  71908. /**
  71909. * Loads an image as an HTMLImageElement.
  71910. * @param input url string, ArrayBuffer, or Blob to load
  71911. * @param onLoad callback called when the image successfully loads
  71912. * @param onError callback called when the image fails to load
  71913. * @param offlineProvider offline provider for caching
  71914. * @returns the HTMLImageElement of the loaded image
  71915. */
  71916. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71917. /**
  71918. * Loads a file
  71919. * @param fileToLoad defines the file to load
  71920. * @param callback defines the callback to call when data is loaded
  71921. * @param progressCallBack defines the callback to call during loading process
  71922. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71923. * @returns a file request object
  71924. */
  71925. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71926. /**
  71927. * Loads a file
  71928. * @param url url string, ArrayBuffer, or Blob to load
  71929. * @param onSuccess callback called when the file successfully loads
  71930. * @param onProgress callback called while file is loading (if the server supports this mode)
  71931. * @param offlineProvider defines the offline provider for caching
  71932. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71933. * @param onError callback called when the file fails to load
  71934. * @returns a file request object
  71935. */
  71936. 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;
  71937. /**
  71938. * Checks if the loaded document was accessed via `file:`-Protocol.
  71939. * @returns boolean
  71940. */
  71941. static IsFileURL(): boolean;
  71942. }
  71943. }
  71944. declare module BABYLON {
  71945. /** @hidden */
  71946. export class ShaderProcessor {
  71947. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71948. private static _ProcessPrecision;
  71949. private static _ExtractOperation;
  71950. private static _BuildSubExpression;
  71951. private static _BuildExpression;
  71952. private static _MoveCursorWithinIf;
  71953. private static _MoveCursor;
  71954. private static _EvaluatePreProcessors;
  71955. private static _PreparePreProcessors;
  71956. private static _ProcessShaderConversion;
  71957. private static _ProcessIncludes;
  71958. }
  71959. }
  71960. declare module BABYLON {
  71961. /**
  71962. * Interface used to define common properties for effect fallbacks
  71963. */
  71964. export interface IEffectFallbacks {
  71965. /**
  71966. * Removes the defines that should be removed when falling back.
  71967. * @param currentDefines defines the current define statements for the shader.
  71968. * @param effect defines the current effect we try to compile
  71969. * @returns The resulting defines with defines of the current rank removed.
  71970. */
  71971. reduce(currentDefines: string, effect: Effect): string;
  71972. /**
  71973. * Removes the fallback from the bound mesh.
  71974. */
  71975. unBindMesh(): void;
  71976. /**
  71977. * Checks to see if more fallbacks are still availible.
  71978. */
  71979. hasMoreFallbacks: boolean;
  71980. }
  71981. }
  71982. declare module BABYLON {
  71983. /**
  71984. * Class used to evalaute queries containing `and` and `or` operators
  71985. */
  71986. export class AndOrNotEvaluator {
  71987. /**
  71988. * Evaluate a query
  71989. * @param query defines the query to evaluate
  71990. * @param evaluateCallback defines the callback used to filter result
  71991. * @returns true if the query matches
  71992. */
  71993. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71994. private static _HandleParenthesisContent;
  71995. private static _SimplifyNegation;
  71996. }
  71997. }
  71998. declare module BABYLON {
  71999. /**
  72000. * Class used to store custom tags
  72001. */
  72002. export class Tags {
  72003. /**
  72004. * Adds support for tags on the given object
  72005. * @param obj defines the object to use
  72006. */
  72007. static EnableFor(obj: any): void;
  72008. /**
  72009. * Removes tags support
  72010. * @param obj defines the object to use
  72011. */
  72012. static DisableFor(obj: any): void;
  72013. /**
  72014. * Gets a boolean indicating if the given object has tags
  72015. * @param obj defines the object to use
  72016. * @returns a boolean
  72017. */
  72018. static HasTags(obj: any): boolean;
  72019. /**
  72020. * Gets the tags available on a given object
  72021. * @param obj defines the object to use
  72022. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72023. * @returns the tags
  72024. */
  72025. static GetTags(obj: any, asString?: boolean): any;
  72026. /**
  72027. * Adds tags to an object
  72028. * @param obj defines the object to use
  72029. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72030. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72031. */
  72032. static AddTagsTo(obj: any, tagsString: string): void;
  72033. /**
  72034. * @hidden
  72035. */
  72036. static _AddTagTo(obj: any, tag: string): void;
  72037. /**
  72038. * Removes specific tags from a specific object
  72039. * @param obj defines the object to use
  72040. * @param tagsString defines the tags to remove
  72041. */
  72042. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72043. /**
  72044. * @hidden
  72045. */
  72046. static _RemoveTagFrom(obj: any, tag: string): void;
  72047. /**
  72048. * Defines if tags hosted on an object match a given query
  72049. * @param obj defines the object to use
  72050. * @param tagsQuery defines the tag query
  72051. * @returns a boolean
  72052. */
  72053. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72054. }
  72055. }
  72056. declare module BABYLON {
  72057. /**
  72058. * Defines potential orientation for back face culling
  72059. */
  72060. export enum Orientation {
  72061. /**
  72062. * Clockwise
  72063. */
  72064. CW = 0,
  72065. /** Counter clockwise */
  72066. CCW = 1
  72067. }
  72068. /** Class used to represent a Bezier curve */
  72069. export class BezierCurve {
  72070. /**
  72071. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72072. * @param t defines the time
  72073. * @param x1 defines the left coordinate on X axis
  72074. * @param y1 defines the left coordinate on Y axis
  72075. * @param x2 defines the right coordinate on X axis
  72076. * @param y2 defines the right coordinate on Y axis
  72077. * @returns the interpolated value
  72078. */
  72079. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72080. }
  72081. /**
  72082. * Defines angle representation
  72083. */
  72084. export class Angle {
  72085. private _radians;
  72086. /**
  72087. * Creates an Angle object of "radians" radians (float).
  72088. * @param radians the angle in radians
  72089. */
  72090. constructor(radians: number);
  72091. /**
  72092. * Get value in degrees
  72093. * @returns the Angle value in degrees (float)
  72094. */
  72095. degrees(): number;
  72096. /**
  72097. * Get value in radians
  72098. * @returns the Angle value in radians (float)
  72099. */
  72100. radians(): number;
  72101. /**
  72102. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72103. * @param a defines first vector
  72104. * @param b defines second vector
  72105. * @returns a new Angle
  72106. */
  72107. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72108. /**
  72109. * Gets a new Angle object from the given float in radians
  72110. * @param radians defines the angle value in radians
  72111. * @returns a new Angle
  72112. */
  72113. static FromRadians(radians: number): Angle;
  72114. /**
  72115. * Gets a new Angle object from the given float in degrees
  72116. * @param degrees defines the angle value in degrees
  72117. * @returns a new Angle
  72118. */
  72119. static FromDegrees(degrees: number): Angle;
  72120. }
  72121. /**
  72122. * This represents an arc in a 2d space.
  72123. */
  72124. export class Arc2 {
  72125. /** Defines the start point of the arc */
  72126. startPoint: Vector2;
  72127. /** Defines the mid point of the arc */
  72128. midPoint: Vector2;
  72129. /** Defines the end point of the arc */
  72130. endPoint: Vector2;
  72131. /**
  72132. * Defines the center point of the arc.
  72133. */
  72134. centerPoint: Vector2;
  72135. /**
  72136. * Defines the radius of the arc.
  72137. */
  72138. radius: number;
  72139. /**
  72140. * Defines the angle of the arc (from mid point to end point).
  72141. */
  72142. angle: Angle;
  72143. /**
  72144. * Defines the start angle of the arc (from start point to middle point).
  72145. */
  72146. startAngle: Angle;
  72147. /**
  72148. * Defines the orientation of the arc (clock wise/counter clock wise).
  72149. */
  72150. orientation: Orientation;
  72151. /**
  72152. * Creates an Arc object from the three given points : start, middle and end.
  72153. * @param startPoint Defines the start point of the arc
  72154. * @param midPoint Defines the midlle point of the arc
  72155. * @param endPoint Defines the end point of the arc
  72156. */
  72157. constructor(
  72158. /** Defines the start point of the arc */
  72159. startPoint: Vector2,
  72160. /** Defines the mid point of the arc */
  72161. midPoint: Vector2,
  72162. /** Defines the end point of the arc */
  72163. endPoint: Vector2);
  72164. }
  72165. /**
  72166. * Represents a 2D path made up of multiple 2D points
  72167. */
  72168. export class Path2 {
  72169. private _points;
  72170. private _length;
  72171. /**
  72172. * If the path start and end point are the same
  72173. */
  72174. closed: boolean;
  72175. /**
  72176. * Creates a Path2 object from the starting 2D coordinates x and y.
  72177. * @param x the starting points x value
  72178. * @param y the starting points y value
  72179. */
  72180. constructor(x: number, y: number);
  72181. /**
  72182. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72183. * @param x the added points x value
  72184. * @param y the added points y value
  72185. * @returns the updated Path2.
  72186. */
  72187. addLineTo(x: number, y: number): Path2;
  72188. /**
  72189. * 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.
  72190. * @param midX middle point x value
  72191. * @param midY middle point y value
  72192. * @param endX end point x value
  72193. * @param endY end point y value
  72194. * @param numberOfSegments (default: 36)
  72195. * @returns the updated Path2.
  72196. */
  72197. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72198. /**
  72199. * Closes the Path2.
  72200. * @returns the Path2.
  72201. */
  72202. close(): Path2;
  72203. /**
  72204. * Gets the sum of the distance between each sequential point in the path
  72205. * @returns the Path2 total length (float).
  72206. */
  72207. length(): number;
  72208. /**
  72209. * Gets the points which construct the path
  72210. * @returns the Path2 internal array of points.
  72211. */
  72212. getPoints(): Vector2[];
  72213. /**
  72214. * Retreives the point at the distance aways from the starting point
  72215. * @param normalizedLengthPosition the length along the path to retreive the point from
  72216. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72217. */
  72218. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72219. /**
  72220. * Creates a new path starting from an x and y position
  72221. * @param x starting x value
  72222. * @param y starting y value
  72223. * @returns a new Path2 starting at the coordinates (x, y).
  72224. */
  72225. static StartingAt(x: number, y: number): Path2;
  72226. }
  72227. /**
  72228. * Represents a 3D path made up of multiple 3D points
  72229. */
  72230. export class Path3D {
  72231. /**
  72232. * an array of Vector3, the curve axis of the Path3D
  72233. */
  72234. path: Vector3[];
  72235. private _curve;
  72236. private _distances;
  72237. private _tangents;
  72238. private _normals;
  72239. private _binormals;
  72240. private _raw;
  72241. /**
  72242. * new Path3D(path, normal, raw)
  72243. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72244. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72245. * @param path an array of Vector3, the curve axis of the Path3D
  72246. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72247. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72248. */
  72249. constructor(
  72250. /**
  72251. * an array of Vector3, the curve axis of the Path3D
  72252. */
  72253. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72254. /**
  72255. * Returns the Path3D array of successive Vector3 designing its curve.
  72256. * @returns the Path3D array of successive Vector3 designing its curve.
  72257. */
  72258. getCurve(): Vector3[];
  72259. /**
  72260. * Returns an array populated with tangent vectors on each Path3D curve point.
  72261. * @returns an array populated with tangent vectors on each Path3D curve point.
  72262. */
  72263. getTangents(): Vector3[];
  72264. /**
  72265. * Returns an array populated with normal vectors on each Path3D curve point.
  72266. * @returns an array populated with normal vectors on each Path3D curve point.
  72267. */
  72268. getNormals(): Vector3[];
  72269. /**
  72270. * Returns an array populated with binormal vectors on each Path3D curve point.
  72271. * @returns an array populated with binormal vectors on each Path3D curve point.
  72272. */
  72273. getBinormals(): Vector3[];
  72274. /**
  72275. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72276. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72277. */
  72278. getDistances(): number[];
  72279. /**
  72280. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72281. * @param path path which all values are copied into the curves points
  72282. * @param firstNormal which should be projected onto the curve
  72283. * @returns the same object updated.
  72284. */
  72285. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72286. private _compute;
  72287. private _getFirstNonNullVector;
  72288. private _getLastNonNullVector;
  72289. private _normalVector;
  72290. }
  72291. /**
  72292. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72293. * A Curve3 is designed from a series of successive Vector3.
  72294. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72295. */
  72296. export class Curve3 {
  72297. private _points;
  72298. private _length;
  72299. /**
  72300. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72301. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72302. * @param v1 (Vector3) the control point
  72303. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72304. * @param nbPoints (integer) the wanted number of points in the curve
  72305. * @returns the created Curve3
  72306. */
  72307. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72308. /**
  72309. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72310. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72311. * @param v1 (Vector3) the first control point
  72312. * @param v2 (Vector3) the second control point
  72313. * @param v3 (Vector3) the end point of the Cubic Bezier
  72314. * @param nbPoints (integer) the wanted number of points in the curve
  72315. * @returns the created Curve3
  72316. */
  72317. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72318. /**
  72319. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72320. * @param p1 (Vector3) the origin point of the Hermite Spline
  72321. * @param t1 (Vector3) the tangent vector at the origin point
  72322. * @param p2 (Vector3) the end point of the Hermite Spline
  72323. * @param t2 (Vector3) the tangent vector at the end point
  72324. * @param nbPoints (integer) the wanted number of points in the curve
  72325. * @returns the created Curve3
  72326. */
  72327. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72328. /**
  72329. * Returns a Curve3 object along a CatmullRom Spline curve :
  72330. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72331. * @param nbPoints (integer) the wanted number of points between each curve control points
  72332. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72333. * @returns the created Curve3
  72334. */
  72335. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72336. /**
  72337. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72338. * A Curve3 is designed from a series of successive Vector3.
  72339. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72340. * @param points points which make up the curve
  72341. */
  72342. constructor(points: Vector3[]);
  72343. /**
  72344. * @returns the Curve3 stored array of successive Vector3
  72345. */
  72346. getPoints(): Vector3[];
  72347. /**
  72348. * @returns the computed length (float) of the curve.
  72349. */
  72350. length(): number;
  72351. /**
  72352. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72353. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72354. * curveA and curveB keep unchanged.
  72355. * @param curve the curve to continue from this curve
  72356. * @returns the newly constructed curve
  72357. */
  72358. continue(curve: DeepImmutable<Curve3>): Curve3;
  72359. private _computeLength;
  72360. }
  72361. }
  72362. declare module BABYLON {
  72363. /**
  72364. * This represents the main contract an easing function should follow.
  72365. * Easing functions are used throughout the animation system.
  72366. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72367. */
  72368. export interface IEasingFunction {
  72369. /**
  72370. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72371. * of the easing function.
  72372. * The link below provides some of the most common examples of easing functions.
  72373. * @see https://easings.net/
  72374. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72375. * @returns the corresponding value on the curve defined by the easing function
  72376. */
  72377. ease(gradient: number): number;
  72378. }
  72379. /**
  72380. * Base class used for every default easing function.
  72381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72382. */
  72383. export class EasingFunction implements IEasingFunction {
  72384. /**
  72385. * Interpolation follows the mathematical formula associated with the easing function.
  72386. */
  72387. static readonly EASINGMODE_EASEIN: number;
  72388. /**
  72389. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72390. */
  72391. static readonly EASINGMODE_EASEOUT: number;
  72392. /**
  72393. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72394. */
  72395. static readonly EASINGMODE_EASEINOUT: number;
  72396. private _easingMode;
  72397. /**
  72398. * Sets the easing mode of the current function.
  72399. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72400. */
  72401. setEasingMode(easingMode: number): void;
  72402. /**
  72403. * Gets the current easing mode.
  72404. * @returns the easing mode
  72405. */
  72406. getEasingMode(): number;
  72407. /**
  72408. * @hidden
  72409. */
  72410. easeInCore(gradient: number): number;
  72411. /**
  72412. * Given an input gradient between 0 and 1, this returns the corresponding value
  72413. * of the easing function.
  72414. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72415. * @returns the corresponding value on the curve defined by the easing function
  72416. */
  72417. ease(gradient: number): number;
  72418. }
  72419. /**
  72420. * Easing function with a circle shape (see link below).
  72421. * @see https://easings.net/#easeInCirc
  72422. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72423. */
  72424. export class CircleEase extends EasingFunction implements IEasingFunction {
  72425. /** @hidden */
  72426. easeInCore(gradient: number): number;
  72427. }
  72428. /**
  72429. * Easing function with a ease back shape (see link below).
  72430. * @see https://easings.net/#easeInBack
  72431. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72432. */
  72433. export class BackEase extends EasingFunction implements IEasingFunction {
  72434. /** Defines the amplitude of the function */
  72435. amplitude: number;
  72436. /**
  72437. * Instantiates a back ease easing
  72438. * @see https://easings.net/#easeInBack
  72439. * @param amplitude Defines the amplitude of the function
  72440. */
  72441. constructor(
  72442. /** Defines the amplitude of the function */
  72443. amplitude?: number);
  72444. /** @hidden */
  72445. easeInCore(gradient: number): number;
  72446. }
  72447. /**
  72448. * Easing function with a bouncing shape (see link below).
  72449. * @see https://easings.net/#easeInBounce
  72450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72451. */
  72452. export class BounceEase extends EasingFunction implements IEasingFunction {
  72453. /** Defines the number of bounces */
  72454. bounces: number;
  72455. /** Defines the amplitude of the bounce */
  72456. bounciness: number;
  72457. /**
  72458. * Instantiates a bounce easing
  72459. * @see https://easings.net/#easeInBounce
  72460. * @param bounces Defines the number of bounces
  72461. * @param bounciness Defines the amplitude of the bounce
  72462. */
  72463. constructor(
  72464. /** Defines the number of bounces */
  72465. bounces?: number,
  72466. /** Defines the amplitude of the bounce */
  72467. bounciness?: number);
  72468. /** @hidden */
  72469. easeInCore(gradient: number): number;
  72470. }
  72471. /**
  72472. * Easing function with a power of 3 shape (see link below).
  72473. * @see https://easings.net/#easeInCubic
  72474. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72475. */
  72476. export class CubicEase extends EasingFunction implements IEasingFunction {
  72477. /** @hidden */
  72478. easeInCore(gradient: number): number;
  72479. }
  72480. /**
  72481. * Easing function with an elastic shape (see link below).
  72482. * @see https://easings.net/#easeInElastic
  72483. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72484. */
  72485. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72486. /** Defines the number of oscillations*/
  72487. oscillations: number;
  72488. /** Defines the amplitude of the oscillations*/
  72489. springiness: number;
  72490. /**
  72491. * Instantiates an elastic easing function
  72492. * @see https://easings.net/#easeInElastic
  72493. * @param oscillations Defines the number of oscillations
  72494. * @param springiness Defines the amplitude of the oscillations
  72495. */
  72496. constructor(
  72497. /** Defines the number of oscillations*/
  72498. oscillations?: number,
  72499. /** Defines the amplitude of the oscillations*/
  72500. springiness?: number);
  72501. /** @hidden */
  72502. easeInCore(gradient: number): number;
  72503. }
  72504. /**
  72505. * Easing function with an exponential shape (see link below).
  72506. * @see https://easings.net/#easeInExpo
  72507. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72508. */
  72509. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72510. /** Defines the exponent of the function */
  72511. exponent: number;
  72512. /**
  72513. * Instantiates an exponential easing function
  72514. * @see https://easings.net/#easeInExpo
  72515. * @param exponent Defines the exponent of the function
  72516. */
  72517. constructor(
  72518. /** Defines the exponent of the function */
  72519. exponent?: number);
  72520. /** @hidden */
  72521. easeInCore(gradient: number): number;
  72522. }
  72523. /**
  72524. * Easing function with a power shape (see link below).
  72525. * @see https://easings.net/#easeInQuad
  72526. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72527. */
  72528. export class PowerEase extends EasingFunction implements IEasingFunction {
  72529. /** Defines the power of the function */
  72530. power: number;
  72531. /**
  72532. * Instantiates an power base easing function
  72533. * @see https://easings.net/#easeInQuad
  72534. * @param power Defines the power of the function
  72535. */
  72536. constructor(
  72537. /** Defines the power of the function */
  72538. power?: number);
  72539. /** @hidden */
  72540. easeInCore(gradient: number): number;
  72541. }
  72542. /**
  72543. * Easing function with a power of 2 shape (see link below).
  72544. * @see https://easings.net/#easeInQuad
  72545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72546. */
  72547. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72548. /** @hidden */
  72549. easeInCore(gradient: number): number;
  72550. }
  72551. /**
  72552. * Easing function with a power of 4 shape (see link below).
  72553. * @see https://easings.net/#easeInQuart
  72554. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72555. */
  72556. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72557. /** @hidden */
  72558. easeInCore(gradient: number): number;
  72559. }
  72560. /**
  72561. * Easing function with a power of 5 shape (see link below).
  72562. * @see https://easings.net/#easeInQuint
  72563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72564. */
  72565. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72566. /** @hidden */
  72567. easeInCore(gradient: number): number;
  72568. }
  72569. /**
  72570. * Easing function with a sin shape (see link below).
  72571. * @see https://easings.net/#easeInSine
  72572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72573. */
  72574. export class SineEase extends EasingFunction implements IEasingFunction {
  72575. /** @hidden */
  72576. easeInCore(gradient: number): number;
  72577. }
  72578. /**
  72579. * Easing function with a bezier shape (see link below).
  72580. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72582. */
  72583. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72584. /** Defines the x component of the start tangent in the bezier curve */
  72585. x1: number;
  72586. /** Defines the y component of the start tangent in the bezier curve */
  72587. y1: number;
  72588. /** Defines the x component of the end tangent in the bezier curve */
  72589. x2: number;
  72590. /** Defines the y component of the end tangent in the bezier curve */
  72591. y2: number;
  72592. /**
  72593. * Instantiates a bezier function
  72594. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72595. * @param x1 Defines the x component of the start tangent in the bezier curve
  72596. * @param y1 Defines the y component of the start tangent in the bezier curve
  72597. * @param x2 Defines the x component of the end tangent in the bezier curve
  72598. * @param y2 Defines the y component of the end tangent in the bezier curve
  72599. */
  72600. constructor(
  72601. /** Defines the x component of the start tangent in the bezier curve */
  72602. x1?: number,
  72603. /** Defines the y component of the start tangent in the bezier curve */
  72604. y1?: number,
  72605. /** Defines the x component of the end tangent in the bezier curve */
  72606. x2?: number,
  72607. /** Defines the y component of the end tangent in the bezier curve */
  72608. y2?: number);
  72609. /** @hidden */
  72610. easeInCore(gradient: number): number;
  72611. }
  72612. }
  72613. declare module BABYLON {
  72614. /**
  72615. * Defines an interface which represents an animation key frame
  72616. */
  72617. export interface IAnimationKey {
  72618. /**
  72619. * Frame of the key frame
  72620. */
  72621. frame: number;
  72622. /**
  72623. * Value at the specifies key frame
  72624. */
  72625. value: any;
  72626. /**
  72627. * The input tangent for the cubic hermite spline
  72628. */
  72629. inTangent?: any;
  72630. /**
  72631. * The output tangent for the cubic hermite spline
  72632. */
  72633. outTangent?: any;
  72634. /**
  72635. * The animation interpolation type
  72636. */
  72637. interpolation?: AnimationKeyInterpolation;
  72638. }
  72639. /**
  72640. * Enum for the animation key frame interpolation type
  72641. */
  72642. export enum AnimationKeyInterpolation {
  72643. /**
  72644. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72645. */
  72646. STEP = 1
  72647. }
  72648. }
  72649. declare module BABYLON {
  72650. /**
  72651. * Represents the range of an animation
  72652. */
  72653. export class AnimationRange {
  72654. /**The name of the animation range**/
  72655. name: string;
  72656. /**The starting frame of the animation */
  72657. from: number;
  72658. /**The ending frame of the animation*/
  72659. to: number;
  72660. /**
  72661. * Initializes the range of an animation
  72662. * @param name The name of the animation range
  72663. * @param from The starting frame of the animation
  72664. * @param to The ending frame of the animation
  72665. */
  72666. constructor(
  72667. /**The name of the animation range**/
  72668. name: string,
  72669. /**The starting frame of the animation */
  72670. from: number,
  72671. /**The ending frame of the animation*/
  72672. to: number);
  72673. /**
  72674. * Makes a copy of the animation range
  72675. * @returns A copy of the animation range
  72676. */
  72677. clone(): AnimationRange;
  72678. }
  72679. }
  72680. declare module BABYLON {
  72681. /**
  72682. * Composed of a frame, and an action function
  72683. */
  72684. export class AnimationEvent {
  72685. /** The frame for which the event is triggered **/
  72686. frame: number;
  72687. /** The event to perform when triggered **/
  72688. action: (currentFrame: number) => void;
  72689. /** Specifies if the event should be triggered only once**/
  72690. onlyOnce?: boolean | undefined;
  72691. /**
  72692. * Specifies if the animation event is done
  72693. */
  72694. isDone: boolean;
  72695. /**
  72696. * Initializes the animation event
  72697. * @param frame The frame for which the event is triggered
  72698. * @param action The event to perform when triggered
  72699. * @param onlyOnce Specifies if the event should be triggered only once
  72700. */
  72701. constructor(
  72702. /** The frame for which the event is triggered **/
  72703. frame: number,
  72704. /** The event to perform when triggered **/
  72705. action: (currentFrame: number) => void,
  72706. /** Specifies if the event should be triggered only once**/
  72707. onlyOnce?: boolean | undefined);
  72708. /** @hidden */
  72709. _clone(): AnimationEvent;
  72710. }
  72711. }
  72712. declare module BABYLON {
  72713. /**
  72714. * Interface used to define a behavior
  72715. */
  72716. export interface Behavior<T> {
  72717. /** gets or sets behavior's name */
  72718. name: string;
  72719. /**
  72720. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72721. */
  72722. init(): void;
  72723. /**
  72724. * Called when the behavior is attached to a target
  72725. * @param target defines the target where the behavior is attached to
  72726. */
  72727. attach(target: T): void;
  72728. /**
  72729. * Called when the behavior is detached from its target
  72730. */
  72731. detach(): void;
  72732. }
  72733. /**
  72734. * Interface implemented by classes supporting behaviors
  72735. */
  72736. export interface IBehaviorAware<T> {
  72737. /**
  72738. * Attach a behavior
  72739. * @param behavior defines the behavior to attach
  72740. * @returns the current host
  72741. */
  72742. addBehavior(behavior: Behavior<T>): T;
  72743. /**
  72744. * Remove a behavior from the current object
  72745. * @param behavior defines the behavior to detach
  72746. * @returns the current host
  72747. */
  72748. removeBehavior(behavior: Behavior<T>): T;
  72749. /**
  72750. * Gets a behavior using its name to search
  72751. * @param name defines the name to search
  72752. * @returns the behavior or null if not found
  72753. */
  72754. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72755. }
  72756. }
  72757. declare module BABYLON {
  72758. /**
  72759. * Defines an array and its length.
  72760. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72761. */
  72762. export interface ISmartArrayLike<T> {
  72763. /**
  72764. * The data of the array.
  72765. */
  72766. data: Array<T>;
  72767. /**
  72768. * The active length of the array.
  72769. */
  72770. length: number;
  72771. }
  72772. /**
  72773. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72774. */
  72775. export class SmartArray<T> implements ISmartArrayLike<T> {
  72776. /**
  72777. * The full set of data from the array.
  72778. */
  72779. data: Array<T>;
  72780. /**
  72781. * The active length of the array.
  72782. */
  72783. length: number;
  72784. protected _id: number;
  72785. /**
  72786. * Instantiates a Smart Array.
  72787. * @param capacity defines the default capacity of the array.
  72788. */
  72789. constructor(capacity: number);
  72790. /**
  72791. * Pushes a value at the end of the active data.
  72792. * @param value defines the object to push in the array.
  72793. */
  72794. push(value: T): void;
  72795. /**
  72796. * Iterates over the active data and apply the lambda to them.
  72797. * @param func defines the action to apply on each value.
  72798. */
  72799. forEach(func: (content: T) => void): void;
  72800. /**
  72801. * Sorts the full sets of data.
  72802. * @param compareFn defines the comparison function to apply.
  72803. */
  72804. sort(compareFn: (a: T, b: T) => number): void;
  72805. /**
  72806. * Resets the active data to an empty array.
  72807. */
  72808. reset(): void;
  72809. /**
  72810. * Releases all the data from the array as well as the array.
  72811. */
  72812. dispose(): void;
  72813. /**
  72814. * Concats the active data with a given array.
  72815. * @param array defines the data to concatenate with.
  72816. */
  72817. concat(array: any): void;
  72818. /**
  72819. * Returns the position of a value in the active data.
  72820. * @param value defines the value to find the index for
  72821. * @returns the index if found in the active data otherwise -1
  72822. */
  72823. indexOf(value: T): number;
  72824. /**
  72825. * Returns whether an element is part of the active data.
  72826. * @param value defines the value to look for
  72827. * @returns true if found in the active data otherwise false
  72828. */
  72829. contains(value: T): boolean;
  72830. private static _GlobalId;
  72831. }
  72832. /**
  72833. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72834. * The data in this array can only be present once
  72835. */
  72836. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72837. private _duplicateId;
  72838. /**
  72839. * Pushes a value at the end of the active data.
  72840. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72841. * @param value defines the object to push in the array.
  72842. */
  72843. push(value: T): void;
  72844. /**
  72845. * Pushes a value at the end of the active data.
  72846. * If the data is already present, it won t be added again
  72847. * @param value defines the object to push in the array.
  72848. * @returns true if added false if it was already present
  72849. */
  72850. pushNoDuplicate(value: T): boolean;
  72851. /**
  72852. * Resets the active data to an empty array.
  72853. */
  72854. reset(): void;
  72855. /**
  72856. * Concats the active data with a given array.
  72857. * This ensures no dupplicate will be present in the result.
  72858. * @param array defines the data to concatenate with.
  72859. */
  72860. concatWithNoDuplicate(array: any): void;
  72861. }
  72862. }
  72863. declare module BABYLON {
  72864. /**
  72865. * @ignore
  72866. * This is a list of all the different input types that are available in the application.
  72867. * Fo instance: ArcRotateCameraGamepadInput...
  72868. */
  72869. export var CameraInputTypes: {};
  72870. /**
  72871. * This is the contract to implement in order to create a new input class.
  72872. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72873. */
  72874. export interface ICameraInput<TCamera extends Camera> {
  72875. /**
  72876. * Defines the camera the input is attached to.
  72877. */
  72878. camera: Nullable<TCamera>;
  72879. /**
  72880. * Gets the class name of the current intput.
  72881. * @returns the class name
  72882. */
  72883. getClassName(): string;
  72884. /**
  72885. * Get the friendly name associated with the input class.
  72886. * @returns the input friendly name
  72887. */
  72888. getSimpleName(): string;
  72889. /**
  72890. * Attach the input controls to a specific dom element to get the input from.
  72891. * @param element Defines the element the controls should be listened from
  72892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72893. */
  72894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72895. /**
  72896. * Detach the current controls from the specified dom element.
  72897. * @param element Defines the element to stop listening the inputs from
  72898. */
  72899. detachControl(element: Nullable<HTMLElement>): void;
  72900. /**
  72901. * Update the current camera state depending on the inputs that have been used this frame.
  72902. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72903. */
  72904. checkInputs?: () => void;
  72905. }
  72906. /**
  72907. * Represents a map of input types to input instance or input index to input instance.
  72908. */
  72909. export interface CameraInputsMap<TCamera extends Camera> {
  72910. /**
  72911. * Accessor to the input by input type.
  72912. */
  72913. [name: string]: ICameraInput<TCamera>;
  72914. /**
  72915. * Accessor to the input by input index.
  72916. */
  72917. [idx: number]: ICameraInput<TCamera>;
  72918. }
  72919. /**
  72920. * This represents the input manager used within a camera.
  72921. * It helps dealing with all the different kind of input attached to a camera.
  72922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72923. */
  72924. export class CameraInputsManager<TCamera extends Camera> {
  72925. /**
  72926. * Defines the list of inputs attahed to the camera.
  72927. */
  72928. attached: CameraInputsMap<TCamera>;
  72929. /**
  72930. * Defines the dom element the camera is collecting inputs from.
  72931. * This is null if the controls have not been attached.
  72932. */
  72933. attachedElement: Nullable<HTMLElement>;
  72934. /**
  72935. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72936. */
  72937. noPreventDefault: boolean;
  72938. /**
  72939. * Defined the camera the input manager belongs to.
  72940. */
  72941. camera: TCamera;
  72942. /**
  72943. * Update the current camera state depending on the inputs that have been used this frame.
  72944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72945. */
  72946. checkInputs: () => void;
  72947. /**
  72948. * Instantiate a new Camera Input Manager.
  72949. * @param camera Defines the camera the input manager blongs to
  72950. */
  72951. constructor(camera: TCamera);
  72952. /**
  72953. * Add an input method to a camera
  72954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72955. * @param input camera input method
  72956. */
  72957. add(input: ICameraInput<TCamera>): void;
  72958. /**
  72959. * Remove a specific input method from a camera
  72960. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72961. * @param inputToRemove camera input method
  72962. */
  72963. remove(inputToRemove: ICameraInput<TCamera>): void;
  72964. /**
  72965. * Remove a specific input type from a camera
  72966. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72967. * @param inputType the type of the input to remove
  72968. */
  72969. removeByType(inputType: string): void;
  72970. private _addCheckInputs;
  72971. /**
  72972. * Attach the input controls to the currently attached dom element to listen the events from.
  72973. * @param input Defines the input to attach
  72974. */
  72975. attachInput(input: ICameraInput<TCamera>): void;
  72976. /**
  72977. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72978. * @param element Defines the dom element to collect the events from
  72979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72980. */
  72981. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72982. /**
  72983. * Detach the current manager inputs controls from a specific dom element.
  72984. * @param element Defines the dom element to collect the events from
  72985. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72986. */
  72987. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72988. /**
  72989. * Rebuild the dynamic inputCheck function from the current list of
  72990. * defined inputs in the manager.
  72991. */
  72992. rebuildInputCheck(): void;
  72993. /**
  72994. * Remove all attached input methods from a camera
  72995. */
  72996. clear(): void;
  72997. /**
  72998. * Serialize the current input manager attached to a camera.
  72999. * This ensures than once parsed,
  73000. * the input associated to the camera will be identical to the current ones
  73001. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73002. */
  73003. serialize(serializedCamera: any): void;
  73004. /**
  73005. * Parses an input manager serialized JSON to restore the previous list of inputs
  73006. * and states associated to a camera.
  73007. * @param parsedCamera Defines the JSON to parse
  73008. */
  73009. parse(parsedCamera: any): void;
  73010. }
  73011. }
  73012. declare module BABYLON {
  73013. /**
  73014. * Class used to store data that will be store in GPU memory
  73015. */
  73016. export class Buffer {
  73017. private _engine;
  73018. private _buffer;
  73019. /** @hidden */
  73020. _data: Nullable<DataArray>;
  73021. private _updatable;
  73022. private _instanced;
  73023. /**
  73024. * Gets the byte stride.
  73025. */
  73026. readonly byteStride: number;
  73027. /**
  73028. * Constructor
  73029. * @param engine the engine
  73030. * @param data the data to use for this buffer
  73031. * @param updatable whether the data is updatable
  73032. * @param stride the stride (optional)
  73033. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73034. * @param instanced whether the buffer is instanced (optional)
  73035. * @param useBytes set to true if the stride in in bytes (optional)
  73036. */
  73037. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  73038. /**
  73039. * Create a new VertexBuffer based on the current buffer
  73040. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73041. * @param offset defines offset in the buffer (0 by default)
  73042. * @param size defines the size in floats of attributes (position is 3 for instance)
  73043. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73044. * @param instanced defines if the vertex buffer contains indexed data
  73045. * @param useBytes defines if the offset and stride are in bytes
  73046. * @returns the new vertex buffer
  73047. */
  73048. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  73049. /**
  73050. * Gets a boolean indicating if the Buffer is updatable?
  73051. * @returns true if the buffer is updatable
  73052. */
  73053. isUpdatable(): boolean;
  73054. /**
  73055. * Gets current buffer's data
  73056. * @returns a DataArray or null
  73057. */
  73058. getData(): Nullable<DataArray>;
  73059. /**
  73060. * Gets underlying native buffer
  73061. * @returns underlying native buffer
  73062. */
  73063. getBuffer(): Nullable<DataBuffer>;
  73064. /**
  73065. * Gets the stride in float32 units (i.e. byte stride / 4).
  73066. * May not be an integer if the byte stride is not divisible by 4.
  73067. * DEPRECATED. Use byteStride instead.
  73068. * @returns the stride in float32 units
  73069. */
  73070. getStrideSize(): number;
  73071. /**
  73072. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73073. * @param data defines the data to store
  73074. */
  73075. create(data?: Nullable<DataArray>): void;
  73076. /** @hidden */
  73077. _rebuild(): void;
  73078. /**
  73079. * Update current buffer data
  73080. * @param data defines the data to store
  73081. */
  73082. update(data: DataArray): void;
  73083. /**
  73084. * Updates the data directly.
  73085. * @param data the new data
  73086. * @param offset the new offset
  73087. * @param vertexCount the vertex count (optional)
  73088. * @param useBytes set to true if the offset is in bytes
  73089. */
  73090. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73091. /**
  73092. * Release all resources
  73093. */
  73094. dispose(): void;
  73095. }
  73096. /**
  73097. * Specialized buffer used to store vertex data
  73098. */
  73099. export class VertexBuffer {
  73100. /** @hidden */
  73101. _buffer: Buffer;
  73102. private _kind;
  73103. private _size;
  73104. private _ownsBuffer;
  73105. private _instanced;
  73106. private _instanceDivisor;
  73107. /**
  73108. * The byte type.
  73109. */
  73110. static readonly BYTE: number;
  73111. /**
  73112. * The unsigned byte type.
  73113. */
  73114. static readonly UNSIGNED_BYTE: number;
  73115. /**
  73116. * The short type.
  73117. */
  73118. static readonly SHORT: number;
  73119. /**
  73120. * The unsigned short type.
  73121. */
  73122. static readonly UNSIGNED_SHORT: number;
  73123. /**
  73124. * The integer type.
  73125. */
  73126. static readonly INT: number;
  73127. /**
  73128. * The unsigned integer type.
  73129. */
  73130. static readonly UNSIGNED_INT: number;
  73131. /**
  73132. * The float type.
  73133. */
  73134. static readonly FLOAT: number;
  73135. /**
  73136. * Gets or sets the instance divisor when in instanced mode
  73137. */
  73138. instanceDivisor: number;
  73139. /**
  73140. * Gets the byte stride.
  73141. */
  73142. readonly byteStride: number;
  73143. /**
  73144. * Gets the byte offset.
  73145. */
  73146. readonly byteOffset: number;
  73147. /**
  73148. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73149. */
  73150. readonly normalized: boolean;
  73151. /**
  73152. * Gets the data type of each component in the array.
  73153. */
  73154. readonly type: number;
  73155. /**
  73156. * Constructor
  73157. * @param engine the engine
  73158. * @param data the data to use for this vertex buffer
  73159. * @param kind the vertex buffer kind
  73160. * @param updatable whether the data is updatable
  73161. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73162. * @param stride the stride (optional)
  73163. * @param instanced whether the buffer is instanced (optional)
  73164. * @param offset the offset of the data (optional)
  73165. * @param size the number of components (optional)
  73166. * @param type the type of the component (optional)
  73167. * @param normalized whether the data contains normalized data (optional)
  73168. * @param useBytes set to true if stride and offset are in bytes (optional)
  73169. */
  73170. 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);
  73171. /** @hidden */
  73172. _rebuild(): void;
  73173. /**
  73174. * Returns the kind of the VertexBuffer (string)
  73175. * @returns a string
  73176. */
  73177. getKind(): string;
  73178. /**
  73179. * Gets a boolean indicating if the VertexBuffer is updatable?
  73180. * @returns true if the buffer is updatable
  73181. */
  73182. isUpdatable(): boolean;
  73183. /**
  73184. * Gets current buffer's data
  73185. * @returns a DataArray or null
  73186. */
  73187. getData(): Nullable<DataArray>;
  73188. /**
  73189. * Gets underlying native buffer
  73190. * @returns underlying native buffer
  73191. */
  73192. getBuffer(): Nullable<DataBuffer>;
  73193. /**
  73194. * Gets the stride in float32 units (i.e. byte stride / 4).
  73195. * May not be an integer if the byte stride is not divisible by 4.
  73196. * DEPRECATED. Use byteStride instead.
  73197. * @returns the stride in float32 units
  73198. */
  73199. getStrideSize(): number;
  73200. /**
  73201. * Returns the offset as a multiple of the type byte length.
  73202. * DEPRECATED. Use byteOffset instead.
  73203. * @returns the offset in bytes
  73204. */
  73205. getOffset(): number;
  73206. /**
  73207. * Returns the number of components per vertex attribute (integer)
  73208. * @returns the size in float
  73209. */
  73210. getSize(): number;
  73211. /**
  73212. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73213. * @returns true if this buffer is instanced
  73214. */
  73215. getIsInstanced(): boolean;
  73216. /**
  73217. * Returns the instancing divisor, zero for non-instanced (integer).
  73218. * @returns a number
  73219. */
  73220. getInstanceDivisor(): number;
  73221. /**
  73222. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73223. * @param data defines the data to store
  73224. */
  73225. create(data?: DataArray): void;
  73226. /**
  73227. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73228. * This function will create a new buffer if the current one is not updatable
  73229. * @param data defines the data to store
  73230. */
  73231. update(data: DataArray): void;
  73232. /**
  73233. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73234. * Returns the directly updated WebGLBuffer.
  73235. * @param data the new data
  73236. * @param offset the new offset
  73237. * @param useBytes set to true if the offset is in bytes
  73238. */
  73239. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73240. /**
  73241. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73242. */
  73243. dispose(): void;
  73244. /**
  73245. * Enumerates each value of this vertex buffer as numbers.
  73246. * @param count the number of values to enumerate
  73247. * @param callback the callback function called for each value
  73248. */
  73249. forEach(count: number, callback: (value: number, index: number) => void): void;
  73250. /**
  73251. * Positions
  73252. */
  73253. static readonly PositionKind: string;
  73254. /**
  73255. * Normals
  73256. */
  73257. static readonly NormalKind: string;
  73258. /**
  73259. * Tangents
  73260. */
  73261. static readonly TangentKind: string;
  73262. /**
  73263. * Texture coordinates
  73264. */
  73265. static readonly UVKind: string;
  73266. /**
  73267. * Texture coordinates 2
  73268. */
  73269. static readonly UV2Kind: string;
  73270. /**
  73271. * Texture coordinates 3
  73272. */
  73273. static readonly UV3Kind: string;
  73274. /**
  73275. * Texture coordinates 4
  73276. */
  73277. static readonly UV4Kind: string;
  73278. /**
  73279. * Texture coordinates 5
  73280. */
  73281. static readonly UV5Kind: string;
  73282. /**
  73283. * Texture coordinates 6
  73284. */
  73285. static readonly UV6Kind: string;
  73286. /**
  73287. * Colors
  73288. */
  73289. static readonly ColorKind: string;
  73290. /**
  73291. * Matrix indices (for bones)
  73292. */
  73293. static readonly MatricesIndicesKind: string;
  73294. /**
  73295. * Matrix weights (for bones)
  73296. */
  73297. static readonly MatricesWeightsKind: string;
  73298. /**
  73299. * Additional matrix indices (for bones)
  73300. */
  73301. static readonly MatricesIndicesExtraKind: string;
  73302. /**
  73303. * Additional matrix weights (for bones)
  73304. */
  73305. static readonly MatricesWeightsExtraKind: string;
  73306. /**
  73307. * Deduces the stride given a kind.
  73308. * @param kind The kind string to deduce
  73309. * @returns The deduced stride
  73310. */
  73311. static DeduceStride(kind: string): number;
  73312. /**
  73313. * Gets the byte length of the given type.
  73314. * @param type the type
  73315. * @returns the number of bytes
  73316. */
  73317. static GetTypeByteLength(type: number): number;
  73318. /**
  73319. * Enumerates each value of the given parameters as numbers.
  73320. * @param data the data to enumerate
  73321. * @param byteOffset the byte offset of the data
  73322. * @param byteStride the byte stride of the data
  73323. * @param componentCount the number of components per element
  73324. * @param componentType the type of the component
  73325. * @param count the number of values to enumerate
  73326. * @param normalized whether the data is normalized
  73327. * @param callback the callback function called for each value
  73328. */
  73329. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73330. private static _GetFloatValue;
  73331. }
  73332. }
  73333. declare module BABYLON {
  73334. /**
  73335. * @hidden
  73336. */
  73337. export class IntersectionInfo {
  73338. bu: Nullable<number>;
  73339. bv: Nullable<number>;
  73340. distance: number;
  73341. faceId: number;
  73342. subMeshId: number;
  73343. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73344. }
  73345. }
  73346. declare module BABYLON {
  73347. /**
  73348. * Represens a plane by the equation ax + by + cz + d = 0
  73349. */
  73350. export class Plane {
  73351. private static _TmpMatrix;
  73352. /**
  73353. * Normal of the plane (a,b,c)
  73354. */
  73355. normal: Vector3;
  73356. /**
  73357. * d component of the plane
  73358. */
  73359. d: number;
  73360. /**
  73361. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73362. * @param a a component of the plane
  73363. * @param b b component of the plane
  73364. * @param c c component of the plane
  73365. * @param d d component of the plane
  73366. */
  73367. constructor(a: number, b: number, c: number, d: number);
  73368. /**
  73369. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73370. */
  73371. asArray(): number[];
  73372. /**
  73373. * @returns a new plane copied from the current Plane.
  73374. */
  73375. clone(): Plane;
  73376. /**
  73377. * @returns the string "Plane".
  73378. */
  73379. getClassName(): string;
  73380. /**
  73381. * @returns the Plane hash code.
  73382. */
  73383. getHashCode(): number;
  73384. /**
  73385. * Normalize the current Plane in place.
  73386. * @returns the updated Plane.
  73387. */
  73388. normalize(): Plane;
  73389. /**
  73390. * Applies a transformation the plane and returns the result
  73391. * @param transformation the transformation matrix to be applied to the plane
  73392. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73393. */
  73394. transform(transformation: DeepImmutable<Matrix>): Plane;
  73395. /**
  73396. * Calcualtte the dot product between the point and the plane normal
  73397. * @param point point to calculate the dot product with
  73398. * @returns the dot product (float) of the point coordinates and the plane normal.
  73399. */
  73400. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73401. /**
  73402. * Updates the current Plane from the plane defined by the three given points.
  73403. * @param point1 one of the points used to contruct the plane
  73404. * @param point2 one of the points used to contruct the plane
  73405. * @param point3 one of the points used to contruct the plane
  73406. * @returns the updated Plane.
  73407. */
  73408. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73409. /**
  73410. * Checks if the plane is facing a given direction
  73411. * @param direction the direction to check if the plane is facing
  73412. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73413. * @returns True is the vector "direction" is the same side than the plane normal.
  73414. */
  73415. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73416. /**
  73417. * Calculates the distance to a point
  73418. * @param point point to calculate distance to
  73419. * @returns the signed distance (float) from the given point to the Plane.
  73420. */
  73421. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73422. /**
  73423. * Creates a plane from an array
  73424. * @param array the array to create a plane from
  73425. * @returns a new Plane from the given array.
  73426. */
  73427. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73428. /**
  73429. * Creates a plane from three points
  73430. * @param point1 point used to create the plane
  73431. * @param point2 point used to create the plane
  73432. * @param point3 point used to create the plane
  73433. * @returns a new Plane defined by the three given points.
  73434. */
  73435. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73436. /**
  73437. * Creates a plane from an origin point and a normal
  73438. * @param origin origin of the plane to be constructed
  73439. * @param normal normal of the plane to be constructed
  73440. * @returns a new Plane the normal vector to this plane at the given origin point.
  73441. * Note : the vector "normal" is updated because normalized.
  73442. */
  73443. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73444. /**
  73445. * Calculates the distance from a plane and a point
  73446. * @param origin origin of the plane to be constructed
  73447. * @param normal normal of the plane to be constructed
  73448. * @param point point to calculate distance to
  73449. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73450. */
  73451. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73452. }
  73453. }
  73454. declare module BABYLON {
  73455. /**
  73456. * Class used to store bounding sphere information
  73457. */
  73458. export class BoundingSphere {
  73459. /**
  73460. * Gets the center of the bounding sphere in local space
  73461. */
  73462. readonly center: Vector3;
  73463. /**
  73464. * Radius of the bounding sphere in local space
  73465. */
  73466. radius: number;
  73467. /**
  73468. * Gets the center of the bounding sphere in world space
  73469. */
  73470. readonly centerWorld: Vector3;
  73471. /**
  73472. * Radius of the bounding sphere in world space
  73473. */
  73474. radiusWorld: number;
  73475. /**
  73476. * Gets the minimum vector in local space
  73477. */
  73478. readonly minimum: Vector3;
  73479. /**
  73480. * Gets the maximum vector in local space
  73481. */
  73482. readonly maximum: Vector3;
  73483. private _worldMatrix;
  73484. private static readonly TmpVector3;
  73485. /**
  73486. * Creates a new bounding sphere
  73487. * @param min defines the minimum vector (in local space)
  73488. * @param max defines the maximum vector (in local space)
  73489. * @param worldMatrix defines the new world matrix
  73490. */
  73491. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73492. /**
  73493. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73494. * @param min defines the new minimum vector (in local space)
  73495. * @param max defines the new maximum vector (in local space)
  73496. * @param worldMatrix defines the new world matrix
  73497. */
  73498. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73499. /**
  73500. * Scale the current bounding sphere by applying a scale factor
  73501. * @param factor defines the scale factor to apply
  73502. * @returns the current bounding box
  73503. */
  73504. scale(factor: number): BoundingSphere;
  73505. /**
  73506. * Gets the world matrix of the bounding box
  73507. * @returns a matrix
  73508. */
  73509. getWorldMatrix(): DeepImmutable<Matrix>;
  73510. /** @hidden */
  73511. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73512. /**
  73513. * Tests if the bounding sphere is intersecting the frustum planes
  73514. * @param frustumPlanes defines the frustum planes to test
  73515. * @returns true if there is an intersection
  73516. */
  73517. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73518. /**
  73519. * Tests if the bounding sphere center is in between the frustum planes.
  73520. * Used for optimistic fast inclusion.
  73521. * @param frustumPlanes defines the frustum planes to test
  73522. * @returns true if the sphere center is in between the frustum planes
  73523. */
  73524. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73525. /**
  73526. * Tests if a point is inside the bounding sphere
  73527. * @param point defines the point to test
  73528. * @returns true if the point is inside the bounding sphere
  73529. */
  73530. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73531. /**
  73532. * Checks if two sphere intersct
  73533. * @param sphere0 sphere 0
  73534. * @param sphere1 sphere 1
  73535. * @returns true if the speres intersect
  73536. */
  73537. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73538. }
  73539. }
  73540. declare module BABYLON {
  73541. /**
  73542. * Class used to store bounding box information
  73543. */
  73544. export class BoundingBox implements ICullable {
  73545. /**
  73546. * Gets the 8 vectors representing the bounding box in local space
  73547. */
  73548. readonly vectors: Vector3[];
  73549. /**
  73550. * Gets the center of the bounding box in local space
  73551. */
  73552. readonly center: Vector3;
  73553. /**
  73554. * Gets the center of the bounding box in world space
  73555. */
  73556. readonly centerWorld: Vector3;
  73557. /**
  73558. * Gets the extend size in local space
  73559. */
  73560. readonly extendSize: Vector3;
  73561. /**
  73562. * Gets the extend size in world space
  73563. */
  73564. readonly extendSizeWorld: Vector3;
  73565. /**
  73566. * Gets the OBB (object bounding box) directions
  73567. */
  73568. readonly directions: Vector3[];
  73569. /**
  73570. * Gets the 8 vectors representing the bounding box in world space
  73571. */
  73572. readonly vectorsWorld: Vector3[];
  73573. /**
  73574. * Gets the minimum vector in world space
  73575. */
  73576. readonly minimumWorld: Vector3;
  73577. /**
  73578. * Gets the maximum vector in world space
  73579. */
  73580. readonly maximumWorld: Vector3;
  73581. /**
  73582. * Gets the minimum vector in local space
  73583. */
  73584. readonly minimum: Vector3;
  73585. /**
  73586. * Gets the maximum vector in local space
  73587. */
  73588. readonly maximum: Vector3;
  73589. private _worldMatrix;
  73590. private static readonly TmpVector3;
  73591. /**
  73592. * @hidden
  73593. */
  73594. _tag: number;
  73595. /**
  73596. * Creates a new bounding box
  73597. * @param min defines the minimum vector (in local space)
  73598. * @param max defines the maximum vector (in local space)
  73599. * @param worldMatrix defines the new world matrix
  73600. */
  73601. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73602. /**
  73603. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73604. * @param min defines the new minimum vector (in local space)
  73605. * @param max defines the new maximum vector (in local space)
  73606. * @param worldMatrix defines the new world matrix
  73607. */
  73608. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73609. /**
  73610. * Scale the current bounding box by applying a scale factor
  73611. * @param factor defines the scale factor to apply
  73612. * @returns the current bounding box
  73613. */
  73614. scale(factor: number): BoundingBox;
  73615. /**
  73616. * Gets the world matrix of the bounding box
  73617. * @returns a matrix
  73618. */
  73619. getWorldMatrix(): DeepImmutable<Matrix>;
  73620. /** @hidden */
  73621. _update(world: DeepImmutable<Matrix>): void;
  73622. /**
  73623. * Tests if the bounding box is intersecting the frustum planes
  73624. * @param frustumPlanes defines the frustum planes to test
  73625. * @returns true if there is an intersection
  73626. */
  73627. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73628. /**
  73629. * Tests if the bounding box is entirely inside the frustum planes
  73630. * @param frustumPlanes defines the frustum planes to test
  73631. * @returns true if there is an inclusion
  73632. */
  73633. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73634. /**
  73635. * Tests if a point is inside the bounding box
  73636. * @param point defines the point to test
  73637. * @returns true if the point is inside the bounding box
  73638. */
  73639. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73640. /**
  73641. * Tests if the bounding box intersects with a bounding sphere
  73642. * @param sphere defines the sphere to test
  73643. * @returns true if there is an intersection
  73644. */
  73645. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73646. /**
  73647. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73648. * @param min defines the min vector to use
  73649. * @param max defines the max vector to use
  73650. * @returns true if there is an intersection
  73651. */
  73652. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73653. /**
  73654. * Tests if two bounding boxes are intersections
  73655. * @param box0 defines the first box to test
  73656. * @param box1 defines the second box to test
  73657. * @returns true if there is an intersection
  73658. */
  73659. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73660. /**
  73661. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73662. * @param minPoint defines the minimum vector of the bounding box
  73663. * @param maxPoint defines the maximum vector of the bounding box
  73664. * @param sphereCenter defines the sphere center
  73665. * @param sphereRadius defines the sphere radius
  73666. * @returns true if there is an intersection
  73667. */
  73668. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73669. /**
  73670. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73671. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73672. * @param frustumPlanes defines the frustum planes to test
  73673. * @return true if there is an inclusion
  73674. */
  73675. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73676. /**
  73677. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73678. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73679. * @param frustumPlanes defines the frustum planes to test
  73680. * @return true if there is an intersection
  73681. */
  73682. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73683. }
  73684. }
  73685. declare module BABYLON {
  73686. /** @hidden */
  73687. export class Collider {
  73688. /** Define if a collision was found */
  73689. collisionFound: boolean;
  73690. /**
  73691. * Define last intersection point in local space
  73692. */
  73693. intersectionPoint: Vector3;
  73694. /**
  73695. * Define last collided mesh
  73696. */
  73697. collidedMesh: Nullable<AbstractMesh>;
  73698. private _collisionPoint;
  73699. private _planeIntersectionPoint;
  73700. private _tempVector;
  73701. private _tempVector2;
  73702. private _tempVector3;
  73703. private _tempVector4;
  73704. private _edge;
  73705. private _baseToVertex;
  73706. private _destinationPoint;
  73707. private _slidePlaneNormal;
  73708. private _displacementVector;
  73709. /** @hidden */
  73710. _radius: Vector3;
  73711. /** @hidden */
  73712. _retry: number;
  73713. private _velocity;
  73714. private _basePoint;
  73715. private _epsilon;
  73716. /** @hidden */
  73717. _velocityWorldLength: number;
  73718. /** @hidden */
  73719. _basePointWorld: Vector3;
  73720. private _velocityWorld;
  73721. private _normalizedVelocity;
  73722. /** @hidden */
  73723. _initialVelocity: Vector3;
  73724. /** @hidden */
  73725. _initialPosition: Vector3;
  73726. private _nearestDistance;
  73727. private _collisionMask;
  73728. collisionMask: number;
  73729. /**
  73730. * Gets the plane normal used to compute the sliding response (in local space)
  73731. */
  73732. readonly slidePlaneNormal: Vector3;
  73733. /** @hidden */
  73734. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73735. /** @hidden */
  73736. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73737. /** @hidden */
  73738. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73739. /** @hidden */
  73740. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73741. /** @hidden */
  73742. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73743. /** @hidden */
  73744. _getResponse(pos: Vector3, vel: Vector3): void;
  73745. }
  73746. }
  73747. declare module BABYLON {
  73748. /**
  73749. * Interface for cullable objects
  73750. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73751. */
  73752. export interface ICullable {
  73753. /**
  73754. * Checks if the object or part of the object is in the frustum
  73755. * @param frustumPlanes Camera near/planes
  73756. * @returns true if the object is in frustum otherwise false
  73757. */
  73758. isInFrustum(frustumPlanes: Plane[]): boolean;
  73759. /**
  73760. * Checks if a cullable object (mesh...) is in the camera frustum
  73761. * Unlike isInFrustum this cheks the full bounding box
  73762. * @param frustumPlanes Camera near/planes
  73763. * @returns true if the object is in frustum otherwise false
  73764. */
  73765. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73766. }
  73767. /**
  73768. * Info for a bounding data of a mesh
  73769. */
  73770. export class BoundingInfo implements ICullable {
  73771. /**
  73772. * Bounding box for the mesh
  73773. */
  73774. readonly boundingBox: BoundingBox;
  73775. /**
  73776. * Bounding sphere for the mesh
  73777. */
  73778. readonly boundingSphere: BoundingSphere;
  73779. private _isLocked;
  73780. private static readonly TmpVector3;
  73781. /**
  73782. * Constructs bounding info
  73783. * @param minimum min vector of the bounding box/sphere
  73784. * @param maximum max vector of the bounding box/sphere
  73785. * @param worldMatrix defines the new world matrix
  73786. */
  73787. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73788. /**
  73789. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73790. * @param min defines the new minimum vector (in local space)
  73791. * @param max defines the new maximum vector (in local space)
  73792. * @param worldMatrix defines the new world matrix
  73793. */
  73794. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73795. /**
  73796. * min vector of the bounding box/sphere
  73797. */
  73798. readonly minimum: Vector3;
  73799. /**
  73800. * max vector of the bounding box/sphere
  73801. */
  73802. readonly maximum: Vector3;
  73803. /**
  73804. * If the info is locked and won't be updated to avoid perf overhead
  73805. */
  73806. isLocked: boolean;
  73807. /**
  73808. * Updates the bounding sphere and box
  73809. * @param world world matrix to be used to update
  73810. */
  73811. update(world: DeepImmutable<Matrix>): void;
  73812. /**
  73813. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73814. * @param center New center of the bounding info
  73815. * @param extend New extend of the bounding info
  73816. * @returns the current bounding info
  73817. */
  73818. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73819. /**
  73820. * Scale the current bounding info by applying a scale factor
  73821. * @param factor defines the scale factor to apply
  73822. * @returns the current bounding info
  73823. */
  73824. scale(factor: number): BoundingInfo;
  73825. /**
  73826. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73827. * @param frustumPlanes defines the frustum to test
  73828. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73829. * @returns true if the bounding info is in the frustum planes
  73830. */
  73831. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73832. /**
  73833. * Gets the world distance between the min and max points of the bounding box
  73834. */
  73835. readonly diagonalLength: number;
  73836. /**
  73837. * Checks if a cullable object (mesh...) is in the camera frustum
  73838. * Unlike isInFrustum this cheks the full bounding box
  73839. * @param frustumPlanes Camera near/planes
  73840. * @returns true if the object is in frustum otherwise false
  73841. */
  73842. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73843. /** @hidden */
  73844. _checkCollision(collider: Collider): boolean;
  73845. /**
  73846. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73847. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73848. * @param point the point to check intersection with
  73849. * @returns if the point intersects
  73850. */
  73851. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73852. /**
  73853. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73854. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73855. * @param boundingInfo the bounding info to check intersection with
  73856. * @param precise if the intersection should be done using OBB
  73857. * @returns if the bounding info intersects
  73858. */
  73859. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73860. }
  73861. }
  73862. declare module BABYLON {
  73863. /**
  73864. * Extracts minimum and maximum values from a list of indexed positions
  73865. * @param positions defines the positions to use
  73866. * @param indices defines the indices to the positions
  73867. * @param indexStart defines the start index
  73868. * @param indexCount defines the end index
  73869. * @param bias defines bias value to add to the result
  73870. * @return minimum and maximum values
  73871. */
  73872. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73873. minimum: Vector3;
  73874. maximum: Vector3;
  73875. };
  73876. /**
  73877. * Extracts minimum and maximum values from a list of positions
  73878. * @param positions defines the positions to use
  73879. * @param start defines the start index in the positions array
  73880. * @param count defines the number of positions to handle
  73881. * @param bias defines bias value to add to the result
  73882. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73883. * @return minimum and maximum values
  73884. */
  73885. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73886. minimum: Vector3;
  73887. maximum: Vector3;
  73888. };
  73889. }
  73890. declare module BABYLON {
  73891. /** @hidden */
  73892. export class WebGLDataBuffer extends DataBuffer {
  73893. private _buffer;
  73894. constructor(resource: WebGLBuffer);
  73895. readonly underlyingResource: any;
  73896. }
  73897. }
  73898. declare module BABYLON {
  73899. /** @hidden */
  73900. export class WebGLPipelineContext implements IPipelineContext {
  73901. engine: ThinEngine;
  73902. program: Nullable<WebGLProgram>;
  73903. context?: WebGLRenderingContext;
  73904. vertexShader?: WebGLShader;
  73905. fragmentShader?: WebGLShader;
  73906. isParallelCompiled: boolean;
  73907. onCompiled?: () => void;
  73908. transformFeedback?: WebGLTransformFeedback | null;
  73909. readonly isAsync: boolean;
  73910. readonly isReady: boolean;
  73911. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73912. }
  73913. }
  73914. declare module BABYLON {
  73915. interface ThinEngine {
  73916. /**
  73917. * Create an uniform buffer
  73918. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73919. * @param elements defines the content of the uniform buffer
  73920. * @returns the webGL uniform buffer
  73921. */
  73922. createUniformBuffer(elements: FloatArray): DataBuffer;
  73923. /**
  73924. * Create a dynamic uniform buffer
  73925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73926. * @param elements defines the content of the uniform buffer
  73927. * @returns the webGL uniform buffer
  73928. */
  73929. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73930. /**
  73931. * Update an existing uniform buffer
  73932. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73933. * @param uniformBuffer defines the target uniform buffer
  73934. * @param elements defines the content to update
  73935. * @param offset defines the offset in the uniform buffer where update should start
  73936. * @param count defines the size of the data to update
  73937. */
  73938. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73939. /**
  73940. * Bind an uniform buffer to the current webGL context
  73941. * @param buffer defines the buffer to bind
  73942. */
  73943. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73944. /**
  73945. * Bind a buffer to the current webGL context at a given location
  73946. * @param buffer defines the buffer to bind
  73947. * @param location defines the index where to bind the buffer
  73948. */
  73949. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73950. /**
  73951. * Bind a specific block at a given index in a specific shader program
  73952. * @param pipelineContext defines the pipeline context to use
  73953. * @param blockName defines the block name
  73954. * @param index defines the index where to bind the block
  73955. */
  73956. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73957. }
  73958. }
  73959. declare module BABYLON {
  73960. /**
  73961. * Uniform buffer objects.
  73962. *
  73963. * Handles blocks of uniform on the GPU.
  73964. *
  73965. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73966. *
  73967. * For more information, please refer to :
  73968. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73969. */
  73970. export class UniformBuffer {
  73971. private _engine;
  73972. private _buffer;
  73973. private _data;
  73974. private _bufferData;
  73975. private _dynamic?;
  73976. private _uniformLocations;
  73977. private _uniformSizes;
  73978. private _uniformLocationPointer;
  73979. private _needSync;
  73980. private _noUBO;
  73981. private _currentEffect;
  73982. private static _MAX_UNIFORM_SIZE;
  73983. private static _tempBuffer;
  73984. /**
  73985. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73986. * This is dynamic to allow compat with webgl 1 and 2.
  73987. * You will need to pass the name of the uniform as well as the value.
  73988. */
  73989. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73990. /**
  73991. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73992. * This is dynamic to allow compat with webgl 1 and 2.
  73993. * You will need to pass the name of the uniform as well as the value.
  73994. */
  73995. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73996. /**
  73997. * Lambda to Update a single float in a uniform buffer.
  73998. * This is dynamic to allow compat with webgl 1 and 2.
  73999. * You will need to pass the name of the uniform as well as the value.
  74000. */
  74001. updateFloat: (name: string, x: number) => void;
  74002. /**
  74003. * Lambda to Update a vec2 of float in a uniform buffer.
  74004. * This is dynamic to allow compat with webgl 1 and 2.
  74005. * You will need to pass the name of the uniform as well as the value.
  74006. */
  74007. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74008. /**
  74009. * Lambda to Update a vec3 of float in a uniform buffer.
  74010. * This is dynamic to allow compat with webgl 1 and 2.
  74011. * You will need to pass the name of the uniform as well as the value.
  74012. */
  74013. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74014. /**
  74015. * Lambda to Update a vec4 of float in a uniform buffer.
  74016. * This is dynamic to allow compat with webgl 1 and 2.
  74017. * You will need to pass the name of the uniform as well as the value.
  74018. */
  74019. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74020. /**
  74021. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74022. * This is dynamic to allow compat with webgl 1 and 2.
  74023. * You will need to pass the name of the uniform as well as the value.
  74024. */
  74025. updateMatrix: (name: string, mat: Matrix) => void;
  74026. /**
  74027. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74028. * This is dynamic to allow compat with webgl 1 and 2.
  74029. * You will need to pass the name of the uniform as well as the value.
  74030. */
  74031. updateVector3: (name: string, vector: Vector3) => void;
  74032. /**
  74033. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74034. * This is dynamic to allow compat with webgl 1 and 2.
  74035. * You will need to pass the name of the uniform as well as the value.
  74036. */
  74037. updateVector4: (name: string, vector: Vector4) => void;
  74038. /**
  74039. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74040. * This is dynamic to allow compat with webgl 1 and 2.
  74041. * You will need to pass the name of the uniform as well as the value.
  74042. */
  74043. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74044. /**
  74045. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74046. * This is dynamic to allow compat with webgl 1 and 2.
  74047. * You will need to pass the name of the uniform as well as the value.
  74048. */
  74049. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74050. /**
  74051. * Instantiates a new Uniform buffer objects.
  74052. *
  74053. * Handles blocks of uniform on the GPU.
  74054. *
  74055. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74056. *
  74057. * For more information, please refer to :
  74058. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74059. * @param engine Define the engine the buffer is associated with
  74060. * @param data Define the data contained in the buffer
  74061. * @param dynamic Define if the buffer is updatable
  74062. */
  74063. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74064. /**
  74065. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74066. * or just falling back on setUniformXXX calls.
  74067. */
  74068. readonly useUbo: boolean;
  74069. /**
  74070. * Indicates if the WebGL underlying uniform buffer is in sync
  74071. * with the javascript cache data.
  74072. */
  74073. readonly isSync: boolean;
  74074. /**
  74075. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74076. * Also, a dynamic UniformBuffer will disable cache verification and always
  74077. * update the underlying WebGL uniform buffer to the GPU.
  74078. * @returns if Dynamic, otherwise false
  74079. */
  74080. isDynamic(): boolean;
  74081. /**
  74082. * The data cache on JS side.
  74083. * @returns the underlying data as a float array
  74084. */
  74085. getData(): Float32Array;
  74086. /**
  74087. * The underlying WebGL Uniform buffer.
  74088. * @returns the webgl buffer
  74089. */
  74090. getBuffer(): Nullable<DataBuffer>;
  74091. /**
  74092. * std140 layout specifies how to align data within an UBO structure.
  74093. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74094. * for specs.
  74095. */
  74096. private _fillAlignment;
  74097. /**
  74098. * Adds an uniform in the buffer.
  74099. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74100. * for the layout to be correct !
  74101. * @param name Name of the uniform, as used in the uniform block in the shader.
  74102. * @param size Data size, or data directly.
  74103. */
  74104. addUniform(name: string, size: number | number[]): void;
  74105. /**
  74106. * Adds a Matrix 4x4 to the uniform buffer.
  74107. * @param name Name of the uniform, as used in the uniform block in the shader.
  74108. * @param mat A 4x4 matrix.
  74109. */
  74110. addMatrix(name: string, mat: Matrix): void;
  74111. /**
  74112. * Adds a vec2 to the uniform buffer.
  74113. * @param name Name of the uniform, as used in the uniform block in the shader.
  74114. * @param x Define the x component value of the vec2
  74115. * @param y Define the y component value of the vec2
  74116. */
  74117. addFloat2(name: string, x: number, y: number): void;
  74118. /**
  74119. * Adds a vec3 to the uniform buffer.
  74120. * @param name Name of the uniform, as used in the uniform block in the shader.
  74121. * @param x Define the x component value of the vec3
  74122. * @param y Define the y component value of the vec3
  74123. * @param z Define the z component value of the vec3
  74124. */
  74125. addFloat3(name: string, x: number, y: number, z: number): void;
  74126. /**
  74127. * Adds a vec3 to the uniform buffer.
  74128. * @param name Name of the uniform, as used in the uniform block in the shader.
  74129. * @param color Define the vec3 from a Color
  74130. */
  74131. addColor3(name: string, color: Color3): void;
  74132. /**
  74133. * Adds a vec4 to the uniform buffer.
  74134. * @param name Name of the uniform, as used in the uniform block in the shader.
  74135. * @param color Define the rgb components from a Color
  74136. * @param alpha Define the a component of the vec4
  74137. */
  74138. addColor4(name: string, color: Color3, alpha: number): void;
  74139. /**
  74140. * Adds a vec3 to the uniform buffer.
  74141. * @param name Name of the uniform, as used in the uniform block in the shader.
  74142. * @param vector Define the vec3 components from a Vector
  74143. */
  74144. addVector3(name: string, vector: Vector3): void;
  74145. /**
  74146. * Adds a Matrix 3x3 to the uniform buffer.
  74147. * @param name Name of the uniform, as used in the uniform block in the shader.
  74148. */
  74149. addMatrix3x3(name: string): void;
  74150. /**
  74151. * Adds a Matrix 2x2 to the uniform buffer.
  74152. * @param name Name of the uniform, as used in the uniform block in the shader.
  74153. */
  74154. addMatrix2x2(name: string): void;
  74155. /**
  74156. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74157. */
  74158. create(): void;
  74159. /** @hidden */
  74160. _rebuild(): void;
  74161. /**
  74162. * Updates the WebGL Uniform Buffer on the GPU.
  74163. * If the `dynamic` flag is set to true, no cache comparison is done.
  74164. * Otherwise, the buffer will be updated only if the cache differs.
  74165. */
  74166. update(): void;
  74167. /**
  74168. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74169. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74170. * @param data Define the flattened data
  74171. * @param size Define the size of the data.
  74172. */
  74173. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74174. private _valueCache;
  74175. private _cacheMatrix;
  74176. private _updateMatrix3x3ForUniform;
  74177. private _updateMatrix3x3ForEffect;
  74178. private _updateMatrix2x2ForEffect;
  74179. private _updateMatrix2x2ForUniform;
  74180. private _updateFloatForEffect;
  74181. private _updateFloatForUniform;
  74182. private _updateFloat2ForEffect;
  74183. private _updateFloat2ForUniform;
  74184. private _updateFloat3ForEffect;
  74185. private _updateFloat3ForUniform;
  74186. private _updateFloat4ForEffect;
  74187. private _updateFloat4ForUniform;
  74188. private _updateMatrixForEffect;
  74189. private _updateMatrixForUniform;
  74190. private _updateVector3ForEffect;
  74191. private _updateVector3ForUniform;
  74192. private _updateVector4ForEffect;
  74193. private _updateVector4ForUniform;
  74194. private _updateColor3ForEffect;
  74195. private _updateColor3ForUniform;
  74196. private _updateColor4ForEffect;
  74197. private _updateColor4ForUniform;
  74198. /**
  74199. * Sets a sampler uniform on the effect.
  74200. * @param name Define the name of the sampler.
  74201. * @param texture Define the texture to set in the sampler
  74202. */
  74203. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74204. /**
  74205. * Directly updates the value of the uniform in the cache AND on the GPU.
  74206. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74207. * @param data Define the flattened data
  74208. */
  74209. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74210. /**
  74211. * Binds this uniform buffer to an effect.
  74212. * @param effect Define the effect to bind the buffer to
  74213. * @param name Name of the uniform block in the shader.
  74214. */
  74215. bindToEffect(effect: Effect, name: string): void;
  74216. /**
  74217. * Disposes the uniform buffer.
  74218. */
  74219. dispose(): void;
  74220. }
  74221. }
  74222. declare module BABYLON {
  74223. /**
  74224. * Enum that determines the text-wrapping mode to use.
  74225. */
  74226. export enum InspectableType {
  74227. /**
  74228. * Checkbox for booleans
  74229. */
  74230. Checkbox = 0,
  74231. /**
  74232. * Sliders for numbers
  74233. */
  74234. Slider = 1,
  74235. /**
  74236. * Vector3
  74237. */
  74238. Vector3 = 2,
  74239. /**
  74240. * Quaternions
  74241. */
  74242. Quaternion = 3,
  74243. /**
  74244. * Color3
  74245. */
  74246. Color3 = 4,
  74247. /**
  74248. * String
  74249. */
  74250. String = 5
  74251. }
  74252. /**
  74253. * Interface used to define custom inspectable properties.
  74254. * This interface is used by the inspector to display custom property grids
  74255. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74256. */
  74257. export interface IInspectable {
  74258. /**
  74259. * Gets the label to display
  74260. */
  74261. label: string;
  74262. /**
  74263. * Gets the name of the property to edit
  74264. */
  74265. propertyName: string;
  74266. /**
  74267. * Gets the type of the editor to use
  74268. */
  74269. type: InspectableType;
  74270. /**
  74271. * Gets the minimum value of the property when using in "slider" mode
  74272. */
  74273. min?: number;
  74274. /**
  74275. * Gets the maximum value of the property when using in "slider" mode
  74276. */
  74277. max?: number;
  74278. /**
  74279. * Gets the setp to use when using in "slider" mode
  74280. */
  74281. step?: number;
  74282. }
  74283. }
  74284. declare module BABYLON {
  74285. /**
  74286. * Class used to provide helper for timing
  74287. */
  74288. export class TimingTools {
  74289. /**
  74290. * Polyfill for setImmediate
  74291. * @param action defines the action to execute after the current execution block
  74292. */
  74293. static SetImmediate(action: () => void): void;
  74294. }
  74295. }
  74296. declare module BABYLON {
  74297. /**
  74298. * Class used to enable instatition of objects by class name
  74299. */
  74300. export class InstantiationTools {
  74301. /**
  74302. * Use this object to register external classes like custom textures or material
  74303. * to allow the laoders to instantiate them
  74304. */
  74305. static RegisteredExternalClasses: {
  74306. [key: string]: Object;
  74307. };
  74308. /**
  74309. * Tries to instantiate a new object from a given class name
  74310. * @param className defines the class name to instantiate
  74311. * @returns the new object or null if the system was not able to do the instantiation
  74312. */
  74313. static Instantiate(className: string): any;
  74314. }
  74315. }
  74316. declare module BABYLON {
  74317. /**
  74318. * Define options used to create a depth texture
  74319. */
  74320. export class DepthTextureCreationOptions {
  74321. /** Specifies whether or not a stencil should be allocated in the texture */
  74322. generateStencil?: boolean;
  74323. /** Specifies whether or not bilinear filtering is enable on the texture */
  74324. bilinearFiltering?: boolean;
  74325. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74326. comparisonFunction?: number;
  74327. /** Specifies if the created texture is a cube texture */
  74328. isCube?: boolean;
  74329. }
  74330. }
  74331. declare module BABYLON {
  74332. interface ThinEngine {
  74333. /**
  74334. * Creates a depth stencil cube texture.
  74335. * This is only available in WebGL 2.
  74336. * @param size The size of face edge in the cube texture.
  74337. * @param options The options defining the cube texture.
  74338. * @returns The cube texture
  74339. */
  74340. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74341. /**
  74342. * Creates a cube texture
  74343. * @param rootUrl defines the url where the files to load is located
  74344. * @param scene defines the current scene
  74345. * @param files defines the list of files to load (1 per face)
  74346. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74347. * @param onLoad defines an optional callback raised when the texture is loaded
  74348. * @param onError defines an optional callback raised if there is an issue to load the texture
  74349. * @param format defines the format of the data
  74350. * @param forcedExtension defines the extension to use to pick the right loader
  74351. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74352. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74353. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74354. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74355. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74356. * @returns the cube texture as an InternalTexture
  74357. */
  74358. 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;
  74359. /**
  74360. * Creates a cube texture
  74361. * @param rootUrl defines the url where the files to load is located
  74362. * @param scene defines the current scene
  74363. * @param files defines the list of files to load (1 per face)
  74364. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74365. * @param onLoad defines an optional callback raised when the texture is loaded
  74366. * @param onError defines an optional callback raised if there is an issue to load the texture
  74367. * @param format defines the format of the data
  74368. * @param forcedExtension defines the extension to use to pick the right loader
  74369. * @returns the cube texture as an InternalTexture
  74370. */
  74371. 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;
  74372. /**
  74373. * Creates a cube texture
  74374. * @param rootUrl defines the url where the files to load is located
  74375. * @param scene defines the current scene
  74376. * @param files defines the list of files to load (1 per face)
  74377. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74378. * @param onLoad defines an optional callback raised when the texture is loaded
  74379. * @param onError defines an optional callback raised if there is an issue to load the texture
  74380. * @param format defines the format of the data
  74381. * @param forcedExtension defines the extension to use to pick the right loader
  74382. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74383. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74384. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74385. * @returns the cube texture as an InternalTexture
  74386. */
  74387. 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;
  74388. /** @hidden */
  74389. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74390. /** @hidden */
  74391. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74392. /** @hidden */
  74393. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74394. /** @hidden */
  74395. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74396. }
  74397. }
  74398. declare module BABYLON {
  74399. /**
  74400. * Class for creating a cube texture
  74401. */
  74402. export class CubeTexture extends BaseTexture {
  74403. private _delayedOnLoad;
  74404. /**
  74405. * The url of the texture
  74406. */
  74407. url: string;
  74408. /**
  74409. * Gets or sets the center of the bounding box associated with the cube texture.
  74410. * It must define where the camera used to render the texture was set
  74411. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74412. */
  74413. boundingBoxPosition: Vector3;
  74414. private _boundingBoxSize;
  74415. /**
  74416. * Gets or sets the size of the bounding box associated with the cube texture
  74417. * When defined, the cubemap will switch to local mode
  74418. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74419. * @example https://www.babylonjs-playground.com/#RNASML
  74420. */
  74421. /**
  74422. * Returns the bounding box size
  74423. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74424. */
  74425. boundingBoxSize: Vector3;
  74426. protected _rotationY: number;
  74427. /**
  74428. * Sets texture matrix rotation angle around Y axis in radians.
  74429. */
  74430. /**
  74431. * Gets texture matrix rotation angle around Y axis radians.
  74432. */
  74433. rotationY: number;
  74434. /**
  74435. * Are mip maps generated for this texture or not.
  74436. */
  74437. readonly noMipmap: boolean;
  74438. private _noMipmap;
  74439. private _files;
  74440. protected _forcedExtension: Nullable<string>;
  74441. private _extensions;
  74442. private _textureMatrix;
  74443. private _format;
  74444. private _createPolynomials;
  74445. /** @hidden */
  74446. _prefiltered: boolean;
  74447. /**
  74448. * Creates a cube texture from an array of image urls
  74449. * @param files defines an array of image urls
  74450. * @param scene defines the hosting scene
  74451. * @param noMipmap specifies if mip maps are not used
  74452. * @returns a cube texture
  74453. */
  74454. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74455. /**
  74456. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74457. * @param url defines the url of the prefiltered texture
  74458. * @param scene defines the scene the texture is attached to
  74459. * @param forcedExtension defines the extension of the file if different from the url
  74460. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74461. * @return the prefiltered texture
  74462. */
  74463. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74464. /**
  74465. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74466. * as prefiltered data.
  74467. * @param rootUrl defines the url of the texture or the root name of the six images
  74468. * @param scene defines the scene the texture is attached to
  74469. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74470. * @param noMipmap defines if mipmaps should be created or not
  74471. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74472. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74473. * @param onError defines a callback triggered in case of error during load
  74474. * @param format defines the internal format to use for the texture once loaded
  74475. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74476. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74477. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74478. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74479. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74480. * @return the cube texture
  74481. */
  74482. 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);
  74483. /**
  74484. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74485. */
  74486. readonly isPrefiltered: boolean;
  74487. /**
  74488. * Get the current class name of the texture useful for serialization or dynamic coding.
  74489. * @returns "CubeTexture"
  74490. */
  74491. getClassName(): string;
  74492. /**
  74493. * Update the url (and optional buffer) of this texture if url was null during construction.
  74494. * @param url the url of the texture
  74495. * @param forcedExtension defines the extension to use
  74496. * @param onLoad callback called when the texture is loaded (defaults to null)
  74497. */
  74498. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74499. /**
  74500. * Delays loading of the cube texture
  74501. * @param forcedExtension defines the extension to use
  74502. */
  74503. delayLoad(forcedExtension?: string): void;
  74504. /**
  74505. * Returns the reflection texture matrix
  74506. * @returns the reflection texture matrix
  74507. */
  74508. getReflectionTextureMatrix(): Matrix;
  74509. /**
  74510. * Sets the reflection texture matrix
  74511. * @param value Reflection texture matrix
  74512. */
  74513. setReflectionTextureMatrix(value: Matrix): void;
  74514. /**
  74515. * Parses text to create a cube texture
  74516. * @param parsedTexture define the serialized text to read from
  74517. * @param scene defines the hosting scene
  74518. * @param rootUrl defines the root url of the cube texture
  74519. * @returns a cube texture
  74520. */
  74521. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74522. /**
  74523. * Makes a clone, or deep copy, of the cube texture
  74524. * @returns a new cube texture
  74525. */
  74526. clone(): CubeTexture;
  74527. }
  74528. }
  74529. declare module BABYLON {
  74530. /**
  74531. * Manages the defines for the Material
  74532. */
  74533. export class MaterialDefines {
  74534. /** @hidden */
  74535. protected _keys: string[];
  74536. private _isDirty;
  74537. /** @hidden */
  74538. _renderId: number;
  74539. /** @hidden */
  74540. _areLightsDirty: boolean;
  74541. /** @hidden */
  74542. _areLightsDisposed: boolean;
  74543. /** @hidden */
  74544. _areAttributesDirty: boolean;
  74545. /** @hidden */
  74546. _areTexturesDirty: boolean;
  74547. /** @hidden */
  74548. _areFresnelDirty: boolean;
  74549. /** @hidden */
  74550. _areMiscDirty: boolean;
  74551. /** @hidden */
  74552. _areImageProcessingDirty: boolean;
  74553. /** @hidden */
  74554. _normals: boolean;
  74555. /** @hidden */
  74556. _uvs: boolean;
  74557. /** @hidden */
  74558. _needNormals: boolean;
  74559. /** @hidden */
  74560. _needUVs: boolean;
  74561. [id: string]: any;
  74562. /**
  74563. * Specifies if the material needs to be re-calculated
  74564. */
  74565. readonly isDirty: boolean;
  74566. /**
  74567. * Marks the material to indicate that it has been re-calculated
  74568. */
  74569. markAsProcessed(): void;
  74570. /**
  74571. * Marks the material to indicate that it needs to be re-calculated
  74572. */
  74573. markAsUnprocessed(): void;
  74574. /**
  74575. * Marks the material to indicate all of its defines need to be re-calculated
  74576. */
  74577. markAllAsDirty(): void;
  74578. /**
  74579. * Marks the material to indicate that image processing needs to be re-calculated
  74580. */
  74581. markAsImageProcessingDirty(): void;
  74582. /**
  74583. * Marks the material to indicate the lights need to be re-calculated
  74584. * @param disposed Defines whether the light is dirty due to dispose or not
  74585. */
  74586. markAsLightDirty(disposed?: boolean): void;
  74587. /**
  74588. * Marks the attribute state as changed
  74589. */
  74590. markAsAttributesDirty(): void;
  74591. /**
  74592. * Marks the texture state as changed
  74593. */
  74594. markAsTexturesDirty(): void;
  74595. /**
  74596. * Marks the fresnel state as changed
  74597. */
  74598. markAsFresnelDirty(): void;
  74599. /**
  74600. * Marks the misc state as changed
  74601. */
  74602. markAsMiscDirty(): void;
  74603. /**
  74604. * Rebuilds the material defines
  74605. */
  74606. rebuild(): void;
  74607. /**
  74608. * Specifies if two material defines are equal
  74609. * @param other - A material define instance to compare to
  74610. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74611. */
  74612. isEqual(other: MaterialDefines): boolean;
  74613. /**
  74614. * Clones this instance's defines to another instance
  74615. * @param other - material defines to clone values to
  74616. */
  74617. cloneTo(other: MaterialDefines): void;
  74618. /**
  74619. * Resets the material define values
  74620. */
  74621. reset(): void;
  74622. /**
  74623. * Converts the material define values to a string
  74624. * @returns - String of material define information
  74625. */
  74626. toString(): string;
  74627. }
  74628. }
  74629. declare module BABYLON {
  74630. /**
  74631. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74632. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74633. * 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;
  74634. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74635. */
  74636. export class ColorCurves {
  74637. private _dirty;
  74638. private _tempColor;
  74639. private _globalCurve;
  74640. private _highlightsCurve;
  74641. private _midtonesCurve;
  74642. private _shadowsCurve;
  74643. private _positiveCurve;
  74644. private _negativeCurve;
  74645. private _globalHue;
  74646. private _globalDensity;
  74647. private _globalSaturation;
  74648. private _globalExposure;
  74649. /**
  74650. * Gets the global Hue value.
  74651. * 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).
  74652. */
  74653. /**
  74654. * Sets the global Hue value.
  74655. * 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).
  74656. */
  74657. globalHue: number;
  74658. /**
  74659. * Gets the global Density value.
  74660. * 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.
  74661. * Values less than zero provide a filter of opposite hue.
  74662. */
  74663. /**
  74664. * Sets the global Density value.
  74665. * 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.
  74666. * Values less than zero provide a filter of opposite hue.
  74667. */
  74668. globalDensity: number;
  74669. /**
  74670. * Gets the global Saturation value.
  74671. * 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.
  74672. */
  74673. /**
  74674. * Sets the global Saturation value.
  74675. * 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.
  74676. */
  74677. globalSaturation: number;
  74678. /**
  74679. * Gets the global Exposure value.
  74680. * 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.
  74681. */
  74682. /**
  74683. * Sets the global Exposure value.
  74684. * 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.
  74685. */
  74686. globalExposure: number;
  74687. private _highlightsHue;
  74688. private _highlightsDensity;
  74689. private _highlightsSaturation;
  74690. private _highlightsExposure;
  74691. /**
  74692. * Gets the highlights Hue value.
  74693. * 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).
  74694. */
  74695. /**
  74696. * Sets the highlights Hue value.
  74697. * 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).
  74698. */
  74699. highlightsHue: number;
  74700. /**
  74701. * Gets the highlights Density value.
  74702. * 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.
  74703. * Values less than zero provide a filter of opposite hue.
  74704. */
  74705. /**
  74706. * Sets the highlights Density value.
  74707. * 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.
  74708. * Values less than zero provide a filter of opposite hue.
  74709. */
  74710. highlightsDensity: number;
  74711. /**
  74712. * Gets the highlights Saturation value.
  74713. * 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.
  74714. */
  74715. /**
  74716. * Sets the highlights Saturation value.
  74717. * 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.
  74718. */
  74719. highlightsSaturation: number;
  74720. /**
  74721. * Gets the highlights Exposure value.
  74722. * 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.
  74723. */
  74724. /**
  74725. * Sets the highlights Exposure value.
  74726. * 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.
  74727. */
  74728. highlightsExposure: number;
  74729. private _midtonesHue;
  74730. private _midtonesDensity;
  74731. private _midtonesSaturation;
  74732. private _midtonesExposure;
  74733. /**
  74734. * Gets the midtones Hue value.
  74735. * 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).
  74736. */
  74737. /**
  74738. * Sets the midtones Hue value.
  74739. * 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).
  74740. */
  74741. midtonesHue: number;
  74742. /**
  74743. * Gets the midtones Density value.
  74744. * 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.
  74745. * Values less than zero provide a filter of opposite hue.
  74746. */
  74747. /**
  74748. * Sets the midtones Density value.
  74749. * 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.
  74750. * Values less than zero provide a filter of opposite hue.
  74751. */
  74752. midtonesDensity: number;
  74753. /**
  74754. * Gets the midtones Saturation value.
  74755. * 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.
  74756. */
  74757. /**
  74758. * Sets the midtones Saturation value.
  74759. * 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.
  74760. */
  74761. midtonesSaturation: number;
  74762. /**
  74763. * Gets the midtones Exposure value.
  74764. * 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.
  74765. */
  74766. /**
  74767. * Sets the midtones Exposure value.
  74768. * 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.
  74769. */
  74770. midtonesExposure: number;
  74771. private _shadowsHue;
  74772. private _shadowsDensity;
  74773. private _shadowsSaturation;
  74774. private _shadowsExposure;
  74775. /**
  74776. * Gets the shadows Hue value.
  74777. * 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).
  74778. */
  74779. /**
  74780. * Sets the shadows Hue value.
  74781. * 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).
  74782. */
  74783. shadowsHue: number;
  74784. /**
  74785. * Gets the shadows Density value.
  74786. * 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.
  74787. * Values less than zero provide a filter of opposite hue.
  74788. */
  74789. /**
  74790. * Sets the shadows Density value.
  74791. * 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.
  74792. * Values less than zero provide a filter of opposite hue.
  74793. */
  74794. shadowsDensity: number;
  74795. /**
  74796. * Gets the shadows Saturation value.
  74797. * 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.
  74798. */
  74799. /**
  74800. * Sets the shadows Saturation value.
  74801. * 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.
  74802. */
  74803. shadowsSaturation: number;
  74804. /**
  74805. * Gets the shadows Exposure value.
  74806. * 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.
  74807. */
  74808. /**
  74809. * Sets the shadows Exposure value.
  74810. * 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.
  74811. */
  74812. shadowsExposure: number;
  74813. /**
  74814. * Returns the class name
  74815. * @returns The class name
  74816. */
  74817. getClassName(): string;
  74818. /**
  74819. * Binds the color curves to the shader.
  74820. * @param colorCurves The color curve to bind
  74821. * @param effect The effect to bind to
  74822. * @param positiveUniform The positive uniform shader parameter
  74823. * @param neutralUniform The neutral uniform shader parameter
  74824. * @param negativeUniform The negative uniform shader parameter
  74825. */
  74826. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74827. /**
  74828. * Prepare the list of uniforms associated with the ColorCurves effects.
  74829. * @param uniformsList The list of uniforms used in the effect
  74830. */
  74831. static PrepareUniforms(uniformsList: string[]): void;
  74832. /**
  74833. * Returns color grading data based on a hue, density, saturation and exposure value.
  74834. * @param filterHue The hue of the color filter.
  74835. * @param filterDensity The density of the color filter.
  74836. * @param saturation The saturation.
  74837. * @param exposure The exposure.
  74838. * @param result The result data container.
  74839. */
  74840. private getColorGradingDataToRef;
  74841. /**
  74842. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74843. * @param value The input slider value in range [-100,100].
  74844. * @returns Adjusted value.
  74845. */
  74846. private static applyColorGradingSliderNonlinear;
  74847. /**
  74848. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74849. * @param hue The hue (H) input.
  74850. * @param saturation The saturation (S) input.
  74851. * @param brightness The brightness (B) input.
  74852. * @result An RGBA color represented as Vector4.
  74853. */
  74854. private static fromHSBToRef;
  74855. /**
  74856. * Returns a value clamped between min and max
  74857. * @param value The value to clamp
  74858. * @param min The minimum of value
  74859. * @param max The maximum of value
  74860. * @returns The clamped value.
  74861. */
  74862. private static clamp;
  74863. /**
  74864. * Clones the current color curve instance.
  74865. * @return The cloned curves
  74866. */
  74867. clone(): ColorCurves;
  74868. /**
  74869. * Serializes the current color curve instance to a json representation.
  74870. * @return a JSON representation
  74871. */
  74872. serialize(): any;
  74873. /**
  74874. * Parses the color curve from a json representation.
  74875. * @param source the JSON source to parse
  74876. * @return The parsed curves
  74877. */
  74878. static Parse(source: any): ColorCurves;
  74879. }
  74880. }
  74881. declare module BABYLON {
  74882. /**
  74883. * Interface to follow in your material defines to integrate easily the
  74884. * Image proccessing functions.
  74885. * @hidden
  74886. */
  74887. export interface IImageProcessingConfigurationDefines {
  74888. IMAGEPROCESSING: boolean;
  74889. VIGNETTE: boolean;
  74890. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74891. VIGNETTEBLENDMODEOPAQUE: boolean;
  74892. TONEMAPPING: boolean;
  74893. TONEMAPPING_ACES: boolean;
  74894. CONTRAST: boolean;
  74895. EXPOSURE: boolean;
  74896. COLORCURVES: boolean;
  74897. COLORGRADING: boolean;
  74898. COLORGRADING3D: boolean;
  74899. SAMPLER3DGREENDEPTH: boolean;
  74900. SAMPLER3DBGRMAP: boolean;
  74901. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74902. }
  74903. /**
  74904. * @hidden
  74905. */
  74906. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74907. IMAGEPROCESSING: boolean;
  74908. VIGNETTE: boolean;
  74909. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74910. VIGNETTEBLENDMODEOPAQUE: boolean;
  74911. TONEMAPPING: boolean;
  74912. TONEMAPPING_ACES: boolean;
  74913. CONTRAST: boolean;
  74914. COLORCURVES: boolean;
  74915. COLORGRADING: boolean;
  74916. COLORGRADING3D: boolean;
  74917. SAMPLER3DGREENDEPTH: boolean;
  74918. SAMPLER3DBGRMAP: boolean;
  74919. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74920. EXPOSURE: boolean;
  74921. constructor();
  74922. }
  74923. /**
  74924. * This groups together the common properties used for image processing either in direct forward pass
  74925. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74926. * or not.
  74927. */
  74928. export class ImageProcessingConfiguration {
  74929. /**
  74930. * Default tone mapping applied in BabylonJS.
  74931. */
  74932. static readonly TONEMAPPING_STANDARD: number;
  74933. /**
  74934. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74935. * to other engines rendering to increase portability.
  74936. */
  74937. static readonly TONEMAPPING_ACES: number;
  74938. /**
  74939. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74940. */
  74941. colorCurves: Nullable<ColorCurves>;
  74942. private _colorCurvesEnabled;
  74943. /**
  74944. * Gets wether the color curves effect is enabled.
  74945. */
  74946. /**
  74947. * Sets wether the color curves effect is enabled.
  74948. */
  74949. colorCurvesEnabled: boolean;
  74950. private _colorGradingTexture;
  74951. /**
  74952. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74953. */
  74954. /**
  74955. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74956. */
  74957. colorGradingTexture: Nullable<BaseTexture>;
  74958. private _colorGradingEnabled;
  74959. /**
  74960. * Gets wether the color grading effect is enabled.
  74961. */
  74962. /**
  74963. * Sets wether the color grading effect is enabled.
  74964. */
  74965. colorGradingEnabled: boolean;
  74966. private _colorGradingWithGreenDepth;
  74967. /**
  74968. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74969. */
  74970. /**
  74971. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74972. */
  74973. colorGradingWithGreenDepth: boolean;
  74974. private _colorGradingBGR;
  74975. /**
  74976. * Gets wether the color grading texture contains BGR values.
  74977. */
  74978. /**
  74979. * Sets wether the color grading texture contains BGR values.
  74980. */
  74981. colorGradingBGR: boolean;
  74982. /** @hidden */
  74983. _exposure: number;
  74984. /**
  74985. * Gets the Exposure used in the effect.
  74986. */
  74987. /**
  74988. * Sets the Exposure used in the effect.
  74989. */
  74990. exposure: number;
  74991. private _toneMappingEnabled;
  74992. /**
  74993. * Gets wether the tone mapping effect is enabled.
  74994. */
  74995. /**
  74996. * Sets wether the tone mapping effect is enabled.
  74997. */
  74998. toneMappingEnabled: boolean;
  74999. private _toneMappingType;
  75000. /**
  75001. * Gets the type of tone mapping effect.
  75002. */
  75003. /**
  75004. * Sets the type of tone mapping effect used in BabylonJS.
  75005. */
  75006. toneMappingType: number;
  75007. protected _contrast: number;
  75008. /**
  75009. * Gets the contrast used in the effect.
  75010. */
  75011. /**
  75012. * Sets the contrast used in the effect.
  75013. */
  75014. contrast: number;
  75015. /**
  75016. * Vignette stretch size.
  75017. */
  75018. vignetteStretch: number;
  75019. /**
  75020. * Vignette centre X Offset.
  75021. */
  75022. vignetteCentreX: number;
  75023. /**
  75024. * Vignette centre Y Offset.
  75025. */
  75026. vignetteCentreY: number;
  75027. /**
  75028. * Vignette weight or intensity of the vignette effect.
  75029. */
  75030. vignetteWeight: number;
  75031. /**
  75032. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75033. * if vignetteEnabled is set to true.
  75034. */
  75035. vignetteColor: Color4;
  75036. /**
  75037. * Camera field of view used by the Vignette effect.
  75038. */
  75039. vignetteCameraFov: number;
  75040. private _vignetteBlendMode;
  75041. /**
  75042. * Gets the vignette blend mode allowing different kind of effect.
  75043. */
  75044. /**
  75045. * Sets the vignette blend mode allowing different kind of effect.
  75046. */
  75047. vignetteBlendMode: number;
  75048. private _vignetteEnabled;
  75049. /**
  75050. * Gets wether the vignette effect is enabled.
  75051. */
  75052. /**
  75053. * Sets wether the vignette effect is enabled.
  75054. */
  75055. vignetteEnabled: boolean;
  75056. private _applyByPostProcess;
  75057. /**
  75058. * Gets wether the image processing is applied through a post process or not.
  75059. */
  75060. /**
  75061. * Sets wether the image processing is applied through a post process or not.
  75062. */
  75063. applyByPostProcess: boolean;
  75064. private _isEnabled;
  75065. /**
  75066. * Gets wether the image processing is enabled or not.
  75067. */
  75068. /**
  75069. * Sets wether the image processing is enabled or not.
  75070. */
  75071. isEnabled: boolean;
  75072. /**
  75073. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75074. */
  75075. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75076. /**
  75077. * Method called each time the image processing information changes requires to recompile the effect.
  75078. */
  75079. protected _updateParameters(): void;
  75080. /**
  75081. * Gets the current class name.
  75082. * @return "ImageProcessingConfiguration"
  75083. */
  75084. getClassName(): string;
  75085. /**
  75086. * Prepare the list of uniforms associated with the Image Processing effects.
  75087. * @param uniforms The list of uniforms used in the effect
  75088. * @param defines the list of defines currently in use
  75089. */
  75090. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75091. /**
  75092. * Prepare the list of samplers associated with the Image Processing effects.
  75093. * @param samplersList The list of uniforms used in the effect
  75094. * @param defines the list of defines currently in use
  75095. */
  75096. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75097. /**
  75098. * Prepare the list of defines associated to the shader.
  75099. * @param defines the list of defines to complete
  75100. * @param forPostProcess Define if we are currently in post process mode or not
  75101. */
  75102. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75103. /**
  75104. * Returns true if all the image processing information are ready.
  75105. * @returns True if ready, otherwise, false
  75106. */
  75107. isReady(): boolean;
  75108. /**
  75109. * Binds the image processing to the shader.
  75110. * @param effect The effect to bind to
  75111. * @param aspectRatio Define the current aspect ratio of the effect
  75112. */
  75113. bind(effect: Effect, aspectRatio?: number): void;
  75114. /**
  75115. * Clones the current image processing instance.
  75116. * @return The cloned image processing
  75117. */
  75118. clone(): ImageProcessingConfiguration;
  75119. /**
  75120. * Serializes the current image processing instance to a json representation.
  75121. * @return a JSON representation
  75122. */
  75123. serialize(): any;
  75124. /**
  75125. * Parses the image processing from a json representation.
  75126. * @param source the JSON source to parse
  75127. * @return The parsed image processing
  75128. */
  75129. static Parse(source: any): ImageProcessingConfiguration;
  75130. private static _VIGNETTEMODE_MULTIPLY;
  75131. private static _VIGNETTEMODE_OPAQUE;
  75132. /**
  75133. * Used to apply the vignette as a mix with the pixel color.
  75134. */
  75135. static readonly VIGNETTEMODE_MULTIPLY: number;
  75136. /**
  75137. * Used to apply the vignette as a replacement of the pixel color.
  75138. */
  75139. static readonly VIGNETTEMODE_OPAQUE: number;
  75140. }
  75141. }
  75142. declare module BABYLON {
  75143. /** @hidden */
  75144. export var postprocessVertexShader: {
  75145. name: string;
  75146. shader: string;
  75147. };
  75148. }
  75149. declare module BABYLON {
  75150. interface ThinEngine {
  75151. /**
  75152. * Creates a new render target texture
  75153. * @param size defines the size of the texture
  75154. * @param options defines the options used to create the texture
  75155. * @returns a new render target texture stored in an InternalTexture
  75156. */
  75157. createRenderTargetTexture(size: number | {
  75158. width: number;
  75159. height: number;
  75160. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75161. }
  75162. }
  75163. declare module BABYLON {
  75164. /** Defines supported spaces */
  75165. export enum Space {
  75166. /** Local (object) space */
  75167. LOCAL = 0,
  75168. /** World space */
  75169. WORLD = 1,
  75170. /** Bone space */
  75171. BONE = 2
  75172. }
  75173. /** Defines the 3 main axes */
  75174. export class Axis {
  75175. /** X axis */
  75176. static X: Vector3;
  75177. /** Y axis */
  75178. static Y: Vector3;
  75179. /** Z axis */
  75180. static Z: Vector3;
  75181. }
  75182. }
  75183. declare module BABYLON {
  75184. /**
  75185. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75186. * This is the base of the follow, arc rotate cameras and Free camera
  75187. * @see http://doc.babylonjs.com/features/cameras
  75188. */
  75189. export class TargetCamera extends Camera {
  75190. private static _RigCamTransformMatrix;
  75191. private static _TargetTransformMatrix;
  75192. private static _TargetFocalPoint;
  75193. /**
  75194. * Define the current direction the camera is moving to
  75195. */
  75196. cameraDirection: Vector3;
  75197. /**
  75198. * Define the current rotation the camera is rotating to
  75199. */
  75200. cameraRotation: Vector2;
  75201. /**
  75202. * When set, the up vector of the camera will be updated by the rotation of the camera
  75203. */
  75204. updateUpVectorFromRotation: boolean;
  75205. private _tmpQuaternion;
  75206. /**
  75207. * Define the current rotation of the camera
  75208. */
  75209. rotation: Vector3;
  75210. /**
  75211. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75212. */
  75213. rotationQuaternion: Quaternion;
  75214. /**
  75215. * Define the current speed of the camera
  75216. */
  75217. speed: number;
  75218. /**
  75219. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75220. * around all axis.
  75221. */
  75222. noRotationConstraint: boolean;
  75223. /**
  75224. * Define the current target of the camera as an object or a position.
  75225. */
  75226. lockedTarget: any;
  75227. /** @hidden */
  75228. _currentTarget: Vector3;
  75229. /** @hidden */
  75230. _initialFocalDistance: number;
  75231. /** @hidden */
  75232. _viewMatrix: Matrix;
  75233. /** @hidden */
  75234. _camMatrix: Matrix;
  75235. /** @hidden */
  75236. _cameraTransformMatrix: Matrix;
  75237. /** @hidden */
  75238. _cameraRotationMatrix: Matrix;
  75239. /** @hidden */
  75240. _referencePoint: Vector3;
  75241. /** @hidden */
  75242. _transformedReferencePoint: Vector3;
  75243. protected _globalCurrentTarget: Vector3;
  75244. protected _globalCurrentUpVector: Vector3;
  75245. /** @hidden */
  75246. _reset: () => void;
  75247. private _defaultUp;
  75248. /**
  75249. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75250. * This is the base of the follow, arc rotate cameras and Free camera
  75251. * @see http://doc.babylonjs.com/features/cameras
  75252. * @param name Defines the name of the camera in the scene
  75253. * @param position Defines the start position of the camera in the scene
  75254. * @param scene Defines the scene the camera belongs to
  75255. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75256. */
  75257. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75258. /**
  75259. * Gets the position in front of the camera at a given distance.
  75260. * @param distance The distance from the camera we want the position to be
  75261. * @returns the position
  75262. */
  75263. getFrontPosition(distance: number): Vector3;
  75264. /** @hidden */
  75265. _getLockedTargetPosition(): Nullable<Vector3>;
  75266. private _storedPosition;
  75267. private _storedRotation;
  75268. private _storedRotationQuaternion;
  75269. /**
  75270. * Store current camera state of the camera (fov, position, rotation, etc..)
  75271. * @returns the camera
  75272. */
  75273. storeState(): Camera;
  75274. /**
  75275. * Restored camera state. You must call storeState() first
  75276. * @returns whether it was successful or not
  75277. * @hidden
  75278. */
  75279. _restoreStateValues(): boolean;
  75280. /** @hidden */
  75281. _initCache(): void;
  75282. /** @hidden */
  75283. _updateCache(ignoreParentClass?: boolean): void;
  75284. /** @hidden */
  75285. _isSynchronizedViewMatrix(): boolean;
  75286. /** @hidden */
  75287. _computeLocalCameraSpeed(): number;
  75288. /**
  75289. * Defines the target the camera should look at.
  75290. * @param target Defines the new target as a Vector or a mesh
  75291. */
  75292. setTarget(target: Vector3): void;
  75293. /**
  75294. * Return the current target position of the camera. This value is expressed in local space.
  75295. * @returns the target position
  75296. */
  75297. getTarget(): Vector3;
  75298. /** @hidden */
  75299. _decideIfNeedsToMove(): boolean;
  75300. /** @hidden */
  75301. _updatePosition(): void;
  75302. /** @hidden */
  75303. _checkInputs(): void;
  75304. protected _updateCameraRotationMatrix(): void;
  75305. /**
  75306. * 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)
  75307. * @returns the current camera
  75308. */
  75309. private _rotateUpVectorWithCameraRotationMatrix;
  75310. private _cachedRotationZ;
  75311. private _cachedQuaternionRotationZ;
  75312. /** @hidden */
  75313. _getViewMatrix(): Matrix;
  75314. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75315. /**
  75316. * @hidden
  75317. */
  75318. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75319. /**
  75320. * @hidden
  75321. */
  75322. _updateRigCameras(): void;
  75323. private _getRigCamPositionAndTarget;
  75324. /**
  75325. * Gets the current object class name.
  75326. * @return the class name
  75327. */
  75328. getClassName(): string;
  75329. }
  75330. }
  75331. declare module BABYLON {
  75332. /**
  75333. * Gather the list of keyboard event types as constants.
  75334. */
  75335. export class KeyboardEventTypes {
  75336. /**
  75337. * The keydown event is fired when a key becomes active (pressed).
  75338. */
  75339. static readonly KEYDOWN: number;
  75340. /**
  75341. * The keyup event is fired when a key has been released.
  75342. */
  75343. static readonly KEYUP: number;
  75344. }
  75345. /**
  75346. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75347. */
  75348. export class KeyboardInfo {
  75349. /**
  75350. * Defines the type of event (KeyboardEventTypes)
  75351. */
  75352. type: number;
  75353. /**
  75354. * Defines the related dom event
  75355. */
  75356. event: KeyboardEvent;
  75357. /**
  75358. * Instantiates a new keyboard info.
  75359. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75360. * @param type Defines the type of event (KeyboardEventTypes)
  75361. * @param event Defines the related dom event
  75362. */
  75363. constructor(
  75364. /**
  75365. * Defines the type of event (KeyboardEventTypes)
  75366. */
  75367. type: number,
  75368. /**
  75369. * Defines the related dom event
  75370. */
  75371. event: KeyboardEvent);
  75372. }
  75373. /**
  75374. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75375. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75376. */
  75377. export class KeyboardInfoPre extends KeyboardInfo {
  75378. /**
  75379. * Defines the type of event (KeyboardEventTypes)
  75380. */
  75381. type: number;
  75382. /**
  75383. * Defines the related dom event
  75384. */
  75385. event: KeyboardEvent;
  75386. /**
  75387. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75388. */
  75389. skipOnPointerObservable: boolean;
  75390. /**
  75391. * Instantiates a new keyboard pre info.
  75392. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75393. * @param type Defines the type of event (KeyboardEventTypes)
  75394. * @param event Defines the related dom event
  75395. */
  75396. constructor(
  75397. /**
  75398. * Defines the type of event (KeyboardEventTypes)
  75399. */
  75400. type: number,
  75401. /**
  75402. * Defines the related dom event
  75403. */
  75404. event: KeyboardEvent);
  75405. }
  75406. }
  75407. declare module BABYLON {
  75408. /**
  75409. * Manage the keyboard inputs to control the movement of a free camera.
  75410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75411. */
  75412. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75413. /**
  75414. * Defines the camera the input is attached to.
  75415. */
  75416. camera: FreeCamera;
  75417. /**
  75418. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75419. */
  75420. keysUp: number[];
  75421. /**
  75422. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75423. */
  75424. keysDown: number[];
  75425. /**
  75426. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75427. */
  75428. keysLeft: number[];
  75429. /**
  75430. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75431. */
  75432. keysRight: number[];
  75433. private _keys;
  75434. private _onCanvasBlurObserver;
  75435. private _onKeyboardObserver;
  75436. private _engine;
  75437. private _scene;
  75438. /**
  75439. * Attach the input controls to a specific dom element to get the input from.
  75440. * @param element Defines the element the controls should be listened from
  75441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75442. */
  75443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75444. /**
  75445. * Detach the current controls from the specified dom element.
  75446. * @param element Defines the element to stop listening the inputs from
  75447. */
  75448. detachControl(element: Nullable<HTMLElement>): void;
  75449. /**
  75450. * Update the current camera state depending on the inputs that have been used this frame.
  75451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75452. */
  75453. checkInputs(): void;
  75454. /**
  75455. * Gets the class name of the current intput.
  75456. * @returns the class name
  75457. */
  75458. getClassName(): string;
  75459. /** @hidden */
  75460. _onLostFocus(): void;
  75461. /**
  75462. * Get the friendly name associated with the input class.
  75463. * @returns the input friendly name
  75464. */
  75465. getSimpleName(): string;
  75466. }
  75467. }
  75468. declare module BABYLON {
  75469. /**
  75470. * Interface describing all the common properties and methods a shadow light needs to implement.
  75471. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75472. * as well as binding the different shadow properties to the effects.
  75473. */
  75474. export interface IShadowLight extends Light {
  75475. /**
  75476. * The light id in the scene (used in scene.findLighById for instance)
  75477. */
  75478. id: string;
  75479. /**
  75480. * The position the shdow will be casted from.
  75481. */
  75482. position: Vector3;
  75483. /**
  75484. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75485. */
  75486. direction: Vector3;
  75487. /**
  75488. * The transformed position. Position of the light in world space taking parenting in account.
  75489. */
  75490. transformedPosition: Vector3;
  75491. /**
  75492. * The transformed direction. Direction of the light in world space taking parenting in account.
  75493. */
  75494. transformedDirection: Vector3;
  75495. /**
  75496. * The friendly name of the light in the scene.
  75497. */
  75498. name: string;
  75499. /**
  75500. * Defines the shadow projection clipping minimum z value.
  75501. */
  75502. shadowMinZ: number;
  75503. /**
  75504. * Defines the shadow projection clipping maximum z value.
  75505. */
  75506. shadowMaxZ: number;
  75507. /**
  75508. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75509. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75510. */
  75511. computeTransformedInformation(): boolean;
  75512. /**
  75513. * Gets the scene the light belongs to.
  75514. * @returns The scene
  75515. */
  75516. getScene(): Scene;
  75517. /**
  75518. * Callback defining a custom Projection Matrix Builder.
  75519. * This can be used to override the default projection matrix computation.
  75520. */
  75521. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75522. /**
  75523. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75524. * @param matrix The materix to updated with the projection information
  75525. * @param viewMatrix The transform matrix of the light
  75526. * @param renderList The list of mesh to render in the map
  75527. * @returns The current light
  75528. */
  75529. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75530. /**
  75531. * Gets the current depth scale used in ESM.
  75532. * @returns The scale
  75533. */
  75534. getDepthScale(): number;
  75535. /**
  75536. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75537. * @returns true if a cube texture needs to be use
  75538. */
  75539. needCube(): boolean;
  75540. /**
  75541. * Detects if the projection matrix requires to be recomputed this frame.
  75542. * @returns true if it requires to be recomputed otherwise, false.
  75543. */
  75544. needProjectionMatrixCompute(): boolean;
  75545. /**
  75546. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75547. */
  75548. forceProjectionMatrixCompute(): void;
  75549. /**
  75550. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75551. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75552. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75553. */
  75554. getShadowDirection(faceIndex?: number): Vector3;
  75555. /**
  75556. * Gets the minZ used for shadow according to both the scene and the light.
  75557. * @param activeCamera The camera we are returning the min for
  75558. * @returns the depth min z
  75559. */
  75560. getDepthMinZ(activeCamera: Camera): number;
  75561. /**
  75562. * Gets the maxZ used for shadow according to both the scene and the light.
  75563. * @param activeCamera The camera we are returning the max for
  75564. * @returns the depth max z
  75565. */
  75566. getDepthMaxZ(activeCamera: Camera): number;
  75567. }
  75568. /**
  75569. * Base implementation IShadowLight
  75570. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75571. */
  75572. export abstract class ShadowLight extends Light implements IShadowLight {
  75573. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75574. protected _position: Vector3;
  75575. protected _setPosition(value: Vector3): void;
  75576. /**
  75577. * Sets the position the shadow will be casted from. Also use as the light position for both
  75578. * point and spot lights.
  75579. */
  75580. /**
  75581. * Sets the position the shadow will be casted from. Also use as the light position for both
  75582. * point and spot lights.
  75583. */
  75584. position: Vector3;
  75585. protected _direction: Vector3;
  75586. protected _setDirection(value: Vector3): void;
  75587. /**
  75588. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75589. * Also use as the light direction on spot and directional lights.
  75590. */
  75591. /**
  75592. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75593. * Also use as the light direction on spot and directional lights.
  75594. */
  75595. direction: Vector3;
  75596. private _shadowMinZ;
  75597. /**
  75598. * Gets the shadow projection clipping minimum z value.
  75599. */
  75600. /**
  75601. * Sets the shadow projection clipping minimum z value.
  75602. */
  75603. shadowMinZ: number;
  75604. private _shadowMaxZ;
  75605. /**
  75606. * Sets the shadow projection clipping maximum z value.
  75607. */
  75608. /**
  75609. * Gets the shadow projection clipping maximum z value.
  75610. */
  75611. shadowMaxZ: number;
  75612. /**
  75613. * Callback defining a custom Projection Matrix Builder.
  75614. * This can be used to override the default projection matrix computation.
  75615. */
  75616. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75617. /**
  75618. * The transformed position. Position of the light in world space taking parenting in account.
  75619. */
  75620. transformedPosition: Vector3;
  75621. /**
  75622. * The transformed direction. Direction of the light in world space taking parenting in account.
  75623. */
  75624. transformedDirection: Vector3;
  75625. private _needProjectionMatrixCompute;
  75626. /**
  75627. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75628. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75629. */
  75630. computeTransformedInformation(): boolean;
  75631. /**
  75632. * Return the depth scale used for the shadow map.
  75633. * @returns the depth scale.
  75634. */
  75635. getDepthScale(): number;
  75636. /**
  75637. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75638. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75639. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75640. */
  75641. getShadowDirection(faceIndex?: number): Vector3;
  75642. /**
  75643. * Returns the ShadowLight absolute position in the World.
  75644. * @returns the position vector in world space
  75645. */
  75646. getAbsolutePosition(): Vector3;
  75647. /**
  75648. * Sets the ShadowLight direction toward the passed target.
  75649. * @param target The point to target in local space
  75650. * @returns the updated ShadowLight direction
  75651. */
  75652. setDirectionToTarget(target: Vector3): Vector3;
  75653. /**
  75654. * Returns the light rotation in euler definition.
  75655. * @returns the x y z rotation in local space.
  75656. */
  75657. getRotation(): Vector3;
  75658. /**
  75659. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75660. * @returns true if a cube texture needs to be use
  75661. */
  75662. needCube(): boolean;
  75663. /**
  75664. * Detects if the projection matrix requires to be recomputed this frame.
  75665. * @returns true if it requires to be recomputed otherwise, false.
  75666. */
  75667. needProjectionMatrixCompute(): boolean;
  75668. /**
  75669. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75670. */
  75671. forceProjectionMatrixCompute(): void;
  75672. /** @hidden */
  75673. _initCache(): void;
  75674. /** @hidden */
  75675. _isSynchronized(): boolean;
  75676. /**
  75677. * Computes the world matrix of the node
  75678. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75679. * @returns the world matrix
  75680. */
  75681. computeWorldMatrix(force?: boolean): Matrix;
  75682. /**
  75683. * Gets the minZ used for shadow according to both the scene and the light.
  75684. * @param activeCamera The camera we are returning the min for
  75685. * @returns the depth min z
  75686. */
  75687. getDepthMinZ(activeCamera: Camera): number;
  75688. /**
  75689. * Gets the maxZ used for shadow according to both the scene and the light.
  75690. * @param activeCamera The camera we are returning the max for
  75691. * @returns the depth max z
  75692. */
  75693. getDepthMaxZ(activeCamera: Camera): number;
  75694. /**
  75695. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75696. * @param matrix The materix to updated with the projection information
  75697. * @param viewMatrix The transform matrix of the light
  75698. * @param renderList The list of mesh to render in the map
  75699. * @returns The current light
  75700. */
  75701. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75702. }
  75703. }
  75704. declare module BABYLON {
  75705. /**
  75706. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75707. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75708. */
  75709. export class EffectFallbacks implements IEffectFallbacks {
  75710. private _defines;
  75711. private _currentRank;
  75712. private _maxRank;
  75713. private _mesh;
  75714. /**
  75715. * Removes the fallback from the bound mesh.
  75716. */
  75717. unBindMesh(): void;
  75718. /**
  75719. * Adds a fallback on the specified property.
  75720. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75721. * @param define The name of the define in the shader
  75722. */
  75723. addFallback(rank: number, define: string): void;
  75724. /**
  75725. * Sets the mesh to use CPU skinning when needing to fallback.
  75726. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75727. * @param mesh The mesh to use the fallbacks.
  75728. */
  75729. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75730. /**
  75731. * Checks to see if more fallbacks are still availible.
  75732. */
  75733. readonly hasMoreFallbacks: boolean;
  75734. /**
  75735. * Removes the defines that should be removed when falling back.
  75736. * @param currentDefines defines the current define statements for the shader.
  75737. * @param effect defines the current effect we try to compile
  75738. * @returns The resulting defines with defines of the current rank removed.
  75739. */
  75740. reduce(currentDefines: string, effect: Effect): string;
  75741. }
  75742. }
  75743. declare module BABYLON {
  75744. /**
  75745. * "Static Class" containing the most commonly used helper while dealing with material for
  75746. * rendering purpose.
  75747. *
  75748. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75749. *
  75750. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75751. */
  75752. export class MaterialHelper {
  75753. /**
  75754. * Bind the current view position to an effect.
  75755. * @param effect The effect to be bound
  75756. * @param scene The scene the eyes position is used from
  75757. */
  75758. static BindEyePosition(effect: Effect, scene: Scene): void;
  75759. /**
  75760. * Helps preparing the defines values about the UVs in used in the effect.
  75761. * UVs are shared as much as we can accross channels in the shaders.
  75762. * @param texture The texture we are preparing the UVs for
  75763. * @param defines The defines to update
  75764. * @param key The channel key "diffuse", "specular"... used in the shader
  75765. */
  75766. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75767. /**
  75768. * Binds a texture matrix value to its corrsponding uniform
  75769. * @param texture The texture to bind the matrix for
  75770. * @param uniformBuffer The uniform buffer receivin the data
  75771. * @param key The channel key "diffuse", "specular"... used in the shader
  75772. */
  75773. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75774. /**
  75775. * Gets the current status of the fog (should it be enabled?)
  75776. * @param mesh defines the mesh to evaluate for fog support
  75777. * @param scene defines the hosting scene
  75778. * @returns true if fog must be enabled
  75779. */
  75780. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75781. /**
  75782. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75783. * @param mesh defines the current mesh
  75784. * @param scene defines the current scene
  75785. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75786. * @param pointsCloud defines if point cloud rendering has to be turned on
  75787. * @param fogEnabled defines if fog has to be turned on
  75788. * @param alphaTest defines if alpha testing has to be turned on
  75789. * @param defines defines the current list of defines
  75790. */
  75791. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75792. /**
  75793. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75794. * @param scene defines the current scene
  75795. * @param engine defines the current engine
  75796. * @param defines specifies the list of active defines
  75797. * @param useInstances defines if instances have to be turned on
  75798. * @param useClipPlane defines if clip plane have to be turned on
  75799. */
  75800. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75801. /**
  75802. * Prepares the defines for bones
  75803. * @param mesh The mesh containing the geometry data we will draw
  75804. * @param defines The defines to update
  75805. */
  75806. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75807. /**
  75808. * Prepares the defines for morph targets
  75809. * @param mesh The mesh containing the geometry data we will draw
  75810. * @param defines The defines to update
  75811. */
  75812. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75813. /**
  75814. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75815. * @param mesh The mesh containing the geometry data we will draw
  75816. * @param defines The defines to update
  75817. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75818. * @param useBones Precise whether bones should be used or not (override mesh info)
  75819. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75820. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75821. * @returns false if defines are considered not dirty and have not been checked
  75822. */
  75823. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75824. /**
  75825. * Prepares the defines related to multiview
  75826. * @param scene The scene we are intending to draw
  75827. * @param defines The defines to update
  75828. */
  75829. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75830. /**
  75831. * Prepares the defines related to the light information passed in parameter
  75832. * @param scene The scene we are intending to draw
  75833. * @param mesh The mesh the effect is compiling for
  75834. * @param light The light the effect is compiling for
  75835. * @param lightIndex The index of the light
  75836. * @param defines The defines to update
  75837. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75838. * @param state Defines the current state regarding what is needed (normals, etc...)
  75839. */
  75840. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75841. needNormals: boolean;
  75842. needRebuild: boolean;
  75843. shadowEnabled: boolean;
  75844. specularEnabled: boolean;
  75845. lightmapMode: boolean;
  75846. }): void;
  75847. /**
  75848. * Prepares the defines related to the light information passed in parameter
  75849. * @param scene The scene we are intending to draw
  75850. * @param mesh The mesh the effect is compiling for
  75851. * @param defines The defines to update
  75852. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75853. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75854. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75855. * @returns true if normals will be required for the rest of the effect
  75856. */
  75857. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75858. /**
  75859. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75860. * @param lightIndex defines the light index
  75861. * @param uniformsList The uniform list
  75862. * @param samplersList The sampler list
  75863. * @param projectedLightTexture defines if projected texture must be used
  75864. * @param uniformBuffersList defines an optional list of uniform buffers
  75865. */
  75866. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75867. /**
  75868. * Prepares the uniforms and samplers list to be used in the effect
  75869. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75870. * @param samplersList The sampler list
  75871. * @param defines The defines helping in the list generation
  75872. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75873. */
  75874. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75875. /**
  75876. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75877. * @param defines The defines to update while falling back
  75878. * @param fallbacks The authorized effect fallbacks
  75879. * @param maxSimultaneousLights The maximum number of lights allowed
  75880. * @param rank the current rank of the Effect
  75881. * @returns The newly affected rank
  75882. */
  75883. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75884. private static _TmpMorphInfluencers;
  75885. /**
  75886. * Prepares the list of attributes required for morph targets according to the effect defines.
  75887. * @param attribs The current list of supported attribs
  75888. * @param mesh The mesh to prepare the morph targets attributes for
  75889. * @param influencers The number of influencers
  75890. */
  75891. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75892. /**
  75893. * Prepares the list of attributes required for morph targets according to the effect defines.
  75894. * @param attribs The current list of supported attribs
  75895. * @param mesh The mesh to prepare the morph targets attributes for
  75896. * @param defines The current Defines of the effect
  75897. */
  75898. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75899. /**
  75900. * Prepares the list of attributes required for bones according to the effect defines.
  75901. * @param attribs The current list of supported attribs
  75902. * @param mesh The mesh to prepare the bones attributes for
  75903. * @param defines The current Defines of the effect
  75904. * @param fallbacks The current efffect fallback strategy
  75905. */
  75906. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75907. /**
  75908. * Check and prepare the list of attributes required for instances according to the effect defines.
  75909. * @param attribs The current list of supported attribs
  75910. * @param defines The current MaterialDefines of the effect
  75911. */
  75912. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75913. /**
  75914. * Add the list of attributes required for instances to the attribs array.
  75915. * @param attribs The current list of supported attribs
  75916. */
  75917. static PushAttributesForInstances(attribs: string[]): void;
  75918. /**
  75919. * Binds the light shadow information to the effect for the given mesh.
  75920. * @param light The light containing the generator
  75921. * @param scene The scene the lights belongs to
  75922. * @param mesh The mesh we are binding the information to render
  75923. * @param lightIndex The light index in the effect used to render the mesh
  75924. * @param effect The effect we are binding the data to
  75925. */
  75926. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75927. /**
  75928. * Binds the light information to the effect.
  75929. * @param light The light containing the generator
  75930. * @param effect The effect we are binding the data to
  75931. * @param lightIndex The light index in the effect used to render
  75932. */
  75933. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75934. /**
  75935. * Binds the lights information from the scene to the effect for the given mesh.
  75936. * @param light Light to bind
  75937. * @param lightIndex Light index
  75938. * @param scene The scene where the light belongs to
  75939. * @param mesh The mesh we are binding the information to render
  75940. * @param effect The effect we are binding the data to
  75941. * @param useSpecular Defines if specular is supported
  75942. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75943. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75944. */
  75945. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75946. /**
  75947. * Binds the lights information from the scene to the effect for the given mesh.
  75948. * @param scene The scene the lights belongs to
  75949. * @param mesh The mesh we are binding the information to render
  75950. * @param effect The effect we are binding the data to
  75951. * @param defines The generated defines for the effect
  75952. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75953. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75954. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75955. */
  75956. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75957. private static _tempFogColor;
  75958. /**
  75959. * Binds the fog information from the scene to the effect for the given mesh.
  75960. * @param scene The scene the lights belongs to
  75961. * @param mesh The mesh we are binding the information to render
  75962. * @param effect The effect we are binding the data to
  75963. * @param linearSpace Defines if the fog effect is applied in linear space
  75964. */
  75965. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75966. /**
  75967. * Binds the bones information from the mesh to the effect.
  75968. * @param mesh The mesh we are binding the information to render
  75969. * @param effect The effect we are binding the data to
  75970. */
  75971. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75972. /**
  75973. * Binds the morph targets information from the mesh to the effect.
  75974. * @param abstractMesh The mesh we are binding the information to render
  75975. * @param effect The effect we are binding the data to
  75976. */
  75977. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75978. /**
  75979. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75980. * @param defines The generated defines used in the effect
  75981. * @param effect The effect we are binding the data to
  75982. * @param scene The scene we are willing to render with logarithmic scale for
  75983. */
  75984. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75985. /**
  75986. * Binds the clip plane information from the scene to the effect.
  75987. * @param scene The scene the clip plane information are extracted from
  75988. * @param effect The effect we are binding the data to
  75989. */
  75990. static BindClipPlane(effect: Effect, scene: Scene): void;
  75991. }
  75992. }
  75993. declare module BABYLON {
  75994. /** @hidden */
  75995. export var packingFunctions: {
  75996. name: string;
  75997. shader: string;
  75998. };
  75999. }
  76000. declare module BABYLON {
  76001. /** @hidden */
  76002. export var shadowMapPixelShader: {
  76003. name: string;
  76004. shader: string;
  76005. };
  76006. }
  76007. declare module BABYLON {
  76008. /** @hidden */
  76009. export var bonesDeclaration: {
  76010. name: string;
  76011. shader: string;
  76012. };
  76013. }
  76014. declare module BABYLON {
  76015. /** @hidden */
  76016. export var morphTargetsVertexGlobalDeclaration: {
  76017. name: string;
  76018. shader: string;
  76019. };
  76020. }
  76021. declare module BABYLON {
  76022. /** @hidden */
  76023. export var morphTargetsVertexDeclaration: {
  76024. name: string;
  76025. shader: string;
  76026. };
  76027. }
  76028. declare module BABYLON {
  76029. /** @hidden */
  76030. export var instancesDeclaration: {
  76031. name: string;
  76032. shader: string;
  76033. };
  76034. }
  76035. declare module BABYLON {
  76036. /** @hidden */
  76037. export var helperFunctions: {
  76038. name: string;
  76039. shader: string;
  76040. };
  76041. }
  76042. declare module BABYLON {
  76043. /** @hidden */
  76044. export var morphTargetsVertex: {
  76045. name: string;
  76046. shader: string;
  76047. };
  76048. }
  76049. declare module BABYLON {
  76050. /** @hidden */
  76051. export var instancesVertex: {
  76052. name: string;
  76053. shader: string;
  76054. };
  76055. }
  76056. declare module BABYLON {
  76057. /** @hidden */
  76058. export var bonesVertex: {
  76059. name: string;
  76060. shader: string;
  76061. };
  76062. }
  76063. declare module BABYLON {
  76064. /** @hidden */
  76065. export var shadowMapVertexShader: {
  76066. name: string;
  76067. shader: string;
  76068. };
  76069. }
  76070. declare module BABYLON {
  76071. /** @hidden */
  76072. export var depthBoxBlurPixelShader: {
  76073. name: string;
  76074. shader: string;
  76075. };
  76076. }
  76077. declare module BABYLON {
  76078. /**
  76079. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76080. */
  76081. export interface ICustomShaderOptions {
  76082. /**
  76083. * Gets or sets the custom shader name to use
  76084. */
  76085. shaderName: string;
  76086. /**
  76087. * The list of attribute names used in the shader
  76088. */
  76089. attributes?: string[];
  76090. /**
  76091. * The list of unifrom names used in the shader
  76092. */
  76093. uniforms?: string[];
  76094. /**
  76095. * The list of sampler names used in the shader
  76096. */
  76097. samplers?: string[];
  76098. /**
  76099. * The list of defines used in the shader
  76100. */
  76101. defines?: string[];
  76102. }
  76103. /**
  76104. * Interface to implement to create a shadow generator compatible with BJS.
  76105. */
  76106. export interface IShadowGenerator {
  76107. /**
  76108. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76109. * @returns The render target texture if present otherwise, null
  76110. */
  76111. getShadowMap(): Nullable<RenderTargetTexture>;
  76112. /**
  76113. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76114. * @returns The render target texture if the shadow map is present otherwise, null
  76115. */
  76116. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76117. /**
  76118. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76119. * @param subMesh The submesh we want to render in the shadow map
  76120. * @param useInstances Defines wether will draw in the map using instances
  76121. * @returns true if ready otherwise, false
  76122. */
  76123. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76124. /**
  76125. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76126. * @param defines Defines of the material we want to update
  76127. * @param lightIndex Index of the light in the enabled light list of the material
  76128. */
  76129. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76130. /**
  76131. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76132. * defined in the generator but impacting the effect).
  76133. * It implies the unifroms available on the materials are the standard BJS ones.
  76134. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76135. * @param effect The effect we are binfing the information for
  76136. */
  76137. bindShadowLight(lightIndex: string, effect: Effect): void;
  76138. /**
  76139. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76140. * (eq to shadow prjection matrix * light transform matrix)
  76141. * @returns The transform matrix used to create the shadow map
  76142. */
  76143. getTransformMatrix(): Matrix;
  76144. /**
  76145. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76146. * Cube and 2D textures for instance.
  76147. */
  76148. recreateShadowMap(): void;
  76149. /**
  76150. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76151. * @param onCompiled Callback triggered at the and of the effects compilation
  76152. * @param options Sets of optional options forcing the compilation with different modes
  76153. */
  76154. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76155. useInstances: boolean;
  76156. }>): void;
  76157. /**
  76158. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76159. * @param options Sets of optional options forcing the compilation with different modes
  76160. * @returns A promise that resolves when the compilation completes
  76161. */
  76162. forceCompilationAsync(options?: Partial<{
  76163. useInstances: boolean;
  76164. }>): Promise<void>;
  76165. /**
  76166. * Serializes the shadow generator setup to a json object.
  76167. * @returns The serialized JSON object
  76168. */
  76169. serialize(): any;
  76170. /**
  76171. * Disposes the Shadow map and related Textures and effects.
  76172. */
  76173. dispose(): void;
  76174. }
  76175. /**
  76176. * Default implementation IShadowGenerator.
  76177. * This is the main object responsible of generating shadows in the framework.
  76178. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76179. */
  76180. export class ShadowGenerator implements IShadowGenerator {
  76181. /**
  76182. * Shadow generator mode None: no filtering applied.
  76183. */
  76184. static readonly FILTER_NONE: number;
  76185. /**
  76186. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76187. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76188. */
  76189. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76190. /**
  76191. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76192. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76193. */
  76194. static readonly FILTER_POISSONSAMPLING: number;
  76195. /**
  76196. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76197. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76198. */
  76199. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76200. /**
  76201. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76202. * edge artifacts on steep falloff.
  76203. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76204. */
  76205. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76206. /**
  76207. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76208. * edge artifacts on steep falloff.
  76209. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76210. */
  76211. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76212. /**
  76213. * Shadow generator mode PCF: Percentage Closer Filtering
  76214. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76215. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76216. */
  76217. static readonly FILTER_PCF: number;
  76218. /**
  76219. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76220. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76221. * Contact Hardening
  76222. */
  76223. static readonly FILTER_PCSS: number;
  76224. /**
  76225. * Reserved for PCF and PCSS
  76226. * Highest Quality.
  76227. *
  76228. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76229. *
  76230. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76231. */
  76232. static readonly QUALITY_HIGH: number;
  76233. /**
  76234. * Reserved for PCF and PCSS
  76235. * Good tradeoff for quality/perf cross devices
  76236. *
  76237. * Execute PCF on a 3*3 kernel.
  76238. *
  76239. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76240. */
  76241. static readonly QUALITY_MEDIUM: number;
  76242. /**
  76243. * Reserved for PCF and PCSS
  76244. * The lowest quality but the fastest.
  76245. *
  76246. * Execute PCF on a 1*1 kernel.
  76247. *
  76248. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76249. */
  76250. static readonly QUALITY_LOW: number;
  76251. /** Gets or sets the custom shader name to use */
  76252. customShaderOptions: ICustomShaderOptions;
  76253. /**
  76254. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76255. */
  76256. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76257. /**
  76258. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76259. */
  76260. onAfterShadowMapRenderObservable: Observable<Effect>;
  76261. /**
  76262. * Observable triggered before a mesh is rendered in the shadow map.
  76263. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76264. */
  76265. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76266. /**
  76267. * Observable triggered after a mesh is rendered in the shadow map.
  76268. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76269. */
  76270. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76271. private _bias;
  76272. /**
  76273. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76274. */
  76275. /**
  76276. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76277. */
  76278. bias: number;
  76279. private _normalBias;
  76280. /**
  76281. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76282. */
  76283. /**
  76284. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76285. */
  76286. normalBias: number;
  76287. private _blurBoxOffset;
  76288. /**
  76289. * Gets the blur box offset: offset applied during the blur pass.
  76290. * Only useful if useKernelBlur = false
  76291. */
  76292. /**
  76293. * Sets the blur box offset: offset applied during the blur pass.
  76294. * Only useful if useKernelBlur = false
  76295. */
  76296. blurBoxOffset: number;
  76297. private _blurScale;
  76298. /**
  76299. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76300. * 2 means half of the size.
  76301. */
  76302. /**
  76303. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76304. * 2 means half of the size.
  76305. */
  76306. blurScale: number;
  76307. private _blurKernel;
  76308. /**
  76309. * Gets the blur kernel: kernel size of the blur pass.
  76310. * Only useful if useKernelBlur = true
  76311. */
  76312. /**
  76313. * Sets the blur kernel: kernel size of the blur pass.
  76314. * Only useful if useKernelBlur = true
  76315. */
  76316. blurKernel: number;
  76317. private _useKernelBlur;
  76318. /**
  76319. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76320. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76321. */
  76322. /**
  76323. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76324. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76325. */
  76326. useKernelBlur: boolean;
  76327. private _depthScale;
  76328. /**
  76329. * Gets the depth scale used in ESM mode.
  76330. */
  76331. /**
  76332. * Sets the depth scale used in ESM mode.
  76333. * This can override the scale stored on the light.
  76334. */
  76335. depthScale: number;
  76336. private _filter;
  76337. /**
  76338. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76339. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76340. */
  76341. /**
  76342. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76343. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76344. */
  76345. filter: number;
  76346. /**
  76347. * Gets if the current filter is set to Poisson Sampling.
  76348. */
  76349. /**
  76350. * Sets the current filter to Poisson Sampling.
  76351. */
  76352. usePoissonSampling: boolean;
  76353. /**
  76354. * Gets if the current filter is set to ESM.
  76355. */
  76356. /**
  76357. * Sets the current filter is to ESM.
  76358. */
  76359. useExponentialShadowMap: boolean;
  76360. /**
  76361. * Gets if the current filter is set to filtered ESM.
  76362. */
  76363. /**
  76364. * Gets if the current filter is set to filtered ESM.
  76365. */
  76366. useBlurExponentialShadowMap: boolean;
  76367. /**
  76368. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76369. * exponential to prevent steep falloff artifacts).
  76370. */
  76371. /**
  76372. * Sets the current filter to "close ESM" (using the inverse of the
  76373. * exponential to prevent steep falloff artifacts).
  76374. */
  76375. useCloseExponentialShadowMap: boolean;
  76376. /**
  76377. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76378. * exponential to prevent steep falloff artifacts).
  76379. */
  76380. /**
  76381. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76382. * exponential to prevent steep falloff artifacts).
  76383. */
  76384. useBlurCloseExponentialShadowMap: boolean;
  76385. /**
  76386. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76387. */
  76388. /**
  76389. * Sets the current filter to "PCF" (percentage closer filtering).
  76390. */
  76391. usePercentageCloserFiltering: boolean;
  76392. private _filteringQuality;
  76393. /**
  76394. * Gets the PCF or PCSS Quality.
  76395. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76396. */
  76397. /**
  76398. * Sets the PCF or PCSS Quality.
  76399. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76400. */
  76401. filteringQuality: number;
  76402. /**
  76403. * Gets if the current filter is set to "PCSS" (contact hardening).
  76404. */
  76405. /**
  76406. * Sets the current filter to "PCSS" (contact hardening).
  76407. */
  76408. useContactHardeningShadow: boolean;
  76409. private _contactHardeningLightSizeUVRatio;
  76410. /**
  76411. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76412. * Using a ratio helps keeping shape stability independently of the map size.
  76413. *
  76414. * It does not account for the light projection as it was having too much
  76415. * instability during the light setup or during light position changes.
  76416. *
  76417. * Only valid if useContactHardeningShadow is true.
  76418. */
  76419. /**
  76420. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76421. * Using a ratio helps keeping shape stability independently of the map size.
  76422. *
  76423. * It does not account for the light projection as it was having too much
  76424. * instability during the light setup or during light position changes.
  76425. *
  76426. * Only valid if useContactHardeningShadow is true.
  76427. */
  76428. contactHardeningLightSizeUVRatio: number;
  76429. private _darkness;
  76430. /** Gets or sets the actual darkness of a shadow */
  76431. darkness: number;
  76432. /**
  76433. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76434. * 0 means strongest and 1 would means no shadow.
  76435. * @returns the darkness.
  76436. */
  76437. getDarkness(): number;
  76438. /**
  76439. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76440. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76441. * @returns the shadow generator allowing fluent coding.
  76442. */
  76443. setDarkness(darkness: number): ShadowGenerator;
  76444. private _transparencyShadow;
  76445. /** Gets or sets the ability to have transparent shadow */
  76446. transparencyShadow: boolean;
  76447. /**
  76448. * Sets the ability to have transparent shadow (boolean).
  76449. * @param transparent True if transparent else False
  76450. * @returns the shadow generator allowing fluent coding
  76451. */
  76452. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76453. private _shadowMap;
  76454. private _shadowMap2;
  76455. /**
  76456. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76457. * @returns The render target texture if present otherwise, null
  76458. */
  76459. getShadowMap(): Nullable<RenderTargetTexture>;
  76460. /**
  76461. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76462. * @returns The render target texture if the shadow map is present otherwise, null
  76463. */
  76464. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76465. /**
  76466. * Gets the class name of that object
  76467. * @returns "ShadowGenerator"
  76468. */
  76469. getClassName(): string;
  76470. /**
  76471. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76472. * @param mesh Mesh to add
  76473. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76474. * @returns the Shadow Generator itself
  76475. */
  76476. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76477. /**
  76478. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76479. * @param mesh Mesh to remove
  76480. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76481. * @returns the Shadow Generator itself
  76482. */
  76483. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76484. /**
  76485. * Controls the extent to which the shadows fade out at the edge of the frustum
  76486. * Used only by directionals and spots
  76487. */
  76488. frustumEdgeFalloff: number;
  76489. private _light;
  76490. /**
  76491. * Returns the associated light object.
  76492. * @returns the light generating the shadow
  76493. */
  76494. getLight(): IShadowLight;
  76495. /**
  76496. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76497. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76498. * It might on the other hand introduce peter panning.
  76499. */
  76500. forceBackFacesOnly: boolean;
  76501. private _scene;
  76502. private _lightDirection;
  76503. private _effect;
  76504. private _viewMatrix;
  76505. private _projectionMatrix;
  76506. private _transformMatrix;
  76507. private _cachedPosition;
  76508. private _cachedDirection;
  76509. private _cachedDefines;
  76510. private _currentRenderID;
  76511. private _boxBlurPostprocess;
  76512. private _kernelBlurXPostprocess;
  76513. private _kernelBlurYPostprocess;
  76514. private _blurPostProcesses;
  76515. private _mapSize;
  76516. private _currentFaceIndex;
  76517. private _currentFaceIndexCache;
  76518. private _textureType;
  76519. private _defaultTextureMatrix;
  76520. private _storedUniqueId;
  76521. /** @hidden */
  76522. static _SceneComponentInitialization: (scene: Scene) => void;
  76523. /**
  76524. * Creates a ShadowGenerator object.
  76525. * A ShadowGenerator is the required tool to use the shadows.
  76526. * Each light casting shadows needs to use its own ShadowGenerator.
  76527. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76528. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76529. * @param light The light object generating the shadows.
  76530. * @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.
  76531. */
  76532. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76533. private _initializeGenerator;
  76534. private _initializeShadowMap;
  76535. private _initializeBlurRTTAndPostProcesses;
  76536. private _renderForShadowMap;
  76537. private _renderSubMeshForShadowMap;
  76538. private _applyFilterValues;
  76539. /**
  76540. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76541. * @param onCompiled Callback triggered at the and of the effects compilation
  76542. * @param options Sets of optional options forcing the compilation with different modes
  76543. */
  76544. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76545. useInstances: boolean;
  76546. }>): void;
  76547. /**
  76548. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76549. * @param options Sets of optional options forcing the compilation with different modes
  76550. * @returns A promise that resolves when the compilation completes
  76551. */
  76552. forceCompilationAsync(options?: Partial<{
  76553. useInstances: boolean;
  76554. }>): Promise<void>;
  76555. /**
  76556. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76557. * @param subMesh The submesh we want to render in the shadow map
  76558. * @param useInstances Defines wether will draw in the map using instances
  76559. * @returns true if ready otherwise, false
  76560. */
  76561. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76562. /**
  76563. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76564. * @param defines Defines of the material we want to update
  76565. * @param lightIndex Index of the light in the enabled light list of the material
  76566. */
  76567. prepareDefines(defines: any, lightIndex: number): void;
  76568. /**
  76569. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76570. * defined in the generator but impacting the effect).
  76571. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76572. * @param effect The effect we are binfing the information for
  76573. */
  76574. bindShadowLight(lightIndex: string, effect: Effect): void;
  76575. /**
  76576. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76577. * (eq to shadow prjection matrix * light transform matrix)
  76578. * @returns The transform matrix used to create the shadow map
  76579. */
  76580. getTransformMatrix(): Matrix;
  76581. /**
  76582. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76583. * Cube and 2D textures for instance.
  76584. */
  76585. recreateShadowMap(): void;
  76586. private _disposeBlurPostProcesses;
  76587. private _disposeRTTandPostProcesses;
  76588. /**
  76589. * Disposes the ShadowGenerator.
  76590. * Returns nothing.
  76591. */
  76592. dispose(): void;
  76593. /**
  76594. * Serializes the shadow generator setup to a json object.
  76595. * @returns The serialized JSON object
  76596. */
  76597. serialize(): any;
  76598. /**
  76599. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76600. * @param parsedShadowGenerator The JSON object to parse
  76601. * @param scene The scene to create the shadow map for
  76602. * @returns The parsed shadow generator
  76603. */
  76604. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76605. }
  76606. }
  76607. declare module BABYLON {
  76608. /**
  76609. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76610. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76611. * 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.
  76612. */
  76613. export abstract class Light extends Node {
  76614. /**
  76615. * Falloff Default: light is falling off following the material specification:
  76616. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76617. */
  76618. static readonly FALLOFF_DEFAULT: number;
  76619. /**
  76620. * Falloff Physical: light is falling off following the inverse squared distance law.
  76621. */
  76622. static readonly FALLOFF_PHYSICAL: number;
  76623. /**
  76624. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76625. * to enhance interoperability with other engines.
  76626. */
  76627. static readonly FALLOFF_GLTF: number;
  76628. /**
  76629. * Falloff Standard: light is falling off like in the standard material
  76630. * to enhance interoperability with other materials.
  76631. */
  76632. static readonly FALLOFF_STANDARD: number;
  76633. /**
  76634. * If every light affecting the material is in this lightmapMode,
  76635. * material.lightmapTexture adds or multiplies
  76636. * (depends on material.useLightmapAsShadowmap)
  76637. * after every other light calculations.
  76638. */
  76639. static readonly LIGHTMAP_DEFAULT: number;
  76640. /**
  76641. * material.lightmapTexture as only diffuse lighting from this light
  76642. * adds only specular lighting from this light
  76643. * adds dynamic shadows
  76644. */
  76645. static readonly LIGHTMAP_SPECULAR: number;
  76646. /**
  76647. * material.lightmapTexture as only lighting
  76648. * no light calculation from this light
  76649. * only adds dynamic shadows from this light
  76650. */
  76651. static readonly LIGHTMAP_SHADOWSONLY: number;
  76652. /**
  76653. * Each light type uses the default quantity according to its type:
  76654. * point/spot lights use luminous intensity
  76655. * directional lights use illuminance
  76656. */
  76657. static readonly INTENSITYMODE_AUTOMATIC: number;
  76658. /**
  76659. * lumen (lm)
  76660. */
  76661. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76662. /**
  76663. * candela (lm/sr)
  76664. */
  76665. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76666. /**
  76667. * lux (lm/m^2)
  76668. */
  76669. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76670. /**
  76671. * nit (cd/m^2)
  76672. */
  76673. static readonly INTENSITYMODE_LUMINANCE: number;
  76674. /**
  76675. * Light type const id of the point light.
  76676. */
  76677. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76678. /**
  76679. * Light type const id of the directional light.
  76680. */
  76681. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76682. /**
  76683. * Light type const id of the spot light.
  76684. */
  76685. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76686. /**
  76687. * Light type const id of the hemispheric light.
  76688. */
  76689. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76690. /**
  76691. * Diffuse gives the basic color to an object.
  76692. */
  76693. diffuse: Color3;
  76694. /**
  76695. * Specular produces a highlight color on an object.
  76696. * Note: This is note affecting PBR materials.
  76697. */
  76698. specular: Color3;
  76699. /**
  76700. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76701. * falling off base on range or angle.
  76702. * This can be set to any values in Light.FALLOFF_x.
  76703. *
  76704. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76705. * other types of materials.
  76706. */
  76707. falloffType: number;
  76708. /**
  76709. * Strength of the light.
  76710. * Note: By default it is define in the framework own unit.
  76711. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76712. */
  76713. intensity: number;
  76714. private _range;
  76715. protected _inverseSquaredRange: number;
  76716. /**
  76717. * Defines how far from the source the light is impacting in scene units.
  76718. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76719. */
  76720. /**
  76721. * Defines how far from the source the light is impacting in scene units.
  76722. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76723. */
  76724. range: number;
  76725. /**
  76726. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76727. * of light.
  76728. */
  76729. private _photometricScale;
  76730. private _intensityMode;
  76731. /**
  76732. * Gets the photometric scale used to interpret the intensity.
  76733. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76734. */
  76735. /**
  76736. * Sets the photometric scale used to interpret the intensity.
  76737. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76738. */
  76739. intensityMode: number;
  76740. private _radius;
  76741. /**
  76742. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76743. */
  76744. /**
  76745. * sets the light radius used by PBR Materials to simulate soft area lights.
  76746. */
  76747. radius: number;
  76748. private _renderPriority;
  76749. /**
  76750. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76751. * exceeding the number allowed of the materials.
  76752. */
  76753. renderPriority: number;
  76754. private _shadowEnabled;
  76755. /**
  76756. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76757. * the current shadow generator.
  76758. */
  76759. /**
  76760. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76761. * the current shadow generator.
  76762. */
  76763. shadowEnabled: boolean;
  76764. private _includedOnlyMeshes;
  76765. /**
  76766. * Gets the only meshes impacted by this light.
  76767. */
  76768. /**
  76769. * Sets the only meshes impacted by this light.
  76770. */
  76771. includedOnlyMeshes: AbstractMesh[];
  76772. private _excludedMeshes;
  76773. /**
  76774. * Gets the meshes not impacted by this light.
  76775. */
  76776. /**
  76777. * Sets the meshes not impacted by this light.
  76778. */
  76779. excludedMeshes: AbstractMesh[];
  76780. private _excludeWithLayerMask;
  76781. /**
  76782. * Gets the layer id use to find what meshes are not impacted by the light.
  76783. * Inactive if 0
  76784. */
  76785. /**
  76786. * Sets the layer id use to find what meshes are not impacted by the light.
  76787. * Inactive if 0
  76788. */
  76789. excludeWithLayerMask: number;
  76790. private _includeOnlyWithLayerMask;
  76791. /**
  76792. * Gets the layer id use to find what meshes are impacted by the light.
  76793. * Inactive if 0
  76794. */
  76795. /**
  76796. * Sets the layer id use to find what meshes are impacted by the light.
  76797. * Inactive if 0
  76798. */
  76799. includeOnlyWithLayerMask: number;
  76800. private _lightmapMode;
  76801. /**
  76802. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76803. */
  76804. /**
  76805. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76806. */
  76807. lightmapMode: number;
  76808. /**
  76809. * Shadow generator associted to the light.
  76810. * @hidden Internal use only.
  76811. */
  76812. _shadowGenerator: Nullable<IShadowGenerator>;
  76813. /**
  76814. * @hidden Internal use only.
  76815. */
  76816. _excludedMeshesIds: string[];
  76817. /**
  76818. * @hidden Internal use only.
  76819. */
  76820. _includedOnlyMeshesIds: string[];
  76821. /**
  76822. * The current light unifom buffer.
  76823. * @hidden Internal use only.
  76824. */
  76825. _uniformBuffer: UniformBuffer;
  76826. /**
  76827. * Creates a Light object in the scene.
  76828. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76829. * @param name The firendly name of the light
  76830. * @param scene The scene the light belongs too
  76831. */
  76832. constructor(name: string, scene: Scene);
  76833. protected abstract _buildUniformLayout(): void;
  76834. /**
  76835. * Sets the passed Effect "effect" with the Light information.
  76836. * @param effect The effect to update
  76837. * @param lightIndex The index of the light in the effect to update
  76838. * @returns The light
  76839. */
  76840. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76841. /**
  76842. * Sets the passed Effect "effect" with the Light information.
  76843. * @param effect The effect to update
  76844. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76845. * @returns The light
  76846. */
  76847. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76848. /**
  76849. * Returns the string "Light".
  76850. * @returns the class name
  76851. */
  76852. getClassName(): string;
  76853. /** @hidden */
  76854. readonly _isLight: boolean;
  76855. /**
  76856. * Converts the light information to a readable string for debug purpose.
  76857. * @param fullDetails Supports for multiple levels of logging within scene loading
  76858. * @returns the human readable light info
  76859. */
  76860. toString(fullDetails?: boolean): string;
  76861. /** @hidden */
  76862. protected _syncParentEnabledState(): void;
  76863. /**
  76864. * Set the enabled state of this node.
  76865. * @param value - the new enabled state
  76866. */
  76867. setEnabled(value: boolean): void;
  76868. /**
  76869. * Returns the Light associated shadow generator if any.
  76870. * @return the associated shadow generator.
  76871. */
  76872. getShadowGenerator(): Nullable<IShadowGenerator>;
  76873. /**
  76874. * Returns a Vector3, the absolute light position in the World.
  76875. * @returns the world space position of the light
  76876. */
  76877. getAbsolutePosition(): Vector3;
  76878. /**
  76879. * Specifies if the light will affect the passed mesh.
  76880. * @param mesh The mesh to test against the light
  76881. * @return true the mesh is affected otherwise, false.
  76882. */
  76883. canAffectMesh(mesh: AbstractMesh): boolean;
  76884. /**
  76885. * Sort function to order lights for rendering.
  76886. * @param a First Light object to compare to second.
  76887. * @param b Second Light object to compare first.
  76888. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76889. */
  76890. static CompareLightsPriority(a: Light, b: Light): number;
  76891. /**
  76892. * Releases resources associated with this node.
  76893. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76894. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76895. */
  76896. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76897. /**
  76898. * Returns the light type ID (integer).
  76899. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76900. */
  76901. getTypeID(): number;
  76902. /**
  76903. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76904. * @returns the scaled intensity in intensity mode unit
  76905. */
  76906. getScaledIntensity(): number;
  76907. /**
  76908. * Returns a new Light object, named "name", from the current one.
  76909. * @param name The name of the cloned light
  76910. * @returns the new created light
  76911. */
  76912. clone(name: string): Nullable<Light>;
  76913. /**
  76914. * Serializes the current light into a Serialization object.
  76915. * @returns the serialized object.
  76916. */
  76917. serialize(): any;
  76918. /**
  76919. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76920. * This new light is named "name" and added to the passed scene.
  76921. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76922. * @param name The friendly name of the light
  76923. * @param scene The scene the new light will belong to
  76924. * @returns the constructor function
  76925. */
  76926. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76927. /**
  76928. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76929. * @param parsedLight The JSON representation of the light
  76930. * @param scene The scene to create the parsed light in
  76931. * @returns the created light after parsing
  76932. */
  76933. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76934. private _hookArrayForExcluded;
  76935. private _hookArrayForIncludedOnly;
  76936. private _resyncMeshes;
  76937. /**
  76938. * Forces the meshes to update their light related information in their rendering used effects
  76939. * @hidden Internal Use Only
  76940. */
  76941. _markMeshesAsLightDirty(): void;
  76942. /**
  76943. * Recomputes the cached photometric scale if needed.
  76944. */
  76945. private _computePhotometricScale;
  76946. /**
  76947. * Returns the Photometric Scale according to the light type and intensity mode.
  76948. */
  76949. private _getPhotometricScale;
  76950. /**
  76951. * Reorder the light in the scene according to their defined priority.
  76952. * @hidden Internal Use Only
  76953. */
  76954. _reorderLightsInScene(): void;
  76955. /**
  76956. * Prepares the list of defines specific to the light type.
  76957. * @param defines the list of defines
  76958. * @param lightIndex defines the index of the light for the effect
  76959. */
  76960. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76961. }
  76962. }
  76963. declare module BABYLON {
  76964. /**
  76965. * Interface used to define Action
  76966. */
  76967. export interface IAction {
  76968. /**
  76969. * Trigger for the action
  76970. */
  76971. trigger: number;
  76972. /** Options of the trigger */
  76973. triggerOptions: any;
  76974. /**
  76975. * Gets the trigger parameters
  76976. * @returns the trigger parameters
  76977. */
  76978. getTriggerParameter(): any;
  76979. /**
  76980. * Internal only - executes current action event
  76981. * @hidden
  76982. */
  76983. _executeCurrent(evt?: ActionEvent): void;
  76984. /**
  76985. * Serialize placeholder for child classes
  76986. * @param parent of child
  76987. * @returns the serialized object
  76988. */
  76989. serialize(parent: any): any;
  76990. /**
  76991. * Internal only
  76992. * @hidden
  76993. */
  76994. _prepare(): void;
  76995. /**
  76996. * Internal only - manager for action
  76997. * @hidden
  76998. */
  76999. _actionManager: AbstractActionManager;
  77000. /**
  77001. * Adds action to chain of actions, may be a DoNothingAction
  77002. * @param action defines the next action to execute
  77003. * @returns The action passed in
  77004. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77005. */
  77006. then(action: IAction): IAction;
  77007. }
  77008. /**
  77009. * The action to be carried out following a trigger
  77010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77011. */
  77012. export class Action implements IAction {
  77013. /** the trigger, with or without parameters, for the action */
  77014. triggerOptions: any;
  77015. /**
  77016. * Trigger for the action
  77017. */
  77018. trigger: number;
  77019. /**
  77020. * Internal only - manager for action
  77021. * @hidden
  77022. */
  77023. _actionManager: ActionManager;
  77024. private _nextActiveAction;
  77025. private _child;
  77026. private _condition?;
  77027. private _triggerParameter;
  77028. /**
  77029. * An event triggered prior to action being executed.
  77030. */
  77031. onBeforeExecuteObservable: Observable<Action>;
  77032. /**
  77033. * Creates a new Action
  77034. * @param triggerOptions the trigger, with or without parameters, for the action
  77035. * @param condition an optional determinant of action
  77036. */
  77037. constructor(
  77038. /** the trigger, with or without parameters, for the action */
  77039. triggerOptions: any, condition?: Condition);
  77040. /**
  77041. * Internal only
  77042. * @hidden
  77043. */
  77044. _prepare(): void;
  77045. /**
  77046. * Gets the trigger parameters
  77047. * @returns the trigger parameters
  77048. */
  77049. getTriggerParameter(): any;
  77050. /**
  77051. * Internal only - executes current action event
  77052. * @hidden
  77053. */
  77054. _executeCurrent(evt?: ActionEvent): void;
  77055. /**
  77056. * Execute placeholder for child classes
  77057. * @param evt optional action event
  77058. */
  77059. execute(evt?: ActionEvent): void;
  77060. /**
  77061. * Skips to next active action
  77062. */
  77063. skipToNextActiveAction(): void;
  77064. /**
  77065. * Adds action to chain of actions, may be a DoNothingAction
  77066. * @param action defines the next action to execute
  77067. * @returns The action passed in
  77068. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77069. */
  77070. then(action: Action): Action;
  77071. /**
  77072. * Internal only
  77073. * @hidden
  77074. */
  77075. _getProperty(propertyPath: string): string;
  77076. /**
  77077. * Internal only
  77078. * @hidden
  77079. */
  77080. _getEffectiveTarget(target: any, propertyPath: string): any;
  77081. /**
  77082. * Serialize placeholder for child classes
  77083. * @param parent of child
  77084. * @returns the serialized object
  77085. */
  77086. serialize(parent: any): any;
  77087. /**
  77088. * Internal only called by serialize
  77089. * @hidden
  77090. */
  77091. protected _serialize(serializedAction: any, parent?: any): any;
  77092. /**
  77093. * Internal only
  77094. * @hidden
  77095. */
  77096. static _SerializeValueAsString: (value: any) => string;
  77097. /**
  77098. * Internal only
  77099. * @hidden
  77100. */
  77101. static _GetTargetProperty: (target: Node | Scene) => {
  77102. name: string;
  77103. targetType: string;
  77104. value: string;
  77105. };
  77106. }
  77107. }
  77108. declare module BABYLON {
  77109. /**
  77110. * A Condition applied to an Action
  77111. */
  77112. export class Condition {
  77113. /**
  77114. * Internal only - manager for action
  77115. * @hidden
  77116. */
  77117. _actionManager: ActionManager;
  77118. /**
  77119. * Internal only
  77120. * @hidden
  77121. */
  77122. _evaluationId: number;
  77123. /**
  77124. * Internal only
  77125. * @hidden
  77126. */
  77127. _currentResult: boolean;
  77128. /**
  77129. * Creates a new Condition
  77130. * @param actionManager the manager of the action the condition is applied to
  77131. */
  77132. constructor(actionManager: ActionManager);
  77133. /**
  77134. * Check if the current condition is valid
  77135. * @returns a boolean
  77136. */
  77137. isValid(): boolean;
  77138. /**
  77139. * Internal only
  77140. * @hidden
  77141. */
  77142. _getProperty(propertyPath: string): string;
  77143. /**
  77144. * Internal only
  77145. * @hidden
  77146. */
  77147. _getEffectiveTarget(target: any, propertyPath: string): any;
  77148. /**
  77149. * Serialize placeholder for child classes
  77150. * @returns the serialized object
  77151. */
  77152. serialize(): any;
  77153. /**
  77154. * Internal only
  77155. * @hidden
  77156. */
  77157. protected _serialize(serializedCondition: any): any;
  77158. }
  77159. /**
  77160. * Defines specific conditional operators as extensions of Condition
  77161. */
  77162. export class ValueCondition extends Condition {
  77163. /** path to specify the property of the target the conditional operator uses */
  77164. propertyPath: string;
  77165. /** the value compared by the conditional operator against the current value of the property */
  77166. value: any;
  77167. /** the conditional operator, default ValueCondition.IsEqual */
  77168. operator: number;
  77169. /**
  77170. * Internal only
  77171. * @hidden
  77172. */
  77173. private static _IsEqual;
  77174. /**
  77175. * Internal only
  77176. * @hidden
  77177. */
  77178. private static _IsDifferent;
  77179. /**
  77180. * Internal only
  77181. * @hidden
  77182. */
  77183. private static _IsGreater;
  77184. /**
  77185. * Internal only
  77186. * @hidden
  77187. */
  77188. private static _IsLesser;
  77189. /**
  77190. * returns the number for IsEqual
  77191. */
  77192. static readonly IsEqual: number;
  77193. /**
  77194. * Returns the number for IsDifferent
  77195. */
  77196. static readonly IsDifferent: number;
  77197. /**
  77198. * Returns the number for IsGreater
  77199. */
  77200. static readonly IsGreater: number;
  77201. /**
  77202. * Returns the number for IsLesser
  77203. */
  77204. static readonly IsLesser: number;
  77205. /**
  77206. * Internal only The action manager for the condition
  77207. * @hidden
  77208. */
  77209. _actionManager: ActionManager;
  77210. /**
  77211. * Internal only
  77212. * @hidden
  77213. */
  77214. private _target;
  77215. /**
  77216. * Internal only
  77217. * @hidden
  77218. */
  77219. private _effectiveTarget;
  77220. /**
  77221. * Internal only
  77222. * @hidden
  77223. */
  77224. private _property;
  77225. /**
  77226. * Creates a new ValueCondition
  77227. * @param actionManager manager for the action the condition applies to
  77228. * @param target for the action
  77229. * @param propertyPath path to specify the property of the target the conditional operator uses
  77230. * @param value the value compared by the conditional operator against the current value of the property
  77231. * @param operator the conditional operator, default ValueCondition.IsEqual
  77232. */
  77233. constructor(actionManager: ActionManager, target: any,
  77234. /** path to specify the property of the target the conditional operator uses */
  77235. propertyPath: string,
  77236. /** the value compared by the conditional operator against the current value of the property */
  77237. value: any,
  77238. /** the conditional operator, default ValueCondition.IsEqual */
  77239. operator?: number);
  77240. /**
  77241. * Compares the given value with the property value for the specified conditional operator
  77242. * @returns the result of the comparison
  77243. */
  77244. isValid(): boolean;
  77245. /**
  77246. * Serialize the ValueCondition into a JSON compatible object
  77247. * @returns serialization object
  77248. */
  77249. serialize(): any;
  77250. /**
  77251. * Gets the name of the conditional operator for the ValueCondition
  77252. * @param operator the conditional operator
  77253. * @returns the name
  77254. */
  77255. static GetOperatorName(operator: number): string;
  77256. }
  77257. /**
  77258. * Defines a predicate condition as an extension of Condition
  77259. */
  77260. export class PredicateCondition extends Condition {
  77261. /** defines the predicate function used to validate the condition */
  77262. predicate: () => boolean;
  77263. /**
  77264. * Internal only - manager for action
  77265. * @hidden
  77266. */
  77267. _actionManager: ActionManager;
  77268. /**
  77269. * Creates a new PredicateCondition
  77270. * @param actionManager manager for the action the condition applies to
  77271. * @param predicate defines the predicate function used to validate the condition
  77272. */
  77273. constructor(actionManager: ActionManager,
  77274. /** defines the predicate function used to validate the condition */
  77275. predicate: () => boolean);
  77276. /**
  77277. * @returns the validity of the predicate condition
  77278. */
  77279. isValid(): boolean;
  77280. }
  77281. /**
  77282. * Defines a state condition as an extension of Condition
  77283. */
  77284. export class StateCondition extends Condition {
  77285. /** Value to compare with target state */
  77286. value: string;
  77287. /**
  77288. * Internal only - manager for action
  77289. * @hidden
  77290. */
  77291. _actionManager: ActionManager;
  77292. /**
  77293. * Internal only
  77294. * @hidden
  77295. */
  77296. private _target;
  77297. /**
  77298. * Creates a new StateCondition
  77299. * @param actionManager manager for the action the condition applies to
  77300. * @param target of the condition
  77301. * @param value to compare with target state
  77302. */
  77303. constructor(actionManager: ActionManager, target: any,
  77304. /** Value to compare with target state */
  77305. value: string);
  77306. /**
  77307. * Gets a boolean indicating if the current condition is met
  77308. * @returns the validity of the state
  77309. */
  77310. isValid(): boolean;
  77311. /**
  77312. * Serialize the StateCondition into a JSON compatible object
  77313. * @returns serialization object
  77314. */
  77315. serialize(): any;
  77316. }
  77317. }
  77318. declare module BABYLON {
  77319. /**
  77320. * This defines an action responsible to toggle a boolean once triggered.
  77321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77322. */
  77323. export class SwitchBooleanAction extends Action {
  77324. /**
  77325. * The path to the boolean property in the target object
  77326. */
  77327. propertyPath: string;
  77328. private _target;
  77329. private _effectiveTarget;
  77330. private _property;
  77331. /**
  77332. * Instantiate the action
  77333. * @param triggerOptions defines the trigger options
  77334. * @param target defines the object containing the boolean
  77335. * @param propertyPath defines the path to the boolean property in the target object
  77336. * @param condition defines the trigger related conditions
  77337. */
  77338. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77339. /** @hidden */
  77340. _prepare(): void;
  77341. /**
  77342. * Execute the action toggle the boolean value.
  77343. */
  77344. execute(): void;
  77345. /**
  77346. * Serializes the actions and its related information.
  77347. * @param parent defines the object to serialize in
  77348. * @returns the serialized object
  77349. */
  77350. serialize(parent: any): any;
  77351. }
  77352. /**
  77353. * This defines an action responsible to set a the state field of the target
  77354. * to a desired value once triggered.
  77355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77356. */
  77357. export class SetStateAction extends Action {
  77358. /**
  77359. * The value to store in the state field.
  77360. */
  77361. value: string;
  77362. private _target;
  77363. /**
  77364. * Instantiate the action
  77365. * @param triggerOptions defines the trigger options
  77366. * @param target defines the object containing the state property
  77367. * @param value defines the value to store in the state field
  77368. * @param condition defines the trigger related conditions
  77369. */
  77370. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77371. /**
  77372. * Execute the action and store the value on the target state property.
  77373. */
  77374. execute(): void;
  77375. /**
  77376. * Serializes the actions and its related information.
  77377. * @param parent defines the object to serialize in
  77378. * @returns the serialized object
  77379. */
  77380. serialize(parent: any): any;
  77381. }
  77382. /**
  77383. * This defines an action responsible to set a property of the target
  77384. * to a desired value once triggered.
  77385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77386. */
  77387. export class SetValueAction extends Action {
  77388. /**
  77389. * The path of the property to set in the target.
  77390. */
  77391. propertyPath: string;
  77392. /**
  77393. * The value to set in the property
  77394. */
  77395. value: any;
  77396. private _target;
  77397. private _effectiveTarget;
  77398. private _property;
  77399. /**
  77400. * Instantiate the action
  77401. * @param triggerOptions defines the trigger options
  77402. * @param target defines the object containing the property
  77403. * @param propertyPath defines the path of the property to set in the target
  77404. * @param value defines the value to set in the property
  77405. * @param condition defines the trigger related conditions
  77406. */
  77407. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77408. /** @hidden */
  77409. _prepare(): void;
  77410. /**
  77411. * Execute the action and set the targetted property to the desired value.
  77412. */
  77413. execute(): void;
  77414. /**
  77415. * Serializes the actions and its related information.
  77416. * @param parent defines the object to serialize in
  77417. * @returns the serialized object
  77418. */
  77419. serialize(parent: any): any;
  77420. }
  77421. /**
  77422. * This defines an action responsible to increment the target value
  77423. * to a desired value once triggered.
  77424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77425. */
  77426. export class IncrementValueAction extends Action {
  77427. /**
  77428. * The path of the property to increment in the target.
  77429. */
  77430. propertyPath: string;
  77431. /**
  77432. * The value we should increment the property by.
  77433. */
  77434. value: any;
  77435. private _target;
  77436. private _effectiveTarget;
  77437. private _property;
  77438. /**
  77439. * Instantiate the action
  77440. * @param triggerOptions defines the trigger options
  77441. * @param target defines the object containing the property
  77442. * @param propertyPath defines the path of the property to increment in the target
  77443. * @param value defines the value value we should increment the property by
  77444. * @param condition defines the trigger related conditions
  77445. */
  77446. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77447. /** @hidden */
  77448. _prepare(): void;
  77449. /**
  77450. * Execute the action and increment the target of the value amount.
  77451. */
  77452. execute(): void;
  77453. /**
  77454. * Serializes the actions and its related information.
  77455. * @param parent defines the object to serialize in
  77456. * @returns the serialized object
  77457. */
  77458. serialize(parent: any): any;
  77459. }
  77460. /**
  77461. * This defines an action responsible to start an animation once triggered.
  77462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77463. */
  77464. export class PlayAnimationAction extends Action {
  77465. /**
  77466. * Where the animation should start (animation frame)
  77467. */
  77468. from: number;
  77469. /**
  77470. * Where the animation should stop (animation frame)
  77471. */
  77472. to: number;
  77473. /**
  77474. * Define if the animation should loop or stop after the first play.
  77475. */
  77476. loop?: boolean;
  77477. private _target;
  77478. /**
  77479. * Instantiate the action
  77480. * @param triggerOptions defines the trigger options
  77481. * @param target defines the target animation or animation name
  77482. * @param from defines from where the animation should start (animation frame)
  77483. * @param end defines where the animation should stop (animation frame)
  77484. * @param loop defines if the animation should loop or stop after the first play
  77485. * @param condition defines the trigger related conditions
  77486. */
  77487. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77488. /** @hidden */
  77489. _prepare(): void;
  77490. /**
  77491. * Execute the action and play the animation.
  77492. */
  77493. execute(): void;
  77494. /**
  77495. * Serializes the actions and its related information.
  77496. * @param parent defines the object to serialize in
  77497. * @returns the serialized object
  77498. */
  77499. serialize(parent: any): any;
  77500. }
  77501. /**
  77502. * This defines an action responsible to stop an animation once triggered.
  77503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77504. */
  77505. export class StopAnimationAction extends Action {
  77506. private _target;
  77507. /**
  77508. * Instantiate the action
  77509. * @param triggerOptions defines the trigger options
  77510. * @param target defines the target animation or animation name
  77511. * @param condition defines the trigger related conditions
  77512. */
  77513. constructor(triggerOptions: any, target: any, condition?: Condition);
  77514. /** @hidden */
  77515. _prepare(): void;
  77516. /**
  77517. * Execute the action and stop the animation.
  77518. */
  77519. execute(): void;
  77520. /**
  77521. * Serializes the actions and its related information.
  77522. * @param parent defines the object to serialize in
  77523. * @returns the serialized object
  77524. */
  77525. serialize(parent: any): any;
  77526. }
  77527. /**
  77528. * This defines an action responsible that does nothing once triggered.
  77529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77530. */
  77531. export class DoNothingAction extends Action {
  77532. /**
  77533. * Instantiate the action
  77534. * @param triggerOptions defines the trigger options
  77535. * @param condition defines the trigger related conditions
  77536. */
  77537. constructor(triggerOptions?: any, condition?: Condition);
  77538. /**
  77539. * Execute the action and do nothing.
  77540. */
  77541. execute(): void;
  77542. /**
  77543. * Serializes the actions and its related information.
  77544. * @param parent defines the object to serialize in
  77545. * @returns the serialized object
  77546. */
  77547. serialize(parent: any): any;
  77548. }
  77549. /**
  77550. * This defines an action responsible to trigger several actions once triggered.
  77551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77552. */
  77553. export class CombineAction extends Action {
  77554. /**
  77555. * The list of aggregated animations to run.
  77556. */
  77557. children: Action[];
  77558. /**
  77559. * Instantiate the action
  77560. * @param triggerOptions defines the trigger options
  77561. * @param children defines the list of aggregated animations to run
  77562. * @param condition defines the trigger related conditions
  77563. */
  77564. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77565. /** @hidden */
  77566. _prepare(): void;
  77567. /**
  77568. * Execute the action and executes all the aggregated actions.
  77569. */
  77570. execute(evt: ActionEvent): void;
  77571. /**
  77572. * Serializes the actions and its related information.
  77573. * @param parent defines the object to serialize in
  77574. * @returns the serialized object
  77575. */
  77576. serialize(parent: any): any;
  77577. }
  77578. /**
  77579. * This defines an action responsible to run code (external event) once triggered.
  77580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77581. */
  77582. export class ExecuteCodeAction extends Action {
  77583. /**
  77584. * The callback function to run.
  77585. */
  77586. func: (evt: ActionEvent) => void;
  77587. /**
  77588. * Instantiate the action
  77589. * @param triggerOptions defines the trigger options
  77590. * @param func defines the callback function to run
  77591. * @param condition defines the trigger related conditions
  77592. */
  77593. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77594. /**
  77595. * Execute the action and run the attached code.
  77596. */
  77597. execute(evt: ActionEvent): void;
  77598. }
  77599. /**
  77600. * This defines an action responsible to set the parent property of the target once triggered.
  77601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77602. */
  77603. export class SetParentAction extends Action {
  77604. private _parent;
  77605. private _target;
  77606. /**
  77607. * Instantiate the action
  77608. * @param triggerOptions defines the trigger options
  77609. * @param target defines the target containing the parent property
  77610. * @param parent defines from where the animation should start (animation frame)
  77611. * @param condition defines the trigger related conditions
  77612. */
  77613. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77614. /** @hidden */
  77615. _prepare(): void;
  77616. /**
  77617. * Execute the action and set the parent property.
  77618. */
  77619. execute(): void;
  77620. /**
  77621. * Serializes the actions and its related information.
  77622. * @param parent defines the object to serialize in
  77623. * @returns the serialized object
  77624. */
  77625. serialize(parent: any): any;
  77626. }
  77627. }
  77628. declare module BABYLON {
  77629. /**
  77630. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77631. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77633. */
  77634. export class ActionManager extends AbstractActionManager {
  77635. /**
  77636. * Nothing
  77637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77638. */
  77639. static readonly NothingTrigger: number;
  77640. /**
  77641. * On pick
  77642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77643. */
  77644. static readonly OnPickTrigger: number;
  77645. /**
  77646. * On left pick
  77647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77648. */
  77649. static readonly OnLeftPickTrigger: number;
  77650. /**
  77651. * On right pick
  77652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77653. */
  77654. static readonly OnRightPickTrigger: number;
  77655. /**
  77656. * On center pick
  77657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77658. */
  77659. static readonly OnCenterPickTrigger: number;
  77660. /**
  77661. * On pick down
  77662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77663. */
  77664. static readonly OnPickDownTrigger: number;
  77665. /**
  77666. * On double pick
  77667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77668. */
  77669. static readonly OnDoublePickTrigger: number;
  77670. /**
  77671. * On pick up
  77672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77673. */
  77674. static readonly OnPickUpTrigger: number;
  77675. /**
  77676. * On pick out.
  77677. * This trigger will only be raised if you also declared a OnPickDown
  77678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77679. */
  77680. static readonly OnPickOutTrigger: number;
  77681. /**
  77682. * On long press
  77683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77684. */
  77685. static readonly OnLongPressTrigger: number;
  77686. /**
  77687. * On pointer over
  77688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77689. */
  77690. static readonly OnPointerOverTrigger: number;
  77691. /**
  77692. * On pointer out
  77693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77694. */
  77695. static readonly OnPointerOutTrigger: number;
  77696. /**
  77697. * On every frame
  77698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77699. */
  77700. static readonly OnEveryFrameTrigger: number;
  77701. /**
  77702. * On intersection enter
  77703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77704. */
  77705. static readonly OnIntersectionEnterTrigger: number;
  77706. /**
  77707. * On intersection exit
  77708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77709. */
  77710. static readonly OnIntersectionExitTrigger: number;
  77711. /**
  77712. * On key down
  77713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77714. */
  77715. static readonly OnKeyDownTrigger: number;
  77716. /**
  77717. * On key up
  77718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77719. */
  77720. static readonly OnKeyUpTrigger: number;
  77721. private _scene;
  77722. /**
  77723. * Creates a new action manager
  77724. * @param scene defines the hosting scene
  77725. */
  77726. constructor(scene: Scene);
  77727. /**
  77728. * Releases all associated resources
  77729. */
  77730. dispose(): void;
  77731. /**
  77732. * Gets hosting scene
  77733. * @returns the hosting scene
  77734. */
  77735. getScene(): Scene;
  77736. /**
  77737. * Does this action manager handles actions of any of the given triggers
  77738. * @param triggers defines the triggers to be tested
  77739. * @return a boolean indicating whether one (or more) of the triggers is handled
  77740. */
  77741. hasSpecificTriggers(triggers: number[]): boolean;
  77742. /**
  77743. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77744. * speed.
  77745. * @param triggerA defines the trigger to be tested
  77746. * @param triggerB defines the trigger to be tested
  77747. * @return a boolean indicating whether one (or more) of the triggers is handled
  77748. */
  77749. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77750. /**
  77751. * Does this action manager handles actions of a given trigger
  77752. * @param trigger defines the trigger to be tested
  77753. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77754. * @return whether the trigger is handled
  77755. */
  77756. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77757. /**
  77758. * Does this action manager has pointer triggers
  77759. */
  77760. readonly hasPointerTriggers: boolean;
  77761. /**
  77762. * Does this action manager has pick triggers
  77763. */
  77764. readonly hasPickTriggers: boolean;
  77765. /**
  77766. * Registers an action to this action manager
  77767. * @param action defines the action to be registered
  77768. * @return the action amended (prepared) after registration
  77769. */
  77770. registerAction(action: IAction): Nullable<IAction>;
  77771. /**
  77772. * Unregisters an action to this action manager
  77773. * @param action defines the action to be unregistered
  77774. * @return a boolean indicating whether the action has been unregistered
  77775. */
  77776. unregisterAction(action: IAction): Boolean;
  77777. /**
  77778. * Process a specific trigger
  77779. * @param trigger defines the trigger to process
  77780. * @param evt defines the event details to be processed
  77781. */
  77782. processTrigger(trigger: number, evt?: IActionEvent): void;
  77783. /** @hidden */
  77784. _getEffectiveTarget(target: any, propertyPath: string): any;
  77785. /** @hidden */
  77786. _getProperty(propertyPath: string): string;
  77787. /**
  77788. * Serialize this manager to a JSON object
  77789. * @param name defines the property name to store this manager
  77790. * @returns a JSON representation of this manager
  77791. */
  77792. serialize(name: string): any;
  77793. /**
  77794. * Creates a new ActionManager from a JSON data
  77795. * @param parsedActions defines the JSON data to read from
  77796. * @param object defines the hosting mesh
  77797. * @param scene defines the hosting scene
  77798. */
  77799. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77800. /**
  77801. * Get a trigger name by index
  77802. * @param trigger defines the trigger index
  77803. * @returns a trigger name
  77804. */
  77805. static GetTriggerName(trigger: number): string;
  77806. }
  77807. }
  77808. declare module BABYLON {
  77809. /**
  77810. * Class representing a ray with position and direction
  77811. */
  77812. export class Ray {
  77813. /** origin point */
  77814. origin: Vector3;
  77815. /** direction */
  77816. direction: Vector3;
  77817. /** length of the ray */
  77818. length: number;
  77819. private static readonly TmpVector3;
  77820. private _tmpRay;
  77821. /**
  77822. * Creates a new ray
  77823. * @param origin origin point
  77824. * @param direction direction
  77825. * @param length length of the ray
  77826. */
  77827. constructor(
  77828. /** origin point */
  77829. origin: Vector3,
  77830. /** direction */
  77831. direction: Vector3,
  77832. /** length of the ray */
  77833. length?: number);
  77834. /**
  77835. * Checks if the ray intersects a box
  77836. * @param minimum bound of the box
  77837. * @param maximum bound of the box
  77838. * @param intersectionTreshold extra extend to be added to the box in all direction
  77839. * @returns if the box was hit
  77840. */
  77841. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77842. /**
  77843. * Checks if the ray intersects a box
  77844. * @param box the bounding box to check
  77845. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77846. * @returns if the box was hit
  77847. */
  77848. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77849. /**
  77850. * If the ray hits a sphere
  77851. * @param sphere the bounding sphere to check
  77852. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77853. * @returns true if it hits the sphere
  77854. */
  77855. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77856. /**
  77857. * If the ray hits a triange
  77858. * @param vertex0 triangle vertex
  77859. * @param vertex1 triangle vertex
  77860. * @param vertex2 triangle vertex
  77861. * @returns intersection information if hit
  77862. */
  77863. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77864. /**
  77865. * Checks if ray intersects a plane
  77866. * @param plane the plane to check
  77867. * @returns the distance away it was hit
  77868. */
  77869. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77870. /**
  77871. * Calculate the intercept of a ray on a given axis
  77872. * @param axis to check 'x' | 'y' | 'z'
  77873. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77874. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77875. */
  77876. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77877. /**
  77878. * Checks if ray intersects a mesh
  77879. * @param mesh the mesh to check
  77880. * @param fastCheck if only the bounding box should checked
  77881. * @returns picking info of the intersecton
  77882. */
  77883. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77884. /**
  77885. * Checks if ray intersects a mesh
  77886. * @param meshes the meshes to check
  77887. * @param fastCheck if only the bounding box should checked
  77888. * @param results array to store result in
  77889. * @returns Array of picking infos
  77890. */
  77891. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77892. private _comparePickingInfo;
  77893. private static smallnum;
  77894. private static rayl;
  77895. /**
  77896. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77897. * @param sega the first point of the segment to test the intersection against
  77898. * @param segb the second point of the segment to test the intersection against
  77899. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77900. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77901. */
  77902. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77903. /**
  77904. * Update the ray from viewport position
  77905. * @param x position
  77906. * @param y y position
  77907. * @param viewportWidth viewport width
  77908. * @param viewportHeight viewport height
  77909. * @param world world matrix
  77910. * @param view view matrix
  77911. * @param projection projection matrix
  77912. * @returns this ray updated
  77913. */
  77914. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77915. /**
  77916. * Creates a ray with origin and direction of 0,0,0
  77917. * @returns the new ray
  77918. */
  77919. static Zero(): Ray;
  77920. /**
  77921. * Creates a new ray from screen space and viewport
  77922. * @param x position
  77923. * @param y y position
  77924. * @param viewportWidth viewport width
  77925. * @param viewportHeight viewport height
  77926. * @param world world matrix
  77927. * @param view view matrix
  77928. * @param projection projection matrix
  77929. * @returns new ray
  77930. */
  77931. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77932. /**
  77933. * 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
  77934. * transformed to the given world matrix.
  77935. * @param origin The origin point
  77936. * @param end The end point
  77937. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77938. * @returns the new ray
  77939. */
  77940. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77941. /**
  77942. * Transforms a ray by a matrix
  77943. * @param ray ray to transform
  77944. * @param matrix matrix to apply
  77945. * @returns the resulting new ray
  77946. */
  77947. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77948. /**
  77949. * Transforms a ray by a matrix
  77950. * @param ray ray to transform
  77951. * @param matrix matrix to apply
  77952. * @param result ray to store result in
  77953. */
  77954. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77955. /**
  77956. * Unproject a ray from screen space to object space
  77957. * @param sourceX defines the screen space x coordinate to use
  77958. * @param sourceY defines the screen space y coordinate to use
  77959. * @param viewportWidth defines the current width of the viewport
  77960. * @param viewportHeight defines the current height of the viewport
  77961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77962. * @param view defines the view matrix to use
  77963. * @param projection defines the projection matrix to use
  77964. */
  77965. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77966. }
  77967. /**
  77968. * Type used to define predicate used to select faces when a mesh intersection is detected
  77969. */
  77970. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77971. interface Scene {
  77972. /** @hidden */
  77973. _tempPickingRay: Nullable<Ray>;
  77974. /** @hidden */
  77975. _cachedRayForTransform: Ray;
  77976. /** @hidden */
  77977. _pickWithRayInverseMatrix: Matrix;
  77978. /** @hidden */
  77979. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77980. /** @hidden */
  77981. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77982. }
  77983. }
  77984. declare module BABYLON {
  77985. /**
  77986. * Groups all the scene component constants in one place to ease maintenance.
  77987. * @hidden
  77988. */
  77989. export class SceneComponentConstants {
  77990. static readonly NAME_EFFECTLAYER: string;
  77991. static readonly NAME_LAYER: string;
  77992. static readonly NAME_LENSFLARESYSTEM: string;
  77993. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77994. static readonly NAME_PARTICLESYSTEM: string;
  77995. static readonly NAME_GAMEPAD: string;
  77996. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77997. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77998. static readonly NAME_DEPTHRENDERER: string;
  77999. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78000. static readonly NAME_SPRITE: string;
  78001. static readonly NAME_OUTLINERENDERER: string;
  78002. static readonly NAME_PROCEDURALTEXTURE: string;
  78003. static readonly NAME_SHADOWGENERATOR: string;
  78004. static readonly NAME_OCTREE: string;
  78005. static readonly NAME_PHYSICSENGINE: string;
  78006. static readonly NAME_AUDIO: string;
  78007. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78008. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78009. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78010. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78011. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78012. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78013. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78014. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78015. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78016. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78017. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78018. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78019. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78020. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78021. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78022. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78023. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78024. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78025. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78026. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78027. static readonly STEP_AFTERRENDER_AUDIO: number;
  78028. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78029. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78030. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78031. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78032. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78033. static readonly STEP_POINTERMOVE_SPRITE: number;
  78034. static readonly STEP_POINTERDOWN_SPRITE: number;
  78035. static readonly STEP_POINTERUP_SPRITE: number;
  78036. }
  78037. /**
  78038. * This represents a scene component.
  78039. *
  78040. * This is used to decouple the dependency the scene is having on the different workloads like
  78041. * layers, post processes...
  78042. */
  78043. export interface ISceneComponent {
  78044. /**
  78045. * The name of the component. Each component must have a unique name.
  78046. */
  78047. name: string;
  78048. /**
  78049. * The scene the component belongs to.
  78050. */
  78051. scene: Scene;
  78052. /**
  78053. * Register the component to one instance of a scene.
  78054. */
  78055. register(): void;
  78056. /**
  78057. * Rebuilds the elements related to this component in case of
  78058. * context lost for instance.
  78059. */
  78060. rebuild(): void;
  78061. /**
  78062. * Disposes the component and the associated ressources.
  78063. */
  78064. dispose(): void;
  78065. }
  78066. /**
  78067. * This represents a SERIALIZABLE scene component.
  78068. *
  78069. * This extends Scene Component to add Serialization methods on top.
  78070. */
  78071. export interface ISceneSerializableComponent extends ISceneComponent {
  78072. /**
  78073. * Adds all the elements from the container to the scene
  78074. * @param container the container holding the elements
  78075. */
  78076. addFromContainer(container: AbstractScene): void;
  78077. /**
  78078. * Removes all the elements in the container from the scene
  78079. * @param container contains the elements to remove
  78080. * @param dispose if the removed element should be disposed (default: false)
  78081. */
  78082. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78083. /**
  78084. * Serializes the component data to the specified json object
  78085. * @param serializationObject The object to serialize to
  78086. */
  78087. serialize(serializationObject: any): void;
  78088. }
  78089. /**
  78090. * Strong typing of a Mesh related stage step action
  78091. */
  78092. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78093. /**
  78094. * Strong typing of a Evaluate Sub Mesh related stage step action
  78095. */
  78096. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78097. /**
  78098. * Strong typing of a Active Mesh related stage step action
  78099. */
  78100. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78101. /**
  78102. * Strong typing of a Camera related stage step action
  78103. */
  78104. export type CameraStageAction = (camera: Camera) => void;
  78105. /**
  78106. * Strong typing of a Camera Frame buffer related stage step action
  78107. */
  78108. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78109. /**
  78110. * Strong typing of a Render Target related stage step action
  78111. */
  78112. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78113. /**
  78114. * Strong typing of a RenderingGroup related stage step action
  78115. */
  78116. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78117. /**
  78118. * Strong typing of a Mesh Render related stage step action
  78119. */
  78120. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78121. /**
  78122. * Strong typing of a simple stage step action
  78123. */
  78124. export type SimpleStageAction = () => void;
  78125. /**
  78126. * Strong typing of a render target action.
  78127. */
  78128. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78129. /**
  78130. * Strong typing of a pointer move action.
  78131. */
  78132. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78133. /**
  78134. * Strong typing of a pointer up/down action.
  78135. */
  78136. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78137. /**
  78138. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78139. * @hidden
  78140. */
  78141. export class Stage<T extends Function> extends Array<{
  78142. index: number;
  78143. component: ISceneComponent;
  78144. action: T;
  78145. }> {
  78146. /**
  78147. * Hide ctor from the rest of the world.
  78148. * @param items The items to add.
  78149. */
  78150. private constructor();
  78151. /**
  78152. * Creates a new Stage.
  78153. * @returns A new instance of a Stage
  78154. */
  78155. static Create<T extends Function>(): Stage<T>;
  78156. /**
  78157. * Registers a step in an ordered way in the targeted stage.
  78158. * @param index Defines the position to register the step in
  78159. * @param component Defines the component attached to the step
  78160. * @param action Defines the action to launch during the step
  78161. */
  78162. registerStep(index: number, component: ISceneComponent, action: T): void;
  78163. /**
  78164. * Clears all the steps from the stage.
  78165. */
  78166. clear(): void;
  78167. }
  78168. }
  78169. declare module BABYLON {
  78170. interface Scene {
  78171. /** @hidden */
  78172. _pointerOverSprite: Nullable<Sprite>;
  78173. /** @hidden */
  78174. _pickedDownSprite: Nullable<Sprite>;
  78175. /** @hidden */
  78176. _tempSpritePickingRay: Nullable<Ray>;
  78177. /**
  78178. * All of the sprite managers added to this scene
  78179. * @see http://doc.babylonjs.com/babylon101/sprites
  78180. */
  78181. spriteManagers: Array<ISpriteManager>;
  78182. /**
  78183. * An event triggered when sprites rendering is about to start
  78184. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78185. */
  78186. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78187. /**
  78188. * An event triggered when sprites rendering is done
  78189. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78190. */
  78191. onAfterSpritesRenderingObservable: Observable<Scene>;
  78192. /** @hidden */
  78193. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78194. /** Launch a ray to try to pick a sprite in the scene
  78195. * @param x position on screen
  78196. * @param y position on screen
  78197. * @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
  78198. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78199. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78200. * @returns a PickingInfo
  78201. */
  78202. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78203. /** Use the given ray to pick a sprite in the scene
  78204. * @param ray The ray (in world space) to use to pick meshes
  78205. * @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
  78206. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78207. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78208. * @returns a PickingInfo
  78209. */
  78210. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78211. /** @hidden */
  78212. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78213. /** Launch a ray to try to pick sprites in the scene
  78214. * @param x position on screen
  78215. * @param y position on screen
  78216. * @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
  78217. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78218. * @returns a PickingInfo array
  78219. */
  78220. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78221. /** Use the given ray to pick sprites in the scene
  78222. * @param ray The ray (in world space) to use to pick meshes
  78223. * @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
  78224. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78225. * @returns a PickingInfo array
  78226. */
  78227. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78228. /**
  78229. * Force the sprite under the pointer
  78230. * @param sprite defines the sprite to use
  78231. */
  78232. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78233. /**
  78234. * Gets the sprite under the pointer
  78235. * @returns a Sprite or null if no sprite is under the pointer
  78236. */
  78237. getPointerOverSprite(): Nullable<Sprite>;
  78238. }
  78239. /**
  78240. * Defines the sprite scene component responsible to manage sprites
  78241. * in a given scene.
  78242. */
  78243. export class SpriteSceneComponent implements ISceneComponent {
  78244. /**
  78245. * The component name helpfull to identify the component in the list of scene components.
  78246. */
  78247. readonly name: string;
  78248. /**
  78249. * The scene the component belongs to.
  78250. */
  78251. scene: Scene;
  78252. /** @hidden */
  78253. private _spritePredicate;
  78254. /**
  78255. * Creates a new instance of the component for the given scene
  78256. * @param scene Defines the scene to register the component in
  78257. */
  78258. constructor(scene: Scene);
  78259. /**
  78260. * Registers the component in a given scene
  78261. */
  78262. register(): void;
  78263. /**
  78264. * Rebuilds the elements related to this component in case of
  78265. * context lost for instance.
  78266. */
  78267. rebuild(): void;
  78268. /**
  78269. * Disposes the component and the associated ressources.
  78270. */
  78271. dispose(): void;
  78272. private _pickSpriteButKeepRay;
  78273. private _pointerMove;
  78274. private _pointerDown;
  78275. private _pointerUp;
  78276. }
  78277. }
  78278. declare module BABYLON {
  78279. /** @hidden */
  78280. export var fogFragmentDeclaration: {
  78281. name: string;
  78282. shader: string;
  78283. };
  78284. }
  78285. declare module BABYLON {
  78286. /** @hidden */
  78287. export var fogFragment: {
  78288. name: string;
  78289. shader: string;
  78290. };
  78291. }
  78292. declare module BABYLON {
  78293. /** @hidden */
  78294. export var spritesPixelShader: {
  78295. name: string;
  78296. shader: string;
  78297. };
  78298. }
  78299. declare module BABYLON {
  78300. /** @hidden */
  78301. export var fogVertexDeclaration: {
  78302. name: string;
  78303. shader: string;
  78304. };
  78305. }
  78306. declare module BABYLON {
  78307. /** @hidden */
  78308. export var spritesVertexShader: {
  78309. name: string;
  78310. shader: string;
  78311. };
  78312. }
  78313. declare module BABYLON {
  78314. /**
  78315. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78316. */
  78317. export interface ISpriteManager extends IDisposable {
  78318. /**
  78319. * Restricts the camera to viewing objects with the same layerMask.
  78320. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78321. */
  78322. layerMask: number;
  78323. /**
  78324. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78325. */
  78326. isPickable: boolean;
  78327. /**
  78328. * Specifies the rendering group id for this mesh (0 by default)
  78329. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78330. */
  78331. renderingGroupId: number;
  78332. /**
  78333. * Defines the list of sprites managed by the manager.
  78334. */
  78335. sprites: Array<Sprite>;
  78336. /**
  78337. * Tests the intersection of a sprite with a specific ray.
  78338. * @param ray The ray we are sending to test the collision
  78339. * @param camera The camera space we are sending rays in
  78340. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78341. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78342. * @returns picking info or null.
  78343. */
  78344. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78345. /**
  78346. * Intersects the sprites with a ray
  78347. * @param ray defines the ray to intersect with
  78348. * @param camera defines the current active camera
  78349. * @param predicate defines a predicate used to select candidate sprites
  78350. * @returns null if no hit or a PickingInfo array
  78351. */
  78352. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78353. /**
  78354. * Renders the list of sprites on screen.
  78355. */
  78356. render(): void;
  78357. }
  78358. /**
  78359. * Class used to manage multiple sprites on the same spritesheet
  78360. * @see http://doc.babylonjs.com/babylon101/sprites
  78361. */
  78362. export class SpriteManager implements ISpriteManager {
  78363. /** defines the manager's name */
  78364. name: string;
  78365. /** Gets the list of sprites */
  78366. sprites: Sprite[];
  78367. /** Gets or sets the rendering group id (0 by default) */
  78368. renderingGroupId: number;
  78369. /** Gets or sets camera layer mask */
  78370. layerMask: number;
  78371. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78372. fogEnabled: boolean;
  78373. /** Gets or sets a boolean indicating if the sprites are pickable */
  78374. isPickable: boolean;
  78375. /** Defines the default width of a cell in the spritesheet */
  78376. cellWidth: number;
  78377. /** Defines the default height of a cell in the spritesheet */
  78378. cellHeight: number;
  78379. /** Associative array from JSON sprite data file */
  78380. private _cellData;
  78381. /** Array of sprite names from JSON sprite data file */
  78382. private _spriteMap;
  78383. /** True when packed cell data from JSON file is ready*/
  78384. private _packedAndReady;
  78385. /**
  78386. * An event triggered when the manager is disposed.
  78387. */
  78388. onDisposeObservable: Observable<SpriteManager>;
  78389. private _onDisposeObserver;
  78390. /**
  78391. * Callback called when the manager is disposed
  78392. */
  78393. onDispose: () => void;
  78394. private _capacity;
  78395. private _fromPacked;
  78396. private _spriteTexture;
  78397. private _epsilon;
  78398. private _scene;
  78399. private _vertexData;
  78400. private _buffer;
  78401. private _vertexBuffers;
  78402. private _indexBuffer;
  78403. private _effectBase;
  78404. private _effectFog;
  78405. /**
  78406. * Gets or sets the spritesheet texture
  78407. */
  78408. texture: Texture;
  78409. /**
  78410. * Creates a new sprite manager
  78411. * @param name defines the manager's name
  78412. * @param imgUrl defines the sprite sheet url
  78413. * @param capacity defines the maximum allowed number of sprites
  78414. * @param cellSize defines the size of a sprite cell
  78415. * @param scene defines the hosting scene
  78416. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78417. * @param samplingMode defines the smapling mode to use with spritesheet
  78418. * @param fromPacked set to false; do not alter
  78419. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78420. */
  78421. constructor(
  78422. /** defines the manager's name */
  78423. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78424. private _makePacked;
  78425. private _appendSpriteVertex;
  78426. /**
  78427. * Intersects the sprites with a ray
  78428. * @param ray defines the ray to intersect with
  78429. * @param camera defines the current active camera
  78430. * @param predicate defines a predicate used to select candidate sprites
  78431. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78432. * @returns null if no hit or a PickingInfo
  78433. */
  78434. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78435. /**
  78436. * Intersects the sprites with a ray
  78437. * @param ray defines the ray to intersect with
  78438. * @param camera defines the current active camera
  78439. * @param predicate defines a predicate used to select candidate sprites
  78440. * @returns null if no hit or a PickingInfo array
  78441. */
  78442. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78443. /**
  78444. * Render all child sprites
  78445. */
  78446. render(): void;
  78447. /**
  78448. * Release associated resources
  78449. */
  78450. dispose(): void;
  78451. }
  78452. }
  78453. declare module BABYLON {
  78454. /**
  78455. * Class used to represent a sprite
  78456. * @see http://doc.babylonjs.com/babylon101/sprites
  78457. */
  78458. export class Sprite {
  78459. /** defines the name */
  78460. name: string;
  78461. /** Gets or sets the current world position */
  78462. position: Vector3;
  78463. /** Gets or sets the main color */
  78464. color: Color4;
  78465. /** Gets or sets the width */
  78466. width: number;
  78467. /** Gets or sets the height */
  78468. height: number;
  78469. /** Gets or sets rotation angle */
  78470. angle: number;
  78471. /** Gets or sets the cell index in the sprite sheet */
  78472. cellIndex: number;
  78473. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78474. cellRef: string;
  78475. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78476. invertU: number;
  78477. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78478. invertV: number;
  78479. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78480. disposeWhenFinishedAnimating: boolean;
  78481. /** Gets the list of attached animations */
  78482. animations: Animation[];
  78483. /** Gets or sets a boolean indicating if the sprite can be picked */
  78484. isPickable: boolean;
  78485. /**
  78486. * Gets or sets the associated action manager
  78487. */
  78488. actionManager: Nullable<ActionManager>;
  78489. private _animationStarted;
  78490. private _loopAnimation;
  78491. private _fromIndex;
  78492. private _toIndex;
  78493. private _delay;
  78494. private _direction;
  78495. private _manager;
  78496. private _time;
  78497. private _onAnimationEnd;
  78498. /**
  78499. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78500. */
  78501. isVisible: boolean;
  78502. /**
  78503. * Gets or sets the sprite size
  78504. */
  78505. size: number;
  78506. /**
  78507. * Creates a new Sprite
  78508. * @param name defines the name
  78509. * @param manager defines the manager
  78510. */
  78511. constructor(
  78512. /** defines the name */
  78513. name: string, manager: ISpriteManager);
  78514. /**
  78515. * Starts an animation
  78516. * @param from defines the initial key
  78517. * @param to defines the end key
  78518. * @param loop defines if the animation must loop
  78519. * @param delay defines the start delay (in ms)
  78520. * @param onAnimationEnd defines a callback to call when animation ends
  78521. */
  78522. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78523. /** Stops current animation (if any) */
  78524. stopAnimation(): void;
  78525. /** @hidden */
  78526. _animate(deltaTime: number): void;
  78527. /** Release associated resources */
  78528. dispose(): void;
  78529. }
  78530. }
  78531. declare module BABYLON {
  78532. /**
  78533. * Information about the result of picking within a scene
  78534. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78535. */
  78536. export class PickingInfo {
  78537. /** @hidden */
  78538. _pickingUnavailable: boolean;
  78539. /**
  78540. * If the pick collided with an object
  78541. */
  78542. hit: boolean;
  78543. /**
  78544. * Distance away where the pick collided
  78545. */
  78546. distance: number;
  78547. /**
  78548. * The location of pick collision
  78549. */
  78550. pickedPoint: Nullable<Vector3>;
  78551. /**
  78552. * The mesh corresponding the the pick collision
  78553. */
  78554. pickedMesh: Nullable<AbstractMesh>;
  78555. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78556. bu: number;
  78557. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78558. bv: number;
  78559. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78560. faceId: number;
  78561. /** Id of the the submesh that was picked */
  78562. subMeshId: number;
  78563. /** If a sprite was picked, this will be the sprite the pick collided with */
  78564. pickedSprite: Nullable<Sprite>;
  78565. /**
  78566. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78567. */
  78568. originMesh: Nullable<AbstractMesh>;
  78569. /**
  78570. * The ray that was used to perform the picking.
  78571. */
  78572. ray: Nullable<Ray>;
  78573. /**
  78574. * Gets the normal correspodning to the face the pick collided with
  78575. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78576. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78577. * @returns The normal correspodning to the face the pick collided with
  78578. */
  78579. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78580. /**
  78581. * Gets the texture coordinates of where the pick occured
  78582. * @returns the vector containing the coordnates of the texture
  78583. */
  78584. getTextureCoordinates(): Nullable<Vector2>;
  78585. }
  78586. }
  78587. declare module BABYLON {
  78588. /**
  78589. * Gather the list of pointer event types as constants.
  78590. */
  78591. export class PointerEventTypes {
  78592. /**
  78593. * 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.
  78594. */
  78595. static readonly POINTERDOWN: number;
  78596. /**
  78597. * The pointerup event is fired when a pointer is no longer active.
  78598. */
  78599. static readonly POINTERUP: number;
  78600. /**
  78601. * The pointermove event is fired when a pointer changes coordinates.
  78602. */
  78603. static readonly POINTERMOVE: number;
  78604. /**
  78605. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78606. */
  78607. static readonly POINTERWHEEL: number;
  78608. /**
  78609. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78610. */
  78611. static readonly POINTERPICK: number;
  78612. /**
  78613. * The pointertap event is fired when a the object has been touched and released without drag.
  78614. */
  78615. static readonly POINTERTAP: number;
  78616. /**
  78617. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78618. */
  78619. static readonly POINTERDOUBLETAP: number;
  78620. }
  78621. /**
  78622. * Base class of pointer info types.
  78623. */
  78624. export class PointerInfoBase {
  78625. /**
  78626. * Defines the type of event (PointerEventTypes)
  78627. */
  78628. type: number;
  78629. /**
  78630. * Defines the related dom event
  78631. */
  78632. event: PointerEvent | MouseWheelEvent;
  78633. /**
  78634. * Instantiates the base class of pointers info.
  78635. * @param type Defines the type of event (PointerEventTypes)
  78636. * @param event Defines the related dom event
  78637. */
  78638. constructor(
  78639. /**
  78640. * Defines the type of event (PointerEventTypes)
  78641. */
  78642. type: number,
  78643. /**
  78644. * Defines the related dom event
  78645. */
  78646. event: PointerEvent | MouseWheelEvent);
  78647. }
  78648. /**
  78649. * This class is used to store pointer related info for the onPrePointerObservable event.
  78650. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78651. */
  78652. export class PointerInfoPre extends PointerInfoBase {
  78653. /**
  78654. * Ray from a pointer if availible (eg. 6dof controller)
  78655. */
  78656. ray: Nullable<Ray>;
  78657. /**
  78658. * Defines the local position of the pointer on the canvas.
  78659. */
  78660. localPosition: Vector2;
  78661. /**
  78662. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78663. */
  78664. skipOnPointerObservable: boolean;
  78665. /**
  78666. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78667. * @param type Defines the type of event (PointerEventTypes)
  78668. * @param event Defines the related dom event
  78669. * @param localX Defines the local x coordinates of the pointer when the event occured
  78670. * @param localY Defines the local y coordinates of the pointer when the event occured
  78671. */
  78672. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78673. }
  78674. /**
  78675. * This type contains all the data related to a pointer event in Babylon.js.
  78676. * 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.
  78677. */
  78678. export class PointerInfo extends PointerInfoBase {
  78679. /**
  78680. * Defines the picking info associated to the info (if any)\
  78681. */
  78682. pickInfo: Nullable<PickingInfo>;
  78683. /**
  78684. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78685. * @param type Defines the type of event (PointerEventTypes)
  78686. * @param event Defines the related dom event
  78687. * @param pickInfo Defines the picking info associated to the info (if any)\
  78688. */
  78689. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78690. /**
  78691. * Defines the picking info associated to the info (if any)\
  78692. */
  78693. pickInfo: Nullable<PickingInfo>);
  78694. }
  78695. /**
  78696. * Data relating to a touch event on the screen.
  78697. */
  78698. export interface PointerTouch {
  78699. /**
  78700. * X coordinate of touch.
  78701. */
  78702. x: number;
  78703. /**
  78704. * Y coordinate of touch.
  78705. */
  78706. y: number;
  78707. /**
  78708. * Id of touch. Unique for each finger.
  78709. */
  78710. pointerId: number;
  78711. /**
  78712. * Event type passed from DOM.
  78713. */
  78714. type: any;
  78715. }
  78716. }
  78717. declare module BABYLON {
  78718. /**
  78719. * Manage the mouse inputs to control the movement of a free camera.
  78720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78721. */
  78722. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78723. /**
  78724. * Define if touch is enabled in the mouse input
  78725. */
  78726. touchEnabled: boolean;
  78727. /**
  78728. * Defines the camera the input is attached to.
  78729. */
  78730. camera: FreeCamera;
  78731. /**
  78732. * Defines the buttons associated with the input to handle camera move.
  78733. */
  78734. buttons: number[];
  78735. /**
  78736. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78737. */
  78738. angularSensibility: number;
  78739. private _pointerInput;
  78740. private _onMouseMove;
  78741. private _observer;
  78742. private previousPosition;
  78743. /**
  78744. * Observable for when a pointer move event occurs containing the move offset
  78745. */
  78746. onPointerMovedObservable: Observable<{
  78747. offsetX: number;
  78748. offsetY: number;
  78749. }>;
  78750. /**
  78751. * @hidden
  78752. * If the camera should be rotated automatically based on pointer movement
  78753. */
  78754. _allowCameraRotation: boolean;
  78755. /**
  78756. * Manage the mouse inputs to control the movement of a free camera.
  78757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78758. * @param touchEnabled Defines if touch is enabled or not
  78759. */
  78760. constructor(
  78761. /**
  78762. * Define if touch is enabled in the mouse input
  78763. */
  78764. touchEnabled?: boolean);
  78765. /**
  78766. * Attach the input controls to a specific dom element to get the input from.
  78767. * @param element Defines the element the controls should be listened from
  78768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78769. */
  78770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78771. /**
  78772. * Called on JS contextmenu event.
  78773. * Override this method to provide functionality.
  78774. */
  78775. protected onContextMenu(evt: PointerEvent): void;
  78776. /**
  78777. * Detach the current controls from the specified dom element.
  78778. * @param element Defines the element to stop listening the inputs from
  78779. */
  78780. detachControl(element: Nullable<HTMLElement>): void;
  78781. /**
  78782. * Gets the class name of the current intput.
  78783. * @returns the class name
  78784. */
  78785. getClassName(): string;
  78786. /**
  78787. * Get the friendly name associated with the input class.
  78788. * @returns the input friendly name
  78789. */
  78790. getSimpleName(): string;
  78791. }
  78792. }
  78793. declare module BABYLON {
  78794. /**
  78795. * Manage the touch inputs to control the movement of a free camera.
  78796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78797. */
  78798. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78799. /**
  78800. * Defines the camera the input is attached to.
  78801. */
  78802. camera: FreeCamera;
  78803. /**
  78804. * Defines the touch sensibility for rotation.
  78805. * The higher the faster.
  78806. */
  78807. touchAngularSensibility: number;
  78808. /**
  78809. * Defines the touch sensibility for move.
  78810. * The higher the faster.
  78811. */
  78812. touchMoveSensibility: number;
  78813. private _offsetX;
  78814. private _offsetY;
  78815. private _pointerPressed;
  78816. private _pointerInput;
  78817. private _observer;
  78818. private _onLostFocus;
  78819. /**
  78820. * Attach the input controls to a specific dom element to get the input from.
  78821. * @param element Defines the element the controls should be listened from
  78822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78823. */
  78824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78825. /**
  78826. * Detach the current controls from the specified dom element.
  78827. * @param element Defines the element to stop listening the inputs from
  78828. */
  78829. detachControl(element: Nullable<HTMLElement>): void;
  78830. /**
  78831. * Update the current camera state depending on the inputs that have been used this frame.
  78832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78833. */
  78834. checkInputs(): void;
  78835. /**
  78836. * Gets the class name of the current intput.
  78837. * @returns the class name
  78838. */
  78839. getClassName(): string;
  78840. /**
  78841. * Get the friendly name associated with the input class.
  78842. * @returns the input friendly name
  78843. */
  78844. getSimpleName(): string;
  78845. }
  78846. }
  78847. declare module BABYLON {
  78848. /**
  78849. * Default Inputs manager for the FreeCamera.
  78850. * It groups all the default supported inputs for ease of use.
  78851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78852. */
  78853. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78854. /**
  78855. * @hidden
  78856. */
  78857. _mouseInput: Nullable<FreeCameraMouseInput>;
  78858. /**
  78859. * Instantiates a new FreeCameraInputsManager.
  78860. * @param camera Defines the camera the inputs belong to
  78861. */
  78862. constructor(camera: FreeCamera);
  78863. /**
  78864. * Add keyboard input support to the input manager.
  78865. * @returns the current input manager
  78866. */
  78867. addKeyboard(): FreeCameraInputsManager;
  78868. /**
  78869. * Add mouse input support to the input manager.
  78870. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78871. * @returns the current input manager
  78872. */
  78873. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78874. /**
  78875. * Removes the mouse input support from the manager
  78876. * @returns the current input manager
  78877. */
  78878. removeMouse(): FreeCameraInputsManager;
  78879. /**
  78880. * Add touch input support to the input manager.
  78881. * @returns the current input manager
  78882. */
  78883. addTouch(): FreeCameraInputsManager;
  78884. /**
  78885. * Remove all attached input methods from a camera
  78886. */
  78887. clear(): void;
  78888. }
  78889. }
  78890. declare module BABYLON {
  78891. /**
  78892. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78893. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78894. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78895. */
  78896. export class FreeCamera extends TargetCamera {
  78897. /**
  78898. * Define the collision ellipsoid of the camera.
  78899. * This is helpful to simulate a camera body like the player body around the camera
  78900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78901. */
  78902. ellipsoid: Vector3;
  78903. /**
  78904. * Define an offset for the position of the ellipsoid around the camera.
  78905. * This can be helpful to determine the center of the body near the gravity center of the body
  78906. * instead of its head.
  78907. */
  78908. ellipsoidOffset: Vector3;
  78909. /**
  78910. * Enable or disable collisions of the camera with the rest of the scene objects.
  78911. */
  78912. checkCollisions: boolean;
  78913. /**
  78914. * Enable or disable gravity on the camera.
  78915. */
  78916. applyGravity: boolean;
  78917. /**
  78918. * Define the input manager associated to the camera.
  78919. */
  78920. inputs: FreeCameraInputsManager;
  78921. /**
  78922. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78923. * Higher values reduce sensitivity.
  78924. */
  78925. /**
  78926. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78927. * Higher values reduce sensitivity.
  78928. */
  78929. angularSensibility: number;
  78930. /**
  78931. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78932. */
  78933. keysUp: number[];
  78934. /**
  78935. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78936. */
  78937. keysDown: number[];
  78938. /**
  78939. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78940. */
  78941. keysLeft: number[];
  78942. /**
  78943. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78944. */
  78945. keysRight: number[];
  78946. /**
  78947. * Event raised when the camera collide with a mesh in the scene.
  78948. */
  78949. onCollide: (collidedMesh: AbstractMesh) => void;
  78950. private _collider;
  78951. private _needMoveForGravity;
  78952. private _oldPosition;
  78953. private _diffPosition;
  78954. private _newPosition;
  78955. /** @hidden */
  78956. _localDirection: Vector3;
  78957. /** @hidden */
  78958. _transformedDirection: Vector3;
  78959. /**
  78960. * Instantiates a Free Camera.
  78961. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78962. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78963. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78964. * @param name Define the name of the camera in the scene
  78965. * @param position Define the start position of the camera in the scene
  78966. * @param scene Define the scene the camera belongs to
  78967. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78968. */
  78969. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78970. /**
  78971. * Attached controls to the current camera.
  78972. * @param element Defines the element the controls should be listened from
  78973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78974. */
  78975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78976. /**
  78977. * Detach the current controls from the camera.
  78978. * The camera will stop reacting to inputs.
  78979. * @param element Defines the element to stop listening the inputs from
  78980. */
  78981. detachControl(element: HTMLElement): void;
  78982. private _collisionMask;
  78983. /**
  78984. * Define a collision mask to limit the list of object the camera can collide with
  78985. */
  78986. collisionMask: number;
  78987. /** @hidden */
  78988. _collideWithWorld(displacement: Vector3): void;
  78989. private _onCollisionPositionChange;
  78990. /** @hidden */
  78991. _checkInputs(): void;
  78992. /** @hidden */
  78993. _decideIfNeedsToMove(): boolean;
  78994. /** @hidden */
  78995. _updatePosition(): void;
  78996. /**
  78997. * Destroy the camera and release the current resources hold by it.
  78998. */
  78999. dispose(): void;
  79000. /**
  79001. * Gets the current object class name.
  79002. * @return the class name
  79003. */
  79004. getClassName(): string;
  79005. }
  79006. }
  79007. declare module BABYLON {
  79008. /**
  79009. * Represents a gamepad control stick position
  79010. */
  79011. export class StickValues {
  79012. /**
  79013. * The x component of the control stick
  79014. */
  79015. x: number;
  79016. /**
  79017. * The y component of the control stick
  79018. */
  79019. y: number;
  79020. /**
  79021. * Initializes the gamepad x and y control stick values
  79022. * @param x The x component of the gamepad control stick value
  79023. * @param y The y component of the gamepad control stick value
  79024. */
  79025. constructor(
  79026. /**
  79027. * The x component of the control stick
  79028. */
  79029. x: number,
  79030. /**
  79031. * The y component of the control stick
  79032. */
  79033. y: number);
  79034. }
  79035. /**
  79036. * An interface which manages callbacks for gamepad button changes
  79037. */
  79038. export interface GamepadButtonChanges {
  79039. /**
  79040. * Called when a gamepad has been changed
  79041. */
  79042. changed: boolean;
  79043. /**
  79044. * Called when a gamepad press event has been triggered
  79045. */
  79046. pressChanged: boolean;
  79047. /**
  79048. * Called when a touch event has been triggered
  79049. */
  79050. touchChanged: boolean;
  79051. /**
  79052. * Called when a value has changed
  79053. */
  79054. valueChanged: boolean;
  79055. }
  79056. /**
  79057. * Represents a gamepad
  79058. */
  79059. export class Gamepad {
  79060. /**
  79061. * The id of the gamepad
  79062. */
  79063. id: string;
  79064. /**
  79065. * The index of the gamepad
  79066. */
  79067. index: number;
  79068. /**
  79069. * The browser gamepad
  79070. */
  79071. browserGamepad: any;
  79072. /**
  79073. * Specifies what type of gamepad this represents
  79074. */
  79075. type: number;
  79076. private _leftStick;
  79077. private _rightStick;
  79078. /** @hidden */
  79079. _isConnected: boolean;
  79080. private _leftStickAxisX;
  79081. private _leftStickAxisY;
  79082. private _rightStickAxisX;
  79083. private _rightStickAxisY;
  79084. /**
  79085. * Triggered when the left control stick has been changed
  79086. */
  79087. private _onleftstickchanged;
  79088. /**
  79089. * Triggered when the right control stick has been changed
  79090. */
  79091. private _onrightstickchanged;
  79092. /**
  79093. * Represents a gamepad controller
  79094. */
  79095. static GAMEPAD: number;
  79096. /**
  79097. * Represents a generic controller
  79098. */
  79099. static GENERIC: number;
  79100. /**
  79101. * Represents an XBox controller
  79102. */
  79103. static XBOX: number;
  79104. /**
  79105. * Represents a pose-enabled controller
  79106. */
  79107. static POSE_ENABLED: number;
  79108. /**
  79109. * Represents an Dual Shock controller
  79110. */
  79111. static DUALSHOCK: number;
  79112. /**
  79113. * Specifies whether the left control stick should be Y-inverted
  79114. */
  79115. protected _invertLeftStickY: boolean;
  79116. /**
  79117. * Specifies if the gamepad has been connected
  79118. */
  79119. readonly isConnected: boolean;
  79120. /**
  79121. * Initializes the gamepad
  79122. * @param id The id of the gamepad
  79123. * @param index The index of the gamepad
  79124. * @param browserGamepad The browser gamepad
  79125. * @param leftStickX The x component of the left joystick
  79126. * @param leftStickY The y component of the left joystick
  79127. * @param rightStickX The x component of the right joystick
  79128. * @param rightStickY The y component of the right joystick
  79129. */
  79130. constructor(
  79131. /**
  79132. * The id of the gamepad
  79133. */
  79134. id: string,
  79135. /**
  79136. * The index of the gamepad
  79137. */
  79138. index: number,
  79139. /**
  79140. * The browser gamepad
  79141. */
  79142. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79143. /**
  79144. * Callback triggered when the left joystick has changed
  79145. * @param callback
  79146. */
  79147. onleftstickchanged(callback: (values: StickValues) => void): void;
  79148. /**
  79149. * Callback triggered when the right joystick has changed
  79150. * @param callback
  79151. */
  79152. onrightstickchanged(callback: (values: StickValues) => void): void;
  79153. /**
  79154. * Gets the left joystick
  79155. */
  79156. /**
  79157. * Sets the left joystick values
  79158. */
  79159. leftStick: StickValues;
  79160. /**
  79161. * Gets the right joystick
  79162. */
  79163. /**
  79164. * Sets the right joystick value
  79165. */
  79166. rightStick: StickValues;
  79167. /**
  79168. * Updates the gamepad joystick positions
  79169. */
  79170. update(): void;
  79171. /**
  79172. * Disposes the gamepad
  79173. */
  79174. dispose(): void;
  79175. }
  79176. /**
  79177. * Represents a generic gamepad
  79178. */
  79179. export class GenericPad extends Gamepad {
  79180. private _buttons;
  79181. private _onbuttondown;
  79182. private _onbuttonup;
  79183. /**
  79184. * Observable triggered when a button has been pressed
  79185. */
  79186. onButtonDownObservable: Observable<number>;
  79187. /**
  79188. * Observable triggered when a button has been released
  79189. */
  79190. onButtonUpObservable: Observable<number>;
  79191. /**
  79192. * Callback triggered when a button has been pressed
  79193. * @param callback Called when a button has been pressed
  79194. */
  79195. onbuttondown(callback: (buttonPressed: number) => void): void;
  79196. /**
  79197. * Callback triggered when a button has been released
  79198. * @param callback Called when a button has been released
  79199. */
  79200. onbuttonup(callback: (buttonReleased: number) => void): void;
  79201. /**
  79202. * Initializes the generic gamepad
  79203. * @param id The id of the generic gamepad
  79204. * @param index The index of the generic gamepad
  79205. * @param browserGamepad The browser gamepad
  79206. */
  79207. constructor(id: string, index: number, browserGamepad: any);
  79208. private _setButtonValue;
  79209. /**
  79210. * Updates the generic gamepad
  79211. */
  79212. update(): void;
  79213. /**
  79214. * Disposes the generic gamepad
  79215. */
  79216. dispose(): void;
  79217. }
  79218. }
  79219. declare module BABYLON {
  79220. interface Engine {
  79221. /**
  79222. * Creates a raw texture
  79223. * @param data defines the data to store in the texture
  79224. * @param width defines the width of the texture
  79225. * @param height defines the height of the texture
  79226. * @param format defines the format of the data
  79227. * @param generateMipMaps defines if the engine should generate the mip levels
  79228. * @param invertY defines if data must be stored with Y axis inverted
  79229. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79230. * @param compression defines the compression used (null by default)
  79231. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79232. * @returns the raw texture inside an InternalTexture
  79233. */
  79234. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79235. /**
  79236. * Update a raw texture
  79237. * @param texture defines the texture to update
  79238. * @param data defines the data to store in the texture
  79239. * @param format defines the format of the data
  79240. * @param invertY defines if data must be stored with Y axis inverted
  79241. */
  79242. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79243. /**
  79244. * Update a raw texture
  79245. * @param texture defines the texture to update
  79246. * @param data defines the data to store in the texture
  79247. * @param format defines the format of the data
  79248. * @param invertY defines if data must be stored with Y axis inverted
  79249. * @param compression defines the compression used (null by default)
  79250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79251. */
  79252. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79253. /**
  79254. * Creates a new raw cube texture
  79255. * @param data defines the array of data to use to create each face
  79256. * @param size defines the size of the textures
  79257. * @param format defines the format of the data
  79258. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79259. * @param generateMipMaps defines if the engine should generate the mip levels
  79260. * @param invertY defines if data must be stored with Y axis inverted
  79261. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79262. * @param compression defines the compression used (null by default)
  79263. * @returns the cube texture as an InternalTexture
  79264. */
  79265. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79266. /**
  79267. * Update a raw cube texture
  79268. * @param texture defines the texture to udpdate
  79269. * @param data defines the data to store
  79270. * @param format defines the data format
  79271. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79272. * @param invertY defines if data must be stored with Y axis inverted
  79273. */
  79274. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79275. /**
  79276. * Update a raw cube texture
  79277. * @param texture defines the texture to udpdate
  79278. * @param data defines the data to store
  79279. * @param format defines the data format
  79280. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79281. * @param invertY defines if data must be stored with Y axis inverted
  79282. * @param compression defines the compression used (null by default)
  79283. */
  79284. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79285. /**
  79286. * Update a raw cube texture
  79287. * @param texture defines the texture to udpdate
  79288. * @param data defines the data to store
  79289. * @param format defines the data format
  79290. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79291. * @param invertY defines if data must be stored with Y axis inverted
  79292. * @param compression defines the compression used (null by default)
  79293. * @param level defines which level of the texture to update
  79294. */
  79295. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79296. /**
  79297. * Creates a new raw cube texture from a specified url
  79298. * @param url defines the url where the data is located
  79299. * @param scene defines the current scene
  79300. * @param size defines the size of the textures
  79301. * @param format defines the format of the data
  79302. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79303. * @param noMipmap defines if the engine should avoid generating the mip levels
  79304. * @param callback defines a callback used to extract texture data from loaded data
  79305. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79306. * @param onLoad defines a callback called when texture is loaded
  79307. * @param onError defines a callback called if there is an error
  79308. * @returns the cube texture as an InternalTexture
  79309. */
  79310. 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;
  79311. /**
  79312. * Creates a new raw cube texture from a specified url
  79313. * @param url defines the url where the data is located
  79314. * @param scene defines the current scene
  79315. * @param size defines the size of the textures
  79316. * @param format defines the format of the data
  79317. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79318. * @param noMipmap defines if the engine should avoid generating the mip levels
  79319. * @param callback defines a callback used to extract texture data from loaded data
  79320. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79321. * @param onLoad defines a callback called when texture is loaded
  79322. * @param onError defines a callback called if there is an error
  79323. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79324. * @param invertY defines if data must be stored with Y axis inverted
  79325. * @returns the cube texture as an InternalTexture
  79326. */
  79327. 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;
  79328. /**
  79329. * Creates a new raw 3D texture
  79330. * @param data defines the data used to create the texture
  79331. * @param width defines the width of the texture
  79332. * @param height defines the height of the texture
  79333. * @param depth defines the depth of the texture
  79334. * @param format defines the format of the texture
  79335. * @param generateMipMaps defines if the engine must generate mip levels
  79336. * @param invertY defines if data must be stored with Y axis inverted
  79337. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79338. * @param compression defines the compressed used (can be null)
  79339. * @param textureType defines the compressed used (can be null)
  79340. * @returns a new raw 3D texture (stored in an InternalTexture)
  79341. */
  79342. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79343. /**
  79344. * Update a raw 3D texture
  79345. * @param texture defines the texture to update
  79346. * @param data defines the data to store
  79347. * @param format defines the data format
  79348. * @param invertY defines if data must be stored with Y axis inverted
  79349. */
  79350. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79351. /**
  79352. * Update a raw 3D texture
  79353. * @param texture defines the texture to update
  79354. * @param data defines the data to store
  79355. * @param format defines the data format
  79356. * @param invertY defines if data must be stored with Y axis inverted
  79357. * @param compression defines the used compression (can be null)
  79358. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79359. */
  79360. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79361. }
  79362. }
  79363. declare module BABYLON {
  79364. /**
  79365. * Raw texture can help creating a texture directly from an array of data.
  79366. * This can be super useful if you either get the data from an uncompressed source or
  79367. * if you wish to create your texture pixel by pixel.
  79368. */
  79369. export class RawTexture extends Texture {
  79370. /**
  79371. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79372. */
  79373. format: number;
  79374. private _engine;
  79375. /**
  79376. * Instantiates a new RawTexture.
  79377. * Raw texture can help creating a texture directly from an array of data.
  79378. * This can be super useful if you either get the data from an uncompressed source or
  79379. * if you wish to create your texture pixel by pixel.
  79380. * @param data define the array of data to use to create the texture
  79381. * @param width define the width of the texture
  79382. * @param height define the height of the texture
  79383. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79384. * @param scene define the scene the texture belongs to
  79385. * @param generateMipMaps define whether mip maps should be generated or not
  79386. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79387. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79388. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79389. */
  79390. constructor(data: ArrayBufferView, width: number, height: number,
  79391. /**
  79392. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79393. */
  79394. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79395. /**
  79396. * Updates the texture underlying data.
  79397. * @param data Define the new data of the texture
  79398. */
  79399. update(data: ArrayBufferView): void;
  79400. /**
  79401. * Creates a luminance texture from some data.
  79402. * @param data Define the texture data
  79403. * @param width Define the width of the texture
  79404. * @param height Define the height of the texture
  79405. * @param scene Define the scene the texture belongs to
  79406. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79407. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79408. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79409. * @returns the luminance texture
  79410. */
  79411. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79412. /**
  79413. * Creates a luminance alpha texture from some data.
  79414. * @param data Define the texture data
  79415. * @param width Define the width of the texture
  79416. * @param height Define the height of the texture
  79417. * @param scene Define the scene the texture belongs to
  79418. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79419. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79420. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79421. * @returns the luminance alpha texture
  79422. */
  79423. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79424. /**
  79425. * Creates an alpha texture from some data.
  79426. * @param data Define the texture data
  79427. * @param width Define the width of the texture
  79428. * @param height Define the height of the texture
  79429. * @param scene Define the scene the texture belongs to
  79430. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79431. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79432. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79433. * @returns the alpha texture
  79434. */
  79435. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79436. /**
  79437. * Creates a RGB texture from some data.
  79438. * @param data Define the texture data
  79439. * @param width Define the width of the texture
  79440. * @param height Define the height of the texture
  79441. * @param scene Define the scene the texture belongs to
  79442. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79443. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79444. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79445. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79446. * @returns the RGB alpha texture
  79447. */
  79448. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79449. /**
  79450. * Creates a RGBA texture from some data.
  79451. * @param data Define the texture data
  79452. * @param width Define the width of the texture
  79453. * @param height Define the height of the texture
  79454. * @param scene Define the scene the texture belongs to
  79455. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79456. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79457. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79458. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79459. * @returns the RGBA texture
  79460. */
  79461. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79462. /**
  79463. * Creates a R texture from some data.
  79464. * @param data Define the texture data
  79465. * @param width Define the width of the texture
  79466. * @param height Define the height of the texture
  79467. * @param scene Define the scene the texture belongs to
  79468. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79471. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79472. * @returns the R texture
  79473. */
  79474. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79475. }
  79476. }
  79477. declare module BABYLON {
  79478. /**
  79479. * Interface for the size containing width and height
  79480. */
  79481. export interface ISize {
  79482. /**
  79483. * Width
  79484. */
  79485. width: number;
  79486. /**
  79487. * Heighht
  79488. */
  79489. height: number;
  79490. }
  79491. /**
  79492. * Size containing widht and height
  79493. */
  79494. export class Size implements ISize {
  79495. /**
  79496. * Width
  79497. */
  79498. width: number;
  79499. /**
  79500. * Height
  79501. */
  79502. height: number;
  79503. /**
  79504. * Creates a Size object from the given width and height (floats).
  79505. * @param width width of the new size
  79506. * @param height height of the new size
  79507. */
  79508. constructor(width: number, height: number);
  79509. /**
  79510. * Returns a string with the Size width and height
  79511. * @returns a string with the Size width and height
  79512. */
  79513. toString(): string;
  79514. /**
  79515. * "Size"
  79516. * @returns the string "Size"
  79517. */
  79518. getClassName(): string;
  79519. /**
  79520. * Returns the Size hash code.
  79521. * @returns a hash code for a unique width and height
  79522. */
  79523. getHashCode(): number;
  79524. /**
  79525. * Updates the current size from the given one.
  79526. * @param src the given size
  79527. */
  79528. copyFrom(src: Size): void;
  79529. /**
  79530. * Updates in place the current Size from the given floats.
  79531. * @param width width of the new size
  79532. * @param height height of the new size
  79533. * @returns the updated Size.
  79534. */
  79535. copyFromFloats(width: number, height: number): Size;
  79536. /**
  79537. * Updates in place the current Size from the given floats.
  79538. * @param width width to set
  79539. * @param height height to set
  79540. * @returns the updated Size.
  79541. */
  79542. set(width: number, height: number): Size;
  79543. /**
  79544. * Multiplies the width and height by numbers
  79545. * @param w factor to multiple the width by
  79546. * @param h factor to multiple the height by
  79547. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79548. */
  79549. multiplyByFloats(w: number, h: number): Size;
  79550. /**
  79551. * Clones the size
  79552. * @returns a new Size copied from the given one.
  79553. */
  79554. clone(): Size;
  79555. /**
  79556. * True if the current Size and the given one width and height are strictly equal.
  79557. * @param other the other size to compare against
  79558. * @returns True if the current Size and the given one width and height are strictly equal.
  79559. */
  79560. equals(other: Size): boolean;
  79561. /**
  79562. * The surface of the Size : width * height (float).
  79563. */
  79564. readonly surface: number;
  79565. /**
  79566. * Create a new size of zero
  79567. * @returns a new Size set to (0.0, 0.0)
  79568. */
  79569. static Zero(): Size;
  79570. /**
  79571. * Sums the width and height of two sizes
  79572. * @param otherSize size to add to this size
  79573. * @returns a new Size set as the addition result of the current Size and the given one.
  79574. */
  79575. add(otherSize: Size): Size;
  79576. /**
  79577. * Subtracts the width and height of two
  79578. * @param otherSize size to subtract to this size
  79579. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79580. */
  79581. subtract(otherSize: Size): Size;
  79582. /**
  79583. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79584. * @param start starting size to lerp between
  79585. * @param end end size to lerp between
  79586. * @param amount amount to lerp between the start and end values
  79587. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79588. */
  79589. static Lerp(start: Size, end: Size, amount: number): Size;
  79590. }
  79591. }
  79592. declare module BABYLON {
  79593. /**
  79594. * Defines a runtime animation
  79595. */
  79596. export class RuntimeAnimation {
  79597. private _events;
  79598. /**
  79599. * The current frame of the runtime animation
  79600. */
  79601. private _currentFrame;
  79602. /**
  79603. * The animation used by the runtime animation
  79604. */
  79605. private _animation;
  79606. /**
  79607. * The target of the runtime animation
  79608. */
  79609. private _target;
  79610. /**
  79611. * The initiating animatable
  79612. */
  79613. private _host;
  79614. /**
  79615. * The original value of the runtime animation
  79616. */
  79617. private _originalValue;
  79618. /**
  79619. * The original blend value of the runtime animation
  79620. */
  79621. private _originalBlendValue;
  79622. /**
  79623. * The offsets cache of the runtime animation
  79624. */
  79625. private _offsetsCache;
  79626. /**
  79627. * The high limits cache of the runtime animation
  79628. */
  79629. private _highLimitsCache;
  79630. /**
  79631. * Specifies if the runtime animation has been stopped
  79632. */
  79633. private _stopped;
  79634. /**
  79635. * The blending factor of the runtime animation
  79636. */
  79637. private _blendingFactor;
  79638. /**
  79639. * The BabylonJS scene
  79640. */
  79641. private _scene;
  79642. /**
  79643. * The current value of the runtime animation
  79644. */
  79645. private _currentValue;
  79646. /** @hidden */
  79647. _animationState: _IAnimationState;
  79648. /**
  79649. * The active target of the runtime animation
  79650. */
  79651. private _activeTargets;
  79652. private _currentActiveTarget;
  79653. private _directTarget;
  79654. /**
  79655. * The target path of the runtime animation
  79656. */
  79657. private _targetPath;
  79658. /**
  79659. * The weight of the runtime animation
  79660. */
  79661. private _weight;
  79662. /**
  79663. * The ratio offset of the runtime animation
  79664. */
  79665. private _ratioOffset;
  79666. /**
  79667. * The previous delay of the runtime animation
  79668. */
  79669. private _previousDelay;
  79670. /**
  79671. * The previous ratio of the runtime animation
  79672. */
  79673. private _previousRatio;
  79674. private _enableBlending;
  79675. private _keys;
  79676. private _minFrame;
  79677. private _maxFrame;
  79678. private _minValue;
  79679. private _maxValue;
  79680. private _targetIsArray;
  79681. /**
  79682. * Gets the current frame of the runtime animation
  79683. */
  79684. readonly currentFrame: number;
  79685. /**
  79686. * Gets the weight of the runtime animation
  79687. */
  79688. readonly weight: number;
  79689. /**
  79690. * Gets the current value of the runtime animation
  79691. */
  79692. readonly currentValue: any;
  79693. /**
  79694. * Gets the target path of the runtime animation
  79695. */
  79696. readonly targetPath: string;
  79697. /**
  79698. * Gets the actual target of the runtime animation
  79699. */
  79700. readonly target: any;
  79701. /** @hidden */
  79702. _onLoop: () => void;
  79703. /**
  79704. * Create a new RuntimeAnimation object
  79705. * @param target defines the target of the animation
  79706. * @param animation defines the source animation object
  79707. * @param scene defines the hosting scene
  79708. * @param host defines the initiating Animatable
  79709. */
  79710. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79711. private _preparePath;
  79712. /**
  79713. * Gets the animation from the runtime animation
  79714. */
  79715. readonly animation: Animation;
  79716. /**
  79717. * Resets the runtime animation to the beginning
  79718. * @param restoreOriginal defines whether to restore the target property to the original value
  79719. */
  79720. reset(restoreOriginal?: boolean): void;
  79721. /**
  79722. * Specifies if the runtime animation is stopped
  79723. * @returns Boolean specifying if the runtime animation is stopped
  79724. */
  79725. isStopped(): boolean;
  79726. /**
  79727. * Disposes of the runtime animation
  79728. */
  79729. dispose(): void;
  79730. /**
  79731. * Apply the interpolated value to the target
  79732. * @param currentValue defines the value computed by the animation
  79733. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79734. */
  79735. setValue(currentValue: any, weight: number): void;
  79736. private _getOriginalValues;
  79737. private _setValue;
  79738. /**
  79739. * Gets the loop pmode of the runtime animation
  79740. * @returns Loop Mode
  79741. */
  79742. private _getCorrectLoopMode;
  79743. /**
  79744. * Move the current animation to a given frame
  79745. * @param frame defines the frame to move to
  79746. */
  79747. goToFrame(frame: number): void;
  79748. /**
  79749. * @hidden Internal use only
  79750. */
  79751. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79752. /**
  79753. * Execute the current animation
  79754. * @param delay defines the delay to add to the current frame
  79755. * @param from defines the lower bound of the animation range
  79756. * @param to defines the upper bound of the animation range
  79757. * @param loop defines if the current animation must loop
  79758. * @param speedRatio defines the current speed ratio
  79759. * @param weight defines the weight of the animation (default is -1 so no weight)
  79760. * @param onLoop optional callback called when animation loops
  79761. * @returns a boolean indicating if the animation is running
  79762. */
  79763. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79764. }
  79765. }
  79766. declare module BABYLON {
  79767. /**
  79768. * Class used to store an actual running animation
  79769. */
  79770. export class Animatable {
  79771. /** defines the target object */
  79772. target: any;
  79773. /** defines the starting frame number (default is 0) */
  79774. fromFrame: number;
  79775. /** defines the ending frame number (default is 100) */
  79776. toFrame: number;
  79777. /** defines if the animation must loop (default is false) */
  79778. loopAnimation: boolean;
  79779. /** defines a callback to call when animation ends if it is not looping */
  79780. onAnimationEnd?: (() => void) | null | undefined;
  79781. /** defines a callback to call when animation loops */
  79782. onAnimationLoop?: (() => void) | null | undefined;
  79783. private _localDelayOffset;
  79784. private _pausedDelay;
  79785. private _runtimeAnimations;
  79786. private _paused;
  79787. private _scene;
  79788. private _speedRatio;
  79789. private _weight;
  79790. private _syncRoot;
  79791. /**
  79792. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79793. * This will only apply for non looping animation (default is true)
  79794. */
  79795. disposeOnEnd: boolean;
  79796. /**
  79797. * Gets a boolean indicating if the animation has started
  79798. */
  79799. animationStarted: boolean;
  79800. /**
  79801. * Observer raised when the animation ends
  79802. */
  79803. onAnimationEndObservable: Observable<Animatable>;
  79804. /**
  79805. * Observer raised when the animation loops
  79806. */
  79807. onAnimationLoopObservable: Observable<Animatable>;
  79808. /**
  79809. * Gets the root Animatable used to synchronize and normalize animations
  79810. */
  79811. readonly syncRoot: Nullable<Animatable>;
  79812. /**
  79813. * Gets the current frame of the first RuntimeAnimation
  79814. * Used to synchronize Animatables
  79815. */
  79816. readonly masterFrame: number;
  79817. /**
  79818. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79819. */
  79820. weight: number;
  79821. /**
  79822. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79823. */
  79824. speedRatio: number;
  79825. /**
  79826. * Creates a new Animatable
  79827. * @param scene defines the hosting scene
  79828. * @param target defines the target object
  79829. * @param fromFrame defines the starting frame number (default is 0)
  79830. * @param toFrame defines the ending frame number (default is 100)
  79831. * @param loopAnimation defines if the animation must loop (default is false)
  79832. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79833. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79834. * @param animations defines a group of animation to add to the new Animatable
  79835. * @param onAnimationLoop defines a callback to call when animation loops
  79836. */
  79837. constructor(scene: Scene,
  79838. /** defines the target object */
  79839. target: any,
  79840. /** defines the starting frame number (default is 0) */
  79841. fromFrame?: number,
  79842. /** defines the ending frame number (default is 100) */
  79843. toFrame?: number,
  79844. /** defines if the animation must loop (default is false) */
  79845. loopAnimation?: boolean, speedRatio?: number,
  79846. /** defines a callback to call when animation ends if it is not looping */
  79847. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79848. /** defines a callback to call when animation loops */
  79849. onAnimationLoop?: (() => void) | null | undefined);
  79850. /**
  79851. * Synchronize and normalize current Animatable with a source Animatable
  79852. * This is useful when using animation weights and when animations are not of the same length
  79853. * @param root defines the root Animatable to synchronize with
  79854. * @returns the current Animatable
  79855. */
  79856. syncWith(root: Animatable): Animatable;
  79857. /**
  79858. * Gets the list of runtime animations
  79859. * @returns an array of RuntimeAnimation
  79860. */
  79861. getAnimations(): RuntimeAnimation[];
  79862. /**
  79863. * Adds more animations to the current animatable
  79864. * @param target defines the target of the animations
  79865. * @param animations defines the new animations to add
  79866. */
  79867. appendAnimations(target: any, animations: Animation[]): void;
  79868. /**
  79869. * Gets the source animation for a specific property
  79870. * @param property defines the propertyu to look for
  79871. * @returns null or the source animation for the given property
  79872. */
  79873. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79874. /**
  79875. * Gets the runtime animation for a specific property
  79876. * @param property defines the propertyu to look for
  79877. * @returns null or the runtime animation for the given property
  79878. */
  79879. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79880. /**
  79881. * Resets the animatable to its original state
  79882. */
  79883. reset(): void;
  79884. /**
  79885. * Allows the animatable to blend with current running animations
  79886. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79887. * @param blendingSpeed defines the blending speed to use
  79888. */
  79889. enableBlending(blendingSpeed: number): void;
  79890. /**
  79891. * Disable animation blending
  79892. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79893. */
  79894. disableBlending(): void;
  79895. /**
  79896. * Jump directly to a given frame
  79897. * @param frame defines the frame to jump to
  79898. */
  79899. goToFrame(frame: number): void;
  79900. /**
  79901. * Pause the animation
  79902. */
  79903. pause(): void;
  79904. /**
  79905. * Restart the animation
  79906. */
  79907. restart(): void;
  79908. private _raiseOnAnimationEnd;
  79909. /**
  79910. * Stop and delete the current animation
  79911. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79912. * @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)
  79913. */
  79914. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79915. /**
  79916. * Wait asynchronously for the animation to end
  79917. * @returns a promise which will be fullfilled when the animation ends
  79918. */
  79919. waitAsync(): Promise<Animatable>;
  79920. /** @hidden */
  79921. _animate(delay: number): boolean;
  79922. }
  79923. interface Scene {
  79924. /** @hidden */
  79925. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79926. /** @hidden */
  79927. _processLateAnimationBindingsForMatrices(holder: {
  79928. totalWeight: number;
  79929. animations: RuntimeAnimation[];
  79930. originalValue: Matrix;
  79931. }): any;
  79932. /** @hidden */
  79933. _processLateAnimationBindingsForQuaternions(holder: {
  79934. totalWeight: number;
  79935. animations: RuntimeAnimation[];
  79936. originalValue: Quaternion;
  79937. }, refQuaternion: Quaternion): Quaternion;
  79938. /** @hidden */
  79939. _processLateAnimationBindings(): void;
  79940. /**
  79941. * Will start the animation sequence of a given target
  79942. * @param target defines the target
  79943. * @param from defines from which frame should animation start
  79944. * @param to defines until which frame should animation run.
  79945. * @param weight defines the weight to apply to the animation (1.0 by default)
  79946. * @param loop defines if the animation loops
  79947. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79948. * @param onAnimationEnd defines the function to be executed when the animation ends
  79949. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79950. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79951. * @param onAnimationLoop defines the callback to call when an animation loops
  79952. * @returns the animatable object created for this animation
  79953. */
  79954. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79955. /**
  79956. * Will start the animation sequence of a given target
  79957. * @param target defines the target
  79958. * @param from defines from which frame should animation start
  79959. * @param to defines until which frame should animation run.
  79960. * @param loop defines if the animation loops
  79961. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79962. * @param onAnimationEnd defines the function to be executed when the animation ends
  79963. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79964. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79965. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79966. * @param onAnimationLoop defines the callback to call when an animation loops
  79967. * @returns the animatable object created for this animation
  79968. */
  79969. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79970. /**
  79971. * Will start the animation sequence of a given target and its hierarchy
  79972. * @param target defines the target
  79973. * @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.
  79974. * @param from defines from which frame should animation start
  79975. * @param to defines until which frame should animation run.
  79976. * @param loop defines if the animation loops
  79977. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79978. * @param onAnimationEnd defines the function to be executed when the animation ends
  79979. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79980. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79981. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79982. * @param onAnimationLoop defines the callback to call when an animation loops
  79983. * @returns the list of created animatables
  79984. */
  79985. 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[];
  79986. /**
  79987. * Begin a new animation on a given node
  79988. * @param target defines the target where the animation will take place
  79989. * @param animations defines the list of animations to start
  79990. * @param from defines the initial value
  79991. * @param to defines the final value
  79992. * @param loop defines if you want animation to loop (off by default)
  79993. * @param speedRatio defines the speed ratio to apply to all animations
  79994. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79995. * @param onAnimationLoop defines the callback to call when an animation loops
  79996. * @returns the list of created animatables
  79997. */
  79998. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79999. /**
  80000. * Begin a new animation on a given node and its hierarchy
  80001. * @param target defines the root node where the animation will take place
  80002. * @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.
  80003. * @param animations defines the list of animations to start
  80004. * @param from defines the initial value
  80005. * @param to defines the final value
  80006. * @param loop defines if you want animation to loop (off by default)
  80007. * @param speedRatio defines the speed ratio to apply to all animations
  80008. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80009. * @param onAnimationLoop defines the callback to call when an animation loops
  80010. * @returns the list of animatables created for all nodes
  80011. */
  80012. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80013. /**
  80014. * Gets the animatable associated with a specific target
  80015. * @param target defines the target of the animatable
  80016. * @returns the required animatable if found
  80017. */
  80018. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80019. /**
  80020. * Gets all animatables associated with a given target
  80021. * @param target defines the target to look animatables for
  80022. * @returns an array of Animatables
  80023. */
  80024. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80025. /**
  80026. * Stops and removes all animations that have been applied to the scene
  80027. */
  80028. stopAllAnimations(): void;
  80029. /**
  80030. * Gets the current delta time used by animation engine
  80031. */
  80032. deltaTime: number;
  80033. }
  80034. interface Bone {
  80035. /**
  80036. * Copy an animation range from another bone
  80037. * @param source defines the source bone
  80038. * @param rangeName defines the range name to copy
  80039. * @param frameOffset defines the frame offset
  80040. * @param rescaleAsRequired defines if rescaling must be applied if required
  80041. * @param skelDimensionsRatio defines the scaling ratio
  80042. * @returns true if operation was successful
  80043. */
  80044. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80045. }
  80046. }
  80047. declare module BABYLON {
  80048. /**
  80049. * Class used to override all child animations of a given target
  80050. */
  80051. export class AnimationPropertiesOverride {
  80052. /**
  80053. * Gets or sets a value indicating if animation blending must be used
  80054. */
  80055. enableBlending: boolean;
  80056. /**
  80057. * Gets or sets the blending speed to use when enableBlending is true
  80058. */
  80059. blendingSpeed: number;
  80060. /**
  80061. * Gets or sets the default loop mode to use
  80062. */
  80063. loopMode: number;
  80064. }
  80065. }
  80066. declare module BABYLON {
  80067. /**
  80068. * Class used to handle skinning animations
  80069. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80070. */
  80071. export class Skeleton implements IAnimatable {
  80072. /** defines the skeleton name */
  80073. name: string;
  80074. /** defines the skeleton Id */
  80075. id: string;
  80076. /**
  80077. * Defines the list of child bones
  80078. */
  80079. bones: Bone[];
  80080. /**
  80081. * Defines an estimate of the dimension of the skeleton at rest
  80082. */
  80083. dimensionsAtRest: Vector3;
  80084. /**
  80085. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80086. */
  80087. needInitialSkinMatrix: boolean;
  80088. /**
  80089. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80090. */
  80091. overrideMesh: Nullable<AbstractMesh>;
  80092. /**
  80093. * Gets the list of animations attached to this skeleton
  80094. */
  80095. animations: Array<Animation>;
  80096. private _scene;
  80097. private _isDirty;
  80098. private _transformMatrices;
  80099. private _transformMatrixTexture;
  80100. private _meshesWithPoseMatrix;
  80101. private _animatables;
  80102. private _identity;
  80103. private _synchronizedWithMesh;
  80104. private _ranges;
  80105. private _lastAbsoluteTransformsUpdateId;
  80106. private _canUseTextureForBones;
  80107. private _uniqueId;
  80108. /** @hidden */
  80109. _numBonesWithLinkedTransformNode: number;
  80110. /** @hidden */
  80111. _hasWaitingData: Nullable<boolean>;
  80112. /**
  80113. * Specifies if the skeleton should be serialized
  80114. */
  80115. doNotSerialize: boolean;
  80116. private _useTextureToStoreBoneMatrices;
  80117. /**
  80118. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80119. * Please note that this option is not available if the hardware does not support it
  80120. */
  80121. useTextureToStoreBoneMatrices: boolean;
  80122. private _animationPropertiesOverride;
  80123. /**
  80124. * Gets or sets the animation properties override
  80125. */
  80126. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80127. /**
  80128. * List of inspectable custom properties (used by the Inspector)
  80129. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80130. */
  80131. inspectableCustomProperties: IInspectable[];
  80132. /**
  80133. * An observable triggered before computing the skeleton's matrices
  80134. */
  80135. onBeforeComputeObservable: Observable<Skeleton>;
  80136. /**
  80137. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80138. */
  80139. readonly isUsingTextureForMatrices: boolean;
  80140. /**
  80141. * Gets the unique ID of this skeleton
  80142. */
  80143. readonly uniqueId: number;
  80144. /**
  80145. * Creates a new skeleton
  80146. * @param name defines the skeleton name
  80147. * @param id defines the skeleton Id
  80148. * @param scene defines the hosting scene
  80149. */
  80150. constructor(
  80151. /** defines the skeleton name */
  80152. name: string,
  80153. /** defines the skeleton Id */
  80154. id: string, scene: Scene);
  80155. /**
  80156. * Gets the current object class name.
  80157. * @return the class name
  80158. */
  80159. getClassName(): string;
  80160. /**
  80161. * Returns an array containing the root bones
  80162. * @returns an array containing the root bones
  80163. */
  80164. getChildren(): Array<Bone>;
  80165. /**
  80166. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80167. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80168. * @returns a Float32Array containing matrices data
  80169. */
  80170. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80171. /**
  80172. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80173. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80174. * @returns a raw texture containing the data
  80175. */
  80176. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80177. /**
  80178. * Gets the current hosting scene
  80179. * @returns a scene object
  80180. */
  80181. getScene(): Scene;
  80182. /**
  80183. * Gets a string representing the current skeleton data
  80184. * @param fullDetails defines a boolean indicating if we want a verbose version
  80185. * @returns a string representing the current skeleton data
  80186. */
  80187. toString(fullDetails?: boolean): string;
  80188. /**
  80189. * Get bone's index searching by name
  80190. * @param name defines bone's name to search for
  80191. * @return the indice of the bone. Returns -1 if not found
  80192. */
  80193. getBoneIndexByName(name: string): number;
  80194. /**
  80195. * Creater a new animation range
  80196. * @param name defines the name of the range
  80197. * @param from defines the start key
  80198. * @param to defines the end key
  80199. */
  80200. createAnimationRange(name: string, from: number, to: number): void;
  80201. /**
  80202. * Delete a specific animation range
  80203. * @param name defines the name of the range
  80204. * @param deleteFrames defines if frames must be removed as well
  80205. */
  80206. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80207. /**
  80208. * Gets a specific animation range
  80209. * @param name defines the name of the range to look for
  80210. * @returns the requested animation range or null if not found
  80211. */
  80212. getAnimationRange(name: string): Nullable<AnimationRange>;
  80213. /**
  80214. * Gets the list of all animation ranges defined on this skeleton
  80215. * @returns an array
  80216. */
  80217. getAnimationRanges(): Nullable<AnimationRange>[];
  80218. /**
  80219. * Copy animation range from a source skeleton.
  80220. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80221. * @param source defines the source skeleton
  80222. * @param name defines the name of the range to copy
  80223. * @param rescaleAsRequired defines if rescaling must be applied if required
  80224. * @returns true if operation was successful
  80225. */
  80226. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80227. /**
  80228. * Forces the skeleton to go to rest pose
  80229. */
  80230. returnToRest(): void;
  80231. private _getHighestAnimationFrame;
  80232. /**
  80233. * Begin a specific animation range
  80234. * @param name defines the name of the range to start
  80235. * @param loop defines if looping must be turned on (false by default)
  80236. * @param speedRatio defines the speed ratio to apply (1 by default)
  80237. * @param onAnimationEnd defines a callback which will be called when animation will end
  80238. * @returns a new animatable
  80239. */
  80240. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80241. /** @hidden */
  80242. _markAsDirty(): void;
  80243. /** @hidden */
  80244. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80245. /** @hidden */
  80246. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80247. private _computeTransformMatrices;
  80248. /**
  80249. * Build all resources required to render a skeleton
  80250. */
  80251. prepare(): void;
  80252. /**
  80253. * Gets the list of animatables currently running for this skeleton
  80254. * @returns an array of animatables
  80255. */
  80256. getAnimatables(): IAnimatable[];
  80257. /**
  80258. * Clone the current skeleton
  80259. * @param name defines the name of the new skeleton
  80260. * @param id defines the id of the new skeleton
  80261. * @returns the new skeleton
  80262. */
  80263. clone(name: string, id: string): Skeleton;
  80264. /**
  80265. * Enable animation blending for this skeleton
  80266. * @param blendingSpeed defines the blending speed to apply
  80267. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80268. */
  80269. enableBlending(blendingSpeed?: number): void;
  80270. /**
  80271. * Releases all resources associated with the current skeleton
  80272. */
  80273. dispose(): void;
  80274. /**
  80275. * Serialize the skeleton in a JSON object
  80276. * @returns a JSON object
  80277. */
  80278. serialize(): any;
  80279. /**
  80280. * Creates a new skeleton from serialized data
  80281. * @param parsedSkeleton defines the serialized data
  80282. * @param scene defines the hosting scene
  80283. * @returns a new skeleton
  80284. */
  80285. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80286. /**
  80287. * Compute all node absolute transforms
  80288. * @param forceUpdate defines if computation must be done even if cache is up to date
  80289. */
  80290. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80291. /**
  80292. * Gets the root pose matrix
  80293. * @returns a matrix
  80294. */
  80295. getPoseMatrix(): Nullable<Matrix>;
  80296. /**
  80297. * Sorts bones per internal index
  80298. */
  80299. sortBones(): void;
  80300. private _sortBones;
  80301. }
  80302. }
  80303. declare module BABYLON {
  80304. /**
  80305. * Class used to store bone information
  80306. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80307. */
  80308. export class Bone extends Node {
  80309. /**
  80310. * defines the bone name
  80311. */
  80312. name: string;
  80313. private static _tmpVecs;
  80314. private static _tmpQuat;
  80315. private static _tmpMats;
  80316. /**
  80317. * Gets the list of child bones
  80318. */
  80319. children: Bone[];
  80320. /** Gets the animations associated with this bone */
  80321. animations: Animation[];
  80322. /**
  80323. * Gets or sets bone length
  80324. */
  80325. length: number;
  80326. /**
  80327. * @hidden Internal only
  80328. * Set this value to map this bone to a different index in the transform matrices
  80329. * Set this value to -1 to exclude the bone from the transform matrices
  80330. */
  80331. _index: Nullable<number>;
  80332. private _skeleton;
  80333. private _localMatrix;
  80334. private _restPose;
  80335. private _baseMatrix;
  80336. private _absoluteTransform;
  80337. private _invertedAbsoluteTransform;
  80338. private _parent;
  80339. private _scalingDeterminant;
  80340. private _worldTransform;
  80341. private _localScaling;
  80342. private _localRotation;
  80343. private _localPosition;
  80344. private _needToDecompose;
  80345. private _needToCompose;
  80346. /** @hidden */
  80347. _linkedTransformNode: Nullable<TransformNode>;
  80348. /** @hidden */
  80349. _waitingTransformNodeId: Nullable<string>;
  80350. /** @hidden */
  80351. /** @hidden */
  80352. _matrix: Matrix;
  80353. /**
  80354. * Create a new bone
  80355. * @param name defines the bone name
  80356. * @param skeleton defines the parent skeleton
  80357. * @param parentBone defines the parent (can be null if the bone is the root)
  80358. * @param localMatrix defines the local matrix
  80359. * @param restPose defines the rest pose matrix
  80360. * @param baseMatrix defines the base matrix
  80361. * @param index defines index of the bone in the hiearchy
  80362. */
  80363. constructor(
  80364. /**
  80365. * defines the bone name
  80366. */
  80367. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80368. /**
  80369. * Gets the current object class name.
  80370. * @return the class name
  80371. */
  80372. getClassName(): string;
  80373. /**
  80374. * Gets the parent skeleton
  80375. * @returns a skeleton
  80376. */
  80377. getSkeleton(): Skeleton;
  80378. /**
  80379. * Gets parent bone
  80380. * @returns a bone or null if the bone is the root of the bone hierarchy
  80381. */
  80382. getParent(): Nullable<Bone>;
  80383. /**
  80384. * Returns an array containing the root bones
  80385. * @returns an array containing the root bones
  80386. */
  80387. getChildren(): Array<Bone>;
  80388. /**
  80389. * Sets the parent bone
  80390. * @param parent defines the parent (can be null if the bone is the root)
  80391. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80392. */
  80393. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80394. /**
  80395. * Gets the local matrix
  80396. * @returns a matrix
  80397. */
  80398. getLocalMatrix(): Matrix;
  80399. /**
  80400. * Gets the base matrix (initial matrix which remains unchanged)
  80401. * @returns a matrix
  80402. */
  80403. getBaseMatrix(): Matrix;
  80404. /**
  80405. * Gets the rest pose matrix
  80406. * @returns a matrix
  80407. */
  80408. getRestPose(): Matrix;
  80409. /**
  80410. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80411. */
  80412. getWorldMatrix(): Matrix;
  80413. /**
  80414. * Sets the local matrix to rest pose matrix
  80415. */
  80416. returnToRest(): void;
  80417. /**
  80418. * Gets the inverse of the absolute transform matrix.
  80419. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80420. * @returns a matrix
  80421. */
  80422. getInvertedAbsoluteTransform(): Matrix;
  80423. /**
  80424. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80425. * @returns a matrix
  80426. */
  80427. getAbsoluteTransform(): Matrix;
  80428. /**
  80429. * Links with the given transform node.
  80430. * The local matrix of this bone is copied from the transform node every frame.
  80431. * @param transformNode defines the transform node to link to
  80432. */
  80433. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80434. /**
  80435. * Gets the node used to drive the bone's transformation
  80436. * @returns a transform node or null
  80437. */
  80438. getTransformNode(): Nullable<TransformNode>;
  80439. /** Gets or sets current position (in local space) */
  80440. position: Vector3;
  80441. /** Gets or sets current rotation (in local space) */
  80442. rotation: Vector3;
  80443. /** Gets or sets current rotation quaternion (in local space) */
  80444. rotationQuaternion: Quaternion;
  80445. /** Gets or sets current scaling (in local space) */
  80446. scaling: Vector3;
  80447. /**
  80448. * Gets the animation properties override
  80449. */
  80450. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80451. private _decompose;
  80452. private _compose;
  80453. /**
  80454. * Update the base and local matrices
  80455. * @param matrix defines the new base or local matrix
  80456. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80457. * @param updateLocalMatrix defines if the local matrix should be updated
  80458. */
  80459. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80460. /** @hidden */
  80461. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80462. /**
  80463. * Flag the bone as dirty (Forcing it to update everything)
  80464. */
  80465. markAsDirty(): void;
  80466. /** @hidden */
  80467. _markAsDirtyAndCompose(): void;
  80468. private _markAsDirtyAndDecompose;
  80469. /**
  80470. * Translate the bone in local or world space
  80471. * @param vec The amount to translate the bone
  80472. * @param space The space that the translation is in
  80473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80474. */
  80475. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80476. /**
  80477. * Set the postion of the bone in local or world space
  80478. * @param position The position to set the bone
  80479. * @param space The space that the position is in
  80480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80481. */
  80482. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80483. /**
  80484. * Set the absolute position of the bone (world space)
  80485. * @param position The position to set the bone
  80486. * @param mesh The mesh that this bone is attached to
  80487. */
  80488. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80489. /**
  80490. * Scale the bone on the x, y and z axes (in local space)
  80491. * @param x The amount to scale the bone on the x axis
  80492. * @param y The amount to scale the bone on the y axis
  80493. * @param z The amount to scale the bone on the z axis
  80494. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80495. */
  80496. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80497. /**
  80498. * Set the bone scaling in local space
  80499. * @param scale defines the scaling vector
  80500. */
  80501. setScale(scale: Vector3): void;
  80502. /**
  80503. * Gets the current scaling in local space
  80504. * @returns the current scaling vector
  80505. */
  80506. getScale(): Vector3;
  80507. /**
  80508. * Gets the current scaling in local space and stores it in a target vector
  80509. * @param result defines the target vector
  80510. */
  80511. getScaleToRef(result: Vector3): void;
  80512. /**
  80513. * Set the yaw, pitch, and roll of the bone in local or world space
  80514. * @param yaw The rotation of the bone on the y axis
  80515. * @param pitch The rotation of the bone on the x axis
  80516. * @param roll The rotation of the bone on the z axis
  80517. * @param space The space that the axes of rotation are in
  80518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80519. */
  80520. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80521. /**
  80522. * Add a rotation to the bone on an axis in local or world space
  80523. * @param axis The axis to rotate the bone on
  80524. * @param amount The amount to rotate the bone
  80525. * @param space The space that the axis is in
  80526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80527. */
  80528. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80529. /**
  80530. * Set the rotation of the bone to a particular axis angle in local or world space
  80531. * @param axis The axis to rotate the bone on
  80532. * @param angle The angle that the bone should be rotated to
  80533. * @param space The space that the axis is in
  80534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80535. */
  80536. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80537. /**
  80538. * Set the euler rotation of the bone in local of world space
  80539. * @param rotation The euler rotation that the bone should be set to
  80540. * @param space The space that the rotation is in
  80541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80542. */
  80543. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80544. /**
  80545. * Set the quaternion rotation of the bone in local of world space
  80546. * @param quat The quaternion rotation that the bone should be set to
  80547. * @param space The space that the rotation is in
  80548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80549. */
  80550. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80551. /**
  80552. * Set the rotation matrix of the bone in local of world space
  80553. * @param rotMat The rotation matrix that the bone should be set to
  80554. * @param space The space that the rotation is in
  80555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80556. */
  80557. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80558. private _rotateWithMatrix;
  80559. private _getNegativeRotationToRef;
  80560. /**
  80561. * Get the position of the bone in local or world space
  80562. * @param space The space that the returned position is in
  80563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80564. * @returns The position of the bone
  80565. */
  80566. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80567. /**
  80568. * Copy the position of the bone to a vector3 in local or world space
  80569. * @param space The space that the returned position is in
  80570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80571. * @param result The vector3 to copy the position to
  80572. */
  80573. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80574. /**
  80575. * Get the absolute position of the bone (world space)
  80576. * @param mesh The mesh that this bone is attached to
  80577. * @returns The absolute position of the bone
  80578. */
  80579. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80580. /**
  80581. * Copy the absolute position of the bone (world space) to the result param
  80582. * @param mesh The mesh that this bone is attached to
  80583. * @param result The vector3 to copy the absolute position to
  80584. */
  80585. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80586. /**
  80587. * Compute the absolute transforms of this bone and its children
  80588. */
  80589. computeAbsoluteTransforms(): void;
  80590. /**
  80591. * Get the world direction from an axis that is in the local space of the bone
  80592. * @param localAxis The local direction that is used to compute the world direction
  80593. * @param mesh The mesh that this bone is attached to
  80594. * @returns The world direction
  80595. */
  80596. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80597. /**
  80598. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80599. * @param localAxis The local direction that is used to compute the world direction
  80600. * @param mesh The mesh that this bone is attached to
  80601. * @param result The vector3 that the world direction will be copied to
  80602. */
  80603. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80604. /**
  80605. * Get the euler rotation of the bone in local or world space
  80606. * @param space The space that the rotation should be in
  80607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80608. * @returns The euler rotation
  80609. */
  80610. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80611. /**
  80612. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80613. * @param space The space that the rotation should be in
  80614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80615. * @param result The vector3 that the rotation should be copied to
  80616. */
  80617. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80618. /**
  80619. * Get the quaternion rotation of the bone in either local or world space
  80620. * @param space The space that the rotation should be in
  80621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80622. * @returns The quaternion rotation
  80623. */
  80624. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80625. /**
  80626. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80627. * @param space The space that the rotation should be in
  80628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80629. * @param result The quaternion that the rotation should be copied to
  80630. */
  80631. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80632. /**
  80633. * Get the rotation matrix of the bone in local or world space
  80634. * @param space The space that the rotation should be in
  80635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80636. * @returns The rotation matrix
  80637. */
  80638. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80639. /**
  80640. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80641. * @param space The space that the rotation should be in
  80642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80643. * @param result The quaternion that the rotation should be copied to
  80644. */
  80645. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80646. /**
  80647. * Get the world position of a point that is in the local space of the bone
  80648. * @param position The local position
  80649. * @param mesh The mesh that this bone is attached to
  80650. * @returns The world position
  80651. */
  80652. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80653. /**
  80654. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80655. * @param position The local position
  80656. * @param mesh The mesh that this bone is attached to
  80657. * @param result The vector3 that the world position should be copied to
  80658. */
  80659. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80660. /**
  80661. * Get the local position of a point that is in world space
  80662. * @param position The world position
  80663. * @param mesh The mesh that this bone is attached to
  80664. * @returns The local position
  80665. */
  80666. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80667. /**
  80668. * Get the local position of a point that is in world space and copy it to the result param
  80669. * @param position The world position
  80670. * @param mesh The mesh that this bone is attached to
  80671. * @param result The vector3 that the local position should be copied to
  80672. */
  80673. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80674. }
  80675. }
  80676. declare module BABYLON {
  80677. /**
  80678. * 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.
  80679. * @see https://doc.babylonjs.com/how_to/transformnode
  80680. */
  80681. export class TransformNode extends Node {
  80682. /**
  80683. * Object will not rotate to face the camera
  80684. */
  80685. static BILLBOARDMODE_NONE: number;
  80686. /**
  80687. * Object will rotate to face the camera but only on the x axis
  80688. */
  80689. static BILLBOARDMODE_X: number;
  80690. /**
  80691. * Object will rotate to face the camera but only on the y axis
  80692. */
  80693. static BILLBOARDMODE_Y: number;
  80694. /**
  80695. * Object will rotate to face the camera but only on the z axis
  80696. */
  80697. static BILLBOARDMODE_Z: number;
  80698. /**
  80699. * Object will rotate to face the camera
  80700. */
  80701. static BILLBOARDMODE_ALL: number;
  80702. /**
  80703. * Object will rotate to face the camera's position instead of orientation
  80704. */
  80705. static BILLBOARDMODE_USE_POSITION: number;
  80706. private _forward;
  80707. private _forwardInverted;
  80708. private _up;
  80709. private _right;
  80710. private _rightInverted;
  80711. private _position;
  80712. private _rotation;
  80713. private _rotationQuaternion;
  80714. protected _scaling: Vector3;
  80715. protected _isDirty: boolean;
  80716. private _transformToBoneReferal;
  80717. private _isAbsoluteSynced;
  80718. private _billboardMode;
  80719. /**
  80720. * Gets or sets the billboard mode. Default is 0.
  80721. *
  80722. * | Value | Type | Description |
  80723. * | --- | --- | --- |
  80724. * | 0 | BILLBOARDMODE_NONE | |
  80725. * | 1 | BILLBOARDMODE_X | |
  80726. * | 2 | BILLBOARDMODE_Y | |
  80727. * | 4 | BILLBOARDMODE_Z | |
  80728. * | 7 | BILLBOARDMODE_ALL | |
  80729. *
  80730. */
  80731. billboardMode: number;
  80732. private _preserveParentRotationForBillboard;
  80733. /**
  80734. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80735. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80736. */
  80737. preserveParentRotationForBillboard: boolean;
  80738. /**
  80739. * 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
  80740. */
  80741. scalingDeterminant: number;
  80742. private _infiniteDistance;
  80743. /**
  80744. * Gets or sets the distance of the object to max, often used by skybox
  80745. */
  80746. infiniteDistance: boolean;
  80747. /**
  80748. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80749. * By default the system will update normals to compensate
  80750. */
  80751. ignoreNonUniformScaling: boolean;
  80752. /**
  80753. * 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
  80754. */
  80755. reIntegrateRotationIntoRotationQuaternion: boolean;
  80756. /** @hidden */
  80757. _poseMatrix: Nullable<Matrix>;
  80758. /** @hidden */
  80759. _localMatrix: Matrix;
  80760. private _usePivotMatrix;
  80761. private _absolutePosition;
  80762. private _absoluteScaling;
  80763. private _absoluteRotationQuaternion;
  80764. private _pivotMatrix;
  80765. private _pivotMatrixInverse;
  80766. protected _postMultiplyPivotMatrix: boolean;
  80767. protected _isWorldMatrixFrozen: boolean;
  80768. /** @hidden */
  80769. _indexInSceneTransformNodesArray: number;
  80770. /**
  80771. * An event triggered after the world matrix is updated
  80772. */
  80773. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80774. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80775. /**
  80776. * Gets a string identifying the name of the class
  80777. * @returns "TransformNode" string
  80778. */
  80779. getClassName(): string;
  80780. /**
  80781. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80782. */
  80783. position: Vector3;
  80784. /**
  80785. * 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)).
  80786. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80787. */
  80788. rotation: Vector3;
  80789. /**
  80790. * 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)).
  80791. */
  80792. scaling: Vector3;
  80793. /**
  80794. * 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).
  80795. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80796. */
  80797. rotationQuaternion: Nullable<Quaternion>;
  80798. /**
  80799. * The forward direction of that transform in world space.
  80800. */
  80801. readonly forward: Vector3;
  80802. /**
  80803. * The up direction of that transform in world space.
  80804. */
  80805. readonly up: Vector3;
  80806. /**
  80807. * The right direction of that transform in world space.
  80808. */
  80809. readonly right: Vector3;
  80810. /**
  80811. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80812. * @param matrix the matrix to copy the pose from
  80813. * @returns this TransformNode.
  80814. */
  80815. updatePoseMatrix(matrix: Matrix): TransformNode;
  80816. /**
  80817. * Returns the mesh Pose matrix.
  80818. * @returns the pose matrix
  80819. */
  80820. getPoseMatrix(): Matrix;
  80821. /** @hidden */
  80822. _isSynchronized(): boolean;
  80823. /** @hidden */
  80824. _initCache(): void;
  80825. /**
  80826. * Flag the transform node as dirty (Forcing it to update everything)
  80827. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80828. * @returns this transform node
  80829. */
  80830. markAsDirty(property: string): TransformNode;
  80831. /**
  80832. * Returns the current mesh absolute position.
  80833. * Returns a Vector3.
  80834. */
  80835. readonly absolutePosition: Vector3;
  80836. /**
  80837. * Returns the current mesh absolute scaling.
  80838. * Returns a Vector3.
  80839. */
  80840. readonly absoluteScaling: Vector3;
  80841. /**
  80842. * Returns the current mesh absolute rotation.
  80843. * Returns a Quaternion.
  80844. */
  80845. readonly absoluteRotationQuaternion: Quaternion;
  80846. /**
  80847. * Sets a new matrix to apply before all other transformation
  80848. * @param matrix defines the transform matrix
  80849. * @returns the current TransformNode
  80850. */
  80851. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80852. /**
  80853. * Sets a new pivot matrix to the current node
  80854. * @param matrix defines the new pivot matrix to use
  80855. * @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
  80856. * @returns the current TransformNode
  80857. */
  80858. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80859. /**
  80860. * Returns the mesh pivot matrix.
  80861. * Default : Identity.
  80862. * @returns the matrix
  80863. */
  80864. getPivotMatrix(): Matrix;
  80865. /**
  80866. * Instantiate (when possible) or clone that node with its hierarchy
  80867. * @param newParent defines the new parent to use for the instance (or clone)
  80868. * @returns an instance (or a clone) of the current node with its hiearchy
  80869. */
  80870. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80871. /**
  80872. * Prevents the World matrix to be computed any longer
  80873. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80874. * @returns the TransformNode.
  80875. */
  80876. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80877. /**
  80878. * Allows back the World matrix computation.
  80879. * @returns the TransformNode.
  80880. */
  80881. unfreezeWorldMatrix(): this;
  80882. /**
  80883. * True if the World matrix has been frozen.
  80884. */
  80885. readonly isWorldMatrixFrozen: boolean;
  80886. /**
  80887. * Retuns the mesh absolute position in the World.
  80888. * @returns a Vector3.
  80889. */
  80890. getAbsolutePosition(): Vector3;
  80891. /**
  80892. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80893. * @param absolutePosition the absolute position to set
  80894. * @returns the TransformNode.
  80895. */
  80896. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80897. /**
  80898. * Sets the mesh position in its local space.
  80899. * @param vector3 the position to set in localspace
  80900. * @returns the TransformNode.
  80901. */
  80902. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80903. /**
  80904. * Returns the mesh position in the local space from the current World matrix values.
  80905. * @returns a new Vector3.
  80906. */
  80907. getPositionExpressedInLocalSpace(): Vector3;
  80908. /**
  80909. * Translates the mesh along the passed Vector3 in its local space.
  80910. * @param vector3 the distance to translate in localspace
  80911. * @returns the TransformNode.
  80912. */
  80913. locallyTranslate(vector3: Vector3): TransformNode;
  80914. private static _lookAtVectorCache;
  80915. /**
  80916. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80917. * @param targetPoint the position (must be in same space as current mesh) to look at
  80918. * @param yawCor optional yaw (y-axis) correction in radians
  80919. * @param pitchCor optional pitch (x-axis) correction in radians
  80920. * @param rollCor optional roll (z-axis) correction in radians
  80921. * @param space the choosen space of the target
  80922. * @returns the TransformNode.
  80923. */
  80924. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80925. /**
  80926. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80927. * This Vector3 is expressed in the World space.
  80928. * @param localAxis axis to rotate
  80929. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80930. */
  80931. getDirection(localAxis: Vector3): Vector3;
  80932. /**
  80933. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80934. * localAxis is expressed in the mesh local space.
  80935. * result is computed in the Wordl space from the mesh World matrix.
  80936. * @param localAxis axis to rotate
  80937. * @param result the resulting transformnode
  80938. * @returns this TransformNode.
  80939. */
  80940. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80941. /**
  80942. * Sets this transform node rotation to the given local axis.
  80943. * @param localAxis the axis in local space
  80944. * @param yawCor optional yaw (y-axis) correction in radians
  80945. * @param pitchCor optional pitch (x-axis) correction in radians
  80946. * @param rollCor optional roll (z-axis) correction in radians
  80947. * @returns this TransformNode
  80948. */
  80949. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80950. /**
  80951. * Sets a new pivot point to the current node
  80952. * @param point defines the new pivot point to use
  80953. * @param space defines if the point is in world or local space (local by default)
  80954. * @returns the current TransformNode
  80955. */
  80956. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80957. /**
  80958. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80959. * @returns the pivot point
  80960. */
  80961. getPivotPoint(): Vector3;
  80962. /**
  80963. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80964. * @param result the vector3 to store the result
  80965. * @returns this TransformNode.
  80966. */
  80967. getPivotPointToRef(result: Vector3): TransformNode;
  80968. /**
  80969. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80970. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80971. */
  80972. getAbsolutePivotPoint(): Vector3;
  80973. /**
  80974. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80975. * @param result vector3 to store the result
  80976. * @returns this TransformNode.
  80977. */
  80978. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80979. /**
  80980. * Defines the passed node as the parent of the current node.
  80981. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80982. * @see https://doc.babylonjs.com/how_to/parenting
  80983. * @param node the node ot set as the parent
  80984. * @returns this TransformNode.
  80985. */
  80986. setParent(node: Nullable<Node>): TransformNode;
  80987. private _nonUniformScaling;
  80988. /**
  80989. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80990. */
  80991. readonly nonUniformScaling: boolean;
  80992. /** @hidden */
  80993. _updateNonUniformScalingState(value: boolean): boolean;
  80994. /**
  80995. * Attach the current TransformNode to another TransformNode associated with a bone
  80996. * @param bone Bone affecting the TransformNode
  80997. * @param affectedTransformNode TransformNode associated with the bone
  80998. * @returns this object
  80999. */
  81000. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81001. /**
  81002. * Detach the transform node if its associated with a bone
  81003. * @returns this object
  81004. */
  81005. detachFromBone(): TransformNode;
  81006. private static _rotationAxisCache;
  81007. /**
  81008. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81009. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81010. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81011. * The passed axis is also normalized.
  81012. * @param axis the axis to rotate around
  81013. * @param amount the amount to rotate in radians
  81014. * @param space Space to rotate in (Default: local)
  81015. * @returns the TransformNode.
  81016. */
  81017. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81018. /**
  81019. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81020. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81021. * The passed axis is also normalized. .
  81022. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81023. * @param point the point to rotate around
  81024. * @param axis the axis to rotate around
  81025. * @param amount the amount to rotate in radians
  81026. * @returns the TransformNode
  81027. */
  81028. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81029. /**
  81030. * Translates the mesh along the axis vector for the passed distance in the given space.
  81031. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81032. * @param axis the axis to translate in
  81033. * @param distance the distance to translate
  81034. * @param space Space to rotate in (Default: local)
  81035. * @returns the TransformNode.
  81036. */
  81037. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81038. /**
  81039. * Adds a rotation step to the mesh current rotation.
  81040. * x, y, z are Euler angles expressed in radians.
  81041. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81042. * This means this rotation is made in the mesh local space only.
  81043. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81044. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81045. * ```javascript
  81046. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81047. * ```
  81048. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81049. * 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.
  81050. * @param x Rotation to add
  81051. * @param y Rotation to add
  81052. * @param z Rotation to add
  81053. * @returns the TransformNode.
  81054. */
  81055. addRotation(x: number, y: number, z: number): TransformNode;
  81056. /**
  81057. * @hidden
  81058. */
  81059. protected _getEffectiveParent(): Nullable<Node>;
  81060. /**
  81061. * Computes the world matrix of the node
  81062. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81063. * @returns the world matrix
  81064. */
  81065. computeWorldMatrix(force?: boolean): Matrix;
  81066. protected _afterComputeWorldMatrix(): void;
  81067. /**
  81068. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81069. * @param func callback function to add
  81070. *
  81071. * @returns the TransformNode.
  81072. */
  81073. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81074. /**
  81075. * Removes a registered callback function.
  81076. * @param func callback function to remove
  81077. * @returns the TransformNode.
  81078. */
  81079. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81080. /**
  81081. * Gets the position of the current mesh in camera space
  81082. * @param camera defines the camera to use
  81083. * @returns a position
  81084. */
  81085. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81086. /**
  81087. * Returns the distance from the mesh to the active camera
  81088. * @param camera defines the camera to use
  81089. * @returns the distance
  81090. */
  81091. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81092. /**
  81093. * Clone the current transform node
  81094. * @param name Name of the new clone
  81095. * @param newParent New parent for the clone
  81096. * @param doNotCloneChildren Do not clone children hierarchy
  81097. * @returns the new transform node
  81098. */
  81099. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81100. /**
  81101. * Serializes the objects information.
  81102. * @param currentSerializationObject defines the object to serialize in
  81103. * @returns the serialized object
  81104. */
  81105. serialize(currentSerializationObject?: any): any;
  81106. /**
  81107. * Returns a new TransformNode object parsed from the source provided.
  81108. * @param parsedTransformNode is the source.
  81109. * @param scene the scne the object belongs to
  81110. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81111. * @returns a new TransformNode object parsed from the source provided.
  81112. */
  81113. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81114. /**
  81115. * Get all child-transformNodes of this node
  81116. * @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
  81117. * @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
  81118. * @returns an array of TransformNode
  81119. */
  81120. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81121. /**
  81122. * Releases resources associated with this transform node.
  81123. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81124. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81125. */
  81126. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81127. /**
  81128. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81129. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81130. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81131. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81132. * @returns the current mesh
  81133. */
  81134. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81135. private _syncAbsoluteScalingAndRotation;
  81136. }
  81137. }
  81138. declare module BABYLON {
  81139. /**
  81140. * Defines the types of pose enabled controllers that are supported
  81141. */
  81142. export enum PoseEnabledControllerType {
  81143. /**
  81144. * HTC Vive
  81145. */
  81146. VIVE = 0,
  81147. /**
  81148. * Oculus Rift
  81149. */
  81150. OCULUS = 1,
  81151. /**
  81152. * Windows mixed reality
  81153. */
  81154. WINDOWS = 2,
  81155. /**
  81156. * Samsung gear VR
  81157. */
  81158. GEAR_VR = 3,
  81159. /**
  81160. * Google Daydream
  81161. */
  81162. DAYDREAM = 4,
  81163. /**
  81164. * Generic
  81165. */
  81166. GENERIC = 5
  81167. }
  81168. /**
  81169. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81170. */
  81171. export interface MutableGamepadButton {
  81172. /**
  81173. * Value of the button/trigger
  81174. */
  81175. value: number;
  81176. /**
  81177. * If the button/trigger is currently touched
  81178. */
  81179. touched: boolean;
  81180. /**
  81181. * If the button/trigger is currently pressed
  81182. */
  81183. pressed: boolean;
  81184. }
  81185. /**
  81186. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81187. * @hidden
  81188. */
  81189. export interface ExtendedGamepadButton extends GamepadButton {
  81190. /**
  81191. * If the button/trigger is currently pressed
  81192. */
  81193. readonly pressed: boolean;
  81194. /**
  81195. * If the button/trigger is currently touched
  81196. */
  81197. readonly touched: boolean;
  81198. /**
  81199. * Value of the button/trigger
  81200. */
  81201. readonly value: number;
  81202. }
  81203. /** @hidden */
  81204. export interface _GamePadFactory {
  81205. /**
  81206. * Returns wether or not the current gamepad can be created for this type of controller.
  81207. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81208. * @returns true if it can be created, otherwise false
  81209. */
  81210. canCreate(gamepadInfo: any): boolean;
  81211. /**
  81212. * Creates a new instance of the Gamepad.
  81213. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81214. * @returns the new gamepad instance
  81215. */
  81216. create(gamepadInfo: any): Gamepad;
  81217. }
  81218. /**
  81219. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81220. */
  81221. export class PoseEnabledControllerHelper {
  81222. /** @hidden */
  81223. static _ControllerFactories: _GamePadFactory[];
  81224. /** @hidden */
  81225. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81226. /**
  81227. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81228. * @param vrGamepad the gamepad to initialized
  81229. * @returns a vr controller of the type the gamepad identified as
  81230. */
  81231. static InitiateController(vrGamepad: any): Gamepad;
  81232. }
  81233. /**
  81234. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81235. */
  81236. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81237. /**
  81238. * If the controller is used in a webXR session
  81239. */
  81240. isXR: boolean;
  81241. private _deviceRoomPosition;
  81242. private _deviceRoomRotationQuaternion;
  81243. /**
  81244. * The device position in babylon space
  81245. */
  81246. devicePosition: Vector3;
  81247. /**
  81248. * The device rotation in babylon space
  81249. */
  81250. deviceRotationQuaternion: Quaternion;
  81251. /**
  81252. * The scale factor of the device in babylon space
  81253. */
  81254. deviceScaleFactor: number;
  81255. /**
  81256. * (Likely devicePosition should be used instead) The device position in its room space
  81257. */
  81258. position: Vector3;
  81259. /**
  81260. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81261. */
  81262. rotationQuaternion: Quaternion;
  81263. /**
  81264. * The type of controller (Eg. Windows mixed reality)
  81265. */
  81266. controllerType: PoseEnabledControllerType;
  81267. protected _calculatedPosition: Vector3;
  81268. private _calculatedRotation;
  81269. /**
  81270. * The raw pose from the device
  81271. */
  81272. rawPose: DevicePose;
  81273. private _trackPosition;
  81274. private _maxRotationDistFromHeadset;
  81275. private _draggedRoomRotation;
  81276. /**
  81277. * @hidden
  81278. */
  81279. _disableTrackPosition(fixedPosition: Vector3): void;
  81280. /**
  81281. * Internal, the mesh attached to the controller
  81282. * @hidden
  81283. */
  81284. _mesh: Nullable<AbstractMesh>;
  81285. private _poseControlledCamera;
  81286. private _leftHandSystemQuaternion;
  81287. /**
  81288. * Internal, matrix used to convert room space to babylon space
  81289. * @hidden
  81290. */
  81291. _deviceToWorld: Matrix;
  81292. /**
  81293. * Node to be used when casting a ray from the controller
  81294. * @hidden
  81295. */
  81296. _pointingPoseNode: Nullable<TransformNode>;
  81297. /**
  81298. * Name of the child mesh that can be used to cast a ray from the controller
  81299. */
  81300. static readonly POINTING_POSE: string;
  81301. /**
  81302. * Creates a new PoseEnabledController from a gamepad
  81303. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81304. */
  81305. constructor(browserGamepad: any);
  81306. private _workingMatrix;
  81307. /**
  81308. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81309. */
  81310. update(): void;
  81311. /**
  81312. * Updates only the pose device and mesh without doing any button event checking
  81313. */
  81314. protected _updatePoseAndMesh(): void;
  81315. /**
  81316. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81317. * @param poseData raw pose fromthe device
  81318. */
  81319. updateFromDevice(poseData: DevicePose): void;
  81320. /**
  81321. * @hidden
  81322. */
  81323. _meshAttachedObservable: Observable<AbstractMesh>;
  81324. /**
  81325. * Attaches a mesh to the controller
  81326. * @param mesh the mesh to be attached
  81327. */
  81328. attachToMesh(mesh: AbstractMesh): void;
  81329. /**
  81330. * Attaches the controllers mesh to a camera
  81331. * @param camera the camera the mesh should be attached to
  81332. */
  81333. attachToPoseControlledCamera(camera: TargetCamera): void;
  81334. /**
  81335. * Disposes of the controller
  81336. */
  81337. dispose(): void;
  81338. /**
  81339. * The mesh that is attached to the controller
  81340. */
  81341. readonly mesh: Nullable<AbstractMesh>;
  81342. /**
  81343. * Gets the ray of the controller in the direction the controller is pointing
  81344. * @param length the length the resulting ray should be
  81345. * @returns a ray in the direction the controller is pointing
  81346. */
  81347. getForwardRay(length?: number): Ray;
  81348. }
  81349. }
  81350. declare module BABYLON {
  81351. /**
  81352. * Defines the WebVRController object that represents controllers tracked in 3D space
  81353. */
  81354. export abstract class WebVRController extends PoseEnabledController {
  81355. /**
  81356. * Internal, the default controller model for the controller
  81357. */
  81358. protected _defaultModel: Nullable<AbstractMesh>;
  81359. /**
  81360. * Fired when the trigger state has changed
  81361. */
  81362. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81363. /**
  81364. * Fired when the main button state has changed
  81365. */
  81366. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81367. /**
  81368. * Fired when the secondary button state has changed
  81369. */
  81370. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81371. /**
  81372. * Fired when the pad state has changed
  81373. */
  81374. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81375. /**
  81376. * Fired when controllers stick values have changed
  81377. */
  81378. onPadValuesChangedObservable: Observable<StickValues>;
  81379. /**
  81380. * Array of button availible on the controller
  81381. */
  81382. protected _buttons: Array<MutableGamepadButton>;
  81383. private _onButtonStateChange;
  81384. /**
  81385. * Fired when a controller button's state has changed
  81386. * @param callback the callback containing the button that was modified
  81387. */
  81388. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81389. /**
  81390. * X and Y axis corresponding to the controllers joystick
  81391. */
  81392. pad: StickValues;
  81393. /**
  81394. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81395. */
  81396. hand: string;
  81397. /**
  81398. * The default controller model for the controller
  81399. */
  81400. readonly defaultModel: Nullable<AbstractMesh>;
  81401. /**
  81402. * Creates a new WebVRController from a gamepad
  81403. * @param vrGamepad the gamepad that the WebVRController should be created from
  81404. */
  81405. constructor(vrGamepad: any);
  81406. /**
  81407. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81408. */
  81409. update(): void;
  81410. /**
  81411. * Function to be called when a button is modified
  81412. */
  81413. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81414. /**
  81415. * Loads a mesh and attaches it to the controller
  81416. * @param scene the scene the mesh should be added to
  81417. * @param meshLoaded callback for when the mesh has been loaded
  81418. */
  81419. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81420. private _setButtonValue;
  81421. private _changes;
  81422. private _checkChanges;
  81423. /**
  81424. * Disposes of th webVRCOntroller
  81425. */
  81426. dispose(): void;
  81427. }
  81428. }
  81429. declare module BABYLON {
  81430. /**
  81431. * The HemisphericLight simulates the ambient environment light,
  81432. * so the passed direction is the light reflection direction, not the incoming direction.
  81433. */
  81434. export class HemisphericLight extends Light {
  81435. /**
  81436. * The groundColor is the light in the opposite direction to the one specified during creation.
  81437. * 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.
  81438. */
  81439. groundColor: Color3;
  81440. /**
  81441. * The light reflection direction, not the incoming direction.
  81442. */
  81443. direction: Vector3;
  81444. /**
  81445. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81446. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81447. * The HemisphericLight can't cast shadows.
  81448. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81449. * @param name The friendly name of the light
  81450. * @param direction The direction of the light reflection
  81451. * @param scene The scene the light belongs to
  81452. */
  81453. constructor(name: string, direction: Vector3, scene: Scene);
  81454. protected _buildUniformLayout(): void;
  81455. /**
  81456. * Returns the string "HemisphericLight".
  81457. * @return The class name
  81458. */
  81459. getClassName(): string;
  81460. /**
  81461. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81462. * Returns the updated direction.
  81463. * @param target The target the direction should point to
  81464. * @return The computed direction
  81465. */
  81466. setDirectionToTarget(target: Vector3): Vector3;
  81467. /**
  81468. * Returns the shadow generator associated to the light.
  81469. * @returns Always null for hemispheric lights because it does not support shadows.
  81470. */
  81471. getShadowGenerator(): Nullable<IShadowGenerator>;
  81472. /**
  81473. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81474. * @param effect The effect to update
  81475. * @param lightIndex The index of the light in the effect to update
  81476. * @returns The hemispheric light
  81477. */
  81478. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81479. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81480. /**
  81481. * Computes the world matrix of the node
  81482. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81483. * @param useWasUpdatedFlag defines a reserved property
  81484. * @returns the world matrix
  81485. */
  81486. computeWorldMatrix(): Matrix;
  81487. /**
  81488. * Returns the integer 3.
  81489. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81490. */
  81491. getTypeID(): number;
  81492. /**
  81493. * Prepares the list of defines specific to the light type.
  81494. * @param defines the list of defines
  81495. * @param lightIndex defines the index of the light for the effect
  81496. */
  81497. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81498. }
  81499. }
  81500. declare module BABYLON {
  81501. /** @hidden */
  81502. export var vrMultiviewToSingleviewPixelShader: {
  81503. name: string;
  81504. shader: string;
  81505. };
  81506. }
  81507. declare module BABYLON {
  81508. /**
  81509. * Renders to multiple views with a single draw call
  81510. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81511. */
  81512. export class MultiviewRenderTarget extends RenderTargetTexture {
  81513. /**
  81514. * Creates a multiview render target
  81515. * @param scene scene used with the render target
  81516. * @param size the size of the render target (used for each view)
  81517. */
  81518. constructor(scene: Scene, size?: number | {
  81519. width: number;
  81520. height: number;
  81521. } | {
  81522. ratio: number;
  81523. });
  81524. /**
  81525. * @hidden
  81526. * @param faceIndex the face index, if its a cube texture
  81527. */
  81528. _bindFrameBuffer(faceIndex?: number): void;
  81529. /**
  81530. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81531. * @returns the view count
  81532. */
  81533. getViewCount(): number;
  81534. }
  81535. }
  81536. declare module BABYLON {
  81537. /**
  81538. * Represents a camera frustum
  81539. */
  81540. export class Frustum {
  81541. /**
  81542. * Gets the planes representing the frustum
  81543. * @param transform matrix to be applied to the returned planes
  81544. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81545. */
  81546. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81547. /**
  81548. * Gets the near frustum plane transformed by the transform matrix
  81549. * @param transform transformation matrix to be applied to the resulting frustum plane
  81550. * @param frustumPlane the resuling frustum plane
  81551. */
  81552. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81553. /**
  81554. * Gets the far frustum plane transformed by the transform matrix
  81555. * @param transform transformation matrix to be applied to the resulting frustum plane
  81556. * @param frustumPlane the resuling frustum plane
  81557. */
  81558. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81559. /**
  81560. * Gets the left frustum plane transformed by the transform matrix
  81561. * @param transform transformation matrix to be applied to the resulting frustum plane
  81562. * @param frustumPlane the resuling frustum plane
  81563. */
  81564. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81565. /**
  81566. * Gets the right frustum plane transformed by the transform matrix
  81567. * @param transform transformation matrix to be applied to the resulting frustum plane
  81568. * @param frustumPlane the resuling frustum plane
  81569. */
  81570. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81571. /**
  81572. * Gets the top frustum plane transformed by the transform matrix
  81573. * @param transform transformation matrix to be applied to the resulting frustum plane
  81574. * @param frustumPlane the resuling frustum plane
  81575. */
  81576. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81577. /**
  81578. * Gets the bottom frustum plane transformed by the transform matrix
  81579. * @param transform transformation matrix to be applied to the resulting frustum plane
  81580. * @param frustumPlane the resuling frustum plane
  81581. */
  81582. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81583. /**
  81584. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81585. * @param transform transformation matrix to be applied to the resulting frustum planes
  81586. * @param frustumPlanes the resuling frustum planes
  81587. */
  81588. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81589. }
  81590. }
  81591. declare module BABYLON {
  81592. interface Engine {
  81593. /**
  81594. * Creates a new multiview render target
  81595. * @param width defines the width of the texture
  81596. * @param height defines the height of the texture
  81597. * @returns the created multiview texture
  81598. */
  81599. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81600. /**
  81601. * Binds a multiview framebuffer to be drawn to
  81602. * @param multiviewTexture texture to bind
  81603. */
  81604. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81605. }
  81606. interface Camera {
  81607. /**
  81608. * @hidden
  81609. * 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)
  81610. */
  81611. _useMultiviewToSingleView: boolean;
  81612. /**
  81613. * @hidden
  81614. * 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)
  81615. */
  81616. _multiviewTexture: Nullable<RenderTargetTexture>;
  81617. /**
  81618. * @hidden
  81619. * ensures the multiview texture of the camera exists and has the specified width/height
  81620. * @param width height to set on the multiview texture
  81621. * @param height width to set on the multiview texture
  81622. */
  81623. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81624. }
  81625. interface Scene {
  81626. /** @hidden */
  81627. _transformMatrixR: Matrix;
  81628. /** @hidden */
  81629. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81630. /** @hidden */
  81631. _createMultiviewUbo(): void;
  81632. /** @hidden */
  81633. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81634. /** @hidden */
  81635. _renderMultiviewToSingleView(camera: Camera): void;
  81636. }
  81637. }
  81638. declare module BABYLON {
  81639. /**
  81640. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81641. * This will not be used for webXR as it supports displaying texture arrays directly
  81642. */
  81643. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81644. /**
  81645. * Initializes a VRMultiviewToSingleview
  81646. * @param name name of the post process
  81647. * @param camera camera to be applied to
  81648. * @param scaleFactor scaling factor to the size of the output texture
  81649. */
  81650. constructor(name: string, camera: Camera, scaleFactor: number);
  81651. }
  81652. }
  81653. declare module BABYLON {
  81654. interface Engine {
  81655. /** @hidden */
  81656. _vrDisplay: any;
  81657. /** @hidden */
  81658. _vrSupported: boolean;
  81659. /** @hidden */
  81660. _oldSize: Size;
  81661. /** @hidden */
  81662. _oldHardwareScaleFactor: number;
  81663. /** @hidden */
  81664. _vrExclusivePointerMode: boolean;
  81665. /** @hidden */
  81666. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81667. /** @hidden */
  81668. _onVRDisplayPointerRestricted: () => void;
  81669. /** @hidden */
  81670. _onVRDisplayPointerUnrestricted: () => void;
  81671. /** @hidden */
  81672. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81673. /** @hidden */
  81674. _onVrDisplayDisconnect: Nullable<() => void>;
  81675. /** @hidden */
  81676. _onVrDisplayPresentChange: Nullable<() => void>;
  81677. /**
  81678. * Observable signaled when VR display mode changes
  81679. */
  81680. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81681. /**
  81682. * Observable signaled when VR request present is complete
  81683. */
  81684. onVRRequestPresentComplete: Observable<boolean>;
  81685. /**
  81686. * Observable signaled when VR request present starts
  81687. */
  81688. onVRRequestPresentStart: Observable<Engine>;
  81689. /**
  81690. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81691. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81692. */
  81693. isInVRExclusivePointerMode: boolean;
  81694. /**
  81695. * Gets a boolean indicating if a webVR device was detected
  81696. * @returns true if a webVR device was detected
  81697. */
  81698. isVRDevicePresent(): boolean;
  81699. /**
  81700. * Gets the current webVR device
  81701. * @returns the current webVR device (or null)
  81702. */
  81703. getVRDevice(): any;
  81704. /**
  81705. * Initializes a webVR display and starts listening to display change events
  81706. * The onVRDisplayChangedObservable will be notified upon these changes
  81707. * @returns A promise containing a VRDisplay and if vr is supported
  81708. */
  81709. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81710. /** @hidden */
  81711. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81712. /**
  81713. * Call this function to switch to webVR mode
  81714. * Will do nothing if webVR is not supported or if there is no webVR device
  81715. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81716. */
  81717. enableVR(): void;
  81718. /** @hidden */
  81719. _onVRFullScreenTriggered(): void;
  81720. }
  81721. }
  81722. declare module BABYLON {
  81723. /**
  81724. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81725. * IMPORTANT!! The data is right-hand data.
  81726. * @export
  81727. * @interface DevicePose
  81728. */
  81729. export interface DevicePose {
  81730. /**
  81731. * The position of the device, values in array are [x,y,z].
  81732. */
  81733. readonly position: Nullable<Float32Array>;
  81734. /**
  81735. * The linearVelocity of the device, values in array are [x,y,z].
  81736. */
  81737. readonly linearVelocity: Nullable<Float32Array>;
  81738. /**
  81739. * The linearAcceleration of the device, values in array are [x,y,z].
  81740. */
  81741. readonly linearAcceleration: Nullable<Float32Array>;
  81742. /**
  81743. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81744. */
  81745. readonly orientation: Nullable<Float32Array>;
  81746. /**
  81747. * The angularVelocity of the device, values in array are [x,y,z].
  81748. */
  81749. readonly angularVelocity: Nullable<Float32Array>;
  81750. /**
  81751. * The angularAcceleration of the device, values in array are [x,y,z].
  81752. */
  81753. readonly angularAcceleration: Nullable<Float32Array>;
  81754. }
  81755. /**
  81756. * Interface representing a pose controlled object in Babylon.
  81757. * A pose controlled object has both regular pose values as well as pose values
  81758. * from an external device such as a VR head mounted display
  81759. */
  81760. export interface PoseControlled {
  81761. /**
  81762. * The position of the object in babylon space.
  81763. */
  81764. position: Vector3;
  81765. /**
  81766. * The rotation quaternion of the object in babylon space.
  81767. */
  81768. rotationQuaternion: Quaternion;
  81769. /**
  81770. * The position of the device in babylon space.
  81771. */
  81772. devicePosition?: Vector3;
  81773. /**
  81774. * The rotation quaternion of the device in babylon space.
  81775. */
  81776. deviceRotationQuaternion: Quaternion;
  81777. /**
  81778. * The raw pose coming from the device.
  81779. */
  81780. rawPose: Nullable<DevicePose>;
  81781. /**
  81782. * The scale of the device to be used when translating from device space to babylon space.
  81783. */
  81784. deviceScaleFactor: number;
  81785. /**
  81786. * Updates the poseControlled values based on the input device pose.
  81787. * @param poseData the pose data to update the object with
  81788. */
  81789. updateFromDevice(poseData: DevicePose): void;
  81790. }
  81791. /**
  81792. * Set of options to customize the webVRCamera
  81793. */
  81794. export interface WebVROptions {
  81795. /**
  81796. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81797. */
  81798. trackPosition?: boolean;
  81799. /**
  81800. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81801. */
  81802. positionScale?: number;
  81803. /**
  81804. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81805. */
  81806. displayName?: string;
  81807. /**
  81808. * Should the native controller meshes be initialized. (default: true)
  81809. */
  81810. controllerMeshes?: boolean;
  81811. /**
  81812. * Creating a default HemiLight only on controllers. (default: true)
  81813. */
  81814. defaultLightingOnControllers?: boolean;
  81815. /**
  81816. * If you don't want to use the default VR button of the helper. (default: false)
  81817. */
  81818. useCustomVRButton?: boolean;
  81819. /**
  81820. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81821. */
  81822. customVRButton?: HTMLButtonElement;
  81823. /**
  81824. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81825. */
  81826. rayLength?: number;
  81827. /**
  81828. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81829. */
  81830. defaultHeight?: number;
  81831. /**
  81832. * If multiview should be used if availible (default: false)
  81833. */
  81834. useMultiview?: boolean;
  81835. }
  81836. /**
  81837. * This represents a WebVR camera.
  81838. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81839. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81840. */
  81841. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81842. private webVROptions;
  81843. /**
  81844. * @hidden
  81845. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81846. */
  81847. _vrDevice: any;
  81848. /**
  81849. * The rawPose of the vrDevice.
  81850. */
  81851. rawPose: Nullable<DevicePose>;
  81852. private _onVREnabled;
  81853. private _specsVersion;
  81854. private _attached;
  81855. private _frameData;
  81856. protected _descendants: Array<Node>;
  81857. private _deviceRoomPosition;
  81858. /** @hidden */
  81859. _deviceRoomRotationQuaternion: Quaternion;
  81860. private _standingMatrix;
  81861. /**
  81862. * Represents device position in babylon space.
  81863. */
  81864. devicePosition: Vector3;
  81865. /**
  81866. * Represents device rotation in babylon space.
  81867. */
  81868. deviceRotationQuaternion: Quaternion;
  81869. /**
  81870. * The scale of the device to be used when translating from device space to babylon space.
  81871. */
  81872. deviceScaleFactor: number;
  81873. private _deviceToWorld;
  81874. private _worldToDevice;
  81875. /**
  81876. * References to the webVR controllers for the vrDevice.
  81877. */
  81878. controllers: Array<WebVRController>;
  81879. /**
  81880. * Emits an event when a controller is attached.
  81881. */
  81882. onControllersAttachedObservable: Observable<WebVRController[]>;
  81883. /**
  81884. * Emits an event when a controller's mesh has been loaded;
  81885. */
  81886. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81887. /**
  81888. * Emits an event when the HMD's pose has been updated.
  81889. */
  81890. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81891. private _poseSet;
  81892. /**
  81893. * If the rig cameras be used as parent instead of this camera.
  81894. */
  81895. rigParenting: boolean;
  81896. private _lightOnControllers;
  81897. private _defaultHeight?;
  81898. /**
  81899. * Instantiates a WebVRFreeCamera.
  81900. * @param name The name of the WebVRFreeCamera
  81901. * @param position The starting anchor position for the camera
  81902. * @param scene The scene the camera belongs to
  81903. * @param webVROptions a set of customizable options for the webVRCamera
  81904. */
  81905. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81906. /**
  81907. * Gets the device distance from the ground in meters.
  81908. * @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.
  81909. */
  81910. deviceDistanceToRoomGround(): number;
  81911. /**
  81912. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81913. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81914. */
  81915. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81916. /**
  81917. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81918. * @returns A promise with a boolean set to if the standing matrix is supported.
  81919. */
  81920. useStandingMatrixAsync(): Promise<boolean>;
  81921. /**
  81922. * Disposes the camera
  81923. */
  81924. dispose(): void;
  81925. /**
  81926. * Gets a vrController by name.
  81927. * @param name The name of the controller to retreive
  81928. * @returns the controller matching the name specified or null if not found
  81929. */
  81930. getControllerByName(name: string): Nullable<WebVRController>;
  81931. private _leftController;
  81932. /**
  81933. * The controller corresponding to the users left hand.
  81934. */
  81935. readonly leftController: Nullable<WebVRController>;
  81936. private _rightController;
  81937. /**
  81938. * The controller corresponding to the users right hand.
  81939. */
  81940. readonly rightController: Nullable<WebVRController>;
  81941. /**
  81942. * Casts a ray forward from the vrCamera's gaze.
  81943. * @param length Length of the ray (default: 100)
  81944. * @returns the ray corresponding to the gaze
  81945. */
  81946. getForwardRay(length?: number): Ray;
  81947. /**
  81948. * @hidden
  81949. * Updates the camera based on device's frame data
  81950. */
  81951. _checkInputs(): void;
  81952. /**
  81953. * Updates the poseControlled values based on the input device pose.
  81954. * @param poseData Pose coming from the device
  81955. */
  81956. updateFromDevice(poseData: DevicePose): void;
  81957. private _htmlElementAttached;
  81958. private _detachIfAttached;
  81959. /**
  81960. * WebVR's attach control will start broadcasting frames to the device.
  81961. * Note that in certain browsers (chrome for example) this function must be called
  81962. * within a user-interaction callback. Example:
  81963. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81964. *
  81965. * @param element html element to attach the vrDevice to
  81966. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81967. */
  81968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81969. /**
  81970. * Detaches the camera from the html element and disables VR
  81971. *
  81972. * @param element html element to detach from
  81973. */
  81974. detachControl(element: HTMLElement): void;
  81975. /**
  81976. * @returns the name of this class
  81977. */
  81978. getClassName(): string;
  81979. /**
  81980. * Calls resetPose on the vrDisplay
  81981. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81982. */
  81983. resetToCurrentRotation(): void;
  81984. /**
  81985. * @hidden
  81986. * Updates the rig cameras (left and right eye)
  81987. */
  81988. _updateRigCameras(): void;
  81989. private _workingVector;
  81990. private _oneVector;
  81991. private _workingMatrix;
  81992. private updateCacheCalled;
  81993. private _correctPositionIfNotTrackPosition;
  81994. /**
  81995. * @hidden
  81996. * Updates the cached values of the camera
  81997. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81998. */
  81999. _updateCache(ignoreParentClass?: boolean): void;
  82000. /**
  82001. * @hidden
  82002. * Get current device position in babylon world
  82003. */
  82004. _computeDevicePosition(): void;
  82005. /**
  82006. * Updates the current device position and rotation in the babylon world
  82007. */
  82008. update(): void;
  82009. /**
  82010. * @hidden
  82011. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82012. * @returns an identity matrix
  82013. */
  82014. _getViewMatrix(): Matrix;
  82015. private _tmpMatrix;
  82016. /**
  82017. * This function is called by the two RIG cameras.
  82018. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82019. * @hidden
  82020. */
  82021. _getWebVRViewMatrix(): Matrix;
  82022. /** @hidden */
  82023. _getWebVRProjectionMatrix(): Matrix;
  82024. private _onGamepadConnectedObserver;
  82025. private _onGamepadDisconnectedObserver;
  82026. private _updateCacheWhenTrackingDisabledObserver;
  82027. /**
  82028. * Initializes the controllers and their meshes
  82029. */
  82030. initControllers(): void;
  82031. }
  82032. }
  82033. declare module BABYLON {
  82034. /**
  82035. * Size options for a post process
  82036. */
  82037. export type PostProcessOptions = {
  82038. width: number;
  82039. height: number;
  82040. };
  82041. /**
  82042. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82043. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82044. */
  82045. export class PostProcess {
  82046. /** Name of the PostProcess. */
  82047. name: string;
  82048. /**
  82049. * Gets or sets the unique id of the post process
  82050. */
  82051. uniqueId: number;
  82052. /**
  82053. * Width of the texture to apply the post process on
  82054. */
  82055. width: number;
  82056. /**
  82057. * Height of the texture to apply the post process on
  82058. */
  82059. height: number;
  82060. /**
  82061. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82062. * @hidden
  82063. */
  82064. _outputTexture: Nullable<InternalTexture>;
  82065. /**
  82066. * Sampling mode used by the shader
  82067. * See https://doc.babylonjs.com/classes/3.1/texture
  82068. */
  82069. renderTargetSamplingMode: number;
  82070. /**
  82071. * Clear color to use when screen clearing
  82072. */
  82073. clearColor: Color4;
  82074. /**
  82075. * If the buffer needs to be cleared before applying the post process. (default: true)
  82076. * Should be set to false if shader will overwrite all previous pixels.
  82077. */
  82078. autoClear: boolean;
  82079. /**
  82080. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82081. */
  82082. alphaMode: number;
  82083. /**
  82084. * Sets the setAlphaBlendConstants of the babylon engine
  82085. */
  82086. alphaConstants: Color4;
  82087. /**
  82088. * Animations to be used for the post processing
  82089. */
  82090. animations: Animation[];
  82091. /**
  82092. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82093. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82094. */
  82095. enablePixelPerfectMode: boolean;
  82096. /**
  82097. * Force the postprocess to be applied without taking in account viewport
  82098. */
  82099. forceFullscreenViewport: boolean;
  82100. /**
  82101. * List of inspectable custom properties (used by the Inspector)
  82102. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82103. */
  82104. inspectableCustomProperties: IInspectable[];
  82105. /**
  82106. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82107. *
  82108. * | Value | Type | Description |
  82109. * | ----- | ----------------------------------- | ----------- |
  82110. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82111. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82112. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82113. *
  82114. */
  82115. scaleMode: number;
  82116. /**
  82117. * Force textures to be a power of two (default: false)
  82118. */
  82119. alwaysForcePOT: boolean;
  82120. private _samples;
  82121. /**
  82122. * Number of sample textures (default: 1)
  82123. */
  82124. samples: number;
  82125. /**
  82126. * Modify the scale of the post process to be the same as the viewport (default: false)
  82127. */
  82128. adaptScaleToCurrentViewport: boolean;
  82129. private _camera;
  82130. private _scene;
  82131. private _engine;
  82132. private _options;
  82133. private _reusable;
  82134. private _textureType;
  82135. /**
  82136. * Smart array of input and output textures for the post process.
  82137. * @hidden
  82138. */
  82139. _textures: SmartArray<InternalTexture>;
  82140. /**
  82141. * The index in _textures that corresponds to the output texture.
  82142. * @hidden
  82143. */
  82144. _currentRenderTextureInd: number;
  82145. private _effect;
  82146. private _samplers;
  82147. private _fragmentUrl;
  82148. private _vertexUrl;
  82149. private _parameters;
  82150. private _scaleRatio;
  82151. protected _indexParameters: any;
  82152. private _shareOutputWithPostProcess;
  82153. private _texelSize;
  82154. private _forcedOutputTexture;
  82155. /**
  82156. * Returns the fragment url or shader name used in the post process.
  82157. * @returns the fragment url or name in the shader store.
  82158. */
  82159. getEffectName(): string;
  82160. /**
  82161. * An event triggered when the postprocess is activated.
  82162. */
  82163. onActivateObservable: Observable<Camera>;
  82164. private _onActivateObserver;
  82165. /**
  82166. * A function that is added to the onActivateObservable
  82167. */
  82168. onActivate: Nullable<(camera: Camera) => void>;
  82169. /**
  82170. * An event triggered when the postprocess changes its size.
  82171. */
  82172. onSizeChangedObservable: Observable<PostProcess>;
  82173. private _onSizeChangedObserver;
  82174. /**
  82175. * A function that is added to the onSizeChangedObservable
  82176. */
  82177. onSizeChanged: (postProcess: PostProcess) => void;
  82178. /**
  82179. * An event triggered when the postprocess applies its effect.
  82180. */
  82181. onApplyObservable: Observable<Effect>;
  82182. private _onApplyObserver;
  82183. /**
  82184. * A function that is added to the onApplyObservable
  82185. */
  82186. onApply: (effect: Effect) => void;
  82187. /**
  82188. * An event triggered before rendering the postprocess
  82189. */
  82190. onBeforeRenderObservable: Observable<Effect>;
  82191. private _onBeforeRenderObserver;
  82192. /**
  82193. * A function that is added to the onBeforeRenderObservable
  82194. */
  82195. onBeforeRender: (effect: Effect) => void;
  82196. /**
  82197. * An event triggered after rendering the postprocess
  82198. */
  82199. onAfterRenderObservable: Observable<Effect>;
  82200. private _onAfterRenderObserver;
  82201. /**
  82202. * A function that is added to the onAfterRenderObservable
  82203. */
  82204. onAfterRender: (efect: Effect) => void;
  82205. /**
  82206. * 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
  82207. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82208. */
  82209. inputTexture: InternalTexture;
  82210. /**
  82211. * Gets the camera which post process is applied to.
  82212. * @returns The camera the post process is applied to.
  82213. */
  82214. getCamera(): Camera;
  82215. /**
  82216. * Gets the texel size of the postprocess.
  82217. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82218. */
  82219. readonly texelSize: Vector2;
  82220. /**
  82221. * Creates a new instance PostProcess
  82222. * @param name The name of the PostProcess.
  82223. * @param fragmentUrl The url of the fragment shader to be used.
  82224. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82225. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82226. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82227. * @param camera The camera to apply the render pass to.
  82228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82229. * @param engine The engine which the post process will be applied. (default: current engine)
  82230. * @param reusable If the post process can be reused on the same frame. (default: false)
  82231. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82232. * @param textureType Type of textures used when performing the post process. (default: 0)
  82233. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82234. * @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
  82235. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82236. */
  82237. constructor(
  82238. /** Name of the PostProcess. */
  82239. 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);
  82240. /**
  82241. * Gets a string idenfifying the name of the class
  82242. * @returns "PostProcess" string
  82243. */
  82244. getClassName(): string;
  82245. /**
  82246. * Gets the engine which this post process belongs to.
  82247. * @returns The engine the post process was enabled with.
  82248. */
  82249. getEngine(): Engine;
  82250. /**
  82251. * The effect that is created when initializing the post process.
  82252. * @returns The created effect corresponding the the postprocess.
  82253. */
  82254. getEffect(): Effect;
  82255. /**
  82256. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82257. * @param postProcess The post process to share the output with.
  82258. * @returns This post process.
  82259. */
  82260. shareOutputWith(postProcess: PostProcess): PostProcess;
  82261. /**
  82262. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82263. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82264. */
  82265. useOwnOutput(): void;
  82266. /**
  82267. * Updates the effect with the current post process compile time values and recompiles the shader.
  82268. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82269. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82270. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82271. * @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
  82272. * @param onCompiled Called when the shader has been compiled.
  82273. * @param onError Called if there is an error when compiling a shader.
  82274. */
  82275. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82276. /**
  82277. * The post process is reusable if it can be used multiple times within one frame.
  82278. * @returns If the post process is reusable
  82279. */
  82280. isReusable(): boolean;
  82281. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82282. markTextureDirty(): void;
  82283. /**
  82284. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82285. * 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.
  82286. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82287. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82288. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82289. * @returns The target texture that was bound to be written to.
  82290. */
  82291. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82292. /**
  82293. * If the post process is supported.
  82294. */
  82295. readonly isSupported: boolean;
  82296. /**
  82297. * The aspect ratio of the output texture.
  82298. */
  82299. readonly aspectRatio: number;
  82300. /**
  82301. * Get a value indicating if the post-process is ready to be used
  82302. * @returns true if the post-process is ready (shader is compiled)
  82303. */
  82304. isReady(): boolean;
  82305. /**
  82306. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82307. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82308. */
  82309. apply(): Nullable<Effect>;
  82310. private _disposeTextures;
  82311. /**
  82312. * Disposes the post process.
  82313. * @param camera The camera to dispose the post process on.
  82314. */
  82315. dispose(camera?: Camera): void;
  82316. }
  82317. }
  82318. declare module BABYLON {
  82319. /** @hidden */
  82320. export var kernelBlurVaryingDeclaration: {
  82321. name: string;
  82322. shader: string;
  82323. };
  82324. }
  82325. declare module BABYLON {
  82326. /** @hidden */
  82327. export var kernelBlurFragment: {
  82328. name: string;
  82329. shader: string;
  82330. };
  82331. }
  82332. declare module BABYLON {
  82333. /** @hidden */
  82334. export var kernelBlurFragment2: {
  82335. name: string;
  82336. shader: string;
  82337. };
  82338. }
  82339. declare module BABYLON {
  82340. /** @hidden */
  82341. export var kernelBlurPixelShader: {
  82342. name: string;
  82343. shader: string;
  82344. };
  82345. }
  82346. declare module BABYLON {
  82347. /** @hidden */
  82348. export var kernelBlurVertex: {
  82349. name: string;
  82350. shader: string;
  82351. };
  82352. }
  82353. declare module BABYLON {
  82354. /** @hidden */
  82355. export var kernelBlurVertexShader: {
  82356. name: string;
  82357. shader: string;
  82358. };
  82359. }
  82360. declare module BABYLON {
  82361. /**
  82362. * The Blur Post Process which blurs an image based on a kernel and direction.
  82363. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82364. */
  82365. export class BlurPostProcess extends PostProcess {
  82366. /** The direction in which to blur the image. */
  82367. direction: Vector2;
  82368. private blockCompilation;
  82369. protected _kernel: number;
  82370. protected _idealKernel: number;
  82371. protected _packedFloat: boolean;
  82372. private _staticDefines;
  82373. /**
  82374. * Sets the length in pixels of the blur sample region
  82375. */
  82376. /**
  82377. * Gets the length in pixels of the blur sample region
  82378. */
  82379. kernel: number;
  82380. /**
  82381. * Sets wether or not the blur needs to unpack/repack floats
  82382. */
  82383. /**
  82384. * Gets wether or not the blur is unpacking/repacking floats
  82385. */
  82386. packedFloat: boolean;
  82387. /**
  82388. * Creates a new instance BlurPostProcess
  82389. * @param name The name of the effect.
  82390. * @param direction The direction in which to blur the image.
  82391. * @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.
  82392. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82393. * @param camera The camera to apply the render pass to.
  82394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82395. * @param engine The engine which the post process will be applied. (default: current engine)
  82396. * @param reusable If the post process can be reused on the same frame. (default: false)
  82397. * @param textureType Type of textures used when performing the post process. (default: 0)
  82398. * @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)
  82399. */
  82400. constructor(name: string,
  82401. /** The direction in which to blur the image. */
  82402. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82403. /**
  82404. * Updates the effect with the current post process compile time values and recompiles the shader.
  82405. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82406. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82407. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82408. * @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
  82409. * @param onCompiled Called when the shader has been compiled.
  82410. * @param onError Called if there is an error when compiling a shader.
  82411. */
  82412. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82413. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82414. /**
  82415. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82416. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82417. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82418. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82419. * The gaps between physical kernels are compensated for in the weighting of the samples
  82420. * @param idealKernel Ideal blur kernel.
  82421. * @return Nearest best kernel.
  82422. */
  82423. protected _nearestBestKernel(idealKernel: number): number;
  82424. /**
  82425. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82426. * @param x The point on the Gaussian distribution to sample.
  82427. * @return the value of the Gaussian function at x.
  82428. */
  82429. protected _gaussianWeight(x: number): number;
  82430. /**
  82431. * Generates a string that can be used as a floating point number in GLSL.
  82432. * @param x Value to print.
  82433. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82434. * @return GLSL float string.
  82435. */
  82436. protected _glslFloat(x: number, decimalFigures?: number): string;
  82437. }
  82438. }
  82439. declare module BABYLON {
  82440. /**
  82441. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82442. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82443. * You can then easily use it as a reflectionTexture on a flat surface.
  82444. * In case the surface is not a plane, please consider relying on reflection probes.
  82445. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82446. */
  82447. export class MirrorTexture extends RenderTargetTexture {
  82448. private scene;
  82449. /**
  82450. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82451. * 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.
  82452. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82453. */
  82454. mirrorPlane: Plane;
  82455. /**
  82456. * Define the blur ratio used to blur the reflection if needed.
  82457. */
  82458. blurRatio: number;
  82459. /**
  82460. * Define the adaptive blur kernel used to blur the reflection if needed.
  82461. * This will autocompute the closest best match for the `blurKernel`
  82462. */
  82463. adaptiveBlurKernel: number;
  82464. /**
  82465. * Define the blur kernel used to blur the reflection if needed.
  82466. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82467. */
  82468. blurKernel: number;
  82469. /**
  82470. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82471. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82472. */
  82473. blurKernelX: number;
  82474. /**
  82475. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82476. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82477. */
  82478. blurKernelY: number;
  82479. private _autoComputeBlurKernel;
  82480. protected _onRatioRescale(): void;
  82481. private _updateGammaSpace;
  82482. private _imageProcessingConfigChangeObserver;
  82483. private _transformMatrix;
  82484. private _mirrorMatrix;
  82485. private _savedViewMatrix;
  82486. private _blurX;
  82487. private _blurY;
  82488. private _adaptiveBlurKernel;
  82489. private _blurKernelX;
  82490. private _blurKernelY;
  82491. private _blurRatio;
  82492. /**
  82493. * Instantiates a Mirror Texture.
  82494. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82495. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82496. * You can then easily use it as a reflectionTexture on a flat surface.
  82497. * In case the surface is not a plane, please consider relying on reflection probes.
  82498. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82499. * @param name
  82500. * @param size
  82501. * @param scene
  82502. * @param generateMipMaps
  82503. * @param type
  82504. * @param samplingMode
  82505. * @param generateDepthBuffer
  82506. */
  82507. constructor(name: string, size: number | {
  82508. width: number;
  82509. height: number;
  82510. } | {
  82511. ratio: number;
  82512. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82513. private _preparePostProcesses;
  82514. /**
  82515. * Clone the mirror texture.
  82516. * @returns the cloned texture
  82517. */
  82518. clone(): MirrorTexture;
  82519. /**
  82520. * Serialize the texture to a JSON representation you could use in Parse later on
  82521. * @returns the serialized JSON representation
  82522. */
  82523. serialize(): any;
  82524. /**
  82525. * Dispose the texture and release its associated resources.
  82526. */
  82527. dispose(): void;
  82528. }
  82529. }
  82530. declare module BABYLON {
  82531. /**
  82532. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82533. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82534. */
  82535. export class Texture extends BaseTexture {
  82536. /**
  82537. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82538. */
  82539. static SerializeBuffers: boolean;
  82540. /** @hidden */
  82541. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82542. /** @hidden */
  82543. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82544. /** @hidden */
  82545. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82546. /** nearest is mag = nearest and min = nearest and mip = linear */
  82547. static readonly NEAREST_SAMPLINGMODE: number;
  82548. /** nearest is mag = nearest and min = nearest and mip = linear */
  82549. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82550. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82551. static readonly BILINEAR_SAMPLINGMODE: number;
  82552. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82553. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82554. /** Trilinear is mag = linear and min = linear and mip = linear */
  82555. static readonly TRILINEAR_SAMPLINGMODE: number;
  82556. /** Trilinear is mag = linear and min = linear and mip = linear */
  82557. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82558. /** mag = nearest and min = nearest and mip = nearest */
  82559. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82560. /** mag = nearest and min = linear and mip = nearest */
  82561. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82562. /** mag = nearest and min = linear and mip = linear */
  82563. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82564. /** mag = nearest and min = linear and mip = none */
  82565. static readonly NEAREST_LINEAR: number;
  82566. /** mag = nearest and min = nearest and mip = none */
  82567. static readonly NEAREST_NEAREST: number;
  82568. /** mag = linear and min = nearest and mip = nearest */
  82569. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82570. /** mag = linear and min = nearest and mip = linear */
  82571. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82572. /** mag = linear and min = linear and mip = none */
  82573. static readonly LINEAR_LINEAR: number;
  82574. /** mag = linear and min = nearest and mip = none */
  82575. static readonly LINEAR_NEAREST: number;
  82576. /** Explicit coordinates mode */
  82577. static readonly EXPLICIT_MODE: number;
  82578. /** Spherical coordinates mode */
  82579. static readonly SPHERICAL_MODE: number;
  82580. /** Planar coordinates mode */
  82581. static readonly PLANAR_MODE: number;
  82582. /** Cubic coordinates mode */
  82583. static readonly CUBIC_MODE: number;
  82584. /** Projection coordinates mode */
  82585. static readonly PROJECTION_MODE: number;
  82586. /** Inverse Cubic coordinates mode */
  82587. static readonly SKYBOX_MODE: number;
  82588. /** Inverse Cubic coordinates mode */
  82589. static readonly INVCUBIC_MODE: number;
  82590. /** Equirectangular coordinates mode */
  82591. static readonly EQUIRECTANGULAR_MODE: number;
  82592. /** Equirectangular Fixed coordinates mode */
  82593. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82594. /** Equirectangular Fixed Mirrored coordinates mode */
  82595. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82596. /** Texture is not repeating outside of 0..1 UVs */
  82597. static readonly CLAMP_ADDRESSMODE: number;
  82598. /** Texture is repeating outside of 0..1 UVs */
  82599. static readonly WRAP_ADDRESSMODE: number;
  82600. /** Texture is repeating and mirrored */
  82601. static readonly MIRROR_ADDRESSMODE: number;
  82602. /**
  82603. * 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
  82604. */
  82605. static UseSerializedUrlIfAny: boolean;
  82606. /**
  82607. * Define the url of the texture.
  82608. */
  82609. url: Nullable<string>;
  82610. /**
  82611. * Define an offset on the texture to offset the u coordinates of the UVs
  82612. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82613. */
  82614. uOffset: number;
  82615. /**
  82616. * Define an offset on the texture to offset the v coordinates of the UVs
  82617. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82618. */
  82619. vOffset: number;
  82620. /**
  82621. * Define an offset on the texture to scale the u coordinates of the UVs
  82622. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82623. */
  82624. uScale: number;
  82625. /**
  82626. * Define an offset on the texture to scale the v coordinates of the UVs
  82627. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82628. */
  82629. vScale: number;
  82630. /**
  82631. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82632. * @see http://doc.babylonjs.com/how_to/more_materials
  82633. */
  82634. uAng: number;
  82635. /**
  82636. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82637. * @see http://doc.babylonjs.com/how_to/more_materials
  82638. */
  82639. vAng: number;
  82640. /**
  82641. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82642. * @see http://doc.babylonjs.com/how_to/more_materials
  82643. */
  82644. wAng: number;
  82645. /**
  82646. * Defines the center of rotation (U)
  82647. */
  82648. uRotationCenter: number;
  82649. /**
  82650. * Defines the center of rotation (V)
  82651. */
  82652. vRotationCenter: number;
  82653. /**
  82654. * Defines the center of rotation (W)
  82655. */
  82656. wRotationCenter: number;
  82657. /**
  82658. * Are mip maps generated for this texture or not.
  82659. */
  82660. readonly noMipmap: boolean;
  82661. /**
  82662. * List of inspectable custom properties (used by the Inspector)
  82663. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82664. */
  82665. inspectableCustomProperties: Nullable<IInspectable[]>;
  82666. private _noMipmap;
  82667. /** @hidden */
  82668. _invertY: boolean;
  82669. private _rowGenerationMatrix;
  82670. private _cachedTextureMatrix;
  82671. private _projectionModeMatrix;
  82672. private _t0;
  82673. private _t1;
  82674. private _t2;
  82675. private _cachedUOffset;
  82676. private _cachedVOffset;
  82677. private _cachedUScale;
  82678. private _cachedVScale;
  82679. private _cachedUAng;
  82680. private _cachedVAng;
  82681. private _cachedWAng;
  82682. private _cachedProjectionMatrixId;
  82683. private _cachedCoordinatesMode;
  82684. /** @hidden */
  82685. protected _initialSamplingMode: number;
  82686. /** @hidden */
  82687. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82688. private _deleteBuffer;
  82689. protected _format: Nullable<number>;
  82690. private _delayedOnLoad;
  82691. private _delayedOnError;
  82692. /**
  82693. * Observable triggered once the texture has been loaded.
  82694. */
  82695. onLoadObservable: Observable<Texture>;
  82696. protected _isBlocking: boolean;
  82697. /**
  82698. * Is the texture preventing material to render while loading.
  82699. * If false, a default texture will be used instead of the loading one during the preparation step.
  82700. */
  82701. isBlocking: boolean;
  82702. /**
  82703. * Get the current sampling mode associated with the texture.
  82704. */
  82705. readonly samplingMode: number;
  82706. /**
  82707. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82708. */
  82709. readonly invertY: boolean;
  82710. /**
  82711. * Instantiates a new texture.
  82712. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82713. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82714. * @param url define the url of the picture to load as a texture
  82715. * @param scene define the scene or engine the texture will belong to
  82716. * @param noMipmap define if the texture will require mip maps or not
  82717. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82718. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82719. * @param onLoad define a callback triggered when the texture has been loaded
  82720. * @param onError define a callback triggered when an error occurred during the loading session
  82721. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82722. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82723. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82724. */
  82725. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  82726. /**
  82727. * Update the url (and optional buffer) of this texture if url was null during construction.
  82728. * @param url the url of the texture
  82729. * @param buffer the buffer of the texture (defaults to null)
  82730. * @param onLoad callback called when the texture is loaded (defaults to null)
  82731. */
  82732. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82733. /**
  82734. * Finish the loading sequence of a texture flagged as delayed load.
  82735. * @hidden
  82736. */
  82737. delayLoad(): void;
  82738. private _prepareRowForTextureGeneration;
  82739. /**
  82740. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82741. * @returns the transform matrix of the texture.
  82742. */
  82743. getTextureMatrix(): Matrix;
  82744. /**
  82745. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82746. * @returns The reflection texture transform
  82747. */
  82748. getReflectionTextureMatrix(): Matrix;
  82749. /**
  82750. * Clones the texture.
  82751. * @returns the cloned texture
  82752. */
  82753. clone(): Texture;
  82754. /**
  82755. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82756. * @returns The JSON representation of the texture
  82757. */
  82758. serialize(): any;
  82759. /**
  82760. * Get the current class name of the texture useful for serialization or dynamic coding.
  82761. * @returns "Texture"
  82762. */
  82763. getClassName(): string;
  82764. /**
  82765. * Dispose the texture and release its associated resources.
  82766. */
  82767. dispose(): void;
  82768. /**
  82769. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82770. * @param parsedTexture Define the JSON representation of the texture
  82771. * @param scene Define the scene the parsed texture should be instantiated in
  82772. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82773. * @returns The parsed texture if successful
  82774. */
  82775. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82776. /**
  82777. * Creates a texture from its base 64 representation.
  82778. * @param data Define the base64 payload without the data: prefix
  82779. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82780. * @param scene Define the scene the texture should belong to
  82781. * @param noMipmap Forces the texture to not create mip map information if true
  82782. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82783. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82784. * @param onLoad define a callback triggered when the texture has been loaded
  82785. * @param onError define a callback triggered when an error occurred during the loading session
  82786. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82787. * @returns the created texture
  82788. */
  82789. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82790. /**
  82791. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82792. * @param data Define the base64 payload without the data: prefix
  82793. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82794. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82795. * @param scene Define the scene the texture should belong to
  82796. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82797. * @param noMipmap Forces the texture to not create mip map information if true
  82798. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82799. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82800. * @param onLoad define a callback triggered when the texture has been loaded
  82801. * @param onError define a callback triggered when an error occurred during the loading session
  82802. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82803. * @returns the created texture
  82804. */
  82805. 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;
  82806. }
  82807. }
  82808. declare module BABYLON {
  82809. /**
  82810. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82811. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82812. */
  82813. export class PostProcessManager {
  82814. private _scene;
  82815. private _indexBuffer;
  82816. private _vertexBuffers;
  82817. /**
  82818. * Creates a new instance PostProcess
  82819. * @param scene The scene that the post process is associated with.
  82820. */
  82821. constructor(scene: Scene);
  82822. private _prepareBuffers;
  82823. private _buildIndexBuffer;
  82824. /**
  82825. * Rebuilds the vertex buffers of the manager.
  82826. * @hidden
  82827. */
  82828. _rebuild(): void;
  82829. /**
  82830. * Prepares a frame to be run through a post process.
  82831. * @param sourceTexture The input texture to the post procesess. (default: null)
  82832. * @param postProcesses An array of post processes to be run. (default: null)
  82833. * @returns True if the post processes were able to be run.
  82834. * @hidden
  82835. */
  82836. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82837. /**
  82838. * Manually render a set of post processes to a texture.
  82839. * @param postProcesses An array of post processes to be run.
  82840. * @param targetTexture The target texture to render to.
  82841. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82842. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82843. * @param lodLevel defines which lod of the texture to render to
  82844. */
  82845. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82846. /**
  82847. * Finalize the result of the output of the postprocesses.
  82848. * @param doNotPresent If true the result will not be displayed to the screen.
  82849. * @param targetTexture The target texture to render to.
  82850. * @param faceIndex The index of the face to bind the target texture to.
  82851. * @param postProcesses The array of post processes to render.
  82852. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82853. * @hidden
  82854. */
  82855. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82856. /**
  82857. * Disposes of the post process manager.
  82858. */
  82859. dispose(): void;
  82860. }
  82861. }
  82862. declare module BABYLON {
  82863. /** Interface used by value gradients (color, factor, ...) */
  82864. export interface IValueGradient {
  82865. /**
  82866. * Gets or sets the gradient value (between 0 and 1)
  82867. */
  82868. gradient: number;
  82869. }
  82870. /** Class used to store color4 gradient */
  82871. export class ColorGradient implements IValueGradient {
  82872. /**
  82873. * Gets or sets the gradient value (between 0 and 1)
  82874. */
  82875. gradient: number;
  82876. /**
  82877. * Gets or sets first associated color
  82878. */
  82879. color1: Color4;
  82880. /**
  82881. * Gets or sets second associated color
  82882. */
  82883. color2?: Color4;
  82884. /**
  82885. * Will get a color picked randomly between color1 and color2.
  82886. * If color2 is undefined then color1 will be used
  82887. * @param result defines the target Color4 to store the result in
  82888. */
  82889. getColorToRef(result: Color4): void;
  82890. }
  82891. /** Class used to store color 3 gradient */
  82892. export class Color3Gradient implements IValueGradient {
  82893. /**
  82894. * Gets or sets the gradient value (between 0 and 1)
  82895. */
  82896. gradient: number;
  82897. /**
  82898. * Gets or sets the associated color
  82899. */
  82900. color: Color3;
  82901. }
  82902. /** Class used to store factor gradient */
  82903. export class FactorGradient implements IValueGradient {
  82904. /**
  82905. * Gets or sets the gradient value (between 0 and 1)
  82906. */
  82907. gradient: number;
  82908. /**
  82909. * Gets or sets first associated factor
  82910. */
  82911. factor1: number;
  82912. /**
  82913. * Gets or sets second associated factor
  82914. */
  82915. factor2?: number;
  82916. /**
  82917. * Will get a number picked randomly between factor1 and factor2.
  82918. * If factor2 is undefined then factor1 will be used
  82919. * @returns the picked number
  82920. */
  82921. getFactor(): number;
  82922. }
  82923. /**
  82924. * Helper used to simplify some generic gradient tasks
  82925. */
  82926. export class GradientHelper {
  82927. /**
  82928. * Gets the current gradient from an array of IValueGradient
  82929. * @param ratio defines the current ratio to get
  82930. * @param gradients defines the array of IValueGradient
  82931. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82932. */
  82933. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82934. }
  82935. }
  82936. declare module BABYLON {
  82937. interface ThinEngine {
  82938. /**
  82939. * Creates a dynamic texture
  82940. * @param width defines the width of the texture
  82941. * @param height defines the height of the texture
  82942. * @param generateMipMaps defines if the engine should generate the mip levels
  82943. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82944. * @returns the dynamic texture inside an InternalTexture
  82945. */
  82946. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82947. /**
  82948. * Update the content of a dynamic texture
  82949. * @param texture defines the texture to update
  82950. * @param canvas defines the canvas containing the source
  82951. * @param invertY defines if data must be stored with Y axis inverted
  82952. * @param premulAlpha defines if alpha is stored as premultiplied
  82953. * @param format defines the format of the data
  82954. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82955. */
  82956. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82957. }
  82958. }
  82959. declare module BABYLON {
  82960. /**
  82961. * A class extending Texture allowing drawing on a texture
  82962. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82963. */
  82964. export class DynamicTexture extends Texture {
  82965. private _generateMipMaps;
  82966. private _canvas;
  82967. private _context;
  82968. private _engine;
  82969. /**
  82970. * Creates a DynamicTexture
  82971. * @param name defines the name of the texture
  82972. * @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
  82973. * @param scene defines the scene where you want the texture
  82974. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82975. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82976. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82977. */
  82978. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82979. /**
  82980. * Get the current class name of the texture useful for serialization or dynamic coding.
  82981. * @returns "DynamicTexture"
  82982. */
  82983. getClassName(): string;
  82984. /**
  82985. * Gets the current state of canRescale
  82986. */
  82987. readonly canRescale: boolean;
  82988. private _recreate;
  82989. /**
  82990. * Scales the texture
  82991. * @param ratio the scale factor to apply to both width and height
  82992. */
  82993. scale(ratio: number): void;
  82994. /**
  82995. * Resizes the texture
  82996. * @param width the new width
  82997. * @param height the new height
  82998. */
  82999. scaleTo(width: number, height: number): void;
  83000. /**
  83001. * Gets the context of the canvas used by the texture
  83002. * @returns the canvas context of the dynamic texture
  83003. */
  83004. getContext(): CanvasRenderingContext2D;
  83005. /**
  83006. * Clears the texture
  83007. */
  83008. clear(): void;
  83009. /**
  83010. * Updates the texture
  83011. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83012. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83013. */
  83014. update(invertY?: boolean, premulAlpha?: boolean): void;
  83015. /**
  83016. * Draws text onto the texture
  83017. * @param text defines the text to be drawn
  83018. * @param x defines the placement of the text from the left
  83019. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83020. * @param font defines the font to be used with font-style, font-size, font-name
  83021. * @param color defines the color used for the text
  83022. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83023. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83024. * @param update defines whether texture is immediately update (default is true)
  83025. */
  83026. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83027. /**
  83028. * Clones the texture
  83029. * @returns the clone of the texture.
  83030. */
  83031. clone(): DynamicTexture;
  83032. /**
  83033. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83034. * @returns a serialized dynamic texture object
  83035. */
  83036. serialize(): any;
  83037. /** @hidden */
  83038. _rebuild(): void;
  83039. }
  83040. }
  83041. declare module BABYLON {
  83042. interface AbstractScene {
  83043. /**
  83044. * The list of procedural textures added to the scene
  83045. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83046. */
  83047. proceduralTextures: Array<ProceduralTexture>;
  83048. }
  83049. /**
  83050. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83051. * in a given scene.
  83052. */
  83053. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83054. /**
  83055. * The component name helpfull to identify the component in the list of scene components.
  83056. */
  83057. readonly name: string;
  83058. /**
  83059. * The scene the component belongs to.
  83060. */
  83061. scene: Scene;
  83062. /**
  83063. * Creates a new instance of the component for the given scene
  83064. * @param scene Defines the scene to register the component in
  83065. */
  83066. constructor(scene: Scene);
  83067. /**
  83068. * Registers the component in a given scene
  83069. */
  83070. register(): void;
  83071. /**
  83072. * Rebuilds the elements related to this component in case of
  83073. * context lost for instance.
  83074. */
  83075. rebuild(): void;
  83076. /**
  83077. * Disposes the component and the associated ressources.
  83078. */
  83079. dispose(): void;
  83080. private _beforeClear;
  83081. }
  83082. }
  83083. declare module BABYLON {
  83084. interface ThinEngine {
  83085. /**
  83086. * Creates a new render target cube texture
  83087. * @param size defines the size of the texture
  83088. * @param options defines the options used to create the texture
  83089. * @returns a new render target cube texture stored in an InternalTexture
  83090. */
  83091. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83092. }
  83093. }
  83094. declare module BABYLON {
  83095. /** @hidden */
  83096. export var proceduralVertexShader: {
  83097. name: string;
  83098. shader: string;
  83099. };
  83100. }
  83101. declare module BABYLON {
  83102. /**
  83103. * 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.
  83104. * This is the base class of any Procedural texture and contains most of the shareable code.
  83105. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83106. */
  83107. export class ProceduralTexture extends Texture {
  83108. isCube: boolean;
  83109. /**
  83110. * Define if the texture is enabled or not (disabled texture will not render)
  83111. */
  83112. isEnabled: boolean;
  83113. /**
  83114. * Define if the texture must be cleared before rendering (default is true)
  83115. */
  83116. autoClear: boolean;
  83117. /**
  83118. * Callback called when the texture is generated
  83119. */
  83120. onGenerated: () => void;
  83121. /**
  83122. * Event raised when the texture is generated
  83123. */
  83124. onGeneratedObservable: Observable<ProceduralTexture>;
  83125. /** @hidden */
  83126. _generateMipMaps: boolean;
  83127. /** @hidden **/
  83128. _effect: Effect;
  83129. /** @hidden */
  83130. _textures: {
  83131. [key: string]: Texture;
  83132. };
  83133. private _size;
  83134. private _currentRefreshId;
  83135. private _refreshRate;
  83136. private _vertexBuffers;
  83137. private _indexBuffer;
  83138. private _uniforms;
  83139. private _samplers;
  83140. private _fragment;
  83141. private _floats;
  83142. private _ints;
  83143. private _floatsArrays;
  83144. private _colors3;
  83145. private _colors4;
  83146. private _vectors2;
  83147. private _vectors3;
  83148. private _matrices;
  83149. private _fallbackTexture;
  83150. private _fallbackTextureUsed;
  83151. private _engine;
  83152. private _cachedDefines;
  83153. private _contentUpdateId;
  83154. private _contentData;
  83155. /**
  83156. * Instantiates a new procedural texture.
  83157. * 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.
  83158. * This is the base class of any Procedural texture and contains most of the shareable code.
  83159. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83160. * @param name Define the name of the texture
  83161. * @param size Define the size of the texture to create
  83162. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83163. * @param scene Define the scene the texture belongs to
  83164. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83165. * @param generateMipMaps Define if the texture should creates mip maps or not
  83166. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83167. */
  83168. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83169. /**
  83170. * The effect that is created when initializing the post process.
  83171. * @returns The created effect corresponding the the postprocess.
  83172. */
  83173. getEffect(): Effect;
  83174. /**
  83175. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83176. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83177. */
  83178. getContent(): Nullable<ArrayBufferView>;
  83179. private _createIndexBuffer;
  83180. /** @hidden */
  83181. _rebuild(): void;
  83182. /**
  83183. * Resets the texture in order to recreate its associated resources.
  83184. * This can be called in case of context loss
  83185. */
  83186. reset(): void;
  83187. protected _getDefines(): string;
  83188. /**
  83189. * Is the texture ready to be used ? (rendered at least once)
  83190. * @returns true if ready, otherwise, false.
  83191. */
  83192. isReady(): boolean;
  83193. /**
  83194. * Resets the refresh counter of the texture and start bak from scratch.
  83195. * Could be useful to regenerate the texture if it is setup to render only once.
  83196. */
  83197. resetRefreshCounter(): void;
  83198. /**
  83199. * Set the fragment shader to use in order to render the texture.
  83200. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83201. */
  83202. setFragment(fragment: any): void;
  83203. /**
  83204. * Define the refresh rate of the texture or the rendering frequency.
  83205. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83206. */
  83207. refreshRate: number;
  83208. /** @hidden */
  83209. _shouldRender(): boolean;
  83210. /**
  83211. * Get the size the texture is rendering at.
  83212. * @returns the size (texture is always squared)
  83213. */
  83214. getRenderSize(): number;
  83215. /**
  83216. * Resize the texture to new value.
  83217. * @param size Define the new size the texture should have
  83218. * @param generateMipMaps Define whether the new texture should create mip maps
  83219. */
  83220. resize(size: number, generateMipMaps: boolean): void;
  83221. private _checkUniform;
  83222. /**
  83223. * Set a texture in the shader program used to render.
  83224. * @param name Define the name of the uniform samplers as defined in the shader
  83225. * @param texture Define the texture to bind to this sampler
  83226. * @return the texture itself allowing "fluent" like uniform updates
  83227. */
  83228. setTexture(name: string, texture: Texture): ProceduralTexture;
  83229. /**
  83230. * Set a float in the shader.
  83231. * @param name Define the name of the uniform as defined in the shader
  83232. * @param value Define the value to give to the uniform
  83233. * @return the texture itself allowing "fluent" like uniform updates
  83234. */
  83235. setFloat(name: string, value: number): ProceduralTexture;
  83236. /**
  83237. * Set a int in the shader.
  83238. * @param name Define the name of the uniform as defined in the shader
  83239. * @param value Define the value to give to the uniform
  83240. * @return the texture itself allowing "fluent" like uniform updates
  83241. */
  83242. setInt(name: string, value: number): ProceduralTexture;
  83243. /**
  83244. * Set an array of floats in the shader.
  83245. * @param name Define the name of the uniform as defined in the shader
  83246. * @param value Define the value to give to the uniform
  83247. * @return the texture itself allowing "fluent" like uniform updates
  83248. */
  83249. setFloats(name: string, value: number[]): ProceduralTexture;
  83250. /**
  83251. * Set a vec3 in the shader from a Color3.
  83252. * @param name Define the name of the uniform as defined in the shader
  83253. * @param value Define the value to give to the uniform
  83254. * @return the texture itself allowing "fluent" like uniform updates
  83255. */
  83256. setColor3(name: string, value: Color3): ProceduralTexture;
  83257. /**
  83258. * Set a vec4 in the shader from a Color4.
  83259. * @param name Define the name of the uniform as defined in the shader
  83260. * @param value Define the value to give to the uniform
  83261. * @return the texture itself allowing "fluent" like uniform updates
  83262. */
  83263. setColor4(name: string, value: Color4): ProceduralTexture;
  83264. /**
  83265. * Set a vec2 in the shader from a Vector2.
  83266. * @param name Define the name of the uniform as defined in the shader
  83267. * @param value Define the value to give to the uniform
  83268. * @return the texture itself allowing "fluent" like uniform updates
  83269. */
  83270. setVector2(name: string, value: Vector2): ProceduralTexture;
  83271. /**
  83272. * Set a vec3 in the shader from a Vector3.
  83273. * @param name Define the name of the uniform as defined in the shader
  83274. * @param value Define the value to give to the uniform
  83275. * @return the texture itself allowing "fluent" like uniform updates
  83276. */
  83277. setVector3(name: string, value: Vector3): ProceduralTexture;
  83278. /**
  83279. * Set a mat4 in the shader from a MAtrix.
  83280. * @param name Define the name of the uniform as defined in the shader
  83281. * @param value Define the value to give to the uniform
  83282. * @return the texture itself allowing "fluent" like uniform updates
  83283. */
  83284. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83285. /**
  83286. * Render the texture to its associated render target.
  83287. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83288. */
  83289. render(useCameraPostProcess?: boolean): void;
  83290. /**
  83291. * Clone the texture.
  83292. * @returns the cloned texture
  83293. */
  83294. clone(): ProceduralTexture;
  83295. /**
  83296. * Dispose the texture and release its asoociated resources.
  83297. */
  83298. dispose(): void;
  83299. }
  83300. }
  83301. declare module BABYLON {
  83302. /**
  83303. * This represents the base class for particle system in Babylon.
  83304. * 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.
  83305. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83306. * @example https://doc.babylonjs.com/babylon101/particles
  83307. */
  83308. export class BaseParticleSystem {
  83309. /**
  83310. * Source color is added to the destination color without alpha affecting the result
  83311. */
  83312. static BLENDMODE_ONEONE: number;
  83313. /**
  83314. * Blend current color and particle color using particle’s alpha
  83315. */
  83316. static BLENDMODE_STANDARD: number;
  83317. /**
  83318. * Add current color and particle color multiplied by particle’s alpha
  83319. */
  83320. static BLENDMODE_ADD: number;
  83321. /**
  83322. * Multiply current color with particle color
  83323. */
  83324. static BLENDMODE_MULTIPLY: number;
  83325. /**
  83326. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83327. */
  83328. static BLENDMODE_MULTIPLYADD: number;
  83329. /**
  83330. * List of animations used by the particle system.
  83331. */
  83332. animations: Animation[];
  83333. /**
  83334. * The id of the Particle system.
  83335. */
  83336. id: string;
  83337. /**
  83338. * The friendly name of the Particle system.
  83339. */
  83340. name: string;
  83341. /**
  83342. * The rendering group used by the Particle system to chose when to render.
  83343. */
  83344. renderingGroupId: number;
  83345. /**
  83346. * The emitter represents the Mesh or position we are attaching the particle system to.
  83347. */
  83348. emitter: Nullable<AbstractMesh | Vector3>;
  83349. /**
  83350. * The maximum number of particles to emit per frame
  83351. */
  83352. emitRate: number;
  83353. /**
  83354. * If you want to launch only a few particles at once, that can be done, as well.
  83355. */
  83356. manualEmitCount: number;
  83357. /**
  83358. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83359. */
  83360. updateSpeed: number;
  83361. /**
  83362. * The amount of time the particle system is running (depends of the overall update speed).
  83363. */
  83364. targetStopDuration: number;
  83365. /**
  83366. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83367. */
  83368. disposeOnStop: boolean;
  83369. /**
  83370. * Minimum power of emitting particles.
  83371. */
  83372. minEmitPower: number;
  83373. /**
  83374. * Maximum power of emitting particles.
  83375. */
  83376. maxEmitPower: number;
  83377. /**
  83378. * Minimum life time of emitting particles.
  83379. */
  83380. minLifeTime: number;
  83381. /**
  83382. * Maximum life time of emitting particles.
  83383. */
  83384. maxLifeTime: number;
  83385. /**
  83386. * Minimum Size of emitting particles.
  83387. */
  83388. minSize: number;
  83389. /**
  83390. * Maximum Size of emitting particles.
  83391. */
  83392. maxSize: number;
  83393. /**
  83394. * Minimum scale of emitting particles on X axis.
  83395. */
  83396. minScaleX: number;
  83397. /**
  83398. * Maximum scale of emitting particles on X axis.
  83399. */
  83400. maxScaleX: number;
  83401. /**
  83402. * Minimum scale of emitting particles on Y axis.
  83403. */
  83404. minScaleY: number;
  83405. /**
  83406. * Maximum scale of emitting particles on Y axis.
  83407. */
  83408. maxScaleY: number;
  83409. /**
  83410. * Gets or sets the minimal initial rotation in radians.
  83411. */
  83412. minInitialRotation: number;
  83413. /**
  83414. * Gets or sets the maximal initial rotation in radians.
  83415. */
  83416. maxInitialRotation: number;
  83417. /**
  83418. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83419. */
  83420. minAngularSpeed: number;
  83421. /**
  83422. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83423. */
  83424. maxAngularSpeed: number;
  83425. /**
  83426. * The texture used to render each particle. (this can be a spritesheet)
  83427. */
  83428. particleTexture: Nullable<Texture>;
  83429. /**
  83430. * The layer mask we are rendering the particles through.
  83431. */
  83432. layerMask: number;
  83433. /**
  83434. * This can help using your own shader to render the particle system.
  83435. * The according effect will be created
  83436. */
  83437. customShader: any;
  83438. /**
  83439. * By default particle system starts as soon as they are created. This prevents the
  83440. * automatic start to happen and let you decide when to start emitting particles.
  83441. */
  83442. preventAutoStart: boolean;
  83443. private _noiseTexture;
  83444. /**
  83445. * Gets or sets a texture used to add random noise to particle positions
  83446. */
  83447. noiseTexture: Nullable<ProceduralTexture>;
  83448. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83449. noiseStrength: Vector3;
  83450. /**
  83451. * Callback triggered when the particle animation is ending.
  83452. */
  83453. onAnimationEnd: Nullable<() => void>;
  83454. /**
  83455. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83456. */
  83457. blendMode: number;
  83458. /**
  83459. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83460. * to override the particles.
  83461. */
  83462. forceDepthWrite: boolean;
  83463. /** 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 */
  83464. preWarmCycles: number;
  83465. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83466. preWarmStepOffset: number;
  83467. /**
  83468. * 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)
  83469. */
  83470. spriteCellChangeSpeed: number;
  83471. /**
  83472. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83473. */
  83474. startSpriteCellID: number;
  83475. /**
  83476. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83477. */
  83478. endSpriteCellID: number;
  83479. /**
  83480. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83481. */
  83482. spriteCellWidth: number;
  83483. /**
  83484. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83485. */
  83486. spriteCellHeight: number;
  83487. /**
  83488. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83489. */
  83490. spriteRandomStartCell: boolean;
  83491. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83492. translationPivot: Vector2;
  83493. /** @hidden */
  83494. protected _isAnimationSheetEnabled: boolean;
  83495. /**
  83496. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83497. */
  83498. beginAnimationOnStart: boolean;
  83499. /**
  83500. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83501. */
  83502. beginAnimationFrom: number;
  83503. /**
  83504. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83505. */
  83506. beginAnimationTo: number;
  83507. /**
  83508. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83509. */
  83510. beginAnimationLoop: boolean;
  83511. /**
  83512. * Gets or sets a world offset applied to all particles
  83513. */
  83514. worldOffset: Vector3;
  83515. /**
  83516. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83517. */
  83518. isAnimationSheetEnabled: boolean;
  83519. /**
  83520. * Get hosting scene
  83521. * @returns the scene
  83522. */
  83523. getScene(): Scene;
  83524. /**
  83525. * You can use gravity if you want to give an orientation to your particles.
  83526. */
  83527. gravity: Vector3;
  83528. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83529. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83530. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83531. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83532. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83533. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83534. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83535. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83536. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83537. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83538. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83539. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83540. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83541. /**
  83542. * Defines the delay in milliseconds before starting the system (0 by default)
  83543. */
  83544. startDelay: number;
  83545. /**
  83546. * Gets the current list of drag gradients.
  83547. * You must use addDragGradient and removeDragGradient to udpate this list
  83548. * @returns the list of drag gradients
  83549. */
  83550. getDragGradients(): Nullable<Array<FactorGradient>>;
  83551. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83552. limitVelocityDamping: number;
  83553. /**
  83554. * Gets the current list of limit velocity gradients.
  83555. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83556. * @returns the list of limit velocity gradients
  83557. */
  83558. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83559. /**
  83560. * Gets the current list of color gradients.
  83561. * You must use addColorGradient and removeColorGradient to udpate this list
  83562. * @returns the list of color gradients
  83563. */
  83564. getColorGradients(): Nullable<Array<ColorGradient>>;
  83565. /**
  83566. * Gets the current list of size gradients.
  83567. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83568. * @returns the list of size gradients
  83569. */
  83570. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83571. /**
  83572. * Gets the current list of color remap gradients.
  83573. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83574. * @returns the list of color remap gradients
  83575. */
  83576. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83577. /**
  83578. * Gets the current list of alpha remap gradients.
  83579. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83580. * @returns the list of alpha remap gradients
  83581. */
  83582. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83583. /**
  83584. * Gets the current list of life time gradients.
  83585. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83586. * @returns the list of life time gradients
  83587. */
  83588. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83589. /**
  83590. * Gets the current list of angular speed gradients.
  83591. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83592. * @returns the list of angular speed gradients
  83593. */
  83594. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83595. /**
  83596. * Gets the current list of velocity gradients.
  83597. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83598. * @returns the list of velocity gradients
  83599. */
  83600. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83601. /**
  83602. * Gets the current list of start size gradients.
  83603. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83604. * @returns the list of start size gradients
  83605. */
  83606. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83607. /**
  83608. * Gets the current list of emit rate gradients.
  83609. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83610. * @returns the list of emit rate gradients
  83611. */
  83612. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83613. /**
  83614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83615. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83616. */
  83617. direction1: Vector3;
  83618. /**
  83619. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83620. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83621. */
  83622. direction2: Vector3;
  83623. /**
  83624. * 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.
  83625. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83626. */
  83627. minEmitBox: Vector3;
  83628. /**
  83629. * 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.
  83630. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83631. */
  83632. maxEmitBox: Vector3;
  83633. /**
  83634. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83635. */
  83636. color1: Color4;
  83637. /**
  83638. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83639. */
  83640. color2: Color4;
  83641. /**
  83642. * Color the particle will have at the end of its lifetime
  83643. */
  83644. colorDead: Color4;
  83645. /**
  83646. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83647. */
  83648. textureMask: Color4;
  83649. /**
  83650. * The particle emitter type defines the emitter used by the particle system.
  83651. * It can be for example box, sphere, or cone...
  83652. */
  83653. particleEmitterType: IParticleEmitterType;
  83654. /** @hidden */
  83655. _isSubEmitter: boolean;
  83656. /**
  83657. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83658. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83659. */
  83660. billboardMode: number;
  83661. protected _isBillboardBased: boolean;
  83662. /**
  83663. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83664. */
  83665. isBillboardBased: boolean;
  83666. /**
  83667. * The scene the particle system belongs to.
  83668. */
  83669. protected _scene: Scene;
  83670. /**
  83671. * Local cache of defines for image processing.
  83672. */
  83673. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83674. /**
  83675. * Default configuration related to image processing available in the standard Material.
  83676. */
  83677. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83678. /**
  83679. * Gets the image processing configuration used either in this material.
  83680. */
  83681. /**
  83682. * Sets the Default image processing configuration used either in the this material.
  83683. *
  83684. * If sets to null, the scene one is in use.
  83685. */
  83686. imageProcessingConfiguration: ImageProcessingConfiguration;
  83687. /**
  83688. * Attaches a new image processing configuration to the Standard Material.
  83689. * @param configuration
  83690. */
  83691. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83692. /** @hidden */
  83693. protected _reset(): void;
  83694. /** @hidden */
  83695. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83696. /**
  83697. * Instantiates a particle system.
  83698. * 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.
  83699. * @param name The name of the particle system
  83700. */
  83701. constructor(name: string);
  83702. /**
  83703. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83704. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83705. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83706. * @returns the emitter
  83707. */
  83708. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83709. /**
  83710. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83711. * @param radius The radius of the hemisphere to emit from
  83712. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83713. * @returns the emitter
  83714. */
  83715. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83716. /**
  83717. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83718. * @param radius The radius of the sphere to emit from
  83719. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83720. * @returns the emitter
  83721. */
  83722. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83723. /**
  83724. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83725. * @param radius The radius of the sphere to emit from
  83726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83728. * @returns the emitter
  83729. */
  83730. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83731. /**
  83732. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83733. * @param radius The radius of the emission cylinder
  83734. * @param height The height of the emission cylinder
  83735. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83736. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83737. * @returns the emitter
  83738. */
  83739. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83740. /**
  83741. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83742. * @param radius The radius of the cylinder to emit from
  83743. * @param height The height of the emission cylinder
  83744. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83747. * @returns the emitter
  83748. */
  83749. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83750. /**
  83751. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83752. * @param radius The radius of the cone to emit from
  83753. * @param angle The base angle of the cone
  83754. * @returns the emitter
  83755. */
  83756. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83757. /**
  83758. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83759. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83760. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83761. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83762. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83763. * @returns the emitter
  83764. */
  83765. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83766. }
  83767. }
  83768. declare module BABYLON {
  83769. /**
  83770. * Type of sub emitter
  83771. */
  83772. export enum SubEmitterType {
  83773. /**
  83774. * Attached to the particle over it's lifetime
  83775. */
  83776. ATTACHED = 0,
  83777. /**
  83778. * Created when the particle dies
  83779. */
  83780. END = 1
  83781. }
  83782. /**
  83783. * Sub emitter class used to emit particles from an existing particle
  83784. */
  83785. export class SubEmitter {
  83786. /**
  83787. * the particle system to be used by the sub emitter
  83788. */
  83789. particleSystem: ParticleSystem;
  83790. /**
  83791. * Type of the submitter (Default: END)
  83792. */
  83793. type: SubEmitterType;
  83794. /**
  83795. * 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)
  83796. * Note: This only is supported when using an emitter of type Mesh
  83797. */
  83798. inheritDirection: boolean;
  83799. /**
  83800. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83801. */
  83802. inheritedVelocityAmount: number;
  83803. /**
  83804. * Creates a sub emitter
  83805. * @param particleSystem the particle system to be used by the sub emitter
  83806. */
  83807. constructor(
  83808. /**
  83809. * the particle system to be used by the sub emitter
  83810. */
  83811. particleSystem: ParticleSystem);
  83812. /**
  83813. * Clones the sub emitter
  83814. * @returns the cloned sub emitter
  83815. */
  83816. clone(): SubEmitter;
  83817. /**
  83818. * Serialize current object to a JSON object
  83819. * @returns the serialized object
  83820. */
  83821. serialize(): any;
  83822. /** @hidden */
  83823. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83824. /**
  83825. * Creates a new SubEmitter from a serialized JSON version
  83826. * @param serializationObject defines the JSON object to read from
  83827. * @param scene defines the hosting scene
  83828. * @param rootUrl defines the rootUrl for data loading
  83829. * @returns a new SubEmitter
  83830. */
  83831. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83832. /** Release associated resources */
  83833. dispose(): void;
  83834. }
  83835. }
  83836. declare module BABYLON {
  83837. /** @hidden */
  83838. export var clipPlaneFragmentDeclaration: {
  83839. name: string;
  83840. shader: string;
  83841. };
  83842. }
  83843. declare module BABYLON {
  83844. /** @hidden */
  83845. export var imageProcessingDeclaration: {
  83846. name: string;
  83847. shader: string;
  83848. };
  83849. }
  83850. declare module BABYLON {
  83851. /** @hidden */
  83852. export var imageProcessingFunctions: {
  83853. name: string;
  83854. shader: string;
  83855. };
  83856. }
  83857. declare module BABYLON {
  83858. /** @hidden */
  83859. export var clipPlaneFragment: {
  83860. name: string;
  83861. shader: string;
  83862. };
  83863. }
  83864. declare module BABYLON {
  83865. /** @hidden */
  83866. export var particlesPixelShader: {
  83867. name: string;
  83868. shader: string;
  83869. };
  83870. }
  83871. declare module BABYLON {
  83872. /** @hidden */
  83873. export var clipPlaneVertexDeclaration: {
  83874. name: string;
  83875. shader: string;
  83876. };
  83877. }
  83878. declare module BABYLON {
  83879. /** @hidden */
  83880. export var clipPlaneVertex: {
  83881. name: string;
  83882. shader: string;
  83883. };
  83884. }
  83885. declare module BABYLON {
  83886. /** @hidden */
  83887. export var particlesVertexShader: {
  83888. name: string;
  83889. shader: string;
  83890. };
  83891. }
  83892. declare module BABYLON {
  83893. /**
  83894. * This represents a particle system in Babylon.
  83895. * 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.
  83896. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83897. * @example https://doc.babylonjs.com/babylon101/particles
  83898. */
  83899. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83900. /**
  83901. * Billboard mode will only apply to Y axis
  83902. */
  83903. static readonly BILLBOARDMODE_Y: number;
  83904. /**
  83905. * Billboard mode will apply to all axes
  83906. */
  83907. static readonly BILLBOARDMODE_ALL: number;
  83908. /**
  83909. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83910. */
  83911. static readonly BILLBOARDMODE_STRETCHED: number;
  83912. /**
  83913. * This function can be defined to provide custom update for active particles.
  83914. * This function will be called instead of regular update (age, position, color, etc.).
  83915. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83916. */
  83917. updateFunction: (particles: Particle[]) => void;
  83918. private _emitterWorldMatrix;
  83919. /**
  83920. * This function can be defined to specify initial direction for every new particle.
  83921. * It by default use the emitterType defined function
  83922. */
  83923. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83924. /**
  83925. * This function can be defined to specify initial position for every new particle.
  83926. * It by default use the emitterType defined function
  83927. */
  83928. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83929. /**
  83930. * @hidden
  83931. */
  83932. _inheritedVelocityOffset: Vector3;
  83933. /**
  83934. * An event triggered when the system is disposed
  83935. */
  83936. onDisposeObservable: Observable<ParticleSystem>;
  83937. private _onDisposeObserver;
  83938. /**
  83939. * Sets a callback that will be triggered when the system is disposed
  83940. */
  83941. onDispose: () => void;
  83942. private _particles;
  83943. private _epsilon;
  83944. private _capacity;
  83945. private _stockParticles;
  83946. private _newPartsExcess;
  83947. private _vertexData;
  83948. private _vertexBuffer;
  83949. private _vertexBuffers;
  83950. private _spriteBuffer;
  83951. private _indexBuffer;
  83952. private _effect;
  83953. private _customEffect;
  83954. private _cachedDefines;
  83955. private _scaledColorStep;
  83956. private _colorDiff;
  83957. private _scaledDirection;
  83958. private _scaledGravity;
  83959. private _currentRenderId;
  83960. private _alive;
  83961. private _useInstancing;
  83962. private _started;
  83963. private _stopped;
  83964. private _actualFrame;
  83965. private _scaledUpdateSpeed;
  83966. private _vertexBufferSize;
  83967. /** @hidden */
  83968. _currentEmitRateGradient: Nullable<FactorGradient>;
  83969. /** @hidden */
  83970. _currentEmitRate1: number;
  83971. /** @hidden */
  83972. _currentEmitRate2: number;
  83973. /** @hidden */
  83974. _currentStartSizeGradient: Nullable<FactorGradient>;
  83975. /** @hidden */
  83976. _currentStartSize1: number;
  83977. /** @hidden */
  83978. _currentStartSize2: number;
  83979. private readonly _rawTextureWidth;
  83980. private _rampGradientsTexture;
  83981. private _useRampGradients;
  83982. /** Gets or sets a boolean indicating that ramp gradients must be used
  83983. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83984. */
  83985. useRampGradients: boolean;
  83986. /**
  83987. * 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.
  83988. * 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: [])
  83989. */
  83990. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83991. private _subEmitters;
  83992. /**
  83993. * @hidden
  83994. * If the particle systems emitter should be disposed when the particle system is disposed
  83995. */
  83996. _disposeEmitterOnDispose: boolean;
  83997. /**
  83998. * The current active Sub-systems, this property is used by the root particle system only.
  83999. */
  84000. activeSubSystems: Array<ParticleSystem>;
  84001. private _rootParticleSystem;
  84002. /**
  84003. * Gets the current list of active particles
  84004. */
  84005. readonly particles: Particle[];
  84006. /**
  84007. * Returns the string "ParticleSystem"
  84008. * @returns a string containing the class name
  84009. */
  84010. getClassName(): string;
  84011. /**
  84012. * Instantiates a particle system.
  84013. * 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.
  84014. * @param name The name of the particle system
  84015. * @param capacity The max number of particles alive at the same time
  84016. * @param scene The scene the particle system belongs to
  84017. * @param customEffect a custom effect used to change the way particles are rendered by default
  84018. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84019. * @param epsilon Offset used to render the particles
  84020. */
  84021. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84022. private _addFactorGradient;
  84023. private _removeFactorGradient;
  84024. /**
  84025. * Adds a new life time gradient
  84026. * @param gradient defines the gradient to use (between 0 and 1)
  84027. * @param factor defines the life time factor to affect to the specified gradient
  84028. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84029. * @returns the current particle system
  84030. */
  84031. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84032. /**
  84033. * Remove a specific life time gradient
  84034. * @param gradient defines the gradient to remove
  84035. * @returns the current particle system
  84036. */
  84037. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84038. /**
  84039. * Adds a new size gradient
  84040. * @param gradient defines the gradient to use (between 0 and 1)
  84041. * @param factor defines the size factor to affect to the specified gradient
  84042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84043. * @returns the current particle system
  84044. */
  84045. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84046. /**
  84047. * Remove a specific size gradient
  84048. * @param gradient defines the gradient to remove
  84049. * @returns the current particle system
  84050. */
  84051. removeSizeGradient(gradient: number): IParticleSystem;
  84052. /**
  84053. * Adds a new color remap gradient
  84054. * @param gradient defines the gradient to use (between 0 and 1)
  84055. * @param min defines the color remap minimal range
  84056. * @param max defines the color remap maximal range
  84057. * @returns the current particle system
  84058. */
  84059. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84060. /**
  84061. * Remove a specific color remap gradient
  84062. * @param gradient defines the gradient to remove
  84063. * @returns the current particle system
  84064. */
  84065. removeColorRemapGradient(gradient: number): IParticleSystem;
  84066. /**
  84067. * Adds a new alpha remap gradient
  84068. * @param gradient defines the gradient to use (between 0 and 1)
  84069. * @param min defines the alpha remap minimal range
  84070. * @param max defines the alpha remap maximal range
  84071. * @returns the current particle system
  84072. */
  84073. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84074. /**
  84075. * Remove a specific alpha remap gradient
  84076. * @param gradient defines the gradient to remove
  84077. * @returns the current particle system
  84078. */
  84079. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84080. /**
  84081. * Adds a new angular speed gradient
  84082. * @param gradient defines the gradient to use (between 0 and 1)
  84083. * @param factor defines the angular speed to affect to the specified gradient
  84084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84085. * @returns the current particle system
  84086. */
  84087. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84088. /**
  84089. * Remove a specific angular speed gradient
  84090. * @param gradient defines the gradient to remove
  84091. * @returns the current particle system
  84092. */
  84093. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84094. /**
  84095. * Adds a new velocity gradient
  84096. * @param gradient defines the gradient to use (between 0 and 1)
  84097. * @param factor defines the velocity to affect to the specified gradient
  84098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84099. * @returns the current particle system
  84100. */
  84101. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84102. /**
  84103. * Remove a specific velocity gradient
  84104. * @param gradient defines the gradient to remove
  84105. * @returns the current particle system
  84106. */
  84107. removeVelocityGradient(gradient: number): IParticleSystem;
  84108. /**
  84109. * Adds a new limit velocity gradient
  84110. * @param gradient defines the gradient to use (between 0 and 1)
  84111. * @param factor defines the limit velocity value to affect to the specified gradient
  84112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84113. * @returns the current particle system
  84114. */
  84115. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84116. /**
  84117. * Remove a specific limit velocity gradient
  84118. * @param gradient defines the gradient to remove
  84119. * @returns the current particle system
  84120. */
  84121. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84122. /**
  84123. * Adds a new drag gradient
  84124. * @param gradient defines the gradient to use (between 0 and 1)
  84125. * @param factor defines the drag value to affect to the specified gradient
  84126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84127. * @returns the current particle system
  84128. */
  84129. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84130. /**
  84131. * Remove a specific drag gradient
  84132. * @param gradient defines the gradient to remove
  84133. * @returns the current particle system
  84134. */
  84135. removeDragGradient(gradient: number): IParticleSystem;
  84136. /**
  84137. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84138. * @param gradient defines the gradient to use (between 0 and 1)
  84139. * @param factor defines the emit rate value to affect to the specified gradient
  84140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84141. * @returns the current particle system
  84142. */
  84143. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84144. /**
  84145. * Remove a specific emit rate gradient
  84146. * @param gradient defines the gradient to remove
  84147. * @returns the current particle system
  84148. */
  84149. removeEmitRateGradient(gradient: number): IParticleSystem;
  84150. /**
  84151. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84152. * @param gradient defines the gradient to use (between 0 and 1)
  84153. * @param factor defines the start size value to affect to the specified gradient
  84154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84155. * @returns the current particle system
  84156. */
  84157. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84158. /**
  84159. * Remove a specific start size gradient
  84160. * @param gradient defines the gradient to remove
  84161. * @returns the current particle system
  84162. */
  84163. removeStartSizeGradient(gradient: number): IParticleSystem;
  84164. private _createRampGradientTexture;
  84165. /**
  84166. * Gets the current list of ramp gradients.
  84167. * You must use addRampGradient and removeRampGradient to udpate this list
  84168. * @returns the list of ramp gradients
  84169. */
  84170. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84171. /**
  84172. * Adds a new ramp gradient used to remap particle colors
  84173. * @param gradient defines the gradient to use (between 0 and 1)
  84174. * @param color defines the color to affect to the specified gradient
  84175. * @returns the current particle system
  84176. */
  84177. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84178. /**
  84179. * Remove a specific ramp gradient
  84180. * @param gradient defines the gradient to remove
  84181. * @returns the current particle system
  84182. */
  84183. removeRampGradient(gradient: number): ParticleSystem;
  84184. /**
  84185. * Adds a new color gradient
  84186. * @param gradient defines the gradient to use (between 0 and 1)
  84187. * @param color1 defines the color to affect to the specified gradient
  84188. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84189. * @returns this particle system
  84190. */
  84191. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84192. /**
  84193. * Remove a specific color gradient
  84194. * @param gradient defines the gradient to remove
  84195. * @returns this particle system
  84196. */
  84197. removeColorGradient(gradient: number): IParticleSystem;
  84198. private _fetchR;
  84199. protected _reset(): void;
  84200. private _resetEffect;
  84201. private _createVertexBuffers;
  84202. private _createIndexBuffer;
  84203. /**
  84204. * Gets the maximum number of particles active at the same time.
  84205. * @returns The max number of active particles.
  84206. */
  84207. getCapacity(): number;
  84208. /**
  84209. * Gets whether there are still active particles in the system.
  84210. * @returns True if it is alive, otherwise false.
  84211. */
  84212. isAlive(): boolean;
  84213. /**
  84214. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84215. * @returns True if it has been started, otherwise false.
  84216. */
  84217. isStarted(): boolean;
  84218. private _prepareSubEmitterInternalArray;
  84219. /**
  84220. * Starts the particle system and begins to emit
  84221. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84222. */
  84223. start(delay?: number): void;
  84224. /**
  84225. * Stops the particle system.
  84226. * @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.
  84227. */
  84228. stop(stopSubEmitters?: boolean): void;
  84229. /**
  84230. * Remove all active particles
  84231. */
  84232. reset(): void;
  84233. /**
  84234. * @hidden (for internal use only)
  84235. */
  84236. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84237. /**
  84238. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84239. * Its lifetime will start back at 0.
  84240. */
  84241. recycleParticle: (particle: Particle) => void;
  84242. private _stopSubEmitters;
  84243. private _createParticle;
  84244. private _removeFromRoot;
  84245. private _emitFromParticle;
  84246. private _update;
  84247. /** @hidden */
  84248. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84249. /** @hidden */
  84250. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84251. /** @hidden */
  84252. private _getEffect;
  84253. /**
  84254. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84255. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84256. */
  84257. animate(preWarmOnly?: boolean): void;
  84258. private _appendParticleVertices;
  84259. /**
  84260. * Rebuilds the particle system.
  84261. */
  84262. rebuild(): void;
  84263. /**
  84264. * Is this system ready to be used/rendered
  84265. * @return true if the system is ready
  84266. */
  84267. isReady(): boolean;
  84268. private _render;
  84269. /**
  84270. * Renders the particle system in its current state.
  84271. * @returns the current number of particles
  84272. */
  84273. render(): number;
  84274. /**
  84275. * Disposes the particle system and free the associated resources
  84276. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84277. */
  84278. dispose(disposeTexture?: boolean): void;
  84279. /**
  84280. * Clones the particle system.
  84281. * @param name The name of the cloned object
  84282. * @param newEmitter The new emitter to use
  84283. * @returns the cloned particle system
  84284. */
  84285. clone(name: string, newEmitter: any): ParticleSystem;
  84286. /**
  84287. * Serializes the particle system to a JSON object.
  84288. * @returns the JSON object
  84289. */
  84290. serialize(): any;
  84291. /** @hidden */
  84292. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84293. /** @hidden */
  84294. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84295. /**
  84296. * Parses a JSON object to create a particle system.
  84297. * @param parsedParticleSystem The JSON object to parse
  84298. * @param scene The scene to create the particle system in
  84299. * @param rootUrl The root url to use to load external dependencies like texture
  84300. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84301. * @returns the Parsed particle system
  84302. */
  84303. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84304. }
  84305. }
  84306. declare module BABYLON {
  84307. /**
  84308. * A particle represents one of the element emitted by a particle system.
  84309. * This is mainly define by its coordinates, direction, velocity and age.
  84310. */
  84311. export class Particle {
  84312. /**
  84313. * The particle system the particle belongs to.
  84314. */
  84315. particleSystem: ParticleSystem;
  84316. private static _Count;
  84317. /**
  84318. * Unique ID of the particle
  84319. */
  84320. id: number;
  84321. /**
  84322. * The world position of the particle in the scene.
  84323. */
  84324. position: Vector3;
  84325. /**
  84326. * The world direction of the particle in the scene.
  84327. */
  84328. direction: Vector3;
  84329. /**
  84330. * The color of the particle.
  84331. */
  84332. color: Color4;
  84333. /**
  84334. * The color change of the particle per step.
  84335. */
  84336. colorStep: Color4;
  84337. /**
  84338. * Defines how long will the life of the particle be.
  84339. */
  84340. lifeTime: number;
  84341. /**
  84342. * The current age of the particle.
  84343. */
  84344. age: number;
  84345. /**
  84346. * The current size of the particle.
  84347. */
  84348. size: number;
  84349. /**
  84350. * The current scale of the particle.
  84351. */
  84352. scale: Vector2;
  84353. /**
  84354. * The current angle of the particle.
  84355. */
  84356. angle: number;
  84357. /**
  84358. * Defines how fast is the angle changing.
  84359. */
  84360. angularSpeed: number;
  84361. /**
  84362. * Defines the cell index used by the particle to be rendered from a sprite.
  84363. */
  84364. cellIndex: number;
  84365. /**
  84366. * The information required to support color remapping
  84367. */
  84368. remapData: Vector4;
  84369. /** @hidden */
  84370. _randomCellOffset?: number;
  84371. /** @hidden */
  84372. _initialDirection: Nullable<Vector3>;
  84373. /** @hidden */
  84374. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84375. /** @hidden */
  84376. _initialStartSpriteCellID: number;
  84377. /** @hidden */
  84378. _initialEndSpriteCellID: number;
  84379. /** @hidden */
  84380. _currentColorGradient: Nullable<ColorGradient>;
  84381. /** @hidden */
  84382. _currentColor1: Color4;
  84383. /** @hidden */
  84384. _currentColor2: Color4;
  84385. /** @hidden */
  84386. _currentSizeGradient: Nullable<FactorGradient>;
  84387. /** @hidden */
  84388. _currentSize1: number;
  84389. /** @hidden */
  84390. _currentSize2: number;
  84391. /** @hidden */
  84392. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84393. /** @hidden */
  84394. _currentAngularSpeed1: number;
  84395. /** @hidden */
  84396. _currentAngularSpeed2: number;
  84397. /** @hidden */
  84398. _currentVelocityGradient: Nullable<FactorGradient>;
  84399. /** @hidden */
  84400. _currentVelocity1: number;
  84401. /** @hidden */
  84402. _currentVelocity2: number;
  84403. /** @hidden */
  84404. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84405. /** @hidden */
  84406. _currentLimitVelocity1: number;
  84407. /** @hidden */
  84408. _currentLimitVelocity2: number;
  84409. /** @hidden */
  84410. _currentDragGradient: Nullable<FactorGradient>;
  84411. /** @hidden */
  84412. _currentDrag1: number;
  84413. /** @hidden */
  84414. _currentDrag2: number;
  84415. /** @hidden */
  84416. _randomNoiseCoordinates1: Vector3;
  84417. /** @hidden */
  84418. _randomNoiseCoordinates2: Vector3;
  84419. /**
  84420. * Creates a new instance Particle
  84421. * @param particleSystem the particle system the particle belongs to
  84422. */
  84423. constructor(
  84424. /**
  84425. * The particle system the particle belongs to.
  84426. */
  84427. particleSystem: ParticleSystem);
  84428. private updateCellInfoFromSystem;
  84429. /**
  84430. * Defines how the sprite cell index is updated for the particle
  84431. */
  84432. updateCellIndex(): void;
  84433. /** @hidden */
  84434. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84435. /** @hidden */
  84436. _inheritParticleInfoToSubEmitters(): void;
  84437. /** @hidden */
  84438. _reset(): void;
  84439. /**
  84440. * Copy the properties of particle to another one.
  84441. * @param other the particle to copy the information to.
  84442. */
  84443. copyTo(other: Particle): void;
  84444. }
  84445. }
  84446. declare module BABYLON {
  84447. /**
  84448. * Particle emitter represents a volume emitting particles.
  84449. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84450. */
  84451. export interface IParticleEmitterType {
  84452. /**
  84453. * Called by the particle System when the direction is computed for the created particle.
  84454. * @param worldMatrix is the world matrix of the particle system
  84455. * @param directionToUpdate is the direction vector to update with the result
  84456. * @param particle is the particle we are computed the direction for
  84457. */
  84458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84459. /**
  84460. * Called by the particle System when the position is computed for the created particle.
  84461. * @param worldMatrix is the world matrix of the particle system
  84462. * @param positionToUpdate is the position vector to update with the result
  84463. * @param particle is the particle we are computed the position for
  84464. */
  84465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84466. /**
  84467. * Clones the current emitter and returns a copy of it
  84468. * @returns the new emitter
  84469. */
  84470. clone(): IParticleEmitterType;
  84471. /**
  84472. * Called by the GPUParticleSystem to setup the update shader
  84473. * @param effect defines the update shader
  84474. */
  84475. applyToShader(effect: Effect): void;
  84476. /**
  84477. * Returns a string to use to update the GPU particles update shader
  84478. * @returns the effect defines string
  84479. */
  84480. getEffectDefines(): string;
  84481. /**
  84482. * Returns a string representing the class name
  84483. * @returns a string containing the class name
  84484. */
  84485. getClassName(): string;
  84486. /**
  84487. * Serializes the particle system to a JSON object.
  84488. * @returns the JSON object
  84489. */
  84490. serialize(): any;
  84491. /**
  84492. * Parse properties from a JSON object
  84493. * @param serializationObject defines the JSON object
  84494. */
  84495. parse(serializationObject: any): void;
  84496. }
  84497. }
  84498. declare module BABYLON {
  84499. /**
  84500. * Particle emitter emitting particles from the inside of a box.
  84501. * It emits the particles randomly between 2 given directions.
  84502. */
  84503. export class BoxParticleEmitter implements IParticleEmitterType {
  84504. /**
  84505. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84506. */
  84507. direction1: Vector3;
  84508. /**
  84509. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84510. */
  84511. direction2: Vector3;
  84512. /**
  84513. * 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.
  84514. */
  84515. minEmitBox: Vector3;
  84516. /**
  84517. * 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.
  84518. */
  84519. maxEmitBox: Vector3;
  84520. /**
  84521. * Creates a new instance BoxParticleEmitter
  84522. */
  84523. constructor();
  84524. /**
  84525. * Called by the particle System when the direction is computed for the created particle.
  84526. * @param worldMatrix is the world matrix of the particle system
  84527. * @param directionToUpdate is the direction vector to update with the result
  84528. * @param particle is the particle we are computed the direction for
  84529. */
  84530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84531. /**
  84532. * Called by the particle System when the position is computed for the created particle.
  84533. * @param worldMatrix is the world matrix of the particle system
  84534. * @param positionToUpdate is the position vector to update with the result
  84535. * @param particle is the particle we are computed the position for
  84536. */
  84537. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84538. /**
  84539. * Clones the current emitter and returns a copy of it
  84540. * @returns the new emitter
  84541. */
  84542. clone(): BoxParticleEmitter;
  84543. /**
  84544. * Called by the GPUParticleSystem to setup the update shader
  84545. * @param effect defines the update shader
  84546. */
  84547. applyToShader(effect: Effect): void;
  84548. /**
  84549. * Returns a string to use to update the GPU particles update shader
  84550. * @returns a string containng the defines string
  84551. */
  84552. getEffectDefines(): string;
  84553. /**
  84554. * Returns the string "BoxParticleEmitter"
  84555. * @returns a string containing the class name
  84556. */
  84557. getClassName(): string;
  84558. /**
  84559. * Serializes the particle system to a JSON object.
  84560. * @returns the JSON object
  84561. */
  84562. serialize(): any;
  84563. /**
  84564. * Parse properties from a JSON object
  84565. * @param serializationObject defines the JSON object
  84566. */
  84567. parse(serializationObject: any): void;
  84568. }
  84569. }
  84570. declare module BABYLON {
  84571. /**
  84572. * Particle emitter emitting particles from the inside of a cone.
  84573. * It emits the particles alongside the cone volume from the base to the particle.
  84574. * The emission direction might be randomized.
  84575. */
  84576. export class ConeParticleEmitter implements IParticleEmitterType {
  84577. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84578. directionRandomizer: number;
  84579. private _radius;
  84580. private _angle;
  84581. private _height;
  84582. /**
  84583. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84584. */
  84585. radiusRange: number;
  84586. /**
  84587. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84588. */
  84589. heightRange: number;
  84590. /**
  84591. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84592. */
  84593. emitFromSpawnPointOnly: boolean;
  84594. /**
  84595. * Gets or sets the radius of the emission cone
  84596. */
  84597. radius: number;
  84598. /**
  84599. * Gets or sets the angle of the emission cone
  84600. */
  84601. angle: number;
  84602. private _buildHeight;
  84603. /**
  84604. * Creates a new instance ConeParticleEmitter
  84605. * @param radius the radius of the emission cone (1 by default)
  84606. * @param angle the cone base angle (PI by default)
  84607. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84608. */
  84609. constructor(radius?: number, angle?: number,
  84610. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84611. directionRandomizer?: number);
  84612. /**
  84613. * Called by the particle System when the direction is computed for the created particle.
  84614. * @param worldMatrix is the world matrix of the particle system
  84615. * @param directionToUpdate is the direction vector to update with the result
  84616. * @param particle is the particle we are computed the direction for
  84617. */
  84618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84619. /**
  84620. * Called by the particle System when the position is computed for the created particle.
  84621. * @param worldMatrix is the world matrix of the particle system
  84622. * @param positionToUpdate is the position vector to update with the result
  84623. * @param particle is the particle we are computed the position for
  84624. */
  84625. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84626. /**
  84627. * Clones the current emitter and returns a copy of it
  84628. * @returns the new emitter
  84629. */
  84630. clone(): ConeParticleEmitter;
  84631. /**
  84632. * Called by the GPUParticleSystem to setup the update shader
  84633. * @param effect defines the update shader
  84634. */
  84635. applyToShader(effect: Effect): void;
  84636. /**
  84637. * Returns a string to use to update the GPU particles update shader
  84638. * @returns a string containng the defines string
  84639. */
  84640. getEffectDefines(): string;
  84641. /**
  84642. * Returns the string "ConeParticleEmitter"
  84643. * @returns a string containing the class name
  84644. */
  84645. getClassName(): string;
  84646. /**
  84647. * Serializes the particle system to a JSON object.
  84648. * @returns the JSON object
  84649. */
  84650. serialize(): any;
  84651. /**
  84652. * Parse properties from a JSON object
  84653. * @param serializationObject defines the JSON object
  84654. */
  84655. parse(serializationObject: any): void;
  84656. }
  84657. }
  84658. declare module BABYLON {
  84659. /**
  84660. * Particle emitter emitting particles from the inside of a cylinder.
  84661. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84662. */
  84663. export class CylinderParticleEmitter implements IParticleEmitterType {
  84664. /**
  84665. * The radius of the emission cylinder.
  84666. */
  84667. radius: number;
  84668. /**
  84669. * The height of the emission cylinder.
  84670. */
  84671. height: number;
  84672. /**
  84673. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84674. */
  84675. radiusRange: number;
  84676. /**
  84677. * How much to randomize the particle direction [0-1].
  84678. */
  84679. directionRandomizer: number;
  84680. /**
  84681. * Creates a new instance CylinderParticleEmitter
  84682. * @param radius the radius of the emission cylinder (1 by default)
  84683. * @param height the height of the emission cylinder (1 by default)
  84684. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84685. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84686. */
  84687. constructor(
  84688. /**
  84689. * The radius of the emission cylinder.
  84690. */
  84691. radius?: number,
  84692. /**
  84693. * The height of the emission cylinder.
  84694. */
  84695. height?: number,
  84696. /**
  84697. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84698. */
  84699. radiusRange?: number,
  84700. /**
  84701. * How much to randomize the particle direction [0-1].
  84702. */
  84703. directionRandomizer?: number);
  84704. /**
  84705. * Called by the particle System when the direction is computed for the created particle.
  84706. * @param worldMatrix is the world matrix of the particle system
  84707. * @param directionToUpdate is the direction vector to update with the result
  84708. * @param particle is the particle we are computed the direction for
  84709. */
  84710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84711. /**
  84712. * Called by the particle System when the position is computed for the created particle.
  84713. * @param worldMatrix is the world matrix of the particle system
  84714. * @param positionToUpdate is the position vector to update with the result
  84715. * @param particle is the particle we are computed the position for
  84716. */
  84717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84718. /**
  84719. * Clones the current emitter and returns a copy of it
  84720. * @returns the new emitter
  84721. */
  84722. clone(): CylinderParticleEmitter;
  84723. /**
  84724. * Called by the GPUParticleSystem to setup the update shader
  84725. * @param effect defines the update shader
  84726. */
  84727. applyToShader(effect: Effect): void;
  84728. /**
  84729. * Returns a string to use to update the GPU particles update shader
  84730. * @returns a string containng the defines string
  84731. */
  84732. getEffectDefines(): string;
  84733. /**
  84734. * Returns the string "CylinderParticleEmitter"
  84735. * @returns a string containing the class name
  84736. */
  84737. getClassName(): string;
  84738. /**
  84739. * Serializes the particle system to a JSON object.
  84740. * @returns the JSON object
  84741. */
  84742. serialize(): any;
  84743. /**
  84744. * Parse properties from a JSON object
  84745. * @param serializationObject defines the JSON object
  84746. */
  84747. parse(serializationObject: any): void;
  84748. }
  84749. /**
  84750. * Particle emitter emitting particles from the inside of a cylinder.
  84751. * It emits the particles randomly between two vectors.
  84752. */
  84753. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84754. /**
  84755. * The min limit of the emission direction.
  84756. */
  84757. direction1: Vector3;
  84758. /**
  84759. * The max limit of the emission direction.
  84760. */
  84761. direction2: Vector3;
  84762. /**
  84763. * Creates a new instance CylinderDirectedParticleEmitter
  84764. * @param radius the radius of the emission cylinder (1 by default)
  84765. * @param height the height of the emission cylinder (1 by default)
  84766. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84767. * @param direction1 the min limit of the emission direction (up vector by default)
  84768. * @param direction2 the max limit of the emission direction (up vector by default)
  84769. */
  84770. constructor(radius?: number, height?: number, radiusRange?: number,
  84771. /**
  84772. * The min limit of the emission direction.
  84773. */
  84774. direction1?: Vector3,
  84775. /**
  84776. * The max limit of the emission direction.
  84777. */
  84778. direction2?: Vector3);
  84779. /**
  84780. * Called by the particle System when the direction is computed for the created particle.
  84781. * @param worldMatrix is the world matrix of the particle system
  84782. * @param directionToUpdate is the direction vector to update with the result
  84783. * @param particle is the particle we are computed the direction for
  84784. */
  84785. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84786. /**
  84787. * Clones the current emitter and returns a copy of it
  84788. * @returns the new emitter
  84789. */
  84790. clone(): CylinderDirectedParticleEmitter;
  84791. /**
  84792. * Called by the GPUParticleSystem to setup the update shader
  84793. * @param effect defines the update shader
  84794. */
  84795. applyToShader(effect: Effect): void;
  84796. /**
  84797. * Returns a string to use to update the GPU particles update shader
  84798. * @returns a string containng the defines string
  84799. */
  84800. getEffectDefines(): string;
  84801. /**
  84802. * Returns the string "CylinderDirectedParticleEmitter"
  84803. * @returns a string containing the class name
  84804. */
  84805. getClassName(): string;
  84806. /**
  84807. * Serializes the particle system to a JSON object.
  84808. * @returns the JSON object
  84809. */
  84810. serialize(): any;
  84811. /**
  84812. * Parse properties from a JSON object
  84813. * @param serializationObject defines the JSON object
  84814. */
  84815. parse(serializationObject: any): void;
  84816. }
  84817. }
  84818. declare module BABYLON {
  84819. /**
  84820. * Particle emitter emitting particles from the inside of a hemisphere.
  84821. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84822. */
  84823. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84824. /**
  84825. * The radius of the emission hemisphere.
  84826. */
  84827. radius: number;
  84828. /**
  84829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84830. */
  84831. radiusRange: number;
  84832. /**
  84833. * How much to randomize the particle direction [0-1].
  84834. */
  84835. directionRandomizer: number;
  84836. /**
  84837. * Creates a new instance HemisphericParticleEmitter
  84838. * @param radius the radius of the emission hemisphere (1 by default)
  84839. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84840. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84841. */
  84842. constructor(
  84843. /**
  84844. * The radius of the emission hemisphere.
  84845. */
  84846. radius?: number,
  84847. /**
  84848. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84849. */
  84850. radiusRange?: number,
  84851. /**
  84852. * How much to randomize the particle direction [0-1].
  84853. */
  84854. directionRandomizer?: number);
  84855. /**
  84856. * Called by the particle System when the direction is computed for the created particle.
  84857. * @param worldMatrix is the world matrix of the particle system
  84858. * @param directionToUpdate is the direction vector to update with the result
  84859. * @param particle is the particle we are computed the direction for
  84860. */
  84861. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84862. /**
  84863. * Called by the particle System when the position is computed for the created particle.
  84864. * @param worldMatrix is the world matrix of the particle system
  84865. * @param positionToUpdate is the position vector to update with the result
  84866. * @param particle is the particle we are computed the position for
  84867. */
  84868. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84869. /**
  84870. * Clones the current emitter and returns a copy of it
  84871. * @returns the new emitter
  84872. */
  84873. clone(): HemisphericParticleEmitter;
  84874. /**
  84875. * Called by the GPUParticleSystem to setup the update shader
  84876. * @param effect defines the update shader
  84877. */
  84878. applyToShader(effect: Effect): void;
  84879. /**
  84880. * Returns a string to use to update the GPU particles update shader
  84881. * @returns a string containng the defines string
  84882. */
  84883. getEffectDefines(): string;
  84884. /**
  84885. * Returns the string "HemisphericParticleEmitter"
  84886. * @returns a string containing the class name
  84887. */
  84888. getClassName(): string;
  84889. /**
  84890. * Serializes the particle system to a JSON object.
  84891. * @returns the JSON object
  84892. */
  84893. serialize(): any;
  84894. /**
  84895. * Parse properties from a JSON object
  84896. * @param serializationObject defines the JSON object
  84897. */
  84898. parse(serializationObject: any): void;
  84899. }
  84900. }
  84901. declare module BABYLON {
  84902. /**
  84903. * Particle emitter emitting particles from a point.
  84904. * It emits the particles randomly between 2 given directions.
  84905. */
  84906. export class PointParticleEmitter implements IParticleEmitterType {
  84907. /**
  84908. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84909. */
  84910. direction1: Vector3;
  84911. /**
  84912. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84913. */
  84914. direction2: Vector3;
  84915. /**
  84916. * Creates a new instance PointParticleEmitter
  84917. */
  84918. constructor();
  84919. /**
  84920. * Called by the particle System when the direction is computed for the created particle.
  84921. * @param worldMatrix is the world matrix of the particle system
  84922. * @param directionToUpdate is the direction vector to update with the result
  84923. * @param particle is the particle we are computed the direction for
  84924. */
  84925. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84926. /**
  84927. * Called by the particle System when the position is computed for the created particle.
  84928. * @param worldMatrix is the world matrix of the particle system
  84929. * @param positionToUpdate is the position vector to update with the result
  84930. * @param particle is the particle we are computed the position for
  84931. */
  84932. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84933. /**
  84934. * Clones the current emitter and returns a copy of it
  84935. * @returns the new emitter
  84936. */
  84937. clone(): PointParticleEmitter;
  84938. /**
  84939. * Called by the GPUParticleSystem to setup the update shader
  84940. * @param effect defines the update shader
  84941. */
  84942. applyToShader(effect: Effect): void;
  84943. /**
  84944. * Returns a string to use to update the GPU particles update shader
  84945. * @returns a string containng the defines string
  84946. */
  84947. getEffectDefines(): string;
  84948. /**
  84949. * Returns the string "PointParticleEmitter"
  84950. * @returns a string containing the class name
  84951. */
  84952. getClassName(): string;
  84953. /**
  84954. * Serializes the particle system to a JSON object.
  84955. * @returns the JSON object
  84956. */
  84957. serialize(): any;
  84958. /**
  84959. * Parse properties from a JSON object
  84960. * @param serializationObject defines the JSON object
  84961. */
  84962. parse(serializationObject: any): void;
  84963. }
  84964. }
  84965. declare module BABYLON {
  84966. /**
  84967. * Particle emitter emitting particles from the inside of a sphere.
  84968. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84969. */
  84970. export class SphereParticleEmitter implements IParticleEmitterType {
  84971. /**
  84972. * The radius of the emission sphere.
  84973. */
  84974. radius: number;
  84975. /**
  84976. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84977. */
  84978. radiusRange: number;
  84979. /**
  84980. * How much to randomize the particle direction [0-1].
  84981. */
  84982. directionRandomizer: number;
  84983. /**
  84984. * Creates a new instance SphereParticleEmitter
  84985. * @param radius the radius of the emission sphere (1 by default)
  84986. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84987. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84988. */
  84989. constructor(
  84990. /**
  84991. * The radius of the emission sphere.
  84992. */
  84993. radius?: number,
  84994. /**
  84995. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84996. */
  84997. radiusRange?: number,
  84998. /**
  84999. * How much to randomize the particle direction [0-1].
  85000. */
  85001. directionRandomizer?: number);
  85002. /**
  85003. * Called by the particle System when the direction is computed for the created particle.
  85004. * @param worldMatrix is the world matrix of the particle system
  85005. * @param directionToUpdate is the direction vector to update with the result
  85006. * @param particle is the particle we are computed the direction for
  85007. */
  85008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85009. /**
  85010. * Called by the particle System when the position is computed for the created particle.
  85011. * @param worldMatrix is the world matrix of the particle system
  85012. * @param positionToUpdate is the position vector to update with the result
  85013. * @param particle is the particle we are computed the position for
  85014. */
  85015. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85016. /**
  85017. * Clones the current emitter and returns a copy of it
  85018. * @returns the new emitter
  85019. */
  85020. clone(): SphereParticleEmitter;
  85021. /**
  85022. * Called by the GPUParticleSystem to setup the update shader
  85023. * @param effect defines the update shader
  85024. */
  85025. applyToShader(effect: Effect): void;
  85026. /**
  85027. * Returns a string to use to update the GPU particles update shader
  85028. * @returns a string containng the defines string
  85029. */
  85030. getEffectDefines(): string;
  85031. /**
  85032. * Returns the string "SphereParticleEmitter"
  85033. * @returns a string containing the class name
  85034. */
  85035. getClassName(): string;
  85036. /**
  85037. * Serializes the particle system to a JSON object.
  85038. * @returns the JSON object
  85039. */
  85040. serialize(): any;
  85041. /**
  85042. * Parse properties from a JSON object
  85043. * @param serializationObject defines the JSON object
  85044. */
  85045. parse(serializationObject: any): void;
  85046. }
  85047. /**
  85048. * Particle emitter emitting particles from the inside of a sphere.
  85049. * It emits the particles randomly between two vectors.
  85050. */
  85051. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85052. /**
  85053. * The min limit of the emission direction.
  85054. */
  85055. direction1: Vector3;
  85056. /**
  85057. * The max limit of the emission direction.
  85058. */
  85059. direction2: Vector3;
  85060. /**
  85061. * Creates a new instance SphereDirectedParticleEmitter
  85062. * @param radius the radius of the emission sphere (1 by default)
  85063. * @param direction1 the min limit of the emission direction (up vector by default)
  85064. * @param direction2 the max limit of the emission direction (up vector by default)
  85065. */
  85066. constructor(radius?: number,
  85067. /**
  85068. * The min limit of the emission direction.
  85069. */
  85070. direction1?: Vector3,
  85071. /**
  85072. * The max limit of the emission direction.
  85073. */
  85074. direction2?: Vector3);
  85075. /**
  85076. * Called by the particle System when the direction is computed for the created particle.
  85077. * @param worldMatrix is the world matrix of the particle system
  85078. * @param directionToUpdate is the direction vector to update with the result
  85079. * @param particle is the particle we are computed the direction for
  85080. */
  85081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85082. /**
  85083. * Clones the current emitter and returns a copy of it
  85084. * @returns the new emitter
  85085. */
  85086. clone(): SphereDirectedParticleEmitter;
  85087. /**
  85088. * Called by the GPUParticleSystem to setup the update shader
  85089. * @param effect defines the update shader
  85090. */
  85091. applyToShader(effect: Effect): void;
  85092. /**
  85093. * Returns a string to use to update the GPU particles update shader
  85094. * @returns a string containng the defines string
  85095. */
  85096. getEffectDefines(): string;
  85097. /**
  85098. * Returns the string "SphereDirectedParticleEmitter"
  85099. * @returns a string containing the class name
  85100. */
  85101. getClassName(): string;
  85102. /**
  85103. * Serializes the particle system to a JSON object.
  85104. * @returns the JSON object
  85105. */
  85106. serialize(): any;
  85107. /**
  85108. * Parse properties from a JSON object
  85109. * @param serializationObject defines the JSON object
  85110. */
  85111. parse(serializationObject: any): void;
  85112. }
  85113. }
  85114. declare module BABYLON {
  85115. /**
  85116. * Interface representing a particle system in Babylon.js.
  85117. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85118. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85119. */
  85120. export interface IParticleSystem {
  85121. /**
  85122. * List of animations used by the particle system.
  85123. */
  85124. animations: Animation[];
  85125. /**
  85126. * The id of the Particle system.
  85127. */
  85128. id: string;
  85129. /**
  85130. * The name of the Particle system.
  85131. */
  85132. name: string;
  85133. /**
  85134. * The emitter represents the Mesh or position we are attaching the particle system to.
  85135. */
  85136. emitter: Nullable<AbstractMesh | Vector3>;
  85137. /**
  85138. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85139. */
  85140. isBillboardBased: boolean;
  85141. /**
  85142. * The rendering group used by the Particle system to chose when to render.
  85143. */
  85144. renderingGroupId: number;
  85145. /**
  85146. * The layer mask we are rendering the particles through.
  85147. */
  85148. layerMask: number;
  85149. /**
  85150. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85151. */
  85152. updateSpeed: number;
  85153. /**
  85154. * The amount of time the particle system is running (depends of the overall update speed).
  85155. */
  85156. targetStopDuration: number;
  85157. /**
  85158. * The texture used to render each particle. (this can be a spritesheet)
  85159. */
  85160. particleTexture: Nullable<Texture>;
  85161. /**
  85162. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85163. */
  85164. blendMode: number;
  85165. /**
  85166. * Minimum life time of emitting particles.
  85167. */
  85168. minLifeTime: number;
  85169. /**
  85170. * Maximum life time of emitting particles.
  85171. */
  85172. maxLifeTime: number;
  85173. /**
  85174. * Minimum Size of emitting particles.
  85175. */
  85176. minSize: number;
  85177. /**
  85178. * Maximum Size of emitting particles.
  85179. */
  85180. maxSize: number;
  85181. /**
  85182. * Minimum scale of emitting particles on X axis.
  85183. */
  85184. minScaleX: number;
  85185. /**
  85186. * Maximum scale of emitting particles on X axis.
  85187. */
  85188. maxScaleX: number;
  85189. /**
  85190. * Minimum scale of emitting particles on Y axis.
  85191. */
  85192. minScaleY: number;
  85193. /**
  85194. * Maximum scale of emitting particles on Y axis.
  85195. */
  85196. maxScaleY: number;
  85197. /**
  85198. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85199. */
  85200. color1: Color4;
  85201. /**
  85202. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85203. */
  85204. color2: Color4;
  85205. /**
  85206. * Color the particle will have at the end of its lifetime.
  85207. */
  85208. colorDead: Color4;
  85209. /**
  85210. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85211. */
  85212. emitRate: number;
  85213. /**
  85214. * You can use gravity if you want to give an orientation to your particles.
  85215. */
  85216. gravity: Vector3;
  85217. /**
  85218. * Minimum power of emitting particles.
  85219. */
  85220. minEmitPower: number;
  85221. /**
  85222. * Maximum power of emitting particles.
  85223. */
  85224. maxEmitPower: number;
  85225. /**
  85226. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85227. */
  85228. minAngularSpeed: number;
  85229. /**
  85230. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85231. */
  85232. maxAngularSpeed: number;
  85233. /**
  85234. * Gets or sets the minimal initial rotation in radians.
  85235. */
  85236. minInitialRotation: number;
  85237. /**
  85238. * Gets or sets the maximal initial rotation in radians.
  85239. */
  85240. maxInitialRotation: number;
  85241. /**
  85242. * The particle emitter type defines the emitter used by the particle system.
  85243. * It can be for example box, sphere, or cone...
  85244. */
  85245. particleEmitterType: Nullable<IParticleEmitterType>;
  85246. /**
  85247. * Defines the delay in milliseconds before starting the system (0 by default)
  85248. */
  85249. startDelay: number;
  85250. /**
  85251. * 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
  85252. */
  85253. preWarmCycles: number;
  85254. /**
  85255. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85256. */
  85257. preWarmStepOffset: number;
  85258. /**
  85259. * 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)
  85260. */
  85261. spriteCellChangeSpeed: number;
  85262. /**
  85263. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85264. */
  85265. startSpriteCellID: number;
  85266. /**
  85267. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85268. */
  85269. endSpriteCellID: number;
  85270. /**
  85271. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85272. */
  85273. spriteCellWidth: number;
  85274. /**
  85275. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85276. */
  85277. spriteCellHeight: number;
  85278. /**
  85279. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85280. */
  85281. spriteRandomStartCell: boolean;
  85282. /**
  85283. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85284. */
  85285. isAnimationSheetEnabled: boolean;
  85286. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85287. translationPivot: Vector2;
  85288. /**
  85289. * Gets or sets a texture used to add random noise to particle positions
  85290. */
  85291. noiseTexture: Nullable<BaseTexture>;
  85292. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85293. noiseStrength: Vector3;
  85294. /**
  85295. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85296. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85297. */
  85298. billboardMode: number;
  85299. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85300. limitVelocityDamping: number;
  85301. /**
  85302. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85303. */
  85304. beginAnimationOnStart: boolean;
  85305. /**
  85306. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85307. */
  85308. beginAnimationFrom: number;
  85309. /**
  85310. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85311. */
  85312. beginAnimationTo: number;
  85313. /**
  85314. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85315. */
  85316. beginAnimationLoop: boolean;
  85317. /**
  85318. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85319. */
  85320. disposeOnStop: boolean;
  85321. /**
  85322. * Gets the maximum number of particles active at the same time.
  85323. * @returns The max number of active particles.
  85324. */
  85325. getCapacity(): number;
  85326. /**
  85327. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85328. * @returns True if it has been started, otherwise false.
  85329. */
  85330. isStarted(): boolean;
  85331. /**
  85332. * Animates the particle system for this frame.
  85333. */
  85334. animate(): void;
  85335. /**
  85336. * Renders the particle system in its current state.
  85337. * @returns the current number of particles
  85338. */
  85339. render(): number;
  85340. /**
  85341. * Dispose the particle system and frees its associated resources.
  85342. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85343. */
  85344. dispose(disposeTexture?: boolean): void;
  85345. /**
  85346. * Clones the particle system.
  85347. * @param name The name of the cloned object
  85348. * @param newEmitter The new emitter to use
  85349. * @returns the cloned particle system
  85350. */
  85351. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85352. /**
  85353. * Serializes the particle system to a JSON object.
  85354. * @returns the JSON object
  85355. */
  85356. serialize(): any;
  85357. /**
  85358. * Rebuild the particle system
  85359. */
  85360. rebuild(): void;
  85361. /**
  85362. * Starts the particle system and begins to emit
  85363. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85364. */
  85365. start(delay?: number): void;
  85366. /**
  85367. * Stops the particle system.
  85368. */
  85369. stop(): void;
  85370. /**
  85371. * Remove all active particles
  85372. */
  85373. reset(): void;
  85374. /**
  85375. * Is this system ready to be used/rendered
  85376. * @return true if the system is ready
  85377. */
  85378. isReady(): boolean;
  85379. /**
  85380. * Adds a new color gradient
  85381. * @param gradient defines the gradient to use (between 0 and 1)
  85382. * @param color1 defines the color to affect to the specified gradient
  85383. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85384. * @returns the current particle system
  85385. */
  85386. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85387. /**
  85388. * Remove a specific color gradient
  85389. * @param gradient defines the gradient to remove
  85390. * @returns the current particle system
  85391. */
  85392. removeColorGradient(gradient: number): IParticleSystem;
  85393. /**
  85394. * Adds a new size gradient
  85395. * @param gradient defines the gradient to use (between 0 and 1)
  85396. * @param factor defines the size factor to affect to the specified gradient
  85397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85398. * @returns the current particle system
  85399. */
  85400. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85401. /**
  85402. * Remove a specific size gradient
  85403. * @param gradient defines the gradient to remove
  85404. * @returns the current particle system
  85405. */
  85406. removeSizeGradient(gradient: number): IParticleSystem;
  85407. /**
  85408. * Gets the current list of color gradients.
  85409. * You must use addColorGradient and removeColorGradient to udpate this list
  85410. * @returns the list of color gradients
  85411. */
  85412. getColorGradients(): Nullable<Array<ColorGradient>>;
  85413. /**
  85414. * Gets the current list of size gradients.
  85415. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85416. * @returns the list of size gradients
  85417. */
  85418. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85419. /**
  85420. * Gets the current list of angular speed gradients.
  85421. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85422. * @returns the list of angular speed gradients
  85423. */
  85424. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85425. /**
  85426. * Adds a new angular speed gradient
  85427. * @param gradient defines the gradient to use (between 0 and 1)
  85428. * @param factor defines the angular speed to affect to the specified gradient
  85429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85430. * @returns the current particle system
  85431. */
  85432. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85433. /**
  85434. * Remove a specific angular speed gradient
  85435. * @param gradient defines the gradient to remove
  85436. * @returns the current particle system
  85437. */
  85438. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85439. /**
  85440. * Gets the current list of velocity gradients.
  85441. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85442. * @returns the list of velocity gradients
  85443. */
  85444. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85445. /**
  85446. * Adds a new velocity gradient
  85447. * @param gradient defines the gradient to use (between 0 and 1)
  85448. * @param factor defines the velocity to affect to the specified gradient
  85449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85450. * @returns the current particle system
  85451. */
  85452. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85453. /**
  85454. * Remove a specific velocity gradient
  85455. * @param gradient defines the gradient to remove
  85456. * @returns the current particle system
  85457. */
  85458. removeVelocityGradient(gradient: number): IParticleSystem;
  85459. /**
  85460. * Gets the current list of limit velocity gradients.
  85461. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85462. * @returns the list of limit velocity gradients
  85463. */
  85464. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85465. /**
  85466. * Adds a new limit velocity gradient
  85467. * @param gradient defines the gradient to use (between 0 and 1)
  85468. * @param factor defines the limit velocity to affect to the specified gradient
  85469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85470. * @returns the current particle system
  85471. */
  85472. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85473. /**
  85474. * Remove a specific limit velocity gradient
  85475. * @param gradient defines the gradient to remove
  85476. * @returns the current particle system
  85477. */
  85478. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85479. /**
  85480. * Adds a new drag gradient
  85481. * @param gradient defines the gradient to use (between 0 and 1)
  85482. * @param factor defines the drag to affect to the specified gradient
  85483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85484. * @returns the current particle system
  85485. */
  85486. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85487. /**
  85488. * Remove a specific drag gradient
  85489. * @param gradient defines the gradient to remove
  85490. * @returns the current particle system
  85491. */
  85492. removeDragGradient(gradient: number): IParticleSystem;
  85493. /**
  85494. * Gets the current list of drag gradients.
  85495. * You must use addDragGradient and removeDragGradient to udpate this list
  85496. * @returns the list of drag gradients
  85497. */
  85498. getDragGradients(): Nullable<Array<FactorGradient>>;
  85499. /**
  85500. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85501. * @param gradient defines the gradient to use (between 0 and 1)
  85502. * @param factor defines the emit rate to affect to the specified gradient
  85503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85504. * @returns the current particle system
  85505. */
  85506. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85507. /**
  85508. * Remove a specific emit rate gradient
  85509. * @param gradient defines the gradient to remove
  85510. * @returns the current particle system
  85511. */
  85512. removeEmitRateGradient(gradient: number): IParticleSystem;
  85513. /**
  85514. * Gets the current list of emit rate gradients.
  85515. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85516. * @returns the list of emit rate gradients
  85517. */
  85518. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85519. /**
  85520. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85521. * @param gradient defines the gradient to use (between 0 and 1)
  85522. * @param factor defines the start size to affect to the specified gradient
  85523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85524. * @returns the current particle system
  85525. */
  85526. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85527. /**
  85528. * Remove a specific start size gradient
  85529. * @param gradient defines the gradient to remove
  85530. * @returns the current particle system
  85531. */
  85532. removeStartSizeGradient(gradient: number): IParticleSystem;
  85533. /**
  85534. * Gets the current list of start size gradients.
  85535. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85536. * @returns the list of start size gradients
  85537. */
  85538. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85539. /**
  85540. * Adds a new life time gradient
  85541. * @param gradient defines the gradient to use (between 0 and 1)
  85542. * @param factor defines the life time factor to affect to the specified gradient
  85543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85544. * @returns the current particle system
  85545. */
  85546. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85547. /**
  85548. * Remove a specific life time gradient
  85549. * @param gradient defines the gradient to remove
  85550. * @returns the current particle system
  85551. */
  85552. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85553. /**
  85554. * Gets the current list of life time gradients.
  85555. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85556. * @returns the list of life time gradients
  85557. */
  85558. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85559. /**
  85560. * Gets the current list of color gradients.
  85561. * You must use addColorGradient and removeColorGradient to udpate this list
  85562. * @returns the list of color gradients
  85563. */
  85564. getColorGradients(): Nullable<Array<ColorGradient>>;
  85565. /**
  85566. * Adds a new ramp gradient used to remap particle colors
  85567. * @param gradient defines the gradient to use (between 0 and 1)
  85568. * @param color defines the color to affect to the specified gradient
  85569. * @returns the current particle system
  85570. */
  85571. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85572. /**
  85573. * Gets the current list of ramp gradients.
  85574. * You must use addRampGradient and removeRampGradient to udpate this list
  85575. * @returns the list of ramp gradients
  85576. */
  85577. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85578. /** Gets or sets a boolean indicating that ramp gradients must be used
  85579. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85580. */
  85581. useRampGradients: boolean;
  85582. /**
  85583. * Adds a new color remap gradient
  85584. * @param gradient defines the gradient to use (between 0 and 1)
  85585. * @param min defines the color remap minimal range
  85586. * @param max defines the color remap maximal range
  85587. * @returns the current particle system
  85588. */
  85589. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85590. /**
  85591. * Gets the current list of color remap gradients.
  85592. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85593. * @returns the list of color remap gradients
  85594. */
  85595. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85596. /**
  85597. * Adds a new alpha remap gradient
  85598. * @param gradient defines the gradient to use (between 0 and 1)
  85599. * @param min defines the alpha remap minimal range
  85600. * @param max defines the alpha remap maximal range
  85601. * @returns the current particle system
  85602. */
  85603. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85604. /**
  85605. * Gets the current list of alpha remap gradients.
  85606. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85607. * @returns the list of alpha remap gradients
  85608. */
  85609. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85610. /**
  85611. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85614. * @returns the emitter
  85615. */
  85616. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85617. /**
  85618. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85619. * @param radius The radius of the hemisphere to emit from
  85620. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85621. * @returns the emitter
  85622. */
  85623. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85624. /**
  85625. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85626. * @param radius The radius of the sphere to emit from
  85627. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85628. * @returns the emitter
  85629. */
  85630. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85631. /**
  85632. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85633. * @param radius The radius of the sphere to emit from
  85634. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85635. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85636. * @returns the emitter
  85637. */
  85638. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85639. /**
  85640. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85641. * @param radius The radius of the emission cylinder
  85642. * @param height The height of the emission cylinder
  85643. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85644. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85645. * @returns the emitter
  85646. */
  85647. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85648. /**
  85649. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85650. * @param radius The radius of the cylinder to emit from
  85651. * @param height The height of the emission cylinder
  85652. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85655. * @returns the emitter
  85656. */
  85657. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85658. /**
  85659. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85660. * @param radius The radius of the cone to emit from
  85661. * @param angle The base angle of the cone
  85662. * @returns the emitter
  85663. */
  85664. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85665. /**
  85666. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85669. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85670. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85671. * @returns the emitter
  85672. */
  85673. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85674. /**
  85675. * Get hosting scene
  85676. * @returns the scene
  85677. */
  85678. getScene(): Scene;
  85679. }
  85680. }
  85681. declare module BABYLON {
  85682. /**
  85683. * Creates an instance based on a source mesh.
  85684. */
  85685. export class InstancedMesh extends AbstractMesh {
  85686. private _sourceMesh;
  85687. private _currentLOD;
  85688. /** @hidden */
  85689. _indexInSourceMeshInstanceArray: number;
  85690. constructor(name: string, source: Mesh);
  85691. /**
  85692. * Returns the string "InstancedMesh".
  85693. */
  85694. getClassName(): string;
  85695. /** Gets the list of lights affecting that mesh */
  85696. readonly lightSources: Light[];
  85697. _resyncLightSources(): void;
  85698. _resyncLighSource(light: Light): void;
  85699. _removeLightSource(light: Light, dispose: boolean): void;
  85700. /**
  85701. * If the source mesh receives shadows
  85702. */
  85703. readonly receiveShadows: boolean;
  85704. /**
  85705. * The material of the source mesh
  85706. */
  85707. readonly material: Nullable<Material>;
  85708. /**
  85709. * Visibility of the source mesh
  85710. */
  85711. readonly visibility: number;
  85712. /**
  85713. * Skeleton of the source mesh
  85714. */
  85715. readonly skeleton: Nullable<Skeleton>;
  85716. /**
  85717. * Rendering ground id of the source mesh
  85718. */
  85719. renderingGroupId: number;
  85720. /**
  85721. * Returns the total number of vertices (integer).
  85722. */
  85723. getTotalVertices(): number;
  85724. /**
  85725. * Returns a positive integer : the total number of indices in this mesh geometry.
  85726. * @returns the numner of indices or zero if the mesh has no geometry.
  85727. */
  85728. getTotalIndices(): number;
  85729. /**
  85730. * The source mesh of the instance
  85731. */
  85732. readonly sourceMesh: Mesh;
  85733. /**
  85734. * Is this node ready to be used/rendered
  85735. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85736. * @return {boolean} is it ready
  85737. */
  85738. isReady(completeCheck?: boolean): boolean;
  85739. /**
  85740. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85741. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85742. * @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.
  85743. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85744. */
  85745. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85746. /**
  85747. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85748. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85749. * The `data` are either a numeric array either a Float32Array.
  85750. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85751. * 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).
  85752. * Note that a new underlying VertexBuffer object is created each call.
  85753. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85754. *
  85755. * Possible `kind` values :
  85756. * - VertexBuffer.PositionKind
  85757. * - VertexBuffer.UVKind
  85758. * - VertexBuffer.UV2Kind
  85759. * - VertexBuffer.UV3Kind
  85760. * - VertexBuffer.UV4Kind
  85761. * - VertexBuffer.UV5Kind
  85762. * - VertexBuffer.UV6Kind
  85763. * - VertexBuffer.ColorKind
  85764. * - VertexBuffer.MatricesIndicesKind
  85765. * - VertexBuffer.MatricesIndicesExtraKind
  85766. * - VertexBuffer.MatricesWeightsKind
  85767. * - VertexBuffer.MatricesWeightsExtraKind
  85768. *
  85769. * Returns the Mesh.
  85770. */
  85771. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85772. /**
  85773. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85774. * If the mesh has no geometry, it is simply returned as it is.
  85775. * The `data` are either a numeric array either a Float32Array.
  85776. * No new underlying VertexBuffer object is created.
  85777. * 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.
  85778. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85779. *
  85780. * Possible `kind` values :
  85781. * - VertexBuffer.PositionKind
  85782. * - VertexBuffer.UVKind
  85783. * - VertexBuffer.UV2Kind
  85784. * - VertexBuffer.UV3Kind
  85785. * - VertexBuffer.UV4Kind
  85786. * - VertexBuffer.UV5Kind
  85787. * - VertexBuffer.UV6Kind
  85788. * - VertexBuffer.ColorKind
  85789. * - VertexBuffer.MatricesIndicesKind
  85790. * - VertexBuffer.MatricesIndicesExtraKind
  85791. * - VertexBuffer.MatricesWeightsKind
  85792. * - VertexBuffer.MatricesWeightsExtraKind
  85793. *
  85794. * Returns the Mesh.
  85795. */
  85796. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85797. /**
  85798. * Sets the mesh indices.
  85799. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85800. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85801. * This method creates a new index buffer each call.
  85802. * Returns the Mesh.
  85803. */
  85804. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85805. /**
  85806. * Boolean : True if the mesh owns the requested kind of data.
  85807. */
  85808. isVerticesDataPresent(kind: string): boolean;
  85809. /**
  85810. * Returns an array of indices (IndicesArray).
  85811. */
  85812. getIndices(): Nullable<IndicesArray>;
  85813. readonly _positions: Nullable<Vector3[]>;
  85814. /**
  85815. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85816. * This means the mesh underlying bounding box and sphere are recomputed.
  85817. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85818. * @returns the current mesh
  85819. */
  85820. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85821. /** @hidden */
  85822. _preActivate(): InstancedMesh;
  85823. /** @hidden */
  85824. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85825. /** @hidden */
  85826. _postActivate(): void;
  85827. getWorldMatrix(): Matrix;
  85828. readonly isAnInstance: boolean;
  85829. /**
  85830. * Returns the current associated LOD AbstractMesh.
  85831. */
  85832. getLOD(camera: Camera): AbstractMesh;
  85833. /** @hidden */
  85834. _syncSubMeshes(): InstancedMesh;
  85835. /** @hidden */
  85836. _generatePointsArray(): boolean;
  85837. /**
  85838. * Creates a new InstancedMesh from the current mesh.
  85839. * - name (string) : the cloned mesh name
  85840. * - newParent (optional Node) : the optional Node to parent the clone to.
  85841. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85842. *
  85843. * Returns the clone.
  85844. */
  85845. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85846. /**
  85847. * Disposes the InstancedMesh.
  85848. * Returns nothing.
  85849. */
  85850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85851. }
  85852. }
  85853. declare module BABYLON {
  85854. /**
  85855. * Defines the options associated with the creation of a shader material.
  85856. */
  85857. export interface IShaderMaterialOptions {
  85858. /**
  85859. * Does the material work in alpha blend mode
  85860. */
  85861. needAlphaBlending: boolean;
  85862. /**
  85863. * Does the material work in alpha test mode
  85864. */
  85865. needAlphaTesting: boolean;
  85866. /**
  85867. * The list of attribute names used in the shader
  85868. */
  85869. attributes: string[];
  85870. /**
  85871. * The list of unifrom names used in the shader
  85872. */
  85873. uniforms: string[];
  85874. /**
  85875. * The list of UBO names used in the shader
  85876. */
  85877. uniformBuffers: string[];
  85878. /**
  85879. * The list of sampler names used in the shader
  85880. */
  85881. samplers: string[];
  85882. /**
  85883. * The list of defines used in the shader
  85884. */
  85885. defines: string[];
  85886. }
  85887. /**
  85888. * 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.
  85889. *
  85890. * This returned material effects how the mesh will look based on the code in the shaders.
  85891. *
  85892. * @see http://doc.babylonjs.com/how_to/shader_material
  85893. */
  85894. export class ShaderMaterial extends Material {
  85895. private _shaderPath;
  85896. private _options;
  85897. private _textures;
  85898. private _textureArrays;
  85899. private _floats;
  85900. private _ints;
  85901. private _floatsArrays;
  85902. private _colors3;
  85903. private _colors3Arrays;
  85904. private _colors4;
  85905. private _colors4Arrays;
  85906. private _vectors2;
  85907. private _vectors3;
  85908. private _vectors4;
  85909. private _matrices;
  85910. private _matrices3x3;
  85911. private _matrices2x2;
  85912. private _vectors2Arrays;
  85913. private _vectors3Arrays;
  85914. private _vectors4Arrays;
  85915. private _cachedWorldViewMatrix;
  85916. private _cachedWorldViewProjectionMatrix;
  85917. private _renderId;
  85918. /**
  85919. * Instantiate a new shader material.
  85920. * 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.
  85921. * This returned material effects how the mesh will look based on the code in the shaders.
  85922. * @see http://doc.babylonjs.com/how_to/shader_material
  85923. * @param name Define the name of the material in the scene
  85924. * @param scene Define the scene the material belongs to
  85925. * @param shaderPath Defines the route to the shader code in one of three ways:
  85926. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85927. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85928. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85929. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85930. * @param options Define the options used to create the shader
  85931. */
  85932. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85933. /**
  85934. * Gets the options used to compile the shader.
  85935. * They can be modified to trigger a new compilation
  85936. */
  85937. readonly options: IShaderMaterialOptions;
  85938. /**
  85939. * Gets the current class name of the material e.g. "ShaderMaterial"
  85940. * Mainly use in serialization.
  85941. * @returns the class name
  85942. */
  85943. getClassName(): string;
  85944. /**
  85945. * Specifies if the material will require alpha blending
  85946. * @returns a boolean specifying if alpha blending is needed
  85947. */
  85948. needAlphaBlending(): boolean;
  85949. /**
  85950. * Specifies if this material should be rendered in alpha test mode
  85951. * @returns a boolean specifying if an alpha test is needed.
  85952. */
  85953. needAlphaTesting(): boolean;
  85954. private _checkUniform;
  85955. /**
  85956. * Set a texture in the shader.
  85957. * @param name Define the name of the uniform samplers as defined in the shader
  85958. * @param texture Define the texture to bind to this sampler
  85959. * @return the material itself allowing "fluent" like uniform updates
  85960. */
  85961. setTexture(name: string, texture: Texture): ShaderMaterial;
  85962. /**
  85963. * Set a texture array in the shader.
  85964. * @param name Define the name of the uniform sampler array as defined in the shader
  85965. * @param textures Define the list of textures to bind to this sampler
  85966. * @return the material itself allowing "fluent" like uniform updates
  85967. */
  85968. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85969. /**
  85970. * Set a float in the shader.
  85971. * @param name Define the name of the uniform as defined in the shader
  85972. * @param value Define the value to give to the uniform
  85973. * @return the material itself allowing "fluent" like uniform updates
  85974. */
  85975. setFloat(name: string, value: number): ShaderMaterial;
  85976. /**
  85977. * Set a int in the shader.
  85978. * @param name Define the name of the uniform as defined in the shader
  85979. * @param value Define the value to give to the uniform
  85980. * @return the material itself allowing "fluent" like uniform updates
  85981. */
  85982. setInt(name: string, value: number): ShaderMaterial;
  85983. /**
  85984. * Set an array of floats in the shader.
  85985. * @param name Define the name of the uniform as defined in the shader
  85986. * @param value Define the value to give to the uniform
  85987. * @return the material itself allowing "fluent" like uniform updates
  85988. */
  85989. setFloats(name: string, value: number[]): ShaderMaterial;
  85990. /**
  85991. * Set a vec3 in the shader from a Color3.
  85992. * @param name Define the name of the uniform as defined in the shader
  85993. * @param value Define the value to give to the uniform
  85994. * @return the material itself allowing "fluent" like uniform updates
  85995. */
  85996. setColor3(name: string, value: Color3): ShaderMaterial;
  85997. /**
  85998. * Set a vec3 array in the shader from a Color3 array.
  85999. * @param name Define the name of the uniform as defined in the shader
  86000. * @param value Define the value to give to the uniform
  86001. * @return the material itself allowing "fluent" like uniform updates
  86002. */
  86003. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86004. /**
  86005. * Set a vec4 in the shader from a Color4.
  86006. * @param name Define the name of the uniform as defined in the shader
  86007. * @param value Define the value to give to the uniform
  86008. * @return the material itself allowing "fluent" like uniform updates
  86009. */
  86010. setColor4(name: string, value: Color4): ShaderMaterial;
  86011. /**
  86012. * Set a vec4 array in the shader from a Color4 array.
  86013. * @param name Define the name of the uniform as defined in the shader
  86014. * @param value Define the value to give to the uniform
  86015. * @return the material itself allowing "fluent" like uniform updates
  86016. */
  86017. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86018. /**
  86019. * Set a vec2 in the shader from a Vector2.
  86020. * @param name Define the name of the uniform as defined in the shader
  86021. * @param value Define the value to give to the uniform
  86022. * @return the material itself allowing "fluent" like uniform updates
  86023. */
  86024. setVector2(name: string, value: Vector2): ShaderMaterial;
  86025. /**
  86026. * Set a vec3 in the shader from a Vector3.
  86027. * @param name Define the name of the uniform as defined in the shader
  86028. * @param value Define the value to give to the uniform
  86029. * @return the material itself allowing "fluent" like uniform updates
  86030. */
  86031. setVector3(name: string, value: Vector3): ShaderMaterial;
  86032. /**
  86033. * Set a vec4 in the shader from a Vector4.
  86034. * @param name Define the name of the uniform as defined in the shader
  86035. * @param value Define the value to give to the uniform
  86036. * @return the material itself allowing "fluent" like uniform updates
  86037. */
  86038. setVector4(name: string, value: Vector4): ShaderMaterial;
  86039. /**
  86040. * Set a mat4 in the shader from a Matrix.
  86041. * @param name Define the name of the uniform as defined in the shader
  86042. * @param value Define the value to give to the uniform
  86043. * @return the material itself allowing "fluent" like uniform updates
  86044. */
  86045. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86046. /**
  86047. * Set a mat3 in the shader from a Float32Array.
  86048. * @param name Define the name of the uniform as defined in the shader
  86049. * @param value Define the value to give to the uniform
  86050. * @return the material itself allowing "fluent" like uniform updates
  86051. */
  86052. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86053. /**
  86054. * Set a mat2 in the shader from a Float32Array.
  86055. * @param name Define the name of the uniform as defined in the shader
  86056. * @param value Define the value to give to the uniform
  86057. * @return the material itself allowing "fluent" like uniform updates
  86058. */
  86059. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86060. /**
  86061. * Set a vec2 array in the shader from a number array.
  86062. * @param name Define the name of the uniform as defined in the shader
  86063. * @param value Define the value to give to the uniform
  86064. * @return the material itself allowing "fluent" like uniform updates
  86065. */
  86066. setArray2(name: string, value: number[]): ShaderMaterial;
  86067. /**
  86068. * Set a vec3 array in the shader from a number array.
  86069. * @param name Define the name of the uniform as defined in the shader
  86070. * @param value Define the value to give to the uniform
  86071. * @return the material itself allowing "fluent" like uniform updates
  86072. */
  86073. setArray3(name: string, value: number[]): ShaderMaterial;
  86074. /**
  86075. * Set a vec4 array in the shader from a number array.
  86076. * @param name Define the name of the uniform as defined in the shader
  86077. * @param value Define the value to give to the uniform
  86078. * @return the material itself allowing "fluent" like uniform updates
  86079. */
  86080. setArray4(name: string, value: number[]): ShaderMaterial;
  86081. private _checkCache;
  86082. /**
  86083. * Specifies that the submesh is ready to be used
  86084. * @param mesh defines the mesh to check
  86085. * @param subMesh defines which submesh to check
  86086. * @param useInstances specifies that instances should be used
  86087. * @returns a boolean indicating that the submesh is ready or not
  86088. */
  86089. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86090. /**
  86091. * Checks if the material is ready to render the requested mesh
  86092. * @param mesh Define the mesh to render
  86093. * @param useInstances Define whether or not the material is used with instances
  86094. * @returns true if ready, otherwise false
  86095. */
  86096. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86097. /**
  86098. * Binds the world matrix to the material
  86099. * @param world defines the world transformation matrix
  86100. */
  86101. bindOnlyWorldMatrix(world: Matrix): void;
  86102. /**
  86103. * Binds the material to the mesh
  86104. * @param world defines the world transformation matrix
  86105. * @param mesh defines the mesh to bind the material to
  86106. */
  86107. bind(world: Matrix, mesh?: Mesh): void;
  86108. /**
  86109. * Gets the active textures from the material
  86110. * @returns an array of textures
  86111. */
  86112. getActiveTextures(): BaseTexture[];
  86113. /**
  86114. * Specifies if the material uses a texture
  86115. * @param texture defines the texture to check against the material
  86116. * @returns a boolean specifying if the material uses the texture
  86117. */
  86118. hasTexture(texture: BaseTexture): boolean;
  86119. /**
  86120. * Makes a duplicate of the material, and gives it a new name
  86121. * @param name defines the new name for the duplicated material
  86122. * @returns the cloned material
  86123. */
  86124. clone(name: string): ShaderMaterial;
  86125. /**
  86126. * Disposes the material
  86127. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86128. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86129. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86130. */
  86131. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86132. /**
  86133. * Serializes this material in a JSON representation
  86134. * @returns the serialized material object
  86135. */
  86136. serialize(): any;
  86137. /**
  86138. * Creates a shader material from parsed shader material data
  86139. * @param source defines the JSON represnetation of the material
  86140. * @param scene defines the hosting scene
  86141. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86142. * @returns a new material
  86143. */
  86144. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86145. }
  86146. }
  86147. declare module BABYLON {
  86148. /** @hidden */
  86149. export var colorPixelShader: {
  86150. name: string;
  86151. shader: string;
  86152. };
  86153. }
  86154. declare module BABYLON {
  86155. /** @hidden */
  86156. export var colorVertexShader: {
  86157. name: string;
  86158. shader: string;
  86159. };
  86160. }
  86161. declare module BABYLON {
  86162. /**
  86163. * Line mesh
  86164. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86165. */
  86166. export class LinesMesh extends Mesh {
  86167. /**
  86168. * If vertex color should be applied to the mesh
  86169. */
  86170. readonly useVertexColor?: boolean | undefined;
  86171. /**
  86172. * If vertex alpha should be applied to the mesh
  86173. */
  86174. readonly useVertexAlpha?: boolean | undefined;
  86175. /**
  86176. * Color of the line (Default: White)
  86177. */
  86178. color: Color3;
  86179. /**
  86180. * Alpha of the line (Default: 1)
  86181. */
  86182. alpha: number;
  86183. /**
  86184. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86185. * This margin is expressed in world space coordinates, so its value may vary.
  86186. * Default value is 0.1
  86187. */
  86188. intersectionThreshold: number;
  86189. private _colorShader;
  86190. private color4;
  86191. /**
  86192. * Creates a new LinesMesh
  86193. * @param name defines the name
  86194. * @param scene defines the hosting scene
  86195. * @param parent defines the parent mesh if any
  86196. * @param source defines the optional source LinesMesh used to clone data from
  86197. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86198. * When false, achieved by calling a clone(), also passing False.
  86199. * This will make creation of children, recursive.
  86200. * @param useVertexColor defines if this LinesMesh supports vertex color
  86201. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86202. */
  86203. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86204. /**
  86205. * If vertex color should be applied to the mesh
  86206. */
  86207. useVertexColor?: boolean | undefined,
  86208. /**
  86209. * If vertex alpha should be applied to the mesh
  86210. */
  86211. useVertexAlpha?: boolean | undefined);
  86212. private _addClipPlaneDefine;
  86213. private _removeClipPlaneDefine;
  86214. isReady(): boolean;
  86215. /**
  86216. * Returns the string "LineMesh"
  86217. */
  86218. getClassName(): string;
  86219. /**
  86220. * @hidden
  86221. */
  86222. /**
  86223. * @hidden
  86224. */
  86225. material: Material;
  86226. /**
  86227. * @hidden
  86228. */
  86229. readonly checkCollisions: boolean;
  86230. /** @hidden */
  86231. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86232. /** @hidden */
  86233. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86234. /**
  86235. * Disposes of the line mesh
  86236. * @param doNotRecurse If children should be disposed
  86237. */
  86238. dispose(doNotRecurse?: boolean): void;
  86239. /**
  86240. * Returns a new LineMesh object cloned from the current one.
  86241. */
  86242. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86243. /**
  86244. * Creates a new InstancedLinesMesh object from the mesh model.
  86245. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86246. * @param name defines the name of the new instance
  86247. * @returns a new InstancedLinesMesh
  86248. */
  86249. createInstance(name: string): InstancedLinesMesh;
  86250. }
  86251. /**
  86252. * Creates an instance based on a source LinesMesh
  86253. */
  86254. export class InstancedLinesMesh extends InstancedMesh {
  86255. /**
  86256. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86257. * This margin is expressed in world space coordinates, so its value may vary.
  86258. * Initilized with the intersectionThreshold value of the source LinesMesh
  86259. */
  86260. intersectionThreshold: number;
  86261. constructor(name: string, source: LinesMesh);
  86262. /**
  86263. * Returns the string "InstancedLinesMesh".
  86264. */
  86265. getClassName(): string;
  86266. }
  86267. }
  86268. declare module BABYLON {
  86269. /** @hidden */
  86270. export var linePixelShader: {
  86271. name: string;
  86272. shader: string;
  86273. };
  86274. }
  86275. declare module BABYLON {
  86276. /** @hidden */
  86277. export var lineVertexShader: {
  86278. name: string;
  86279. shader: string;
  86280. };
  86281. }
  86282. declare module BABYLON {
  86283. interface AbstractMesh {
  86284. /**
  86285. * Gets the edgesRenderer associated with the mesh
  86286. */
  86287. edgesRenderer: Nullable<EdgesRenderer>;
  86288. }
  86289. interface LinesMesh {
  86290. /**
  86291. * Enables the edge rendering mode on the mesh.
  86292. * This mode makes the mesh edges visible
  86293. * @param epsilon defines the maximal distance between two angles to detect a face
  86294. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86295. * @returns the currentAbstractMesh
  86296. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86297. */
  86298. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86299. }
  86300. interface InstancedLinesMesh {
  86301. /**
  86302. * Enables the edge rendering mode on the mesh.
  86303. * This mode makes the mesh edges visible
  86304. * @param epsilon defines the maximal distance between two angles to detect a face
  86305. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86306. * @returns the current InstancedLinesMesh
  86307. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86308. */
  86309. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86310. }
  86311. /**
  86312. * Defines the minimum contract an Edges renderer should follow.
  86313. */
  86314. export interface IEdgesRenderer extends IDisposable {
  86315. /**
  86316. * Gets or sets a boolean indicating if the edgesRenderer is active
  86317. */
  86318. isEnabled: boolean;
  86319. /**
  86320. * Renders the edges of the attached mesh,
  86321. */
  86322. render(): void;
  86323. /**
  86324. * Checks wether or not the edges renderer is ready to render.
  86325. * @return true if ready, otherwise false.
  86326. */
  86327. isReady(): boolean;
  86328. }
  86329. /**
  86330. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86331. */
  86332. export class EdgesRenderer implements IEdgesRenderer {
  86333. /**
  86334. * Define the size of the edges with an orthographic camera
  86335. */
  86336. edgesWidthScalerForOrthographic: number;
  86337. /**
  86338. * Define the size of the edges with a perspective camera
  86339. */
  86340. edgesWidthScalerForPerspective: number;
  86341. protected _source: AbstractMesh;
  86342. protected _linesPositions: number[];
  86343. protected _linesNormals: number[];
  86344. protected _linesIndices: number[];
  86345. protected _epsilon: number;
  86346. protected _indicesCount: number;
  86347. protected _lineShader: ShaderMaterial;
  86348. protected _ib: DataBuffer;
  86349. protected _buffers: {
  86350. [key: string]: Nullable<VertexBuffer>;
  86351. };
  86352. protected _checkVerticesInsteadOfIndices: boolean;
  86353. private _meshRebuildObserver;
  86354. private _meshDisposeObserver;
  86355. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86356. isEnabled: boolean;
  86357. /**
  86358. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86359. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86360. * @param source Mesh used to create edges
  86361. * @param epsilon sum of angles in adjacency to check for edge
  86362. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86363. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86364. */
  86365. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86366. protected _prepareRessources(): void;
  86367. /** @hidden */
  86368. _rebuild(): void;
  86369. /**
  86370. * Releases the required resources for the edges renderer
  86371. */
  86372. dispose(): void;
  86373. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86374. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86375. /**
  86376. * Checks if the pair of p0 and p1 is en edge
  86377. * @param faceIndex
  86378. * @param edge
  86379. * @param faceNormals
  86380. * @param p0
  86381. * @param p1
  86382. * @private
  86383. */
  86384. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86385. /**
  86386. * push line into the position, normal and index buffer
  86387. * @protected
  86388. */
  86389. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86390. /**
  86391. * Generates lines edges from adjacencjes
  86392. * @private
  86393. */
  86394. _generateEdgesLines(): void;
  86395. /**
  86396. * Checks wether or not the edges renderer is ready to render.
  86397. * @return true if ready, otherwise false.
  86398. */
  86399. isReady(): boolean;
  86400. /**
  86401. * Renders the edges of the attached mesh,
  86402. */
  86403. render(): void;
  86404. }
  86405. /**
  86406. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86407. */
  86408. export class LineEdgesRenderer extends EdgesRenderer {
  86409. /**
  86410. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86411. * @param source LineMesh used to generate edges
  86412. * @param epsilon not important (specified angle for edge detection)
  86413. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86414. */
  86415. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86416. /**
  86417. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86418. */
  86419. _generateEdgesLines(): void;
  86420. }
  86421. }
  86422. declare module BABYLON {
  86423. /**
  86424. * This represents the object necessary to create a rendering group.
  86425. * This is exclusively used and created by the rendering manager.
  86426. * To modify the behavior, you use the available helpers in your scene or meshes.
  86427. * @hidden
  86428. */
  86429. export class RenderingGroup {
  86430. index: number;
  86431. private static _zeroVector;
  86432. private _scene;
  86433. private _opaqueSubMeshes;
  86434. private _transparentSubMeshes;
  86435. private _alphaTestSubMeshes;
  86436. private _depthOnlySubMeshes;
  86437. private _particleSystems;
  86438. private _spriteManagers;
  86439. private _opaqueSortCompareFn;
  86440. private _alphaTestSortCompareFn;
  86441. private _transparentSortCompareFn;
  86442. private _renderOpaque;
  86443. private _renderAlphaTest;
  86444. private _renderTransparent;
  86445. /** @hidden */
  86446. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86447. onBeforeTransparentRendering: () => void;
  86448. /**
  86449. * Set the opaque sort comparison function.
  86450. * If null the sub meshes will be render in the order they were created
  86451. */
  86452. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86453. /**
  86454. * Set the alpha test sort comparison function.
  86455. * If null the sub meshes will be render in the order they were created
  86456. */
  86457. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86458. /**
  86459. * Set the transparent sort comparison function.
  86460. * If null the sub meshes will be render in the order they were created
  86461. */
  86462. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86463. /**
  86464. * Creates a new rendering group.
  86465. * @param index The rendering group index
  86466. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86467. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86468. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86469. */
  86470. 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>);
  86471. /**
  86472. * Render all the sub meshes contained in the group.
  86473. * @param customRenderFunction Used to override the default render behaviour of the group.
  86474. * @returns true if rendered some submeshes.
  86475. */
  86476. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86477. /**
  86478. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86479. * @param subMeshes The submeshes to render
  86480. */
  86481. private renderOpaqueSorted;
  86482. /**
  86483. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86484. * @param subMeshes The submeshes to render
  86485. */
  86486. private renderAlphaTestSorted;
  86487. /**
  86488. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86489. * @param subMeshes The submeshes to render
  86490. */
  86491. private renderTransparentSorted;
  86492. /**
  86493. * Renders the submeshes in a specified order.
  86494. * @param subMeshes The submeshes to sort before render
  86495. * @param sortCompareFn The comparison function use to sort
  86496. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86497. * @param transparent Specifies to activate blending if true
  86498. */
  86499. private static renderSorted;
  86500. /**
  86501. * Renders the submeshes in the order they were dispatched (no sort applied).
  86502. * @param subMeshes The submeshes to render
  86503. */
  86504. private static renderUnsorted;
  86505. /**
  86506. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86507. * are rendered back to front if in the same alpha index.
  86508. *
  86509. * @param a The first submesh
  86510. * @param b The second submesh
  86511. * @returns The result of the comparison
  86512. */
  86513. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86514. /**
  86515. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86516. * are rendered back to front.
  86517. *
  86518. * @param a The first submesh
  86519. * @param b The second submesh
  86520. * @returns The result of the comparison
  86521. */
  86522. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86523. /**
  86524. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86525. * are rendered front to back (prevent overdraw).
  86526. *
  86527. * @param a The first submesh
  86528. * @param b The second submesh
  86529. * @returns The result of the comparison
  86530. */
  86531. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86532. /**
  86533. * Resets the different lists of submeshes to prepare a new frame.
  86534. */
  86535. prepare(): void;
  86536. dispose(): void;
  86537. /**
  86538. * Inserts the submesh in its correct queue depending on its material.
  86539. * @param subMesh The submesh to dispatch
  86540. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86541. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86542. */
  86543. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86544. dispatchSprites(spriteManager: ISpriteManager): void;
  86545. dispatchParticles(particleSystem: IParticleSystem): void;
  86546. private _renderParticles;
  86547. private _renderSprites;
  86548. }
  86549. }
  86550. declare module BABYLON {
  86551. /**
  86552. * Interface describing the different options available in the rendering manager
  86553. * regarding Auto Clear between groups.
  86554. */
  86555. export interface IRenderingManagerAutoClearSetup {
  86556. /**
  86557. * Defines whether or not autoclear is enable.
  86558. */
  86559. autoClear: boolean;
  86560. /**
  86561. * Defines whether or not to autoclear the depth buffer.
  86562. */
  86563. depth: boolean;
  86564. /**
  86565. * Defines whether or not to autoclear the stencil buffer.
  86566. */
  86567. stencil: boolean;
  86568. }
  86569. /**
  86570. * This class is used by the onRenderingGroupObservable
  86571. */
  86572. export class RenderingGroupInfo {
  86573. /**
  86574. * The Scene that being rendered
  86575. */
  86576. scene: Scene;
  86577. /**
  86578. * The camera currently used for the rendering pass
  86579. */
  86580. camera: Nullable<Camera>;
  86581. /**
  86582. * The ID of the renderingGroup being processed
  86583. */
  86584. renderingGroupId: number;
  86585. }
  86586. /**
  86587. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86588. * It is enable to manage the different groups as well as the different necessary sort functions.
  86589. * This should not be used directly aside of the few static configurations
  86590. */
  86591. export class RenderingManager {
  86592. /**
  86593. * The max id used for rendering groups (not included)
  86594. */
  86595. static MAX_RENDERINGGROUPS: number;
  86596. /**
  86597. * The min id used for rendering groups (included)
  86598. */
  86599. static MIN_RENDERINGGROUPS: number;
  86600. /**
  86601. * Used to globally prevent autoclearing scenes.
  86602. */
  86603. static AUTOCLEAR: boolean;
  86604. /**
  86605. * @hidden
  86606. */
  86607. _useSceneAutoClearSetup: boolean;
  86608. private _scene;
  86609. private _renderingGroups;
  86610. private _depthStencilBufferAlreadyCleaned;
  86611. private _autoClearDepthStencil;
  86612. private _customOpaqueSortCompareFn;
  86613. private _customAlphaTestSortCompareFn;
  86614. private _customTransparentSortCompareFn;
  86615. private _renderingGroupInfo;
  86616. /**
  86617. * Instantiates a new rendering group for a particular scene
  86618. * @param scene Defines the scene the groups belongs to
  86619. */
  86620. constructor(scene: Scene);
  86621. private _clearDepthStencilBuffer;
  86622. /**
  86623. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86624. * @hidden
  86625. */
  86626. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86627. /**
  86628. * Resets the different information of the group to prepare a new frame
  86629. * @hidden
  86630. */
  86631. reset(): void;
  86632. /**
  86633. * Dispose and release the group and its associated resources.
  86634. * @hidden
  86635. */
  86636. dispose(): void;
  86637. /**
  86638. * Clear the info related to rendering groups preventing retention points during dispose.
  86639. */
  86640. freeRenderingGroups(): void;
  86641. private _prepareRenderingGroup;
  86642. /**
  86643. * Add a sprite manager to the rendering manager in order to render it this frame.
  86644. * @param spriteManager Define the sprite manager to render
  86645. */
  86646. dispatchSprites(spriteManager: ISpriteManager): void;
  86647. /**
  86648. * Add a particle system to the rendering manager in order to render it this frame.
  86649. * @param particleSystem Define the particle system to render
  86650. */
  86651. dispatchParticles(particleSystem: IParticleSystem): void;
  86652. /**
  86653. * Add a submesh to the manager in order to render it this frame
  86654. * @param subMesh The submesh to dispatch
  86655. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86656. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86657. */
  86658. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86659. /**
  86660. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86661. * This allowed control for front to back rendering or reversly depending of the special needs.
  86662. *
  86663. * @param renderingGroupId The rendering group id corresponding to its index
  86664. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86665. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86666. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86667. */
  86668. 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;
  86669. /**
  86670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86671. *
  86672. * @param renderingGroupId The rendering group id corresponding to its index
  86673. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86674. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86675. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86676. */
  86677. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86678. /**
  86679. * Gets the current auto clear configuration for one rendering group of the rendering
  86680. * manager.
  86681. * @param index the rendering group index to get the information for
  86682. * @returns The auto clear setup for the requested rendering group
  86683. */
  86684. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86685. }
  86686. }
  86687. declare module BABYLON {
  86688. /**
  86689. * This Helps creating a texture that will be created from a camera in your scene.
  86690. * It is basically a dynamic texture that could be used to create special effects for instance.
  86691. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86692. */
  86693. export class RenderTargetTexture extends Texture {
  86694. isCube: boolean;
  86695. /**
  86696. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86697. */
  86698. static readonly REFRESHRATE_RENDER_ONCE: number;
  86699. /**
  86700. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86701. */
  86702. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86703. /**
  86704. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86705. * the central point of your effect and can save a lot of performances.
  86706. */
  86707. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86708. /**
  86709. * Use this predicate to dynamically define the list of mesh you want to render.
  86710. * If set, the renderList property will be overwritten.
  86711. */
  86712. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86713. private _renderList;
  86714. /**
  86715. * Use this list to define the list of mesh you want to render.
  86716. */
  86717. renderList: Nullable<Array<AbstractMesh>>;
  86718. private _hookArray;
  86719. /**
  86720. * Define if particles should be rendered in your texture.
  86721. */
  86722. renderParticles: boolean;
  86723. /**
  86724. * Define if sprites should be rendered in your texture.
  86725. */
  86726. renderSprites: boolean;
  86727. /**
  86728. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86729. */
  86730. coordinatesMode: number;
  86731. /**
  86732. * Define the camera used to render the texture.
  86733. */
  86734. activeCamera: Nullable<Camera>;
  86735. /**
  86736. * Override the render function of the texture with your own one.
  86737. */
  86738. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86739. /**
  86740. * Define if camera post processes should be use while rendering the texture.
  86741. */
  86742. useCameraPostProcesses: boolean;
  86743. /**
  86744. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86745. */
  86746. ignoreCameraViewport: boolean;
  86747. private _postProcessManager;
  86748. private _postProcesses;
  86749. private _resizeObserver;
  86750. /**
  86751. * An event triggered when the texture is unbind.
  86752. */
  86753. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86754. /**
  86755. * An event triggered when the texture is unbind.
  86756. */
  86757. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86758. private _onAfterUnbindObserver;
  86759. /**
  86760. * Set a after unbind callback in the texture.
  86761. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86762. */
  86763. onAfterUnbind: () => void;
  86764. /**
  86765. * An event triggered before rendering the texture
  86766. */
  86767. onBeforeRenderObservable: Observable<number>;
  86768. private _onBeforeRenderObserver;
  86769. /**
  86770. * Set a before render callback in the texture.
  86771. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86772. */
  86773. onBeforeRender: (faceIndex: number) => void;
  86774. /**
  86775. * An event triggered after rendering the texture
  86776. */
  86777. onAfterRenderObservable: Observable<number>;
  86778. private _onAfterRenderObserver;
  86779. /**
  86780. * Set a after render callback in the texture.
  86781. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86782. */
  86783. onAfterRender: (faceIndex: number) => void;
  86784. /**
  86785. * An event triggered after the texture clear
  86786. */
  86787. onClearObservable: Observable<Engine>;
  86788. private _onClearObserver;
  86789. /**
  86790. * Set a clear callback in the texture.
  86791. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86792. */
  86793. onClear: (Engine: Engine) => void;
  86794. /**
  86795. * An event triggered when the texture is resized.
  86796. */
  86797. onResizeObservable: Observable<RenderTargetTexture>;
  86798. /**
  86799. * Define the clear color of the Render Target if it should be different from the scene.
  86800. */
  86801. clearColor: Color4;
  86802. protected _size: number | {
  86803. width: number;
  86804. height: number;
  86805. };
  86806. protected _initialSizeParameter: number | {
  86807. width: number;
  86808. height: number;
  86809. } | {
  86810. ratio: number;
  86811. };
  86812. protected _sizeRatio: Nullable<number>;
  86813. /** @hidden */
  86814. _generateMipMaps: boolean;
  86815. protected _renderingManager: RenderingManager;
  86816. /** @hidden */
  86817. _waitingRenderList: string[];
  86818. protected _doNotChangeAspectRatio: boolean;
  86819. protected _currentRefreshId: number;
  86820. protected _refreshRate: number;
  86821. protected _textureMatrix: Matrix;
  86822. protected _samples: number;
  86823. protected _renderTargetOptions: RenderTargetCreationOptions;
  86824. /**
  86825. * Gets render target creation options that were used.
  86826. */
  86827. readonly renderTargetOptions: RenderTargetCreationOptions;
  86828. protected _engine: Engine;
  86829. protected _onRatioRescale(): void;
  86830. /**
  86831. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86832. * It must define where the camera used to render the texture is set
  86833. */
  86834. boundingBoxPosition: Vector3;
  86835. private _boundingBoxSize;
  86836. /**
  86837. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86838. * When defined, the cubemap will switch to local mode
  86839. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86840. * @example https://www.babylonjs-playground.com/#RNASML
  86841. */
  86842. boundingBoxSize: Vector3;
  86843. /**
  86844. * In case the RTT has been created with a depth texture, get the associated
  86845. * depth texture.
  86846. * Otherwise, return null.
  86847. */
  86848. depthStencilTexture: Nullable<InternalTexture>;
  86849. /**
  86850. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86851. * or used a shadow, depth texture...
  86852. * @param name The friendly name of the texture
  86853. * @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)
  86854. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86855. * @param generateMipMaps True if mip maps need to be generated after render.
  86856. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86857. * @param type The type of the buffer in the RTT (int, half float, float...)
  86858. * @param isCube True if a cube texture needs to be created
  86859. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86860. * @param generateDepthBuffer True to generate a depth buffer
  86861. * @param generateStencilBuffer True to generate a stencil buffer
  86862. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86863. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86864. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86865. */
  86866. constructor(name: string, size: number | {
  86867. width: number;
  86868. height: number;
  86869. } | {
  86870. ratio: number;
  86871. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86872. /**
  86873. * Creates a depth stencil texture.
  86874. * This is only available in WebGL 2 or with the depth texture extension available.
  86875. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86876. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86877. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86878. */
  86879. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86880. private _processSizeParameter;
  86881. /**
  86882. * Define the number of samples to use in case of MSAA.
  86883. * It defaults to one meaning no MSAA has been enabled.
  86884. */
  86885. samples: number;
  86886. /**
  86887. * Resets the refresh counter of the texture and start bak from scratch.
  86888. * Could be useful to regenerate the texture if it is setup to render only once.
  86889. */
  86890. resetRefreshCounter(): void;
  86891. /**
  86892. * Define the refresh rate of the texture or the rendering frequency.
  86893. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86894. */
  86895. refreshRate: number;
  86896. /**
  86897. * Adds a post process to the render target rendering passes.
  86898. * @param postProcess define the post process to add
  86899. */
  86900. addPostProcess(postProcess: PostProcess): void;
  86901. /**
  86902. * Clear all the post processes attached to the render target
  86903. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86904. */
  86905. clearPostProcesses(dispose?: boolean): void;
  86906. /**
  86907. * Remove one of the post process from the list of attached post processes to the texture
  86908. * @param postProcess define the post process to remove from the list
  86909. */
  86910. removePostProcess(postProcess: PostProcess): void;
  86911. /** @hidden */
  86912. _shouldRender(): boolean;
  86913. /**
  86914. * Gets the actual render size of the texture.
  86915. * @returns the width of the render size
  86916. */
  86917. getRenderSize(): number;
  86918. /**
  86919. * Gets the actual render width of the texture.
  86920. * @returns the width of the render size
  86921. */
  86922. getRenderWidth(): number;
  86923. /**
  86924. * Gets the actual render height of the texture.
  86925. * @returns the height of the render size
  86926. */
  86927. getRenderHeight(): number;
  86928. /**
  86929. * Get if the texture can be rescaled or not.
  86930. */
  86931. readonly canRescale: boolean;
  86932. /**
  86933. * Resize the texture using a ratio.
  86934. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86935. */
  86936. scale(ratio: number): void;
  86937. /**
  86938. * Get the texture reflection matrix used to rotate/transform the reflection.
  86939. * @returns the reflection matrix
  86940. */
  86941. getReflectionTextureMatrix(): Matrix;
  86942. /**
  86943. * Resize the texture to a new desired size.
  86944. * Be carrefull as it will recreate all the data in the new texture.
  86945. * @param size Define the new size. It can be:
  86946. * - a number for squared texture,
  86947. * - an object containing { width: number, height: number }
  86948. * - or an object containing a ratio { ratio: number }
  86949. */
  86950. resize(size: number | {
  86951. width: number;
  86952. height: number;
  86953. } | {
  86954. ratio: number;
  86955. }): void;
  86956. /**
  86957. * Renders all the objects from the render list into the texture.
  86958. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86959. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86960. */
  86961. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86962. private _bestReflectionRenderTargetDimension;
  86963. /**
  86964. * @hidden
  86965. * @param faceIndex face index to bind to if this is a cubetexture
  86966. */
  86967. _bindFrameBuffer(faceIndex?: number): void;
  86968. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86969. private renderToTarget;
  86970. /**
  86971. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86972. * This allowed control for front to back rendering or reversly depending of the special needs.
  86973. *
  86974. * @param renderingGroupId The rendering group id corresponding to its index
  86975. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86976. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86977. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86978. */
  86979. 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;
  86980. /**
  86981. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86982. *
  86983. * @param renderingGroupId The rendering group id corresponding to its index
  86984. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86985. */
  86986. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86987. /**
  86988. * Clones the texture.
  86989. * @returns the cloned texture
  86990. */
  86991. clone(): RenderTargetTexture;
  86992. /**
  86993. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86994. * @returns The JSON representation of the texture
  86995. */
  86996. serialize(): any;
  86997. /**
  86998. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86999. */
  87000. disposeFramebufferObjects(): void;
  87001. /**
  87002. * Dispose the texture and release its associated resources.
  87003. */
  87004. dispose(): void;
  87005. /** @hidden */
  87006. _rebuild(): void;
  87007. /**
  87008. * Clear the info related to rendering groups preventing retention point in material dispose.
  87009. */
  87010. freeRenderingGroups(): void;
  87011. /**
  87012. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87013. * @returns the view count
  87014. */
  87015. getViewCount(): number;
  87016. }
  87017. }
  87018. declare module BABYLON {
  87019. /**
  87020. * Base class for the main features of a material in Babylon.js
  87021. */
  87022. export class Material implements IAnimatable {
  87023. /**
  87024. * Returns the triangle fill mode
  87025. */
  87026. static readonly TriangleFillMode: number;
  87027. /**
  87028. * Returns the wireframe mode
  87029. */
  87030. static readonly WireFrameFillMode: number;
  87031. /**
  87032. * Returns the point fill mode
  87033. */
  87034. static readonly PointFillMode: number;
  87035. /**
  87036. * Returns the point list draw mode
  87037. */
  87038. static readonly PointListDrawMode: number;
  87039. /**
  87040. * Returns the line list draw mode
  87041. */
  87042. static readonly LineListDrawMode: number;
  87043. /**
  87044. * Returns the line loop draw mode
  87045. */
  87046. static readonly LineLoopDrawMode: number;
  87047. /**
  87048. * Returns the line strip draw mode
  87049. */
  87050. static readonly LineStripDrawMode: number;
  87051. /**
  87052. * Returns the triangle strip draw mode
  87053. */
  87054. static readonly TriangleStripDrawMode: number;
  87055. /**
  87056. * Returns the triangle fan draw mode
  87057. */
  87058. static readonly TriangleFanDrawMode: number;
  87059. /**
  87060. * Stores the clock-wise side orientation
  87061. */
  87062. static readonly ClockWiseSideOrientation: number;
  87063. /**
  87064. * Stores the counter clock-wise side orientation
  87065. */
  87066. static readonly CounterClockWiseSideOrientation: number;
  87067. /**
  87068. * The dirty texture flag value
  87069. */
  87070. static readonly TextureDirtyFlag: number;
  87071. /**
  87072. * The dirty light flag value
  87073. */
  87074. static readonly LightDirtyFlag: number;
  87075. /**
  87076. * The dirty fresnel flag value
  87077. */
  87078. static readonly FresnelDirtyFlag: number;
  87079. /**
  87080. * The dirty attribute flag value
  87081. */
  87082. static readonly AttributesDirtyFlag: number;
  87083. /**
  87084. * The dirty misc flag value
  87085. */
  87086. static readonly MiscDirtyFlag: number;
  87087. /**
  87088. * The all dirty flag value
  87089. */
  87090. static readonly AllDirtyFlag: number;
  87091. /**
  87092. * The ID of the material
  87093. */
  87094. id: string;
  87095. /**
  87096. * Gets or sets the unique id of the material
  87097. */
  87098. uniqueId: number;
  87099. /**
  87100. * The name of the material
  87101. */
  87102. name: string;
  87103. /**
  87104. * Gets or sets user defined metadata
  87105. */
  87106. metadata: any;
  87107. /**
  87108. * For internal use only. Please do not use.
  87109. */
  87110. reservedDataStore: any;
  87111. /**
  87112. * Specifies if the ready state should be checked on each call
  87113. */
  87114. checkReadyOnEveryCall: boolean;
  87115. /**
  87116. * Specifies if the ready state should be checked once
  87117. */
  87118. checkReadyOnlyOnce: boolean;
  87119. /**
  87120. * The state of the material
  87121. */
  87122. state: string;
  87123. /**
  87124. * The alpha value of the material
  87125. */
  87126. protected _alpha: number;
  87127. /**
  87128. * List of inspectable custom properties (used by the Inspector)
  87129. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87130. */
  87131. inspectableCustomProperties: IInspectable[];
  87132. /**
  87133. * Sets the alpha value of the material
  87134. */
  87135. /**
  87136. * Gets the alpha value of the material
  87137. */
  87138. alpha: number;
  87139. /**
  87140. * Specifies if back face culling is enabled
  87141. */
  87142. protected _backFaceCulling: boolean;
  87143. /**
  87144. * Sets the back-face culling state
  87145. */
  87146. /**
  87147. * Gets the back-face culling state
  87148. */
  87149. backFaceCulling: boolean;
  87150. /**
  87151. * Stores the value for side orientation
  87152. */
  87153. sideOrientation: number;
  87154. /**
  87155. * Callback triggered when the material is compiled
  87156. */
  87157. onCompiled: Nullable<(effect: Effect) => void>;
  87158. /**
  87159. * Callback triggered when an error occurs
  87160. */
  87161. onError: Nullable<(effect: Effect, errors: string) => void>;
  87162. /**
  87163. * Callback triggered to get the render target textures
  87164. */
  87165. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87166. /**
  87167. * Gets a boolean indicating that current material needs to register RTT
  87168. */
  87169. readonly hasRenderTargetTextures: boolean;
  87170. /**
  87171. * Specifies if the material should be serialized
  87172. */
  87173. doNotSerialize: boolean;
  87174. /**
  87175. * @hidden
  87176. */
  87177. _storeEffectOnSubMeshes: boolean;
  87178. /**
  87179. * Stores the animations for the material
  87180. */
  87181. animations: Nullable<Array<Animation>>;
  87182. /**
  87183. * An event triggered when the material is disposed
  87184. */
  87185. onDisposeObservable: Observable<Material>;
  87186. /**
  87187. * An observer which watches for dispose events
  87188. */
  87189. private _onDisposeObserver;
  87190. private _onUnBindObservable;
  87191. /**
  87192. * Called during a dispose event
  87193. */
  87194. onDispose: () => void;
  87195. private _onBindObservable;
  87196. /**
  87197. * An event triggered when the material is bound
  87198. */
  87199. readonly onBindObservable: Observable<AbstractMesh>;
  87200. /**
  87201. * An observer which watches for bind events
  87202. */
  87203. private _onBindObserver;
  87204. /**
  87205. * Called during a bind event
  87206. */
  87207. onBind: (Mesh: AbstractMesh) => void;
  87208. /**
  87209. * An event triggered when the material is unbound
  87210. */
  87211. readonly onUnBindObservable: Observable<Material>;
  87212. /**
  87213. * Stores the value of the alpha mode
  87214. */
  87215. private _alphaMode;
  87216. /**
  87217. * Sets the value of the alpha mode.
  87218. *
  87219. * | Value | Type | Description |
  87220. * | --- | --- | --- |
  87221. * | 0 | ALPHA_DISABLE | |
  87222. * | 1 | ALPHA_ADD | |
  87223. * | 2 | ALPHA_COMBINE | |
  87224. * | 3 | ALPHA_SUBTRACT | |
  87225. * | 4 | ALPHA_MULTIPLY | |
  87226. * | 5 | ALPHA_MAXIMIZED | |
  87227. * | 6 | ALPHA_ONEONE | |
  87228. * | 7 | ALPHA_PREMULTIPLIED | |
  87229. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87230. * | 9 | ALPHA_INTERPOLATE | |
  87231. * | 10 | ALPHA_SCREENMODE | |
  87232. *
  87233. */
  87234. /**
  87235. * Gets the value of the alpha mode
  87236. */
  87237. alphaMode: number;
  87238. /**
  87239. * Stores the state of the need depth pre-pass value
  87240. */
  87241. private _needDepthPrePass;
  87242. /**
  87243. * Sets the need depth pre-pass value
  87244. */
  87245. /**
  87246. * Gets the depth pre-pass value
  87247. */
  87248. needDepthPrePass: boolean;
  87249. /**
  87250. * Specifies if depth writing should be disabled
  87251. */
  87252. disableDepthWrite: boolean;
  87253. /**
  87254. * Specifies if depth writing should be forced
  87255. */
  87256. forceDepthWrite: boolean;
  87257. /**
  87258. * Specifies if there should be a separate pass for culling
  87259. */
  87260. separateCullingPass: boolean;
  87261. /**
  87262. * Stores the state specifing if fog should be enabled
  87263. */
  87264. private _fogEnabled;
  87265. /**
  87266. * Sets the state for enabling fog
  87267. */
  87268. /**
  87269. * Gets the value of the fog enabled state
  87270. */
  87271. fogEnabled: boolean;
  87272. /**
  87273. * Stores the size of points
  87274. */
  87275. pointSize: number;
  87276. /**
  87277. * Stores the z offset value
  87278. */
  87279. zOffset: number;
  87280. /**
  87281. * Gets a value specifying if wireframe mode is enabled
  87282. */
  87283. /**
  87284. * Sets the state of wireframe mode
  87285. */
  87286. wireframe: boolean;
  87287. /**
  87288. * Gets the value specifying if point clouds are enabled
  87289. */
  87290. /**
  87291. * Sets the state of point cloud mode
  87292. */
  87293. pointsCloud: boolean;
  87294. /**
  87295. * Gets the material fill mode
  87296. */
  87297. /**
  87298. * Sets the material fill mode
  87299. */
  87300. fillMode: number;
  87301. /**
  87302. * @hidden
  87303. * Stores the effects for the material
  87304. */
  87305. _effect: Nullable<Effect>;
  87306. /**
  87307. * @hidden
  87308. * Specifies if the material was previously ready
  87309. */
  87310. _wasPreviouslyReady: boolean;
  87311. /**
  87312. * Specifies if uniform buffers should be used
  87313. */
  87314. private _useUBO;
  87315. /**
  87316. * Stores a reference to the scene
  87317. */
  87318. private _scene;
  87319. /**
  87320. * Stores the fill mode state
  87321. */
  87322. private _fillMode;
  87323. /**
  87324. * Specifies if the depth write state should be cached
  87325. */
  87326. private _cachedDepthWriteState;
  87327. /**
  87328. * Stores the uniform buffer
  87329. */
  87330. protected _uniformBuffer: UniformBuffer;
  87331. /** @hidden */
  87332. _indexInSceneMaterialArray: number;
  87333. /** @hidden */
  87334. meshMap: Nullable<{
  87335. [id: string]: AbstractMesh | undefined;
  87336. }>;
  87337. /**
  87338. * Creates a material instance
  87339. * @param name defines the name of the material
  87340. * @param scene defines the scene to reference
  87341. * @param doNotAdd specifies if the material should be added to the scene
  87342. */
  87343. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87344. /**
  87345. * Returns a string representation of the current material
  87346. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87347. * @returns a string with material information
  87348. */
  87349. toString(fullDetails?: boolean): string;
  87350. /**
  87351. * Gets the class name of the material
  87352. * @returns a string with the class name of the material
  87353. */
  87354. getClassName(): string;
  87355. /**
  87356. * Specifies if updates for the material been locked
  87357. */
  87358. readonly isFrozen: boolean;
  87359. /**
  87360. * Locks updates for the material
  87361. */
  87362. freeze(): void;
  87363. /**
  87364. * Unlocks updates for the material
  87365. */
  87366. unfreeze(): void;
  87367. /**
  87368. * Specifies if the material is ready to be used
  87369. * @param mesh defines the mesh to check
  87370. * @param useInstances specifies if instances should be used
  87371. * @returns a boolean indicating if the material is ready to be used
  87372. */
  87373. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87374. /**
  87375. * Specifies that the submesh is ready to be used
  87376. * @param mesh defines the mesh to check
  87377. * @param subMesh defines which submesh to check
  87378. * @param useInstances specifies that instances should be used
  87379. * @returns a boolean indicating that the submesh is ready or not
  87380. */
  87381. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87382. /**
  87383. * Returns the material effect
  87384. * @returns the effect associated with the material
  87385. */
  87386. getEffect(): Nullable<Effect>;
  87387. /**
  87388. * Returns the current scene
  87389. * @returns a Scene
  87390. */
  87391. getScene(): Scene;
  87392. /**
  87393. * Specifies if the material will require alpha blending
  87394. * @returns a boolean specifying if alpha blending is needed
  87395. */
  87396. needAlphaBlending(): boolean;
  87397. /**
  87398. * Specifies if the mesh will require alpha blending
  87399. * @param mesh defines the mesh to check
  87400. * @returns a boolean specifying if alpha blending is needed for the mesh
  87401. */
  87402. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87403. /**
  87404. * Specifies if this material should be rendered in alpha test mode
  87405. * @returns a boolean specifying if an alpha test is needed.
  87406. */
  87407. needAlphaTesting(): boolean;
  87408. /**
  87409. * Gets the texture used for the alpha test
  87410. * @returns the texture to use for alpha testing
  87411. */
  87412. getAlphaTestTexture(): Nullable<BaseTexture>;
  87413. /**
  87414. * Marks the material to indicate that it needs to be re-calculated
  87415. */
  87416. markDirty(): void;
  87417. /** @hidden */
  87418. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87419. /**
  87420. * Binds the material to the mesh
  87421. * @param world defines the world transformation matrix
  87422. * @param mesh defines the mesh to bind the material to
  87423. */
  87424. bind(world: Matrix, mesh?: Mesh): void;
  87425. /**
  87426. * Binds the submesh to the material
  87427. * @param world defines the world transformation matrix
  87428. * @param mesh defines the mesh containing the submesh
  87429. * @param subMesh defines the submesh to bind the material to
  87430. */
  87431. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87432. /**
  87433. * Binds the world matrix to the material
  87434. * @param world defines the world transformation matrix
  87435. */
  87436. bindOnlyWorldMatrix(world: Matrix): void;
  87437. /**
  87438. * Binds the scene's uniform buffer to the effect.
  87439. * @param effect defines the effect to bind to the scene uniform buffer
  87440. * @param sceneUbo defines the uniform buffer storing scene data
  87441. */
  87442. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87443. /**
  87444. * Binds the view matrix to the effect
  87445. * @param effect defines the effect to bind the view matrix to
  87446. */
  87447. bindView(effect: Effect): void;
  87448. /**
  87449. * Binds the view projection matrix to the effect
  87450. * @param effect defines the effect to bind the view projection matrix to
  87451. */
  87452. bindViewProjection(effect: Effect): void;
  87453. /**
  87454. * Specifies if material alpha testing should be turned on for the mesh
  87455. * @param mesh defines the mesh to check
  87456. */
  87457. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87458. /**
  87459. * Processes to execute after binding the material to a mesh
  87460. * @param mesh defines the rendered mesh
  87461. */
  87462. protected _afterBind(mesh?: Mesh): void;
  87463. /**
  87464. * Unbinds the material from the mesh
  87465. */
  87466. unbind(): void;
  87467. /**
  87468. * Gets the active textures from the material
  87469. * @returns an array of textures
  87470. */
  87471. getActiveTextures(): BaseTexture[];
  87472. /**
  87473. * Specifies if the material uses a texture
  87474. * @param texture defines the texture to check against the material
  87475. * @returns a boolean specifying if the material uses the texture
  87476. */
  87477. hasTexture(texture: BaseTexture): boolean;
  87478. /**
  87479. * Makes a duplicate of the material, and gives it a new name
  87480. * @param name defines the new name for the duplicated material
  87481. * @returns the cloned material
  87482. */
  87483. clone(name: string): Nullable<Material>;
  87484. /**
  87485. * Gets the meshes bound to the material
  87486. * @returns an array of meshes bound to the material
  87487. */
  87488. getBindedMeshes(): AbstractMesh[];
  87489. /**
  87490. * Force shader compilation
  87491. * @param mesh defines the mesh associated with this material
  87492. * @param onCompiled defines a function to execute once the material is compiled
  87493. * @param options defines the options to configure the compilation
  87494. */
  87495. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87496. clipPlane: boolean;
  87497. }>): void;
  87498. /**
  87499. * Force shader compilation
  87500. * @param mesh defines the mesh that will use this material
  87501. * @param options defines additional options for compiling the shaders
  87502. * @returns a promise that resolves when the compilation completes
  87503. */
  87504. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87505. clipPlane: boolean;
  87506. }>): Promise<void>;
  87507. private static readonly _AllDirtyCallBack;
  87508. private static readonly _ImageProcessingDirtyCallBack;
  87509. private static readonly _TextureDirtyCallBack;
  87510. private static readonly _FresnelDirtyCallBack;
  87511. private static readonly _MiscDirtyCallBack;
  87512. private static readonly _LightsDirtyCallBack;
  87513. private static readonly _AttributeDirtyCallBack;
  87514. private static _FresnelAndMiscDirtyCallBack;
  87515. private static _TextureAndMiscDirtyCallBack;
  87516. private static readonly _DirtyCallbackArray;
  87517. private static readonly _RunDirtyCallBacks;
  87518. /**
  87519. * Marks a define in the material to indicate that it needs to be re-computed
  87520. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87521. */
  87522. markAsDirty(flag: number): void;
  87523. /**
  87524. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87525. * @param func defines a function which checks material defines against the submeshes
  87526. */
  87527. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87528. /**
  87529. * Indicates that we need to re-calculated for all submeshes
  87530. */
  87531. protected _markAllSubMeshesAsAllDirty(): void;
  87532. /**
  87533. * Indicates that image processing needs to be re-calculated for all submeshes
  87534. */
  87535. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87536. /**
  87537. * Indicates that textures need to be re-calculated for all submeshes
  87538. */
  87539. protected _markAllSubMeshesAsTexturesDirty(): void;
  87540. /**
  87541. * Indicates that fresnel needs to be re-calculated for all submeshes
  87542. */
  87543. protected _markAllSubMeshesAsFresnelDirty(): void;
  87544. /**
  87545. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87546. */
  87547. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87548. /**
  87549. * Indicates that lights need to be re-calculated for all submeshes
  87550. */
  87551. protected _markAllSubMeshesAsLightsDirty(): void;
  87552. /**
  87553. * Indicates that attributes need to be re-calculated for all submeshes
  87554. */
  87555. protected _markAllSubMeshesAsAttributesDirty(): void;
  87556. /**
  87557. * Indicates that misc needs to be re-calculated for all submeshes
  87558. */
  87559. protected _markAllSubMeshesAsMiscDirty(): void;
  87560. /**
  87561. * Indicates that textures and misc need to be re-calculated for all submeshes
  87562. */
  87563. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87564. /**
  87565. * Disposes the material
  87566. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87567. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87568. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87569. */
  87570. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87571. /** @hidden */
  87572. private releaseVertexArrayObject;
  87573. /**
  87574. * Serializes this material
  87575. * @returns the serialized material object
  87576. */
  87577. serialize(): any;
  87578. /**
  87579. * Creates a material from parsed material data
  87580. * @param parsedMaterial defines parsed material data
  87581. * @param scene defines the hosting scene
  87582. * @param rootUrl defines the root URL to use to load textures
  87583. * @returns a new material
  87584. */
  87585. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87586. }
  87587. }
  87588. declare module BABYLON {
  87589. /**
  87590. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87591. * separate meshes. This can be use to improve performances.
  87592. * @see http://doc.babylonjs.com/how_to/multi_materials
  87593. */
  87594. export class MultiMaterial extends Material {
  87595. private _subMaterials;
  87596. /**
  87597. * Gets or Sets the list of Materials used within the multi material.
  87598. * They need to be ordered according to the submeshes order in the associated mesh
  87599. */
  87600. subMaterials: Nullable<Material>[];
  87601. /**
  87602. * Function used to align with Node.getChildren()
  87603. * @returns the list of Materials used within the multi material
  87604. */
  87605. getChildren(): Nullable<Material>[];
  87606. /**
  87607. * Instantiates a new Multi Material
  87608. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87609. * separate meshes. This can be use to improve performances.
  87610. * @see http://doc.babylonjs.com/how_to/multi_materials
  87611. * @param name Define the name in the scene
  87612. * @param scene Define the scene the material belongs to
  87613. */
  87614. constructor(name: string, scene: Scene);
  87615. private _hookArray;
  87616. /**
  87617. * Get one of the submaterial by its index in the submaterials array
  87618. * @param index The index to look the sub material at
  87619. * @returns The Material if the index has been defined
  87620. */
  87621. getSubMaterial(index: number): Nullable<Material>;
  87622. /**
  87623. * Get the list of active textures for the whole sub materials list.
  87624. * @returns All the textures that will be used during the rendering
  87625. */
  87626. getActiveTextures(): BaseTexture[];
  87627. /**
  87628. * Gets the current class name of the material e.g. "MultiMaterial"
  87629. * Mainly use in serialization.
  87630. * @returns the class name
  87631. */
  87632. getClassName(): string;
  87633. /**
  87634. * Checks if the material is ready to render the requested sub mesh
  87635. * @param mesh Define the mesh the submesh belongs to
  87636. * @param subMesh Define the sub mesh to look readyness for
  87637. * @param useInstances Define whether or not the material is used with instances
  87638. * @returns true if ready, otherwise false
  87639. */
  87640. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87641. /**
  87642. * Clones the current material and its related sub materials
  87643. * @param name Define the name of the newly cloned material
  87644. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87645. * @returns the cloned material
  87646. */
  87647. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87648. /**
  87649. * Serializes the materials into a JSON representation.
  87650. * @returns the JSON representation
  87651. */
  87652. serialize(): any;
  87653. /**
  87654. * Dispose the material and release its associated resources
  87655. * @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)
  87656. * @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)
  87657. * @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)
  87658. */
  87659. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87660. /**
  87661. * Creates a MultiMaterial from parsed MultiMaterial data.
  87662. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87663. * @param scene defines the hosting scene
  87664. * @returns a new MultiMaterial
  87665. */
  87666. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87667. }
  87668. }
  87669. declare module BABYLON {
  87670. /**
  87671. * Base class for submeshes
  87672. */
  87673. export class BaseSubMesh {
  87674. /** @hidden */
  87675. _materialDefines: Nullable<MaterialDefines>;
  87676. /** @hidden */
  87677. _materialEffect: Nullable<Effect>;
  87678. /**
  87679. * Gets associated effect
  87680. */
  87681. readonly effect: Nullable<Effect>;
  87682. /**
  87683. * Sets associated effect (effect used to render this submesh)
  87684. * @param effect defines the effect to associate with
  87685. * @param defines defines the set of defines used to compile this effect
  87686. */
  87687. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87688. }
  87689. /**
  87690. * Defines a subdivision inside a mesh
  87691. */
  87692. export class SubMesh extends BaseSubMesh implements ICullable {
  87693. /** the material index to use */
  87694. materialIndex: number;
  87695. /** vertex index start */
  87696. verticesStart: number;
  87697. /** vertices count */
  87698. verticesCount: number;
  87699. /** index start */
  87700. indexStart: number;
  87701. /** indices count */
  87702. indexCount: number;
  87703. /** @hidden */
  87704. _linesIndexCount: number;
  87705. private _mesh;
  87706. private _renderingMesh;
  87707. private _boundingInfo;
  87708. private _linesIndexBuffer;
  87709. /** @hidden */
  87710. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87711. /** @hidden */
  87712. _trianglePlanes: Plane[];
  87713. /** @hidden */
  87714. _lastColliderTransformMatrix: Nullable<Matrix>;
  87715. /** @hidden */
  87716. _renderId: number;
  87717. /** @hidden */
  87718. _alphaIndex: number;
  87719. /** @hidden */
  87720. _distanceToCamera: number;
  87721. /** @hidden */
  87722. _id: number;
  87723. private _currentMaterial;
  87724. /**
  87725. * Add a new submesh to a mesh
  87726. * @param materialIndex defines the material index to use
  87727. * @param verticesStart defines vertex index start
  87728. * @param verticesCount defines vertices count
  87729. * @param indexStart defines index start
  87730. * @param indexCount defines indices count
  87731. * @param mesh defines the parent mesh
  87732. * @param renderingMesh defines an optional rendering mesh
  87733. * @param createBoundingBox defines if bounding box should be created for this submesh
  87734. * @returns the new submesh
  87735. */
  87736. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87737. /**
  87738. * Creates a new submesh
  87739. * @param materialIndex defines the material index to use
  87740. * @param verticesStart defines vertex index start
  87741. * @param verticesCount defines vertices count
  87742. * @param indexStart defines index start
  87743. * @param indexCount defines indices count
  87744. * @param mesh defines the parent mesh
  87745. * @param renderingMesh defines an optional rendering mesh
  87746. * @param createBoundingBox defines if bounding box should be created for this submesh
  87747. */
  87748. constructor(
  87749. /** the material index to use */
  87750. materialIndex: number,
  87751. /** vertex index start */
  87752. verticesStart: number,
  87753. /** vertices count */
  87754. verticesCount: number,
  87755. /** index start */
  87756. indexStart: number,
  87757. /** indices count */
  87758. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87759. /**
  87760. * Returns true if this submesh covers the entire parent mesh
  87761. * @ignorenaming
  87762. */
  87763. readonly IsGlobal: boolean;
  87764. /**
  87765. * Returns the submesh BoudingInfo object
  87766. * @returns current bounding info (or mesh's one if the submesh is global)
  87767. */
  87768. getBoundingInfo(): BoundingInfo;
  87769. /**
  87770. * Sets the submesh BoundingInfo
  87771. * @param boundingInfo defines the new bounding info to use
  87772. * @returns the SubMesh
  87773. */
  87774. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87775. /**
  87776. * Returns the mesh of the current submesh
  87777. * @return the parent mesh
  87778. */
  87779. getMesh(): AbstractMesh;
  87780. /**
  87781. * Returns the rendering mesh of the submesh
  87782. * @returns the rendering mesh (could be different from parent mesh)
  87783. */
  87784. getRenderingMesh(): Mesh;
  87785. /**
  87786. * Returns the submesh material
  87787. * @returns null or the current material
  87788. */
  87789. getMaterial(): Nullable<Material>;
  87790. /**
  87791. * Sets a new updated BoundingInfo object to the submesh
  87792. * @param data defines an optional position array to use to determine the bounding info
  87793. * @returns the SubMesh
  87794. */
  87795. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87796. /** @hidden */
  87797. _checkCollision(collider: Collider): boolean;
  87798. /**
  87799. * Updates the submesh BoundingInfo
  87800. * @param world defines the world matrix to use to update the bounding info
  87801. * @returns the submesh
  87802. */
  87803. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87804. /**
  87805. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87806. * @param frustumPlanes defines the frustum planes
  87807. * @returns true if the submesh is intersecting with the frustum
  87808. */
  87809. isInFrustum(frustumPlanes: Plane[]): boolean;
  87810. /**
  87811. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87812. * @param frustumPlanes defines the frustum planes
  87813. * @returns true if the submesh is inside the frustum
  87814. */
  87815. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87816. /**
  87817. * Renders the submesh
  87818. * @param enableAlphaMode defines if alpha needs to be used
  87819. * @returns the submesh
  87820. */
  87821. render(enableAlphaMode: boolean): SubMesh;
  87822. /**
  87823. * @hidden
  87824. */
  87825. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87826. /**
  87827. * Checks if the submesh intersects with a ray
  87828. * @param ray defines the ray to test
  87829. * @returns true is the passed ray intersects the submesh bounding box
  87830. */
  87831. canIntersects(ray: Ray): boolean;
  87832. /**
  87833. * Intersects current submesh with a ray
  87834. * @param ray defines the ray to test
  87835. * @param positions defines mesh's positions array
  87836. * @param indices defines mesh's indices array
  87837. * @param fastCheck defines if only bounding info should be used
  87838. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87839. * @returns intersection info or null if no intersection
  87840. */
  87841. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87842. /** @hidden */
  87843. private _intersectLines;
  87844. /** @hidden */
  87845. private _intersectUnIndexedLines;
  87846. /** @hidden */
  87847. private _intersectTriangles;
  87848. /** @hidden */
  87849. private _intersectUnIndexedTriangles;
  87850. /** @hidden */
  87851. _rebuild(): void;
  87852. /**
  87853. * Creates a new submesh from the passed mesh
  87854. * @param newMesh defines the new hosting mesh
  87855. * @param newRenderingMesh defines an optional rendering mesh
  87856. * @returns the new submesh
  87857. */
  87858. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87859. /**
  87860. * Release associated resources
  87861. */
  87862. dispose(): void;
  87863. /**
  87864. * Gets the class name
  87865. * @returns the string "SubMesh".
  87866. */
  87867. getClassName(): string;
  87868. /**
  87869. * Creates a new submesh from indices data
  87870. * @param materialIndex the index of the main mesh material
  87871. * @param startIndex the index where to start the copy in the mesh indices array
  87872. * @param indexCount the number of indices to copy then from the startIndex
  87873. * @param mesh the main mesh to create the submesh from
  87874. * @param renderingMesh the optional rendering mesh
  87875. * @returns a new submesh
  87876. */
  87877. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87878. }
  87879. }
  87880. declare module BABYLON {
  87881. /**
  87882. * Class used to represent data loading progression
  87883. */
  87884. export class SceneLoaderFlags {
  87885. private static _ForceFullSceneLoadingForIncremental;
  87886. private static _ShowLoadingScreen;
  87887. private static _CleanBoneMatrixWeights;
  87888. private static _loggingLevel;
  87889. /**
  87890. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87891. */
  87892. static ForceFullSceneLoadingForIncremental: boolean;
  87893. /**
  87894. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87895. */
  87896. static ShowLoadingScreen: boolean;
  87897. /**
  87898. * Defines the current logging level (while loading the scene)
  87899. * @ignorenaming
  87900. */
  87901. static loggingLevel: number;
  87902. /**
  87903. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87904. */
  87905. static CleanBoneMatrixWeights: boolean;
  87906. }
  87907. }
  87908. declare module BABYLON {
  87909. /**
  87910. * Class used to store geometry data (vertex buffers + index buffer)
  87911. */
  87912. export class Geometry implements IGetSetVerticesData {
  87913. /**
  87914. * Gets or sets the ID of the geometry
  87915. */
  87916. id: string;
  87917. /**
  87918. * Gets or sets the unique ID of the geometry
  87919. */
  87920. uniqueId: number;
  87921. /**
  87922. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87923. */
  87924. delayLoadState: number;
  87925. /**
  87926. * Gets the file containing the data to load when running in delay load state
  87927. */
  87928. delayLoadingFile: Nullable<string>;
  87929. /**
  87930. * Callback called when the geometry is updated
  87931. */
  87932. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87933. private _scene;
  87934. private _engine;
  87935. private _meshes;
  87936. private _totalVertices;
  87937. /** @hidden */
  87938. _indices: IndicesArray;
  87939. /** @hidden */
  87940. _vertexBuffers: {
  87941. [key: string]: VertexBuffer;
  87942. };
  87943. private _isDisposed;
  87944. private _extend;
  87945. private _boundingBias;
  87946. /** @hidden */
  87947. _delayInfo: Array<string>;
  87948. private _indexBuffer;
  87949. private _indexBufferIsUpdatable;
  87950. /** @hidden */
  87951. _boundingInfo: Nullable<BoundingInfo>;
  87952. /** @hidden */
  87953. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87954. /** @hidden */
  87955. _softwareSkinningFrameId: number;
  87956. private _vertexArrayObjects;
  87957. private _updatable;
  87958. /** @hidden */
  87959. _positions: Nullable<Vector3[]>;
  87960. /**
  87961. * 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
  87962. */
  87963. /**
  87964. * 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
  87965. */
  87966. boundingBias: Vector2;
  87967. /**
  87968. * Static function used to attach a new empty geometry to a mesh
  87969. * @param mesh defines the mesh to attach the geometry to
  87970. * @returns the new Geometry
  87971. */
  87972. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87973. /**
  87974. * Creates a new geometry
  87975. * @param id defines the unique ID
  87976. * @param scene defines the hosting scene
  87977. * @param vertexData defines the VertexData used to get geometry data
  87978. * @param updatable defines if geometry must be updatable (false by default)
  87979. * @param mesh defines the mesh that will be associated with the geometry
  87980. */
  87981. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87982. /**
  87983. * Gets the current extend of the geometry
  87984. */
  87985. readonly extend: {
  87986. minimum: Vector3;
  87987. maximum: Vector3;
  87988. };
  87989. /**
  87990. * Gets the hosting scene
  87991. * @returns the hosting Scene
  87992. */
  87993. getScene(): Scene;
  87994. /**
  87995. * Gets the hosting engine
  87996. * @returns the hosting Engine
  87997. */
  87998. getEngine(): Engine;
  87999. /**
  88000. * Defines if the geometry is ready to use
  88001. * @returns true if the geometry is ready to be used
  88002. */
  88003. isReady(): boolean;
  88004. /**
  88005. * Gets a value indicating that the geometry should not be serialized
  88006. */
  88007. readonly doNotSerialize: boolean;
  88008. /** @hidden */
  88009. _rebuild(): void;
  88010. /**
  88011. * Affects all geometry data in one call
  88012. * @param vertexData defines the geometry data
  88013. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88014. */
  88015. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88016. /**
  88017. * Set specific vertex data
  88018. * @param kind defines the data kind (Position, normal, etc...)
  88019. * @param data defines the vertex data to use
  88020. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88021. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88022. */
  88023. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88024. /**
  88025. * Removes a specific vertex data
  88026. * @param kind defines the data kind (Position, normal, etc...)
  88027. */
  88028. removeVerticesData(kind: string): void;
  88029. /**
  88030. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88031. * @param buffer defines the vertex buffer to use
  88032. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88033. */
  88034. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88035. /**
  88036. * Update a specific vertex buffer
  88037. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88038. * It will do nothing if the buffer is not updatable
  88039. * @param kind defines the data kind (Position, normal, etc...)
  88040. * @param data defines the data to use
  88041. * @param offset defines the offset in the target buffer where to store the data
  88042. * @param useBytes set to true if the offset is in bytes
  88043. */
  88044. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88045. /**
  88046. * Update a specific vertex buffer
  88047. * This function will create a new buffer if the current one is not updatable
  88048. * @param kind defines the data kind (Position, normal, etc...)
  88049. * @param data defines the data to use
  88050. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88051. */
  88052. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88053. private _updateBoundingInfo;
  88054. /** @hidden */
  88055. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88056. /**
  88057. * Gets total number of vertices
  88058. * @returns the total number of vertices
  88059. */
  88060. getTotalVertices(): number;
  88061. /**
  88062. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88063. * @param kind defines the data kind (Position, normal, etc...)
  88064. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88065. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88066. * @returns a float array containing vertex data
  88067. */
  88068. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88069. /**
  88070. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88071. * @param kind defines the data kind (Position, normal, etc...)
  88072. * @returns true if the vertex buffer with the specified kind is updatable
  88073. */
  88074. isVertexBufferUpdatable(kind: string): boolean;
  88075. /**
  88076. * Gets a specific vertex buffer
  88077. * @param kind defines the data kind (Position, normal, etc...)
  88078. * @returns a VertexBuffer
  88079. */
  88080. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88081. /**
  88082. * Returns all vertex buffers
  88083. * @return an object holding all vertex buffers indexed by kind
  88084. */
  88085. getVertexBuffers(): Nullable<{
  88086. [key: string]: VertexBuffer;
  88087. }>;
  88088. /**
  88089. * Gets a boolean indicating if specific vertex buffer is present
  88090. * @param kind defines the data kind (Position, normal, etc...)
  88091. * @returns true if data is present
  88092. */
  88093. isVerticesDataPresent(kind: string): boolean;
  88094. /**
  88095. * Gets a list of all attached data kinds (Position, normal, etc...)
  88096. * @returns a list of string containing all kinds
  88097. */
  88098. getVerticesDataKinds(): string[];
  88099. /**
  88100. * Update index buffer
  88101. * @param indices defines the indices to store in the index buffer
  88102. * @param offset defines the offset in the target buffer where to store the data
  88103. * @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)
  88104. */
  88105. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88106. /**
  88107. * Creates a new index buffer
  88108. * @param indices defines the indices to store in the index buffer
  88109. * @param totalVertices defines the total number of vertices (could be null)
  88110. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88111. */
  88112. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88113. /**
  88114. * Return the total number of indices
  88115. * @returns the total number of indices
  88116. */
  88117. getTotalIndices(): number;
  88118. /**
  88119. * Gets the index buffer array
  88120. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88121. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88122. * @returns the index buffer array
  88123. */
  88124. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88125. /**
  88126. * Gets the index buffer
  88127. * @return the index buffer
  88128. */
  88129. getIndexBuffer(): Nullable<DataBuffer>;
  88130. /** @hidden */
  88131. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88132. /**
  88133. * Release the associated resources for a specific mesh
  88134. * @param mesh defines the source mesh
  88135. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88136. */
  88137. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88138. /**
  88139. * Apply current geometry to a given mesh
  88140. * @param mesh defines the mesh to apply geometry to
  88141. */
  88142. applyToMesh(mesh: Mesh): void;
  88143. private _updateExtend;
  88144. private _applyToMesh;
  88145. private notifyUpdate;
  88146. /**
  88147. * Load the geometry if it was flagged as delay loaded
  88148. * @param scene defines the hosting scene
  88149. * @param onLoaded defines a callback called when the geometry is loaded
  88150. */
  88151. load(scene: Scene, onLoaded?: () => void): void;
  88152. private _queueLoad;
  88153. /**
  88154. * Invert the geometry to move from a right handed system to a left handed one.
  88155. */
  88156. toLeftHanded(): void;
  88157. /** @hidden */
  88158. _resetPointsArrayCache(): void;
  88159. /** @hidden */
  88160. _generatePointsArray(): boolean;
  88161. /**
  88162. * Gets a value indicating if the geometry is disposed
  88163. * @returns true if the geometry was disposed
  88164. */
  88165. isDisposed(): boolean;
  88166. private _disposeVertexArrayObjects;
  88167. /**
  88168. * Free all associated resources
  88169. */
  88170. dispose(): void;
  88171. /**
  88172. * Clone the current geometry into a new geometry
  88173. * @param id defines the unique ID of the new geometry
  88174. * @returns a new geometry object
  88175. */
  88176. copy(id: string): Geometry;
  88177. /**
  88178. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88179. * @return a JSON representation of the current geometry data (without the vertices data)
  88180. */
  88181. serialize(): any;
  88182. private toNumberArray;
  88183. /**
  88184. * Serialize all vertices data into a JSON oject
  88185. * @returns a JSON representation of the current geometry data
  88186. */
  88187. serializeVerticeData(): any;
  88188. /**
  88189. * Extracts a clone of a mesh geometry
  88190. * @param mesh defines the source mesh
  88191. * @param id defines the unique ID of the new geometry object
  88192. * @returns the new geometry object
  88193. */
  88194. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88195. /**
  88196. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88197. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88198. * Be aware Math.random() could cause collisions, but:
  88199. * "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"
  88200. * @returns a string containing a new GUID
  88201. */
  88202. static RandomId(): string;
  88203. /** @hidden */
  88204. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88205. private static _CleanMatricesWeights;
  88206. /**
  88207. * Create a new geometry from persisted data (Using .babylon file format)
  88208. * @param parsedVertexData defines the persisted data
  88209. * @param scene defines the hosting scene
  88210. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88211. * @returns the new geometry object
  88212. */
  88213. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88214. }
  88215. }
  88216. declare module BABYLON {
  88217. /**
  88218. * Define an interface for all classes that will get and set the data on vertices
  88219. */
  88220. export interface IGetSetVerticesData {
  88221. /**
  88222. * Gets a boolean indicating if specific vertex data is present
  88223. * @param kind defines the vertex data kind to use
  88224. * @returns true is data kind is present
  88225. */
  88226. isVerticesDataPresent(kind: string): boolean;
  88227. /**
  88228. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88229. * @param kind defines the data kind (Position, normal, etc...)
  88230. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88231. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88232. * @returns a float array containing vertex data
  88233. */
  88234. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88235. /**
  88236. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88237. * @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.
  88238. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88239. * @returns the indices array or an empty array if the mesh has no geometry
  88240. */
  88241. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88242. /**
  88243. * Set specific vertex data
  88244. * @param kind defines the data kind (Position, normal, etc...)
  88245. * @param data defines the vertex data to use
  88246. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88247. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88248. */
  88249. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88250. /**
  88251. * Update a specific associated vertex buffer
  88252. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88253. * - VertexBuffer.PositionKind
  88254. * - VertexBuffer.UVKind
  88255. * - VertexBuffer.UV2Kind
  88256. * - VertexBuffer.UV3Kind
  88257. * - VertexBuffer.UV4Kind
  88258. * - VertexBuffer.UV5Kind
  88259. * - VertexBuffer.UV6Kind
  88260. * - VertexBuffer.ColorKind
  88261. * - VertexBuffer.MatricesIndicesKind
  88262. * - VertexBuffer.MatricesIndicesExtraKind
  88263. * - VertexBuffer.MatricesWeightsKind
  88264. * - VertexBuffer.MatricesWeightsExtraKind
  88265. * @param data defines the data source
  88266. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88267. * @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)
  88268. */
  88269. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88270. /**
  88271. * Creates a new index buffer
  88272. * @param indices defines the indices to store in the index buffer
  88273. * @param totalVertices defines the total number of vertices (could be null)
  88274. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88275. */
  88276. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88277. }
  88278. /**
  88279. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88280. */
  88281. export class VertexData {
  88282. /**
  88283. * Mesh side orientation : usually the external or front surface
  88284. */
  88285. static readonly FRONTSIDE: number;
  88286. /**
  88287. * Mesh side orientation : usually the internal or back surface
  88288. */
  88289. static readonly BACKSIDE: number;
  88290. /**
  88291. * Mesh side orientation : both internal and external or front and back surfaces
  88292. */
  88293. static readonly DOUBLESIDE: number;
  88294. /**
  88295. * Mesh side orientation : by default, `FRONTSIDE`
  88296. */
  88297. static readonly DEFAULTSIDE: number;
  88298. /**
  88299. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88300. */
  88301. positions: Nullable<FloatArray>;
  88302. /**
  88303. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88304. */
  88305. normals: Nullable<FloatArray>;
  88306. /**
  88307. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88308. */
  88309. tangents: Nullable<FloatArray>;
  88310. /**
  88311. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88312. */
  88313. uvs: Nullable<FloatArray>;
  88314. /**
  88315. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88316. */
  88317. uvs2: Nullable<FloatArray>;
  88318. /**
  88319. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88320. */
  88321. uvs3: Nullable<FloatArray>;
  88322. /**
  88323. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88324. */
  88325. uvs4: Nullable<FloatArray>;
  88326. /**
  88327. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88328. */
  88329. uvs5: Nullable<FloatArray>;
  88330. /**
  88331. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88332. */
  88333. uvs6: Nullable<FloatArray>;
  88334. /**
  88335. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88336. */
  88337. colors: Nullable<FloatArray>;
  88338. /**
  88339. * 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).
  88340. */
  88341. matricesIndices: Nullable<FloatArray>;
  88342. /**
  88343. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88344. */
  88345. matricesWeights: Nullable<FloatArray>;
  88346. /**
  88347. * An array extending the number of possible indices
  88348. */
  88349. matricesIndicesExtra: Nullable<FloatArray>;
  88350. /**
  88351. * An array extending the number of possible weights when the number of indices is extended
  88352. */
  88353. matricesWeightsExtra: Nullable<FloatArray>;
  88354. /**
  88355. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88356. */
  88357. indices: Nullable<IndicesArray>;
  88358. /**
  88359. * Uses the passed data array to set the set the values for the specified kind of data
  88360. * @param data a linear array of floating numbers
  88361. * @param kind the type of data that is being set, eg positions, colors etc
  88362. */
  88363. set(data: FloatArray, kind: string): void;
  88364. /**
  88365. * Associates the vertexData to the passed Mesh.
  88366. * Sets it as updatable or not (default `false`)
  88367. * @param mesh the mesh the vertexData is applied to
  88368. * @param updatable when used and having the value true allows new data to update the vertexData
  88369. * @returns the VertexData
  88370. */
  88371. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88372. /**
  88373. * Associates the vertexData to the passed Geometry.
  88374. * Sets it as updatable or not (default `false`)
  88375. * @param geometry the geometry the vertexData is applied to
  88376. * @param updatable when used and having the value true allows new data to update the vertexData
  88377. * @returns VertexData
  88378. */
  88379. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88380. /**
  88381. * Updates the associated mesh
  88382. * @param mesh the mesh to be updated
  88383. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88384. * @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
  88385. * @returns VertexData
  88386. */
  88387. updateMesh(mesh: Mesh): VertexData;
  88388. /**
  88389. * Updates the associated geometry
  88390. * @param geometry the geometry to be updated
  88391. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88392. * @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
  88393. * @returns VertexData.
  88394. */
  88395. updateGeometry(geometry: Geometry): VertexData;
  88396. private _applyTo;
  88397. private _update;
  88398. /**
  88399. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88400. * @param matrix the transforming matrix
  88401. * @returns the VertexData
  88402. */
  88403. transform(matrix: Matrix): VertexData;
  88404. /**
  88405. * Merges the passed VertexData into the current one
  88406. * @param other the VertexData to be merged into the current one
  88407. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88408. * @returns the modified VertexData
  88409. */
  88410. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88411. private _mergeElement;
  88412. private _validate;
  88413. /**
  88414. * Serializes the VertexData
  88415. * @returns a serialized object
  88416. */
  88417. serialize(): any;
  88418. /**
  88419. * Extracts the vertexData from a mesh
  88420. * @param mesh the mesh from which to extract the VertexData
  88421. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88422. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88423. * @returns the object VertexData associated to the passed mesh
  88424. */
  88425. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88426. /**
  88427. * Extracts the vertexData from the geometry
  88428. * @param geometry the geometry from which to extract the VertexData
  88429. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88430. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88431. * @returns the object VertexData associated to the passed mesh
  88432. */
  88433. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88434. private static _ExtractFrom;
  88435. /**
  88436. * Creates the VertexData for a Ribbon
  88437. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88438. * * pathArray array of paths, each of which an array of successive Vector3
  88439. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88440. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88441. * * 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
  88442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88443. * * 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)
  88444. * * 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)
  88445. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88446. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88447. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88448. * @returns the VertexData of the ribbon
  88449. */
  88450. static CreateRibbon(options: {
  88451. pathArray: Vector3[][];
  88452. closeArray?: boolean;
  88453. closePath?: boolean;
  88454. offset?: number;
  88455. sideOrientation?: number;
  88456. frontUVs?: Vector4;
  88457. backUVs?: Vector4;
  88458. invertUV?: boolean;
  88459. uvs?: Vector2[];
  88460. colors?: Color4[];
  88461. }): VertexData;
  88462. /**
  88463. * Creates the VertexData for a box
  88464. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88465. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88466. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88467. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88468. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88469. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88470. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88472. * * 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)
  88473. * * 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)
  88474. * @returns the VertexData of the box
  88475. */
  88476. static CreateBox(options: {
  88477. size?: number;
  88478. width?: number;
  88479. height?: number;
  88480. depth?: number;
  88481. faceUV?: Vector4[];
  88482. faceColors?: Color4[];
  88483. sideOrientation?: number;
  88484. frontUVs?: Vector4;
  88485. backUVs?: Vector4;
  88486. }): VertexData;
  88487. /**
  88488. * Creates the VertexData for a tiled box
  88489. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88490. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88491. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88492. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88493. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88494. * @returns the VertexData of the box
  88495. */
  88496. static CreateTiledBox(options: {
  88497. pattern?: number;
  88498. width?: number;
  88499. height?: number;
  88500. depth?: number;
  88501. tileSize?: number;
  88502. tileWidth?: number;
  88503. tileHeight?: number;
  88504. alignHorizontal?: number;
  88505. alignVertical?: number;
  88506. faceUV?: Vector4[];
  88507. faceColors?: Color4[];
  88508. sideOrientation?: number;
  88509. }): VertexData;
  88510. /**
  88511. * Creates the VertexData for a tiled plane
  88512. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88513. * * pattern a limited pattern arrangement depending on the number
  88514. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88515. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88516. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88518. * * 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)
  88519. * * 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)
  88520. * @returns the VertexData of the tiled plane
  88521. */
  88522. static CreateTiledPlane(options: {
  88523. pattern?: number;
  88524. tileSize?: number;
  88525. tileWidth?: number;
  88526. tileHeight?: number;
  88527. size?: number;
  88528. width?: number;
  88529. height?: number;
  88530. alignHorizontal?: number;
  88531. alignVertical?: number;
  88532. sideOrientation?: number;
  88533. frontUVs?: Vector4;
  88534. backUVs?: Vector4;
  88535. }): VertexData;
  88536. /**
  88537. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88538. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88539. * * segments sets the number of horizontal strips optional, default 32
  88540. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88541. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88542. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88543. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88544. * * 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
  88545. * * 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
  88546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88547. * * 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)
  88548. * * 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)
  88549. * @returns the VertexData of the ellipsoid
  88550. */
  88551. static CreateSphere(options: {
  88552. segments?: number;
  88553. diameter?: number;
  88554. diameterX?: number;
  88555. diameterY?: number;
  88556. diameterZ?: number;
  88557. arc?: number;
  88558. slice?: number;
  88559. sideOrientation?: number;
  88560. frontUVs?: Vector4;
  88561. backUVs?: Vector4;
  88562. }): VertexData;
  88563. /**
  88564. * Creates the VertexData for a cylinder, cone or prism
  88565. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88566. * * height sets the height (y direction) of the cylinder, optional, default 2
  88567. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88568. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88569. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88570. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88571. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88572. * * 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
  88573. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88574. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88575. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88576. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88578. * * 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)
  88579. * * 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)
  88580. * @returns the VertexData of the cylinder, cone or prism
  88581. */
  88582. static CreateCylinder(options: {
  88583. height?: number;
  88584. diameterTop?: number;
  88585. diameterBottom?: number;
  88586. diameter?: number;
  88587. tessellation?: number;
  88588. subdivisions?: number;
  88589. arc?: number;
  88590. faceColors?: Color4[];
  88591. faceUV?: Vector4[];
  88592. hasRings?: boolean;
  88593. enclose?: boolean;
  88594. sideOrientation?: number;
  88595. frontUVs?: Vector4;
  88596. backUVs?: Vector4;
  88597. }): VertexData;
  88598. /**
  88599. * Creates the VertexData for a torus
  88600. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88601. * * diameter the diameter of the torus, optional default 1
  88602. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88603. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88605. * * 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)
  88606. * * 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)
  88607. * @returns the VertexData of the torus
  88608. */
  88609. static CreateTorus(options: {
  88610. diameter?: number;
  88611. thickness?: number;
  88612. tessellation?: number;
  88613. sideOrientation?: number;
  88614. frontUVs?: Vector4;
  88615. backUVs?: Vector4;
  88616. }): VertexData;
  88617. /**
  88618. * Creates the VertexData of the LineSystem
  88619. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88620. * - lines an array of lines, each line being an array of successive Vector3
  88621. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88622. * @returns the VertexData of the LineSystem
  88623. */
  88624. static CreateLineSystem(options: {
  88625. lines: Vector3[][];
  88626. colors?: Nullable<Color4[][]>;
  88627. }): VertexData;
  88628. /**
  88629. * Create the VertexData for a DashedLines
  88630. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88631. * - points an array successive Vector3
  88632. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88633. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88634. * - dashNb the intended total number of dashes, optional, default 200
  88635. * @returns the VertexData for the DashedLines
  88636. */
  88637. static CreateDashedLines(options: {
  88638. points: Vector3[];
  88639. dashSize?: number;
  88640. gapSize?: number;
  88641. dashNb?: number;
  88642. }): VertexData;
  88643. /**
  88644. * Creates the VertexData for a Ground
  88645. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88646. * - width the width (x direction) of the ground, optional, default 1
  88647. * - height the height (z direction) of the ground, optional, default 1
  88648. * - subdivisions the number of subdivisions per side, optional, default 1
  88649. * @returns the VertexData of the Ground
  88650. */
  88651. static CreateGround(options: {
  88652. width?: number;
  88653. height?: number;
  88654. subdivisions?: number;
  88655. subdivisionsX?: number;
  88656. subdivisionsY?: number;
  88657. }): VertexData;
  88658. /**
  88659. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88660. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88661. * * xmin the ground minimum X coordinate, optional, default -1
  88662. * * zmin the ground minimum Z coordinate, optional, default -1
  88663. * * xmax the ground maximum X coordinate, optional, default 1
  88664. * * zmax the ground maximum Z coordinate, optional, default 1
  88665. * * 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}
  88666. * * 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}
  88667. * @returns the VertexData of the TiledGround
  88668. */
  88669. static CreateTiledGround(options: {
  88670. xmin: number;
  88671. zmin: number;
  88672. xmax: number;
  88673. zmax: number;
  88674. subdivisions?: {
  88675. w: number;
  88676. h: number;
  88677. };
  88678. precision?: {
  88679. w: number;
  88680. h: number;
  88681. };
  88682. }): VertexData;
  88683. /**
  88684. * Creates the VertexData of the Ground designed from a heightmap
  88685. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88686. * * width the width (x direction) of the ground
  88687. * * height the height (z direction) of the ground
  88688. * * subdivisions the number of subdivisions per side
  88689. * * minHeight the minimum altitude on the ground, optional, default 0
  88690. * * maxHeight the maximum altitude on the ground, optional default 1
  88691. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88692. * * buffer the array holding the image color data
  88693. * * bufferWidth the width of image
  88694. * * bufferHeight the height of image
  88695. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88696. * @returns the VertexData of the Ground designed from a heightmap
  88697. */
  88698. static CreateGroundFromHeightMap(options: {
  88699. width: number;
  88700. height: number;
  88701. subdivisions: number;
  88702. minHeight: number;
  88703. maxHeight: number;
  88704. colorFilter: Color3;
  88705. buffer: Uint8Array;
  88706. bufferWidth: number;
  88707. bufferHeight: number;
  88708. alphaFilter: number;
  88709. }): VertexData;
  88710. /**
  88711. * Creates the VertexData for a Plane
  88712. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88713. * * size sets the width and height of the plane to the value of size, optional default 1
  88714. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88715. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88717. * * 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)
  88718. * * 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)
  88719. * @returns the VertexData of the box
  88720. */
  88721. static CreatePlane(options: {
  88722. size?: number;
  88723. width?: number;
  88724. height?: number;
  88725. sideOrientation?: number;
  88726. frontUVs?: Vector4;
  88727. backUVs?: Vector4;
  88728. }): VertexData;
  88729. /**
  88730. * Creates the VertexData of the Disc or regular Polygon
  88731. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88732. * * radius the radius of the disc, optional default 0.5
  88733. * * tessellation the number of polygon sides, optional, default 64
  88734. * * 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
  88735. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88736. * * 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)
  88737. * * 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)
  88738. * @returns the VertexData of the box
  88739. */
  88740. static CreateDisc(options: {
  88741. radius?: number;
  88742. tessellation?: number;
  88743. arc?: number;
  88744. sideOrientation?: number;
  88745. frontUVs?: Vector4;
  88746. backUVs?: Vector4;
  88747. }): VertexData;
  88748. /**
  88749. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88750. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88751. * @param polygon a mesh built from polygonTriangulation.build()
  88752. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88753. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88754. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88755. * @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)
  88756. * @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)
  88757. * @returns the VertexData of the Polygon
  88758. */
  88759. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88760. /**
  88761. * Creates the VertexData of the IcoSphere
  88762. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88763. * * radius the radius of the IcoSphere, optional default 1
  88764. * * radiusX allows stretching in the x direction, optional, default radius
  88765. * * radiusY allows stretching in the y direction, optional, default radius
  88766. * * radiusZ allows stretching in the z direction, optional, default radius
  88767. * * flat when true creates a flat shaded mesh, optional, default true
  88768. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88770. * * 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)
  88771. * * 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)
  88772. * @returns the VertexData of the IcoSphere
  88773. */
  88774. static CreateIcoSphere(options: {
  88775. radius?: number;
  88776. radiusX?: number;
  88777. radiusY?: number;
  88778. radiusZ?: number;
  88779. flat?: boolean;
  88780. subdivisions?: number;
  88781. sideOrientation?: number;
  88782. frontUVs?: Vector4;
  88783. backUVs?: Vector4;
  88784. }): VertexData;
  88785. /**
  88786. * Creates the VertexData for a Polyhedron
  88787. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88788. * * type provided types are:
  88789. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88790. * * 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)
  88791. * * size the size of the IcoSphere, optional default 1
  88792. * * sizeX allows stretching in the x direction, optional, default size
  88793. * * sizeY allows stretching in the y direction, optional, default size
  88794. * * sizeZ allows stretching in the z direction, optional, default size
  88795. * * 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
  88796. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88797. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88798. * * flat when true creates a flat shaded mesh, optional, default true
  88799. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88801. * * 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)
  88802. * * 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)
  88803. * @returns the VertexData of the Polyhedron
  88804. */
  88805. static CreatePolyhedron(options: {
  88806. type?: number;
  88807. size?: number;
  88808. sizeX?: number;
  88809. sizeY?: number;
  88810. sizeZ?: number;
  88811. custom?: any;
  88812. faceUV?: Vector4[];
  88813. faceColors?: Color4[];
  88814. flat?: boolean;
  88815. sideOrientation?: number;
  88816. frontUVs?: Vector4;
  88817. backUVs?: Vector4;
  88818. }): VertexData;
  88819. /**
  88820. * Creates the VertexData for a TorusKnot
  88821. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88822. * * radius the radius of the torus knot, optional, default 2
  88823. * * tube the thickness of the tube, optional, default 0.5
  88824. * * radialSegments the number of sides on each tube segments, optional, default 32
  88825. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88826. * * p the number of windings around the z axis, optional, default 2
  88827. * * q the number of windings around the x axis, optional, default 3
  88828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88829. * * 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)
  88830. * * 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)
  88831. * @returns the VertexData of the Torus Knot
  88832. */
  88833. static CreateTorusKnot(options: {
  88834. radius?: number;
  88835. tube?: number;
  88836. radialSegments?: number;
  88837. tubularSegments?: number;
  88838. p?: number;
  88839. q?: number;
  88840. sideOrientation?: number;
  88841. frontUVs?: Vector4;
  88842. backUVs?: Vector4;
  88843. }): VertexData;
  88844. /**
  88845. * Compute normals for given positions and indices
  88846. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88847. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88848. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88849. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88850. * * facetNormals : optional array of facet normals (vector3)
  88851. * * facetPositions : optional array of facet positions (vector3)
  88852. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88853. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88854. * * bInfo : optional bounding info, required for facetPartitioning computation
  88855. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88856. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88857. * * useRightHandedSystem: optional boolean to for right handed system computation
  88858. * * depthSort : optional boolean to enable the facet depth sort computation
  88859. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88860. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88861. */
  88862. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88863. facetNormals?: any;
  88864. facetPositions?: any;
  88865. facetPartitioning?: any;
  88866. ratio?: number;
  88867. bInfo?: any;
  88868. bbSize?: Vector3;
  88869. subDiv?: any;
  88870. useRightHandedSystem?: boolean;
  88871. depthSort?: boolean;
  88872. distanceTo?: Vector3;
  88873. depthSortedFacets?: any;
  88874. }): void;
  88875. /** @hidden */
  88876. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88877. /**
  88878. * Applies VertexData created from the imported parameters to the geometry
  88879. * @param parsedVertexData the parsed data from an imported file
  88880. * @param geometry the geometry to apply the VertexData to
  88881. */
  88882. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88883. }
  88884. }
  88885. declare module BABYLON {
  88886. /**
  88887. * Defines a target to use with MorphTargetManager
  88888. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88889. */
  88890. export class MorphTarget implements IAnimatable {
  88891. /** defines the name of the target */
  88892. name: string;
  88893. /**
  88894. * Gets or sets the list of animations
  88895. */
  88896. animations: Animation[];
  88897. private _scene;
  88898. private _positions;
  88899. private _normals;
  88900. private _tangents;
  88901. private _uvs;
  88902. private _influence;
  88903. /**
  88904. * Observable raised when the influence changes
  88905. */
  88906. onInfluenceChanged: Observable<boolean>;
  88907. /** @hidden */
  88908. _onDataLayoutChanged: Observable<void>;
  88909. /**
  88910. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88911. */
  88912. influence: number;
  88913. /**
  88914. * Gets or sets the id of the morph Target
  88915. */
  88916. id: string;
  88917. private _animationPropertiesOverride;
  88918. /**
  88919. * Gets or sets the animation properties override
  88920. */
  88921. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88922. /**
  88923. * Creates a new MorphTarget
  88924. * @param name defines the name of the target
  88925. * @param influence defines the influence to use
  88926. * @param scene defines the scene the morphtarget belongs to
  88927. */
  88928. constructor(
  88929. /** defines the name of the target */
  88930. name: string, influence?: number, scene?: Nullable<Scene>);
  88931. /**
  88932. * Gets a boolean defining if the target contains position data
  88933. */
  88934. readonly hasPositions: boolean;
  88935. /**
  88936. * Gets a boolean defining if the target contains normal data
  88937. */
  88938. readonly hasNormals: boolean;
  88939. /**
  88940. * Gets a boolean defining if the target contains tangent data
  88941. */
  88942. readonly hasTangents: boolean;
  88943. /**
  88944. * Gets a boolean defining if the target contains texture coordinates data
  88945. */
  88946. readonly hasUVs: boolean;
  88947. /**
  88948. * Affects position data to this target
  88949. * @param data defines the position data to use
  88950. */
  88951. setPositions(data: Nullable<FloatArray>): void;
  88952. /**
  88953. * Gets the position data stored in this target
  88954. * @returns a FloatArray containing the position data (or null if not present)
  88955. */
  88956. getPositions(): Nullable<FloatArray>;
  88957. /**
  88958. * Affects normal data to this target
  88959. * @param data defines the normal data to use
  88960. */
  88961. setNormals(data: Nullable<FloatArray>): void;
  88962. /**
  88963. * Gets the normal data stored in this target
  88964. * @returns a FloatArray containing the normal data (or null if not present)
  88965. */
  88966. getNormals(): Nullable<FloatArray>;
  88967. /**
  88968. * Affects tangent data to this target
  88969. * @param data defines the tangent data to use
  88970. */
  88971. setTangents(data: Nullable<FloatArray>): void;
  88972. /**
  88973. * Gets the tangent data stored in this target
  88974. * @returns a FloatArray containing the tangent data (or null if not present)
  88975. */
  88976. getTangents(): Nullable<FloatArray>;
  88977. /**
  88978. * Affects texture coordinates data to this target
  88979. * @param data defines the texture coordinates data to use
  88980. */
  88981. setUVs(data: Nullable<FloatArray>): void;
  88982. /**
  88983. * Gets the texture coordinates data stored in this target
  88984. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88985. */
  88986. getUVs(): Nullable<FloatArray>;
  88987. /**
  88988. * Serializes the current target into a Serialization object
  88989. * @returns the serialized object
  88990. */
  88991. serialize(): any;
  88992. /**
  88993. * Returns the string "MorphTarget"
  88994. * @returns "MorphTarget"
  88995. */
  88996. getClassName(): string;
  88997. /**
  88998. * Creates a new target from serialized data
  88999. * @param serializationObject defines the serialized data to use
  89000. * @returns a new MorphTarget
  89001. */
  89002. static Parse(serializationObject: any): MorphTarget;
  89003. /**
  89004. * Creates a MorphTarget from mesh data
  89005. * @param mesh defines the source mesh
  89006. * @param name defines the name to use for the new target
  89007. * @param influence defines the influence to attach to the target
  89008. * @returns a new MorphTarget
  89009. */
  89010. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89011. }
  89012. }
  89013. declare module BABYLON {
  89014. /**
  89015. * This class is used to deform meshes using morphing between different targets
  89016. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89017. */
  89018. export class MorphTargetManager {
  89019. private _targets;
  89020. private _targetInfluenceChangedObservers;
  89021. private _targetDataLayoutChangedObservers;
  89022. private _activeTargets;
  89023. private _scene;
  89024. private _influences;
  89025. private _supportsNormals;
  89026. private _supportsTangents;
  89027. private _supportsUVs;
  89028. private _vertexCount;
  89029. private _uniqueId;
  89030. private _tempInfluences;
  89031. /**
  89032. * Gets or sets a boolean indicating if normals must be morphed
  89033. */
  89034. enableNormalMorphing: boolean;
  89035. /**
  89036. * Gets or sets a boolean indicating if tangents must be morphed
  89037. */
  89038. enableTangentMorphing: boolean;
  89039. /**
  89040. * Gets or sets a boolean indicating if UV must be morphed
  89041. */
  89042. enableUVMorphing: boolean;
  89043. /**
  89044. * Creates a new MorphTargetManager
  89045. * @param scene defines the current scene
  89046. */
  89047. constructor(scene?: Nullable<Scene>);
  89048. /**
  89049. * Gets the unique ID of this manager
  89050. */
  89051. readonly uniqueId: number;
  89052. /**
  89053. * Gets the number of vertices handled by this manager
  89054. */
  89055. readonly vertexCount: number;
  89056. /**
  89057. * Gets a boolean indicating if this manager supports morphing of normals
  89058. */
  89059. readonly supportsNormals: boolean;
  89060. /**
  89061. * Gets a boolean indicating if this manager supports morphing of tangents
  89062. */
  89063. readonly supportsTangents: boolean;
  89064. /**
  89065. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89066. */
  89067. readonly supportsUVs: boolean;
  89068. /**
  89069. * Gets the number of targets stored in this manager
  89070. */
  89071. readonly numTargets: number;
  89072. /**
  89073. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89074. */
  89075. readonly numInfluencers: number;
  89076. /**
  89077. * Gets the list of influences (one per target)
  89078. */
  89079. readonly influences: Float32Array;
  89080. /**
  89081. * Gets the active target at specified index. An active target is a target with an influence > 0
  89082. * @param index defines the index to check
  89083. * @returns the requested target
  89084. */
  89085. getActiveTarget(index: number): MorphTarget;
  89086. /**
  89087. * Gets the target at specified index
  89088. * @param index defines the index to check
  89089. * @returns the requested target
  89090. */
  89091. getTarget(index: number): MorphTarget;
  89092. /**
  89093. * Add a new target to this manager
  89094. * @param target defines the target to add
  89095. */
  89096. addTarget(target: MorphTarget): void;
  89097. /**
  89098. * Removes a target from the manager
  89099. * @param target defines the target to remove
  89100. */
  89101. removeTarget(target: MorphTarget): void;
  89102. /**
  89103. * Serializes the current manager into a Serialization object
  89104. * @returns the serialized object
  89105. */
  89106. serialize(): any;
  89107. private _syncActiveTargets;
  89108. /**
  89109. * Syncrhonize the targets with all the meshes using this morph target manager
  89110. */
  89111. synchronize(): void;
  89112. /**
  89113. * Creates a new MorphTargetManager from serialized data
  89114. * @param serializationObject defines the serialized data
  89115. * @param scene defines the hosting scene
  89116. * @returns the new MorphTargetManager
  89117. */
  89118. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89119. }
  89120. }
  89121. declare module BABYLON {
  89122. /**
  89123. * Class used to represent a specific level of detail of a mesh
  89124. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89125. */
  89126. export class MeshLODLevel {
  89127. /** Defines the distance where this level should start being displayed */
  89128. distance: number;
  89129. /** Defines the mesh to use to render this level */
  89130. mesh: Nullable<Mesh>;
  89131. /**
  89132. * Creates a new LOD level
  89133. * @param distance defines the distance where this level should star being displayed
  89134. * @param mesh defines the mesh to use to render this level
  89135. */
  89136. constructor(
  89137. /** Defines the distance where this level should start being displayed */
  89138. distance: number,
  89139. /** Defines the mesh to use to render this level */
  89140. mesh: Nullable<Mesh>);
  89141. }
  89142. }
  89143. declare module BABYLON {
  89144. /**
  89145. * Mesh representing the gorund
  89146. */
  89147. export class GroundMesh extends Mesh {
  89148. /** If octree should be generated */
  89149. generateOctree: boolean;
  89150. private _heightQuads;
  89151. /** @hidden */
  89152. _subdivisionsX: number;
  89153. /** @hidden */
  89154. _subdivisionsY: number;
  89155. /** @hidden */
  89156. _width: number;
  89157. /** @hidden */
  89158. _height: number;
  89159. /** @hidden */
  89160. _minX: number;
  89161. /** @hidden */
  89162. _maxX: number;
  89163. /** @hidden */
  89164. _minZ: number;
  89165. /** @hidden */
  89166. _maxZ: number;
  89167. constructor(name: string, scene: Scene);
  89168. /**
  89169. * "GroundMesh"
  89170. * @returns "GroundMesh"
  89171. */
  89172. getClassName(): string;
  89173. /**
  89174. * The minimum of x and y subdivisions
  89175. */
  89176. readonly subdivisions: number;
  89177. /**
  89178. * X subdivisions
  89179. */
  89180. readonly subdivisionsX: number;
  89181. /**
  89182. * Y subdivisions
  89183. */
  89184. readonly subdivisionsY: number;
  89185. /**
  89186. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89187. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89188. * @param chunksCount the number of subdivisions for x and y
  89189. * @param octreeBlocksSize (Default: 32)
  89190. */
  89191. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89192. /**
  89193. * Returns a height (y) value in the Worl system :
  89194. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89195. * @param x x coordinate
  89196. * @param z z coordinate
  89197. * @returns the ground y position if (x, z) are outside the ground surface.
  89198. */
  89199. getHeightAtCoordinates(x: number, z: number): number;
  89200. /**
  89201. * Returns a normalized vector (Vector3) orthogonal to the ground
  89202. * at the ground coordinates (x, z) expressed in the World system.
  89203. * @param x x coordinate
  89204. * @param z z coordinate
  89205. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89206. */
  89207. getNormalAtCoordinates(x: number, z: number): Vector3;
  89208. /**
  89209. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89210. * at the ground coordinates (x, z) expressed in the World system.
  89211. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89212. * @param x x coordinate
  89213. * @param z z coordinate
  89214. * @param ref vector to store the result
  89215. * @returns the GroundMesh.
  89216. */
  89217. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89218. /**
  89219. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89220. * if the ground has been updated.
  89221. * This can be used in the render loop.
  89222. * @returns the GroundMesh.
  89223. */
  89224. updateCoordinateHeights(): GroundMesh;
  89225. private _getFacetAt;
  89226. private _initHeightQuads;
  89227. private _computeHeightQuads;
  89228. /**
  89229. * Serializes this ground mesh
  89230. * @param serializationObject object to write serialization to
  89231. */
  89232. serialize(serializationObject: any): void;
  89233. /**
  89234. * Parses a serialized ground mesh
  89235. * @param parsedMesh the serialized mesh
  89236. * @param scene the scene to create the ground mesh in
  89237. * @returns the created ground mesh
  89238. */
  89239. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89240. }
  89241. }
  89242. declare module BABYLON {
  89243. /**
  89244. * Interface for Physics-Joint data
  89245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89246. */
  89247. export interface PhysicsJointData {
  89248. /**
  89249. * The main pivot of the joint
  89250. */
  89251. mainPivot?: Vector3;
  89252. /**
  89253. * The connected pivot of the joint
  89254. */
  89255. connectedPivot?: Vector3;
  89256. /**
  89257. * The main axis of the joint
  89258. */
  89259. mainAxis?: Vector3;
  89260. /**
  89261. * The connected axis of the joint
  89262. */
  89263. connectedAxis?: Vector3;
  89264. /**
  89265. * The collision of the joint
  89266. */
  89267. collision?: boolean;
  89268. /**
  89269. * Native Oimo/Cannon/Energy data
  89270. */
  89271. nativeParams?: any;
  89272. }
  89273. /**
  89274. * This is a holder class for the physics joint created by the physics plugin
  89275. * It holds a set of functions to control the underlying joint
  89276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89277. */
  89278. export class PhysicsJoint {
  89279. /**
  89280. * The type of the physics joint
  89281. */
  89282. type: number;
  89283. /**
  89284. * The data for the physics joint
  89285. */
  89286. jointData: PhysicsJointData;
  89287. private _physicsJoint;
  89288. protected _physicsPlugin: IPhysicsEnginePlugin;
  89289. /**
  89290. * Initializes the physics joint
  89291. * @param type The type of the physics joint
  89292. * @param jointData The data for the physics joint
  89293. */
  89294. constructor(
  89295. /**
  89296. * The type of the physics joint
  89297. */
  89298. type: number,
  89299. /**
  89300. * The data for the physics joint
  89301. */
  89302. jointData: PhysicsJointData);
  89303. /**
  89304. * Gets the physics joint
  89305. */
  89306. /**
  89307. * Sets the physics joint
  89308. */
  89309. physicsJoint: any;
  89310. /**
  89311. * Sets the physics plugin
  89312. */
  89313. physicsPlugin: IPhysicsEnginePlugin;
  89314. /**
  89315. * Execute a function that is physics-plugin specific.
  89316. * @param {Function} func the function that will be executed.
  89317. * It accepts two parameters: the physics world and the physics joint
  89318. */
  89319. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89320. /**
  89321. * Distance-Joint type
  89322. */
  89323. static DistanceJoint: number;
  89324. /**
  89325. * Hinge-Joint type
  89326. */
  89327. static HingeJoint: number;
  89328. /**
  89329. * Ball-and-Socket joint type
  89330. */
  89331. static BallAndSocketJoint: number;
  89332. /**
  89333. * Wheel-Joint type
  89334. */
  89335. static WheelJoint: number;
  89336. /**
  89337. * Slider-Joint type
  89338. */
  89339. static SliderJoint: number;
  89340. /**
  89341. * Prismatic-Joint type
  89342. */
  89343. static PrismaticJoint: number;
  89344. /**
  89345. * Universal-Joint type
  89346. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89347. */
  89348. static UniversalJoint: number;
  89349. /**
  89350. * Hinge-Joint 2 type
  89351. */
  89352. static Hinge2Joint: number;
  89353. /**
  89354. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89355. */
  89356. static PointToPointJoint: number;
  89357. /**
  89358. * Spring-Joint type
  89359. */
  89360. static SpringJoint: number;
  89361. /**
  89362. * Lock-Joint type
  89363. */
  89364. static LockJoint: number;
  89365. }
  89366. /**
  89367. * A class representing a physics distance joint
  89368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89369. */
  89370. export class DistanceJoint extends PhysicsJoint {
  89371. /**
  89372. *
  89373. * @param jointData The data for the Distance-Joint
  89374. */
  89375. constructor(jointData: DistanceJointData);
  89376. /**
  89377. * Update the predefined distance.
  89378. * @param maxDistance The maximum preferred distance
  89379. * @param minDistance The minimum preferred distance
  89380. */
  89381. updateDistance(maxDistance: number, minDistance?: number): void;
  89382. }
  89383. /**
  89384. * Represents a Motor-Enabled Joint
  89385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89386. */
  89387. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89388. /**
  89389. * Initializes the Motor-Enabled Joint
  89390. * @param type The type of the joint
  89391. * @param jointData The physica joint data for the joint
  89392. */
  89393. constructor(type: number, jointData: PhysicsJointData);
  89394. /**
  89395. * Set the motor values.
  89396. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89397. * @param force the force to apply
  89398. * @param maxForce max force for this motor.
  89399. */
  89400. setMotor(force?: number, maxForce?: number): void;
  89401. /**
  89402. * Set the motor's limits.
  89403. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89404. * @param upperLimit The upper limit of the motor
  89405. * @param lowerLimit The lower limit of the motor
  89406. */
  89407. setLimit(upperLimit: number, lowerLimit?: number): void;
  89408. }
  89409. /**
  89410. * This class represents a single physics Hinge-Joint
  89411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89412. */
  89413. export class HingeJoint extends MotorEnabledJoint {
  89414. /**
  89415. * Initializes the Hinge-Joint
  89416. * @param jointData The joint data for the Hinge-Joint
  89417. */
  89418. constructor(jointData: PhysicsJointData);
  89419. /**
  89420. * Set the motor values.
  89421. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89422. * @param {number} force the force to apply
  89423. * @param {number} maxForce max force for this motor.
  89424. */
  89425. setMotor(force?: number, maxForce?: number): void;
  89426. /**
  89427. * Set the motor's limits.
  89428. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89429. * @param upperLimit The upper limit of the motor
  89430. * @param lowerLimit The lower limit of the motor
  89431. */
  89432. setLimit(upperLimit: number, lowerLimit?: number): void;
  89433. }
  89434. /**
  89435. * This class represents a dual hinge physics joint (same as wheel joint)
  89436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89437. */
  89438. export class Hinge2Joint extends MotorEnabledJoint {
  89439. /**
  89440. * Initializes the Hinge2-Joint
  89441. * @param jointData The joint data for the Hinge2-Joint
  89442. */
  89443. constructor(jointData: PhysicsJointData);
  89444. /**
  89445. * Set the motor values.
  89446. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89447. * @param {number} targetSpeed the speed the motor is to reach
  89448. * @param {number} maxForce max force for this motor.
  89449. * @param {motorIndex} the motor's index, 0 or 1.
  89450. */
  89451. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89452. /**
  89453. * Set the motor limits.
  89454. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89455. * @param {number} upperLimit the upper limit
  89456. * @param {number} lowerLimit lower limit
  89457. * @param {motorIndex} the motor's index, 0 or 1.
  89458. */
  89459. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89460. }
  89461. /**
  89462. * Interface for a motor enabled joint
  89463. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89464. */
  89465. export interface IMotorEnabledJoint {
  89466. /**
  89467. * Physics joint
  89468. */
  89469. physicsJoint: any;
  89470. /**
  89471. * Sets the motor of the motor-enabled joint
  89472. * @param force The force of the motor
  89473. * @param maxForce The maximum force of the motor
  89474. * @param motorIndex The index of the motor
  89475. */
  89476. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89477. /**
  89478. * Sets the limit of the motor
  89479. * @param upperLimit The upper limit of the motor
  89480. * @param lowerLimit The lower limit of the motor
  89481. * @param motorIndex The index of the motor
  89482. */
  89483. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89484. }
  89485. /**
  89486. * Joint data for a Distance-Joint
  89487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89488. */
  89489. export interface DistanceJointData extends PhysicsJointData {
  89490. /**
  89491. * Max distance the 2 joint objects can be apart
  89492. */
  89493. maxDistance: number;
  89494. }
  89495. /**
  89496. * Joint data from a spring joint
  89497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89498. */
  89499. export interface SpringJointData extends PhysicsJointData {
  89500. /**
  89501. * Length of the spring
  89502. */
  89503. length: number;
  89504. /**
  89505. * Stiffness of the spring
  89506. */
  89507. stiffness: number;
  89508. /**
  89509. * Damping of the spring
  89510. */
  89511. damping: number;
  89512. /** this callback will be called when applying the force to the impostors. */
  89513. forceApplicationCallback: () => void;
  89514. }
  89515. }
  89516. declare module BABYLON {
  89517. /**
  89518. * Holds the data for the raycast result
  89519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89520. */
  89521. export class PhysicsRaycastResult {
  89522. private _hasHit;
  89523. private _hitDistance;
  89524. private _hitNormalWorld;
  89525. private _hitPointWorld;
  89526. private _rayFromWorld;
  89527. private _rayToWorld;
  89528. /**
  89529. * Gets if there was a hit
  89530. */
  89531. readonly hasHit: boolean;
  89532. /**
  89533. * Gets the distance from the hit
  89534. */
  89535. readonly hitDistance: number;
  89536. /**
  89537. * Gets the hit normal/direction in the world
  89538. */
  89539. readonly hitNormalWorld: Vector3;
  89540. /**
  89541. * Gets the hit point in the world
  89542. */
  89543. readonly hitPointWorld: Vector3;
  89544. /**
  89545. * Gets the ray "start point" of the ray in the world
  89546. */
  89547. readonly rayFromWorld: Vector3;
  89548. /**
  89549. * Gets the ray "end point" of the ray in the world
  89550. */
  89551. readonly rayToWorld: Vector3;
  89552. /**
  89553. * Sets the hit data (normal & point in world space)
  89554. * @param hitNormalWorld defines the normal in world space
  89555. * @param hitPointWorld defines the point in world space
  89556. */
  89557. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89558. /**
  89559. * Sets the distance from the start point to the hit point
  89560. * @param distance
  89561. */
  89562. setHitDistance(distance: number): void;
  89563. /**
  89564. * Calculates the distance manually
  89565. */
  89566. calculateHitDistance(): void;
  89567. /**
  89568. * Resets all the values to default
  89569. * @param from The from point on world space
  89570. * @param to The to point on world space
  89571. */
  89572. reset(from?: Vector3, to?: Vector3): void;
  89573. }
  89574. /**
  89575. * Interface for the size containing width and height
  89576. */
  89577. interface IXYZ {
  89578. /**
  89579. * X
  89580. */
  89581. x: number;
  89582. /**
  89583. * Y
  89584. */
  89585. y: number;
  89586. /**
  89587. * Z
  89588. */
  89589. z: number;
  89590. }
  89591. }
  89592. declare module BABYLON {
  89593. /**
  89594. * Interface used to describe a physics joint
  89595. */
  89596. export interface PhysicsImpostorJoint {
  89597. /** Defines the main impostor to which the joint is linked */
  89598. mainImpostor: PhysicsImpostor;
  89599. /** Defines the impostor that is connected to the main impostor using this joint */
  89600. connectedImpostor: PhysicsImpostor;
  89601. /** Defines the joint itself */
  89602. joint: PhysicsJoint;
  89603. }
  89604. /** @hidden */
  89605. export interface IPhysicsEnginePlugin {
  89606. world: any;
  89607. name: string;
  89608. setGravity(gravity: Vector3): void;
  89609. setTimeStep(timeStep: number): void;
  89610. getTimeStep(): number;
  89611. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89612. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89613. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89614. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89615. removePhysicsBody(impostor: PhysicsImpostor): void;
  89616. generateJoint(joint: PhysicsImpostorJoint): void;
  89617. removeJoint(joint: PhysicsImpostorJoint): void;
  89618. isSupported(): boolean;
  89619. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89620. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89621. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89622. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89623. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89624. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89625. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89626. getBodyMass(impostor: PhysicsImpostor): number;
  89627. getBodyFriction(impostor: PhysicsImpostor): number;
  89628. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89629. getBodyRestitution(impostor: PhysicsImpostor): number;
  89630. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89631. getBodyPressure?(impostor: PhysicsImpostor): number;
  89632. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89633. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89634. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89635. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89636. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89637. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89638. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89639. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89640. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89641. sleepBody(impostor: PhysicsImpostor): void;
  89642. wakeUpBody(impostor: PhysicsImpostor): void;
  89643. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89644. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89645. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89646. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89647. getRadius(impostor: PhysicsImpostor): number;
  89648. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89649. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89650. dispose(): void;
  89651. }
  89652. /**
  89653. * Interface used to define a physics engine
  89654. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89655. */
  89656. export interface IPhysicsEngine {
  89657. /**
  89658. * Gets the gravity vector used by the simulation
  89659. */
  89660. gravity: Vector3;
  89661. /**
  89662. * Sets the gravity vector used by the simulation
  89663. * @param gravity defines the gravity vector to use
  89664. */
  89665. setGravity(gravity: Vector3): void;
  89666. /**
  89667. * Set the time step of the physics engine.
  89668. * Default is 1/60.
  89669. * To slow it down, enter 1/600 for example.
  89670. * To speed it up, 1/30
  89671. * @param newTimeStep the new timestep to apply to this world.
  89672. */
  89673. setTimeStep(newTimeStep: number): void;
  89674. /**
  89675. * Get the time step of the physics engine.
  89676. * @returns the current time step
  89677. */
  89678. getTimeStep(): number;
  89679. /**
  89680. * Release all resources
  89681. */
  89682. dispose(): void;
  89683. /**
  89684. * Gets the name of the current physics plugin
  89685. * @returns the name of the plugin
  89686. */
  89687. getPhysicsPluginName(): string;
  89688. /**
  89689. * Adding a new impostor for the impostor tracking.
  89690. * This will be done by the impostor itself.
  89691. * @param impostor the impostor to add
  89692. */
  89693. addImpostor(impostor: PhysicsImpostor): void;
  89694. /**
  89695. * Remove an impostor from the engine.
  89696. * This impostor and its mesh will not longer be updated by the physics engine.
  89697. * @param impostor the impostor to remove
  89698. */
  89699. removeImpostor(impostor: PhysicsImpostor): void;
  89700. /**
  89701. * Add a joint to the physics engine
  89702. * @param mainImpostor defines the main impostor to which the joint is added.
  89703. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89704. * @param joint defines the joint that will connect both impostors.
  89705. */
  89706. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89707. /**
  89708. * Removes a joint from the simulation
  89709. * @param mainImpostor defines the impostor used with the joint
  89710. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89711. * @param joint defines the joint to remove
  89712. */
  89713. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89714. /**
  89715. * Gets the current plugin used to run the simulation
  89716. * @returns current plugin
  89717. */
  89718. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89719. /**
  89720. * Gets the list of physic impostors
  89721. * @returns an array of PhysicsImpostor
  89722. */
  89723. getImpostors(): Array<PhysicsImpostor>;
  89724. /**
  89725. * Gets the impostor for a physics enabled object
  89726. * @param object defines the object impersonated by the impostor
  89727. * @returns the PhysicsImpostor or null if not found
  89728. */
  89729. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89730. /**
  89731. * Gets the impostor for a physics body object
  89732. * @param body defines physics body used by the impostor
  89733. * @returns the PhysicsImpostor or null if not found
  89734. */
  89735. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89736. /**
  89737. * Does a raycast in the physics world
  89738. * @param from when should the ray start?
  89739. * @param to when should the ray end?
  89740. * @returns PhysicsRaycastResult
  89741. */
  89742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89743. /**
  89744. * Called by the scene. No need to call it.
  89745. * @param delta defines the timespam between frames
  89746. */
  89747. _step(delta: number): void;
  89748. }
  89749. }
  89750. declare module BABYLON {
  89751. /**
  89752. * The interface for the physics imposter parameters
  89753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89754. */
  89755. export interface PhysicsImpostorParameters {
  89756. /**
  89757. * The mass of the physics imposter
  89758. */
  89759. mass: number;
  89760. /**
  89761. * The friction of the physics imposter
  89762. */
  89763. friction?: number;
  89764. /**
  89765. * The coefficient of restitution of the physics imposter
  89766. */
  89767. restitution?: number;
  89768. /**
  89769. * The native options of the physics imposter
  89770. */
  89771. nativeOptions?: any;
  89772. /**
  89773. * Specifies if the parent should be ignored
  89774. */
  89775. ignoreParent?: boolean;
  89776. /**
  89777. * Specifies if bi-directional transformations should be disabled
  89778. */
  89779. disableBidirectionalTransformation?: boolean;
  89780. /**
  89781. * The pressure inside the physics imposter, soft object only
  89782. */
  89783. pressure?: number;
  89784. /**
  89785. * The stiffness the physics imposter, soft object only
  89786. */
  89787. stiffness?: number;
  89788. /**
  89789. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89790. */
  89791. velocityIterations?: number;
  89792. /**
  89793. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89794. */
  89795. positionIterations?: number;
  89796. /**
  89797. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89798. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89799. * Add to fix multiple points
  89800. */
  89801. fixedPoints?: number;
  89802. /**
  89803. * The collision margin around a soft object
  89804. */
  89805. margin?: number;
  89806. /**
  89807. * The collision margin around a soft object
  89808. */
  89809. damping?: number;
  89810. /**
  89811. * The path for a rope based on an extrusion
  89812. */
  89813. path?: any;
  89814. /**
  89815. * The shape of an extrusion used for a rope based on an extrusion
  89816. */
  89817. shape?: any;
  89818. }
  89819. /**
  89820. * Interface for a physics-enabled object
  89821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89822. */
  89823. export interface IPhysicsEnabledObject {
  89824. /**
  89825. * The position of the physics-enabled object
  89826. */
  89827. position: Vector3;
  89828. /**
  89829. * The rotation of the physics-enabled object
  89830. */
  89831. rotationQuaternion: Nullable<Quaternion>;
  89832. /**
  89833. * The scale of the physics-enabled object
  89834. */
  89835. scaling: Vector3;
  89836. /**
  89837. * The rotation of the physics-enabled object
  89838. */
  89839. rotation?: Vector3;
  89840. /**
  89841. * The parent of the physics-enabled object
  89842. */
  89843. parent?: any;
  89844. /**
  89845. * The bounding info of the physics-enabled object
  89846. * @returns The bounding info of the physics-enabled object
  89847. */
  89848. getBoundingInfo(): BoundingInfo;
  89849. /**
  89850. * Computes the world matrix
  89851. * @param force Specifies if the world matrix should be computed by force
  89852. * @returns A world matrix
  89853. */
  89854. computeWorldMatrix(force: boolean): Matrix;
  89855. /**
  89856. * Gets the world matrix
  89857. * @returns A world matrix
  89858. */
  89859. getWorldMatrix?(): Matrix;
  89860. /**
  89861. * Gets the child meshes
  89862. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89863. * @returns An array of abstract meshes
  89864. */
  89865. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89866. /**
  89867. * Gets the vertex data
  89868. * @param kind The type of vertex data
  89869. * @returns A nullable array of numbers, or a float32 array
  89870. */
  89871. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89872. /**
  89873. * Gets the indices from the mesh
  89874. * @returns A nullable array of index arrays
  89875. */
  89876. getIndices?(): Nullable<IndicesArray>;
  89877. /**
  89878. * Gets the scene from the mesh
  89879. * @returns the indices array or null
  89880. */
  89881. getScene?(): Scene;
  89882. /**
  89883. * Gets the absolute position from the mesh
  89884. * @returns the absolute position
  89885. */
  89886. getAbsolutePosition(): Vector3;
  89887. /**
  89888. * Gets the absolute pivot point from the mesh
  89889. * @returns the absolute pivot point
  89890. */
  89891. getAbsolutePivotPoint(): Vector3;
  89892. /**
  89893. * Rotates the mesh
  89894. * @param axis The axis of rotation
  89895. * @param amount The amount of rotation
  89896. * @param space The space of the rotation
  89897. * @returns The rotation transform node
  89898. */
  89899. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89900. /**
  89901. * Translates the mesh
  89902. * @param axis The axis of translation
  89903. * @param distance The distance of translation
  89904. * @param space The space of the translation
  89905. * @returns The transform node
  89906. */
  89907. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89908. /**
  89909. * Sets the absolute position of the mesh
  89910. * @param absolutePosition The absolute position of the mesh
  89911. * @returns The transform node
  89912. */
  89913. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89914. /**
  89915. * Gets the class name of the mesh
  89916. * @returns The class name
  89917. */
  89918. getClassName(): string;
  89919. }
  89920. /**
  89921. * Represents a physics imposter
  89922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89923. */
  89924. export class PhysicsImpostor {
  89925. /**
  89926. * The physics-enabled object used as the physics imposter
  89927. */
  89928. object: IPhysicsEnabledObject;
  89929. /**
  89930. * The type of the physics imposter
  89931. */
  89932. type: number;
  89933. private _options;
  89934. private _scene?;
  89935. /**
  89936. * The default object size of the imposter
  89937. */
  89938. static DEFAULT_OBJECT_SIZE: Vector3;
  89939. /**
  89940. * The identity quaternion of the imposter
  89941. */
  89942. static IDENTITY_QUATERNION: Quaternion;
  89943. /** @hidden */
  89944. _pluginData: any;
  89945. private _physicsEngine;
  89946. private _physicsBody;
  89947. private _bodyUpdateRequired;
  89948. private _onBeforePhysicsStepCallbacks;
  89949. private _onAfterPhysicsStepCallbacks;
  89950. /** @hidden */
  89951. _onPhysicsCollideCallbacks: Array<{
  89952. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89953. otherImpostors: Array<PhysicsImpostor>;
  89954. }>;
  89955. private _deltaPosition;
  89956. private _deltaRotation;
  89957. private _deltaRotationConjugated;
  89958. /** @hidden */
  89959. _isFromLine: boolean;
  89960. private _parent;
  89961. private _isDisposed;
  89962. private static _tmpVecs;
  89963. private static _tmpQuat;
  89964. /**
  89965. * Specifies if the physics imposter is disposed
  89966. */
  89967. readonly isDisposed: boolean;
  89968. /**
  89969. * Gets the mass of the physics imposter
  89970. */
  89971. mass: number;
  89972. /**
  89973. * Gets the coefficient of friction
  89974. */
  89975. /**
  89976. * Sets the coefficient of friction
  89977. */
  89978. friction: number;
  89979. /**
  89980. * Gets the coefficient of restitution
  89981. */
  89982. /**
  89983. * Sets the coefficient of restitution
  89984. */
  89985. restitution: number;
  89986. /**
  89987. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89988. */
  89989. /**
  89990. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89991. */
  89992. pressure: number;
  89993. /**
  89994. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89995. */
  89996. /**
  89997. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89998. */
  89999. stiffness: number;
  90000. /**
  90001. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90002. */
  90003. /**
  90004. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90005. */
  90006. velocityIterations: number;
  90007. /**
  90008. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90009. */
  90010. /**
  90011. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90012. */
  90013. positionIterations: number;
  90014. /**
  90015. * The unique id of the physics imposter
  90016. * set by the physics engine when adding this impostor to the array
  90017. */
  90018. uniqueId: number;
  90019. /**
  90020. * @hidden
  90021. */
  90022. soft: boolean;
  90023. /**
  90024. * @hidden
  90025. */
  90026. segments: number;
  90027. private _joints;
  90028. /**
  90029. * Initializes the physics imposter
  90030. * @param object The physics-enabled object used as the physics imposter
  90031. * @param type The type of the physics imposter
  90032. * @param _options The options for the physics imposter
  90033. * @param _scene The Babylon scene
  90034. */
  90035. constructor(
  90036. /**
  90037. * The physics-enabled object used as the physics imposter
  90038. */
  90039. object: IPhysicsEnabledObject,
  90040. /**
  90041. * The type of the physics imposter
  90042. */
  90043. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90044. /**
  90045. * This function will completly initialize this impostor.
  90046. * It will create a new body - but only if this mesh has no parent.
  90047. * If it has, this impostor will not be used other than to define the impostor
  90048. * of the child mesh.
  90049. * @hidden
  90050. */
  90051. _init(): void;
  90052. private _getPhysicsParent;
  90053. /**
  90054. * Should a new body be generated.
  90055. * @returns boolean specifying if body initialization is required
  90056. */
  90057. isBodyInitRequired(): boolean;
  90058. /**
  90059. * Sets the updated scaling
  90060. * @param updated Specifies if the scaling is updated
  90061. */
  90062. setScalingUpdated(): void;
  90063. /**
  90064. * Force a regeneration of this or the parent's impostor's body.
  90065. * Use under cautious - This will remove all joints already implemented.
  90066. */
  90067. forceUpdate(): void;
  90068. /**
  90069. * Gets the body that holds this impostor. Either its own, or its parent.
  90070. */
  90071. /**
  90072. * Set the physics body. Used mainly by the physics engine/plugin
  90073. */
  90074. physicsBody: any;
  90075. /**
  90076. * Get the parent of the physics imposter
  90077. * @returns Physics imposter or null
  90078. */
  90079. /**
  90080. * Sets the parent of the physics imposter
  90081. */
  90082. parent: Nullable<PhysicsImpostor>;
  90083. /**
  90084. * Resets the update flags
  90085. */
  90086. resetUpdateFlags(): void;
  90087. /**
  90088. * Gets the object extend size
  90089. * @returns the object extend size
  90090. */
  90091. getObjectExtendSize(): Vector3;
  90092. /**
  90093. * Gets the object center
  90094. * @returns The object center
  90095. */
  90096. getObjectCenter(): Vector3;
  90097. /**
  90098. * Get a specific parametes from the options parameter
  90099. * @param paramName The object parameter name
  90100. * @returns The object parameter
  90101. */
  90102. getParam(paramName: string): any;
  90103. /**
  90104. * Sets a specific parameter in the options given to the physics plugin
  90105. * @param paramName The parameter name
  90106. * @param value The value of the parameter
  90107. */
  90108. setParam(paramName: string, value: number): void;
  90109. /**
  90110. * Specifically change the body's mass option. Won't recreate the physics body object
  90111. * @param mass The mass of the physics imposter
  90112. */
  90113. setMass(mass: number): void;
  90114. /**
  90115. * Gets the linear velocity
  90116. * @returns linear velocity or null
  90117. */
  90118. getLinearVelocity(): Nullable<Vector3>;
  90119. /**
  90120. * Sets the linear velocity
  90121. * @param velocity linear velocity or null
  90122. */
  90123. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90124. /**
  90125. * Gets the angular velocity
  90126. * @returns angular velocity or null
  90127. */
  90128. getAngularVelocity(): Nullable<Vector3>;
  90129. /**
  90130. * Sets the angular velocity
  90131. * @param velocity The velocity or null
  90132. */
  90133. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90134. /**
  90135. * Execute a function with the physics plugin native code
  90136. * Provide a function the will have two variables - the world object and the physics body object
  90137. * @param func The function to execute with the physics plugin native code
  90138. */
  90139. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90140. /**
  90141. * Register a function that will be executed before the physics world is stepping forward
  90142. * @param func The function to execute before the physics world is stepped forward
  90143. */
  90144. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90145. /**
  90146. * Unregister a function that will be executed before the physics world is stepping forward
  90147. * @param func The function to execute before the physics world is stepped forward
  90148. */
  90149. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90150. /**
  90151. * Register a function that will be executed after the physics step
  90152. * @param func The function to execute after physics step
  90153. */
  90154. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90155. /**
  90156. * Unregisters a function that will be executed after the physics step
  90157. * @param func The function to execute after physics step
  90158. */
  90159. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90160. /**
  90161. * register a function that will be executed when this impostor collides against a different body
  90162. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90163. * @param func Callback that is executed on collision
  90164. */
  90165. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90166. /**
  90167. * Unregisters the physics imposter on contact
  90168. * @param collideAgainst The physics object to collide against
  90169. * @param func Callback to execute on collision
  90170. */
  90171. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90172. private _tmpQuat;
  90173. private _tmpQuat2;
  90174. /**
  90175. * Get the parent rotation
  90176. * @returns The parent rotation
  90177. */
  90178. getParentsRotation(): Quaternion;
  90179. /**
  90180. * this function is executed by the physics engine.
  90181. */
  90182. beforeStep: () => void;
  90183. /**
  90184. * this function is executed by the physics engine
  90185. */
  90186. afterStep: () => void;
  90187. /**
  90188. * Legacy collision detection event support
  90189. */
  90190. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90191. /**
  90192. * event and body object due to cannon's event-based architecture.
  90193. */
  90194. onCollide: (e: {
  90195. body: any;
  90196. }) => void;
  90197. /**
  90198. * Apply a force
  90199. * @param force The force to apply
  90200. * @param contactPoint The contact point for the force
  90201. * @returns The physics imposter
  90202. */
  90203. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90204. /**
  90205. * Apply an impulse
  90206. * @param force The impulse force
  90207. * @param contactPoint The contact point for the impulse force
  90208. * @returns The physics imposter
  90209. */
  90210. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90211. /**
  90212. * A help function to create a joint
  90213. * @param otherImpostor A physics imposter used to create a joint
  90214. * @param jointType The type of joint
  90215. * @param jointData The data for the joint
  90216. * @returns The physics imposter
  90217. */
  90218. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90219. /**
  90220. * Add a joint to this impostor with a different impostor
  90221. * @param otherImpostor A physics imposter used to add a joint
  90222. * @param joint The joint to add
  90223. * @returns The physics imposter
  90224. */
  90225. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90226. /**
  90227. * Add an anchor to a cloth impostor
  90228. * @param otherImpostor rigid impostor to anchor to
  90229. * @param width ratio across width from 0 to 1
  90230. * @param height ratio up height from 0 to 1
  90231. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90232. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90233. * @returns impostor the soft imposter
  90234. */
  90235. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90236. /**
  90237. * Add a hook to a rope impostor
  90238. * @param otherImpostor rigid impostor to anchor to
  90239. * @param length ratio across rope from 0 to 1
  90240. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90241. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90242. * @returns impostor the rope imposter
  90243. */
  90244. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90245. /**
  90246. * Will keep this body still, in a sleep mode.
  90247. * @returns the physics imposter
  90248. */
  90249. sleep(): PhysicsImpostor;
  90250. /**
  90251. * Wake the body up.
  90252. * @returns The physics imposter
  90253. */
  90254. wakeUp(): PhysicsImpostor;
  90255. /**
  90256. * Clones the physics imposter
  90257. * @param newObject The physics imposter clones to this physics-enabled object
  90258. * @returns A nullable physics imposter
  90259. */
  90260. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90261. /**
  90262. * Disposes the physics imposter
  90263. */
  90264. dispose(): void;
  90265. /**
  90266. * Sets the delta position
  90267. * @param position The delta position amount
  90268. */
  90269. setDeltaPosition(position: Vector3): void;
  90270. /**
  90271. * Sets the delta rotation
  90272. * @param rotation The delta rotation amount
  90273. */
  90274. setDeltaRotation(rotation: Quaternion): void;
  90275. /**
  90276. * Gets the box size of the physics imposter and stores the result in the input parameter
  90277. * @param result Stores the box size
  90278. * @returns The physics imposter
  90279. */
  90280. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90281. /**
  90282. * Gets the radius of the physics imposter
  90283. * @returns Radius of the physics imposter
  90284. */
  90285. getRadius(): number;
  90286. /**
  90287. * Sync a bone with this impostor
  90288. * @param bone The bone to sync to the impostor.
  90289. * @param boneMesh The mesh that the bone is influencing.
  90290. * @param jointPivot The pivot of the joint / bone in local space.
  90291. * @param distToJoint Optional distance from the impostor to the joint.
  90292. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90293. */
  90294. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90295. /**
  90296. * Sync impostor to a bone
  90297. * @param bone The bone that the impostor will be synced to.
  90298. * @param boneMesh The mesh that the bone is influencing.
  90299. * @param jointPivot The pivot of the joint / bone in local space.
  90300. * @param distToJoint Optional distance from the impostor to the joint.
  90301. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90302. * @param boneAxis Optional vector3 axis the bone is aligned with
  90303. */
  90304. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90305. /**
  90306. * No-Imposter type
  90307. */
  90308. static NoImpostor: number;
  90309. /**
  90310. * Sphere-Imposter type
  90311. */
  90312. static SphereImpostor: number;
  90313. /**
  90314. * Box-Imposter type
  90315. */
  90316. static BoxImpostor: number;
  90317. /**
  90318. * Plane-Imposter type
  90319. */
  90320. static PlaneImpostor: number;
  90321. /**
  90322. * Mesh-imposter type
  90323. */
  90324. static MeshImpostor: number;
  90325. /**
  90326. * Capsule-Impostor type (Ammo.js plugin only)
  90327. */
  90328. static CapsuleImpostor: number;
  90329. /**
  90330. * Cylinder-Imposter type
  90331. */
  90332. static CylinderImpostor: number;
  90333. /**
  90334. * Particle-Imposter type
  90335. */
  90336. static ParticleImpostor: number;
  90337. /**
  90338. * Heightmap-Imposter type
  90339. */
  90340. static HeightmapImpostor: number;
  90341. /**
  90342. * ConvexHull-Impostor type (Ammo.js plugin only)
  90343. */
  90344. static ConvexHullImpostor: number;
  90345. /**
  90346. * Rope-Imposter type
  90347. */
  90348. static RopeImpostor: number;
  90349. /**
  90350. * Cloth-Imposter type
  90351. */
  90352. static ClothImpostor: number;
  90353. /**
  90354. * Softbody-Imposter type
  90355. */
  90356. static SoftbodyImpostor: number;
  90357. }
  90358. }
  90359. declare module BABYLON {
  90360. /**
  90361. * @hidden
  90362. **/
  90363. export class _CreationDataStorage {
  90364. closePath?: boolean;
  90365. closeArray?: boolean;
  90366. idx: number[];
  90367. dashSize: number;
  90368. gapSize: number;
  90369. path3D: Path3D;
  90370. pathArray: Vector3[][];
  90371. arc: number;
  90372. radius: number;
  90373. cap: number;
  90374. tessellation: number;
  90375. }
  90376. /**
  90377. * @hidden
  90378. **/
  90379. class _InstanceDataStorage {
  90380. visibleInstances: any;
  90381. batchCache: _InstancesBatch;
  90382. instancesBufferSize: number;
  90383. instancesBuffer: Nullable<Buffer>;
  90384. instancesData: Float32Array;
  90385. overridenInstanceCount: number;
  90386. isFrozen: boolean;
  90387. previousBatch: Nullable<_InstancesBatch>;
  90388. hardwareInstancedRendering: boolean;
  90389. sideOrientation: number;
  90390. }
  90391. /**
  90392. * @hidden
  90393. **/
  90394. export class _InstancesBatch {
  90395. mustReturn: boolean;
  90396. visibleInstances: Nullable<InstancedMesh[]>[];
  90397. renderSelf: boolean[];
  90398. hardwareInstancedRendering: boolean[];
  90399. }
  90400. /**
  90401. * Class used to represent renderable models
  90402. */
  90403. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90404. /**
  90405. * Mesh side orientation : usually the external or front surface
  90406. */
  90407. static readonly FRONTSIDE: number;
  90408. /**
  90409. * Mesh side orientation : usually the internal or back surface
  90410. */
  90411. static readonly BACKSIDE: number;
  90412. /**
  90413. * Mesh side orientation : both internal and external or front and back surfaces
  90414. */
  90415. static readonly DOUBLESIDE: number;
  90416. /**
  90417. * Mesh side orientation : by default, `FRONTSIDE`
  90418. */
  90419. static readonly DEFAULTSIDE: number;
  90420. /**
  90421. * Mesh cap setting : no cap
  90422. */
  90423. static readonly NO_CAP: number;
  90424. /**
  90425. * Mesh cap setting : one cap at the beginning of the mesh
  90426. */
  90427. static readonly CAP_START: number;
  90428. /**
  90429. * Mesh cap setting : one cap at the end of the mesh
  90430. */
  90431. static readonly CAP_END: number;
  90432. /**
  90433. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90434. */
  90435. static readonly CAP_ALL: number;
  90436. /**
  90437. * Mesh pattern setting : no flip or rotate
  90438. */
  90439. static readonly NO_FLIP: number;
  90440. /**
  90441. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90442. */
  90443. static readonly FLIP_TILE: number;
  90444. /**
  90445. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90446. */
  90447. static readonly ROTATE_TILE: number;
  90448. /**
  90449. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90450. */
  90451. static readonly FLIP_ROW: number;
  90452. /**
  90453. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90454. */
  90455. static readonly ROTATE_ROW: number;
  90456. /**
  90457. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90458. */
  90459. static readonly FLIP_N_ROTATE_TILE: number;
  90460. /**
  90461. * Mesh pattern setting : rotate pattern and rotate
  90462. */
  90463. static readonly FLIP_N_ROTATE_ROW: number;
  90464. /**
  90465. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90466. */
  90467. static readonly CENTER: number;
  90468. /**
  90469. * Mesh tile positioning : part tiles on left
  90470. */
  90471. static readonly LEFT: number;
  90472. /**
  90473. * Mesh tile positioning : part tiles on right
  90474. */
  90475. static readonly RIGHT: number;
  90476. /**
  90477. * Mesh tile positioning : part tiles on top
  90478. */
  90479. static readonly TOP: number;
  90480. /**
  90481. * Mesh tile positioning : part tiles on bottom
  90482. */
  90483. static readonly BOTTOM: number;
  90484. /**
  90485. * Gets the default side orientation.
  90486. * @param orientation the orientation to value to attempt to get
  90487. * @returns the default orientation
  90488. * @hidden
  90489. */
  90490. static _GetDefaultSideOrientation(orientation?: number): number;
  90491. private _internalMeshDataInfo;
  90492. /**
  90493. * An event triggered before rendering the mesh
  90494. */
  90495. readonly onBeforeRenderObservable: Observable<Mesh>;
  90496. /**
  90497. * An event triggered before binding the mesh
  90498. */
  90499. readonly onBeforeBindObservable: Observable<Mesh>;
  90500. /**
  90501. * An event triggered after rendering the mesh
  90502. */
  90503. readonly onAfterRenderObservable: Observable<Mesh>;
  90504. /**
  90505. * An event triggered before drawing the mesh
  90506. */
  90507. readonly onBeforeDrawObservable: Observable<Mesh>;
  90508. private _onBeforeDrawObserver;
  90509. /**
  90510. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90511. */
  90512. onBeforeDraw: () => void;
  90513. readonly hasInstances: boolean;
  90514. /**
  90515. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90516. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90517. */
  90518. delayLoadState: number;
  90519. /**
  90520. * Gets the list of instances created from this mesh
  90521. * it is not supposed to be modified manually.
  90522. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90523. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90524. */
  90525. instances: InstancedMesh[];
  90526. /**
  90527. * Gets the file containing delay loading data for this mesh
  90528. */
  90529. delayLoadingFile: string;
  90530. /** @hidden */
  90531. _binaryInfo: any;
  90532. /**
  90533. * User defined function used to change how LOD level selection is done
  90534. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90535. */
  90536. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90537. /**
  90538. * Gets or sets the morph target manager
  90539. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90540. */
  90541. morphTargetManager: Nullable<MorphTargetManager>;
  90542. /** @hidden */
  90543. _creationDataStorage: Nullable<_CreationDataStorage>;
  90544. /** @hidden */
  90545. _geometry: Nullable<Geometry>;
  90546. /** @hidden */
  90547. _delayInfo: Array<string>;
  90548. /** @hidden */
  90549. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90550. /** @hidden */
  90551. _instanceDataStorage: _InstanceDataStorage;
  90552. private _effectiveMaterial;
  90553. /** @hidden */
  90554. _shouldGenerateFlatShading: boolean;
  90555. /** @hidden */
  90556. _originalBuilderSideOrientation: number;
  90557. /**
  90558. * Use this property to change the original side orientation defined at construction time
  90559. */
  90560. overrideMaterialSideOrientation: Nullable<number>;
  90561. /**
  90562. * Gets the source mesh (the one used to clone this one from)
  90563. */
  90564. readonly source: Nullable<Mesh>;
  90565. /**
  90566. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90567. */
  90568. isUnIndexed: boolean;
  90569. /**
  90570. * @constructor
  90571. * @param name The value used by scene.getMeshByName() to do a lookup.
  90572. * @param scene The scene to add this mesh to.
  90573. * @param parent The parent of this mesh, if it has one
  90574. * @param source An optional Mesh from which geometry is shared, cloned.
  90575. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90576. * When false, achieved by calling a clone(), also passing False.
  90577. * This will make creation of children, recursive.
  90578. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90579. */
  90580. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90581. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90582. /**
  90583. * Gets the class name
  90584. * @returns the string "Mesh".
  90585. */
  90586. getClassName(): string;
  90587. /** @hidden */
  90588. readonly _isMesh: boolean;
  90589. /**
  90590. * Returns a description of this mesh
  90591. * @param fullDetails define if full details about this mesh must be used
  90592. * @returns a descriptive string representing this mesh
  90593. */
  90594. toString(fullDetails?: boolean): string;
  90595. /** @hidden */
  90596. _unBindEffect(): void;
  90597. /**
  90598. * Gets a boolean indicating if this mesh has LOD
  90599. */
  90600. readonly hasLODLevels: boolean;
  90601. /**
  90602. * Gets the list of MeshLODLevel associated with the current mesh
  90603. * @returns an array of MeshLODLevel
  90604. */
  90605. getLODLevels(): MeshLODLevel[];
  90606. private _sortLODLevels;
  90607. /**
  90608. * Add a mesh as LOD level triggered at the given distance.
  90609. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90610. * @param distance The distance from the center of the object to show this level
  90611. * @param mesh The mesh to be added as LOD level (can be null)
  90612. * @return This mesh (for chaining)
  90613. */
  90614. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90615. /**
  90616. * Returns the LOD level mesh at the passed distance or null if not found.
  90617. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90618. * @param distance The distance from the center of the object to show this level
  90619. * @returns a Mesh or `null`
  90620. */
  90621. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90622. /**
  90623. * Remove a mesh from the LOD array
  90624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90625. * @param mesh defines the mesh to be removed
  90626. * @return This mesh (for chaining)
  90627. */
  90628. removeLODLevel(mesh: Mesh): Mesh;
  90629. /**
  90630. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90631. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90632. * @param camera defines the camera to use to compute distance
  90633. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90634. * @return This mesh (for chaining)
  90635. */
  90636. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90637. /**
  90638. * Gets the mesh internal Geometry object
  90639. */
  90640. readonly geometry: Nullable<Geometry>;
  90641. /**
  90642. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90643. * @returns the total number of vertices
  90644. */
  90645. getTotalVertices(): number;
  90646. /**
  90647. * Returns the content of an associated vertex buffer
  90648. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90649. * - VertexBuffer.PositionKind
  90650. * - VertexBuffer.UVKind
  90651. * - VertexBuffer.UV2Kind
  90652. * - VertexBuffer.UV3Kind
  90653. * - VertexBuffer.UV4Kind
  90654. * - VertexBuffer.UV5Kind
  90655. * - VertexBuffer.UV6Kind
  90656. * - VertexBuffer.ColorKind
  90657. * - VertexBuffer.MatricesIndicesKind
  90658. * - VertexBuffer.MatricesIndicesExtraKind
  90659. * - VertexBuffer.MatricesWeightsKind
  90660. * - VertexBuffer.MatricesWeightsExtraKind
  90661. * @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
  90662. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90663. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90664. */
  90665. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90666. /**
  90667. * Returns the mesh VertexBuffer object from the requested `kind`
  90668. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90669. * - VertexBuffer.PositionKind
  90670. * - VertexBuffer.NormalKind
  90671. * - VertexBuffer.UVKind
  90672. * - VertexBuffer.UV2Kind
  90673. * - VertexBuffer.UV3Kind
  90674. * - VertexBuffer.UV4Kind
  90675. * - VertexBuffer.UV5Kind
  90676. * - VertexBuffer.UV6Kind
  90677. * - VertexBuffer.ColorKind
  90678. * - VertexBuffer.MatricesIndicesKind
  90679. * - VertexBuffer.MatricesIndicesExtraKind
  90680. * - VertexBuffer.MatricesWeightsKind
  90681. * - VertexBuffer.MatricesWeightsExtraKind
  90682. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90683. */
  90684. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90685. /**
  90686. * Tests if a specific vertex buffer is associated with this mesh
  90687. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90688. * - VertexBuffer.PositionKind
  90689. * - VertexBuffer.NormalKind
  90690. * - VertexBuffer.UVKind
  90691. * - VertexBuffer.UV2Kind
  90692. * - VertexBuffer.UV3Kind
  90693. * - VertexBuffer.UV4Kind
  90694. * - VertexBuffer.UV5Kind
  90695. * - VertexBuffer.UV6Kind
  90696. * - VertexBuffer.ColorKind
  90697. * - VertexBuffer.MatricesIndicesKind
  90698. * - VertexBuffer.MatricesIndicesExtraKind
  90699. * - VertexBuffer.MatricesWeightsKind
  90700. * - VertexBuffer.MatricesWeightsExtraKind
  90701. * @returns a boolean
  90702. */
  90703. isVerticesDataPresent(kind: string): boolean;
  90704. /**
  90705. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90706. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90707. * - VertexBuffer.PositionKind
  90708. * - VertexBuffer.UVKind
  90709. * - VertexBuffer.UV2Kind
  90710. * - VertexBuffer.UV3Kind
  90711. * - VertexBuffer.UV4Kind
  90712. * - VertexBuffer.UV5Kind
  90713. * - VertexBuffer.UV6Kind
  90714. * - VertexBuffer.ColorKind
  90715. * - VertexBuffer.MatricesIndicesKind
  90716. * - VertexBuffer.MatricesIndicesExtraKind
  90717. * - VertexBuffer.MatricesWeightsKind
  90718. * - VertexBuffer.MatricesWeightsExtraKind
  90719. * @returns a boolean
  90720. */
  90721. isVertexBufferUpdatable(kind: string): boolean;
  90722. /**
  90723. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90724. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90725. * - VertexBuffer.PositionKind
  90726. * - VertexBuffer.NormalKind
  90727. * - VertexBuffer.UVKind
  90728. * - VertexBuffer.UV2Kind
  90729. * - VertexBuffer.UV3Kind
  90730. * - VertexBuffer.UV4Kind
  90731. * - VertexBuffer.UV5Kind
  90732. * - VertexBuffer.UV6Kind
  90733. * - VertexBuffer.ColorKind
  90734. * - VertexBuffer.MatricesIndicesKind
  90735. * - VertexBuffer.MatricesIndicesExtraKind
  90736. * - VertexBuffer.MatricesWeightsKind
  90737. * - VertexBuffer.MatricesWeightsExtraKind
  90738. * @returns an array of strings
  90739. */
  90740. getVerticesDataKinds(): string[];
  90741. /**
  90742. * Returns a positive integer : the total number of indices in this mesh geometry.
  90743. * @returns the numner of indices or zero if the mesh has no geometry.
  90744. */
  90745. getTotalIndices(): number;
  90746. /**
  90747. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90748. * @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.
  90749. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90750. * @returns the indices array or an empty array if the mesh has no geometry
  90751. */
  90752. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90753. readonly isBlocked: boolean;
  90754. /**
  90755. * Determine if the current mesh is ready to be rendered
  90756. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90757. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90758. * @returns true if all associated assets are ready (material, textures, shaders)
  90759. */
  90760. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90761. /**
  90762. * 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.
  90763. */
  90764. readonly areNormalsFrozen: boolean;
  90765. /**
  90766. * 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.
  90767. * @returns the current mesh
  90768. */
  90769. freezeNormals(): Mesh;
  90770. /**
  90771. * 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
  90772. * @returns the current mesh
  90773. */
  90774. unfreezeNormals(): Mesh;
  90775. /**
  90776. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90777. */
  90778. overridenInstanceCount: number;
  90779. /** @hidden */
  90780. _preActivate(): Mesh;
  90781. /** @hidden */
  90782. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90783. /** @hidden */
  90784. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90785. /**
  90786. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90787. * This means the mesh underlying bounding box and sphere are recomputed.
  90788. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90789. * @returns the current mesh
  90790. */
  90791. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90792. /** @hidden */
  90793. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90794. /**
  90795. * This function will subdivide the mesh into multiple submeshes
  90796. * @param count defines the expected number of submeshes
  90797. */
  90798. subdivide(count: number): void;
  90799. /**
  90800. * Copy a FloatArray into a specific associated vertex buffer
  90801. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90802. * - VertexBuffer.PositionKind
  90803. * - VertexBuffer.UVKind
  90804. * - VertexBuffer.UV2Kind
  90805. * - VertexBuffer.UV3Kind
  90806. * - VertexBuffer.UV4Kind
  90807. * - VertexBuffer.UV5Kind
  90808. * - VertexBuffer.UV6Kind
  90809. * - VertexBuffer.ColorKind
  90810. * - VertexBuffer.MatricesIndicesKind
  90811. * - VertexBuffer.MatricesIndicesExtraKind
  90812. * - VertexBuffer.MatricesWeightsKind
  90813. * - VertexBuffer.MatricesWeightsExtraKind
  90814. * @param data defines the data source
  90815. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90816. * @param stride defines the data stride size (can be null)
  90817. * @returns the current mesh
  90818. */
  90819. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90820. /**
  90821. * Flags an associated vertex buffer as updatable
  90822. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90823. * - VertexBuffer.PositionKind
  90824. * - VertexBuffer.UVKind
  90825. * - VertexBuffer.UV2Kind
  90826. * - VertexBuffer.UV3Kind
  90827. * - VertexBuffer.UV4Kind
  90828. * - VertexBuffer.UV5Kind
  90829. * - VertexBuffer.UV6Kind
  90830. * - VertexBuffer.ColorKind
  90831. * - VertexBuffer.MatricesIndicesKind
  90832. * - VertexBuffer.MatricesIndicesExtraKind
  90833. * - VertexBuffer.MatricesWeightsKind
  90834. * - VertexBuffer.MatricesWeightsExtraKind
  90835. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90836. */
  90837. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90838. /**
  90839. * Sets the mesh global Vertex Buffer
  90840. * @param buffer defines the buffer to use
  90841. * @returns the current mesh
  90842. */
  90843. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90844. /**
  90845. * Update a specific associated vertex buffer
  90846. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90847. * - VertexBuffer.PositionKind
  90848. * - VertexBuffer.UVKind
  90849. * - VertexBuffer.UV2Kind
  90850. * - VertexBuffer.UV3Kind
  90851. * - VertexBuffer.UV4Kind
  90852. * - VertexBuffer.UV5Kind
  90853. * - VertexBuffer.UV6Kind
  90854. * - VertexBuffer.ColorKind
  90855. * - VertexBuffer.MatricesIndicesKind
  90856. * - VertexBuffer.MatricesIndicesExtraKind
  90857. * - VertexBuffer.MatricesWeightsKind
  90858. * - VertexBuffer.MatricesWeightsExtraKind
  90859. * @param data defines the data source
  90860. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90861. * @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)
  90862. * @returns the current mesh
  90863. */
  90864. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90865. /**
  90866. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90867. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90868. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90869. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90870. * @returns the current mesh
  90871. */
  90872. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90873. /**
  90874. * Creates a un-shared specific occurence of the geometry for the mesh.
  90875. * @returns the current mesh
  90876. */
  90877. makeGeometryUnique(): Mesh;
  90878. /**
  90879. * Set the index buffer of this mesh
  90880. * @param indices defines the source data
  90881. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90882. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90883. * @returns the current mesh
  90884. */
  90885. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90886. /**
  90887. * Update the current index buffer
  90888. * @param indices defines the source data
  90889. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90890. * @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)
  90891. * @returns the current mesh
  90892. */
  90893. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90894. /**
  90895. * Invert the geometry to move from a right handed system to a left handed one.
  90896. * @returns the current mesh
  90897. */
  90898. toLeftHanded(): Mesh;
  90899. /** @hidden */
  90900. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90901. /** @hidden */
  90902. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90903. /**
  90904. * Registers for this mesh a javascript function called just before the rendering process
  90905. * @param func defines the function to call before rendering this mesh
  90906. * @returns the current mesh
  90907. */
  90908. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90909. /**
  90910. * Disposes a previously registered javascript function called before the rendering
  90911. * @param func defines the function to remove
  90912. * @returns the current mesh
  90913. */
  90914. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90915. /**
  90916. * Registers for this mesh a javascript function called just after the rendering is complete
  90917. * @param func defines the function to call after rendering this mesh
  90918. * @returns the current mesh
  90919. */
  90920. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90921. /**
  90922. * Disposes a previously registered javascript function called after the rendering.
  90923. * @param func defines the function to remove
  90924. * @returns the current mesh
  90925. */
  90926. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90927. /** @hidden */
  90928. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90929. /** @hidden */
  90930. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90931. /** @hidden */
  90932. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90933. /** @hidden */
  90934. _rebuild(): void;
  90935. /** @hidden */
  90936. _freeze(): void;
  90937. /** @hidden */
  90938. _unFreeze(): void;
  90939. /**
  90940. * 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
  90941. * @param subMesh defines the subMesh to render
  90942. * @param enableAlphaMode defines if alpha mode can be changed
  90943. * @returns the current mesh
  90944. */
  90945. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90946. private _onBeforeDraw;
  90947. /**
  90948. * Renormalize the mesh and patch it up if there are no weights
  90949. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90950. * However in the case of zero weights then we set just a single influence to 1.
  90951. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90952. */
  90953. cleanMatrixWeights(): void;
  90954. private normalizeSkinFourWeights;
  90955. private normalizeSkinWeightsAndExtra;
  90956. /**
  90957. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90958. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90959. * the user know there was an issue with importing the mesh
  90960. * @returns a validation object with skinned, valid and report string
  90961. */
  90962. validateSkinning(): {
  90963. skinned: boolean;
  90964. valid: boolean;
  90965. report: string;
  90966. };
  90967. /** @hidden */
  90968. _checkDelayState(): Mesh;
  90969. private _queueLoad;
  90970. /**
  90971. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90972. * A mesh is in the frustum if its bounding box intersects the frustum
  90973. * @param frustumPlanes defines the frustum to test
  90974. * @returns true if the mesh is in the frustum planes
  90975. */
  90976. isInFrustum(frustumPlanes: Plane[]): boolean;
  90977. /**
  90978. * Sets the mesh material by the material or multiMaterial `id` property
  90979. * @param id is a string identifying the material or the multiMaterial
  90980. * @returns the current mesh
  90981. */
  90982. setMaterialByID(id: string): Mesh;
  90983. /**
  90984. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90985. * @returns an array of IAnimatable
  90986. */
  90987. getAnimatables(): IAnimatable[];
  90988. /**
  90989. * Modifies the mesh geometry according to the passed transformation matrix.
  90990. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90991. * The mesh normals are modified using the same transformation.
  90992. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90993. * @param transform defines the transform matrix to use
  90994. * @see http://doc.babylonjs.com/resources/baking_transformations
  90995. * @returns the current mesh
  90996. */
  90997. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90998. /**
  90999. * Modifies the mesh geometry according to its own current World Matrix.
  91000. * The mesh World Matrix is then reset.
  91001. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91002. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91003. * @see http://doc.babylonjs.com/resources/baking_transformations
  91004. * @returns the current mesh
  91005. */
  91006. bakeCurrentTransformIntoVertices(): Mesh;
  91007. /** @hidden */
  91008. readonly _positions: Nullable<Vector3[]>;
  91009. /** @hidden */
  91010. _resetPointsArrayCache(): Mesh;
  91011. /** @hidden */
  91012. _generatePointsArray(): boolean;
  91013. /**
  91014. * Returns a new Mesh object generated from the current mesh properties.
  91015. * This method must not get confused with createInstance()
  91016. * @param name is a string, the name given to the new mesh
  91017. * @param newParent can be any Node object (default `null`)
  91018. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91019. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91020. * @returns a new mesh
  91021. */
  91022. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91023. /**
  91024. * Releases resources associated with this mesh.
  91025. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91026. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91027. */
  91028. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91029. /**
  91030. * Modifies the mesh geometry according to a displacement map.
  91031. * 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.
  91032. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91033. * @param url is a string, the URL from the image file is to be downloaded.
  91034. * @param minHeight is the lower limit of the displacement.
  91035. * @param maxHeight is the upper limit of the displacement.
  91036. * @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.
  91037. * @param uvOffset is an optional vector2 used to offset UV.
  91038. * @param uvScale is an optional vector2 used to scale UV.
  91039. * @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.
  91040. * @returns the Mesh.
  91041. */
  91042. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91043. /**
  91044. * Modifies the mesh geometry according to a displacementMap buffer.
  91045. * 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.
  91046. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91047. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91048. * @param heightMapWidth is the width of the buffer image.
  91049. * @param heightMapHeight is the height of the buffer image.
  91050. * @param minHeight is the lower limit of the displacement.
  91051. * @param maxHeight is the upper limit of the displacement.
  91052. * @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.
  91053. * @param uvOffset is an optional vector2 used to offset UV.
  91054. * @param uvScale is an optional vector2 used to scale UV.
  91055. * @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.
  91056. * @returns the Mesh.
  91057. */
  91058. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91059. /**
  91060. * Modify the mesh to get a flat shading rendering.
  91061. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91062. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91063. * @returns current mesh
  91064. */
  91065. convertToFlatShadedMesh(): Mesh;
  91066. /**
  91067. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91068. * In other words, more vertices, no more indices and a single bigger VBO.
  91069. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91070. * @returns current mesh
  91071. */
  91072. convertToUnIndexedMesh(): Mesh;
  91073. /**
  91074. * Inverses facet orientations.
  91075. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91076. * @param flipNormals will also inverts the normals
  91077. * @returns current mesh
  91078. */
  91079. flipFaces(flipNormals?: boolean): Mesh;
  91080. /**
  91081. * Increase the number of facets and hence vertices in a mesh
  91082. * Vertex normals are interpolated from existing vertex normals
  91083. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91084. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91085. */
  91086. increaseVertices(numberPerEdge: number): void;
  91087. /**
  91088. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91089. * This will undo any application of covertToFlatShadedMesh
  91090. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91091. */
  91092. forceSharedVertices(): void;
  91093. /** @hidden */
  91094. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91095. /** @hidden */
  91096. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91097. /**
  91098. * Creates a new InstancedMesh object from the mesh model.
  91099. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91100. * @param name defines the name of the new instance
  91101. * @returns a new InstancedMesh
  91102. */
  91103. createInstance(name: string): InstancedMesh;
  91104. /**
  91105. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91106. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91107. * @returns the current mesh
  91108. */
  91109. synchronizeInstances(): Mesh;
  91110. /**
  91111. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91112. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91113. * This should be used together with the simplification to avoid disappearing triangles.
  91114. * @param successCallback an optional success callback to be called after the optimization finished.
  91115. * @returns the current mesh
  91116. */
  91117. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91118. /**
  91119. * Serialize current mesh
  91120. * @param serializationObject defines the object which will receive the serialization data
  91121. */
  91122. serialize(serializationObject: any): void;
  91123. /** @hidden */
  91124. _syncGeometryWithMorphTargetManager(): void;
  91125. /** @hidden */
  91126. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91127. /**
  91128. * Returns a new Mesh object parsed from the source provided.
  91129. * @param parsedMesh is the source
  91130. * @param scene defines the hosting scene
  91131. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91132. * @returns a new Mesh
  91133. */
  91134. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91135. /**
  91136. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91137. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91138. * @param name defines the name of the mesh to create
  91139. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91140. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91141. * @param closePath creates a seam between the first and the last points of each path of the path array
  91142. * @param offset is taken in account only if the `pathArray` is containing a single path
  91143. * @param scene defines the hosting scene
  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 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)
  91147. * @returns a new Mesh
  91148. */
  91149. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91150. /**
  91151. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91152. * @param name defines the name of the mesh to create
  91153. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91154. * @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
  91155. * @param scene defines the hosting scene
  91156. * @param updatable defines if the mesh must be flagged as updatable
  91157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91158. * @returns a new Mesh
  91159. */
  91160. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91161. /**
  91162. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91163. * @param name defines the name of the mesh to create
  91164. * @param size sets the size (float) of each box side (default 1)
  91165. * @param scene defines the hosting scene
  91166. * @param updatable defines if the mesh must be flagged as updatable
  91167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91168. * @returns a new Mesh
  91169. */
  91170. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91171. /**
  91172. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91173. * @param name defines the name of the mesh to create
  91174. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91175. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91176. * @param scene defines the hosting scene
  91177. * @param updatable defines if the mesh must be flagged as updatable
  91178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91179. * @returns a new Mesh
  91180. */
  91181. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91182. /**
  91183. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91184. * @param name defines the name of the mesh to create
  91185. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91186. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91187. * @param scene defines the hosting scene
  91188. * @returns a new Mesh
  91189. */
  91190. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91191. /**
  91192. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91193. * @param name defines the name of the mesh to create
  91194. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91195. * @param diameterTop set the top cap diameter (floats, default 1)
  91196. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91197. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91198. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91199. * @param scene defines the hosting scene
  91200. * @param updatable defines if the mesh must be flagged as updatable
  91201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91202. * @returns a new Mesh
  91203. */
  91204. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91205. /**
  91206. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91207. * @param name defines the name of the mesh to create
  91208. * @param diameter sets the diameter size (float) of the torus (default 1)
  91209. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91210. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91211. * @param scene defines the hosting scene
  91212. * @param updatable defines if the mesh must be flagged as updatable
  91213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91214. * @returns a new Mesh
  91215. */
  91216. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91217. /**
  91218. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91219. * @param name defines the name of the mesh to create
  91220. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91221. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91222. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91223. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91224. * @param p the number of windings on X axis (positive integers, default 2)
  91225. * @param q the number of windings on Y axis (positive integers, default 3)
  91226. * @param scene defines the hosting scene
  91227. * @param updatable defines if the mesh must be flagged as updatable
  91228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91229. * @returns a new Mesh
  91230. */
  91231. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91232. /**
  91233. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91234. * @param name defines the name of the mesh to create
  91235. * @param points is an array successive Vector3
  91236. * @param scene defines the hosting scene
  91237. * @param updatable defines if the mesh must be flagged as updatable
  91238. * @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).
  91239. * @returns a new Mesh
  91240. */
  91241. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91242. /**
  91243. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91244. * @param name defines the name of the mesh to create
  91245. * @param points is an array successive Vector3
  91246. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91247. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91248. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91249. * @param scene defines the hosting scene
  91250. * @param updatable defines if the mesh must be flagged as updatable
  91251. * @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)
  91252. * @returns a new Mesh
  91253. */
  91254. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91255. /**
  91256. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91257. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91258. * 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.
  91259. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91260. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91261. * Remember you can only change the shape positions, not their number when updating a polygon.
  91262. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91263. * @param name defines the name of the mesh to create
  91264. * @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
  91265. * @param scene defines the hosting scene
  91266. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91267. * @param updatable defines if the mesh must be flagged as updatable
  91268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91269. * @param earcutInjection can be used to inject your own earcut reference
  91270. * @returns a new Mesh
  91271. */
  91272. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91273. /**
  91274. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91275. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91276. * @param name defines the name of the mesh to create
  91277. * @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
  91278. * @param depth defines the height of extrusion
  91279. * @param scene defines the hosting scene
  91280. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91281. * @param updatable defines if the mesh must be flagged as updatable
  91282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91283. * @param earcutInjection can be used to inject your own earcut reference
  91284. * @returns a new Mesh
  91285. */
  91286. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91287. /**
  91288. * Creates an extruded shape mesh.
  91289. * 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
  91290. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91291. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91292. * @param name defines the name of the mesh to create
  91293. * @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
  91294. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91295. * @param scale is the value to scale the shape
  91296. * @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
  91297. * @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
  91298. * @param scene defines the hosting scene
  91299. * @param updatable defines if the mesh must be flagged as updatable
  91300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91301. * @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)
  91302. * @returns a new Mesh
  91303. */
  91304. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91305. /**
  91306. * Creates an custom extruded shape mesh.
  91307. * The custom extrusion is a parametric shape.
  91308. * It has no predefined shape. Its final shape will depend on the input parameters.
  91309. * Please consider using the same method from the MeshBuilder class instead
  91310. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91311. * @param name defines the name of the mesh to create
  91312. * @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
  91313. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91314. * @param scaleFunction is a custom Javascript function called on each path point
  91315. * @param rotationFunction is a custom Javascript function called on each path point
  91316. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91317. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91318. * @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
  91319. * @param scene defines the hosting scene
  91320. * @param updatable defines if the mesh must be flagged as updatable
  91321. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91322. * @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)
  91323. * @returns a new Mesh
  91324. */
  91325. 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;
  91326. /**
  91327. * Creates lathe mesh.
  91328. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91329. * Please consider using the same method from the MeshBuilder class instead
  91330. * @param name defines the name of the mesh to create
  91331. * @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
  91332. * @param radius is the radius value of the lathe
  91333. * @param tessellation is the side number of the lathe.
  91334. * @param scene defines the hosting scene
  91335. * @param updatable defines if the mesh must be flagged as updatable
  91336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91337. * @returns a new Mesh
  91338. */
  91339. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91340. /**
  91341. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91342. * @param name defines the name of the mesh to create
  91343. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91344. * @param scene defines the hosting scene
  91345. * @param updatable defines if the mesh must be flagged as updatable
  91346. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91347. * @returns a new Mesh
  91348. */
  91349. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91350. /**
  91351. * Creates a ground mesh.
  91352. * Please consider using the same method from the MeshBuilder class instead
  91353. * @param name defines the name of the mesh to create
  91354. * @param width set the width of the ground
  91355. * @param height set the height of the ground
  91356. * @param subdivisions sets the number of subdivisions per side
  91357. * @param scene defines the hosting scene
  91358. * @param updatable defines if the mesh must be flagged as updatable
  91359. * @returns a new Mesh
  91360. */
  91361. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91362. /**
  91363. * Creates a tiled ground mesh.
  91364. * Please consider using the same method from the MeshBuilder class instead
  91365. * @param name defines the name of the mesh to create
  91366. * @param xmin set the ground minimum X coordinate
  91367. * @param zmin set the ground minimum Y coordinate
  91368. * @param xmax set the ground maximum X coordinate
  91369. * @param zmax set the ground maximum Z coordinate
  91370. * @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
  91371. * @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
  91372. * @param scene defines the hosting scene
  91373. * @param updatable defines if the mesh must be flagged as updatable
  91374. * @returns a new Mesh
  91375. */
  91376. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91377. w: number;
  91378. h: number;
  91379. }, precision: {
  91380. w: number;
  91381. h: number;
  91382. }, scene: Scene, updatable?: boolean): Mesh;
  91383. /**
  91384. * Creates a ground mesh from a height map.
  91385. * Please consider using the same method from the MeshBuilder class instead
  91386. * @see http://doc.babylonjs.com/babylon101/height_map
  91387. * @param name defines the name of the mesh to create
  91388. * @param url sets the URL of the height map image resource
  91389. * @param width set the ground width size
  91390. * @param height set the ground height size
  91391. * @param subdivisions sets the number of subdivision per side
  91392. * @param minHeight is the minimum altitude on the ground
  91393. * @param maxHeight is the maximum altitude on the ground
  91394. * @param scene defines the hosting scene
  91395. * @param updatable defines if the mesh must be flagged as updatable
  91396. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91397. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91398. * @returns a new Mesh
  91399. */
  91400. 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;
  91401. /**
  91402. * Creates a tube mesh.
  91403. * The tube is a parametric shape.
  91404. * It has no predefined shape. Its final shape will depend on the input parameters.
  91405. * Please consider using the same method from the MeshBuilder class instead
  91406. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91407. * @param name defines the name of the mesh to create
  91408. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91409. * @param radius sets the tube radius size
  91410. * @param tessellation is the number of sides on the tubular surface
  91411. * @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
  91412. * @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
  91413. * @param scene defines the hosting scene
  91414. * @param updatable defines if the mesh must be flagged as updatable
  91415. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91416. * @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)
  91417. * @returns a new Mesh
  91418. */
  91419. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91420. (i: number, distance: number): number;
  91421. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91422. /**
  91423. * Creates a polyhedron mesh.
  91424. * Please consider using the same method from the MeshBuilder class instead.
  91425. * * 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
  91426. * * The parameter `size` (positive float, default 1) sets the polygon size
  91427. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91428. * * 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`
  91429. * * 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
  91430. * * 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)`)
  91431. * * 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
  91432. * * 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
  91433. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91434. * * If you create a double-sided mesh, you can choose what parts of 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
  91435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91436. * @param name defines the name of the mesh to create
  91437. * @param options defines the options used to create the mesh
  91438. * @param scene defines the hosting scene
  91439. * @returns a new Mesh
  91440. */
  91441. static CreatePolyhedron(name: string, options: {
  91442. type?: number;
  91443. size?: number;
  91444. sizeX?: number;
  91445. sizeY?: number;
  91446. sizeZ?: number;
  91447. custom?: any;
  91448. faceUV?: Vector4[];
  91449. faceColors?: Color4[];
  91450. updatable?: boolean;
  91451. sideOrientation?: number;
  91452. }, scene: Scene): Mesh;
  91453. /**
  91454. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91455. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91456. * * 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`)
  91457. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91458. * * 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
  91459. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91460. * * If you create a double-sided mesh, you can choose what parts of 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
  91461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91462. * @param name defines the name of the mesh
  91463. * @param options defines the options used to create the mesh
  91464. * @param scene defines the hosting scene
  91465. * @returns a new Mesh
  91466. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91467. */
  91468. static CreateIcoSphere(name: string, options: {
  91469. radius?: number;
  91470. flat?: boolean;
  91471. subdivisions?: number;
  91472. sideOrientation?: number;
  91473. updatable?: boolean;
  91474. }, scene: Scene): Mesh;
  91475. /**
  91476. * Creates a decal mesh.
  91477. * Please consider using the same method from the MeshBuilder class instead.
  91478. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91479. * @param name defines the name of the mesh
  91480. * @param sourceMesh defines the mesh receiving the decal
  91481. * @param position sets the position of the decal in world coordinates
  91482. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91483. * @param size sets the decal scaling
  91484. * @param angle sets the angle to rotate the decal
  91485. * @returns a new Mesh
  91486. */
  91487. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91488. /**
  91489. * Prepare internal position array for software CPU skinning
  91490. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91491. */
  91492. setPositionsForCPUSkinning(): Float32Array;
  91493. /**
  91494. * Prepare internal normal array for software CPU skinning
  91495. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91496. */
  91497. setNormalsForCPUSkinning(): Float32Array;
  91498. /**
  91499. * Updates the vertex buffer by applying transformation from the bones
  91500. * @param skeleton defines the skeleton to apply to current mesh
  91501. * @returns the current mesh
  91502. */
  91503. applySkeleton(skeleton: Skeleton): Mesh;
  91504. /**
  91505. * 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
  91506. * @param meshes defines the list of meshes to scan
  91507. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91508. */
  91509. static MinMax(meshes: AbstractMesh[]): {
  91510. min: Vector3;
  91511. max: Vector3;
  91512. };
  91513. /**
  91514. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91515. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91516. * @returns a vector3
  91517. */
  91518. static Center(meshesOrMinMaxVector: {
  91519. min: Vector3;
  91520. max: Vector3;
  91521. } | AbstractMesh[]): Vector3;
  91522. /**
  91523. * Merge the array of meshes into a single mesh for performance reasons.
  91524. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91525. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91526. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91527. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91528. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91529. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91530. * @returns a new mesh
  91531. */
  91532. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91533. /** @hidden */
  91534. addInstance(instance: InstancedMesh): void;
  91535. /** @hidden */
  91536. removeInstance(instance: InstancedMesh): void;
  91537. }
  91538. }
  91539. declare module BABYLON {
  91540. /**
  91541. * This is the base class of all the camera used in the application.
  91542. * @see http://doc.babylonjs.com/features/cameras
  91543. */
  91544. export class Camera extends Node {
  91545. /** @hidden */
  91546. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91547. /**
  91548. * This is the default projection mode used by the cameras.
  91549. * It helps recreating a feeling of perspective and better appreciate depth.
  91550. * This is the best way to simulate real life cameras.
  91551. */
  91552. static readonly PERSPECTIVE_CAMERA: number;
  91553. /**
  91554. * This helps creating camera with an orthographic mode.
  91555. * 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.
  91556. */
  91557. static readonly ORTHOGRAPHIC_CAMERA: number;
  91558. /**
  91559. * This is the default FOV mode for perspective cameras.
  91560. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91561. */
  91562. static readonly FOVMODE_VERTICAL_FIXED: number;
  91563. /**
  91564. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91565. */
  91566. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91567. /**
  91568. * This specifies ther is no need for a camera rig.
  91569. * Basically only one eye is rendered corresponding to the camera.
  91570. */
  91571. static readonly RIG_MODE_NONE: number;
  91572. /**
  91573. * Simulates a camera Rig with one blue eye and one red eye.
  91574. * This can be use with 3d blue and red glasses.
  91575. */
  91576. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91577. /**
  91578. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91579. */
  91580. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91581. /**
  91582. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91583. */
  91584. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91585. /**
  91586. * Defines that both eyes of the camera will be rendered over under each other.
  91587. */
  91588. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91589. /**
  91590. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91591. */
  91592. static readonly RIG_MODE_VR: number;
  91593. /**
  91594. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91595. */
  91596. static readonly RIG_MODE_WEBVR: number;
  91597. /**
  91598. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91599. */
  91600. static readonly RIG_MODE_CUSTOM: number;
  91601. /**
  91602. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91603. */
  91604. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91605. /**
  91606. * Define the input manager associated with the camera.
  91607. */
  91608. inputs: CameraInputsManager<Camera>;
  91609. /** @hidden */
  91610. _position: Vector3;
  91611. /**
  91612. * Define the current local position of the camera in the scene
  91613. */
  91614. position: Vector3;
  91615. /**
  91616. * The vector the camera should consider as up.
  91617. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91618. */
  91619. upVector: Vector3;
  91620. /**
  91621. * Define the current limit on the left side for an orthographic camera
  91622. * In scene unit
  91623. */
  91624. orthoLeft: Nullable<number>;
  91625. /**
  91626. * Define the current limit on the right side for an orthographic camera
  91627. * In scene unit
  91628. */
  91629. orthoRight: Nullable<number>;
  91630. /**
  91631. * Define the current limit on the bottom side for an orthographic camera
  91632. * In scene unit
  91633. */
  91634. orthoBottom: Nullable<number>;
  91635. /**
  91636. * Define the current limit on the top side for an orthographic camera
  91637. * In scene unit
  91638. */
  91639. orthoTop: Nullable<number>;
  91640. /**
  91641. * Field Of View is set in Radians. (default is 0.8)
  91642. */
  91643. fov: number;
  91644. /**
  91645. * Define the minimum distance the camera can see from.
  91646. * This is important to note that the depth buffer are not infinite and the closer it starts
  91647. * the more your scene might encounter depth fighting issue.
  91648. */
  91649. minZ: number;
  91650. /**
  91651. * Define the maximum distance the camera can see to.
  91652. * This is important to note that the depth buffer are not infinite and the further it end
  91653. * the more your scene might encounter depth fighting issue.
  91654. */
  91655. maxZ: number;
  91656. /**
  91657. * Define the default inertia of the camera.
  91658. * This helps giving a smooth feeling to the camera movement.
  91659. */
  91660. inertia: number;
  91661. /**
  91662. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91663. */
  91664. mode: number;
  91665. /**
  91666. * Define wether the camera is intermediate.
  91667. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91668. */
  91669. isIntermediate: boolean;
  91670. /**
  91671. * Define the viewport of the camera.
  91672. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91673. */
  91674. viewport: Viewport;
  91675. /**
  91676. * Restricts the camera to viewing objects with the same layerMask.
  91677. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91678. */
  91679. layerMask: number;
  91680. /**
  91681. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91682. */
  91683. fovMode: number;
  91684. /**
  91685. * Rig mode of the camera.
  91686. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91687. * This is normally controlled byt the camera themselves as internal use.
  91688. */
  91689. cameraRigMode: number;
  91690. /**
  91691. * Defines the distance between both "eyes" in case of a RIG
  91692. */
  91693. interaxialDistance: number;
  91694. /**
  91695. * Defines if stereoscopic rendering is done side by side or over under.
  91696. */
  91697. isStereoscopicSideBySide: boolean;
  91698. /**
  91699. * 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
  91700. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91701. * else in the scene. (Eg. security camera)
  91702. *
  91703. * 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)
  91704. */
  91705. customRenderTargets: RenderTargetTexture[];
  91706. /**
  91707. * When set, the camera will render to this render target instead of the default canvas
  91708. *
  91709. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91710. */
  91711. outputRenderTarget: Nullable<RenderTargetTexture>;
  91712. /**
  91713. * Observable triggered when the camera view matrix has changed.
  91714. */
  91715. onViewMatrixChangedObservable: Observable<Camera>;
  91716. /**
  91717. * Observable triggered when the camera Projection matrix has changed.
  91718. */
  91719. onProjectionMatrixChangedObservable: Observable<Camera>;
  91720. /**
  91721. * Observable triggered when the inputs have been processed.
  91722. */
  91723. onAfterCheckInputsObservable: Observable<Camera>;
  91724. /**
  91725. * Observable triggered when reset has been called and applied to the camera.
  91726. */
  91727. onRestoreStateObservable: Observable<Camera>;
  91728. /** @hidden */
  91729. _cameraRigParams: any;
  91730. /** @hidden */
  91731. _rigCameras: Camera[];
  91732. /** @hidden */
  91733. _rigPostProcess: Nullable<PostProcess>;
  91734. protected _webvrViewMatrix: Matrix;
  91735. /** @hidden */
  91736. _skipRendering: boolean;
  91737. /** @hidden */
  91738. _projectionMatrix: Matrix;
  91739. /** @hidden */
  91740. _postProcesses: Nullable<PostProcess>[];
  91741. /** @hidden */
  91742. _activeMeshes: SmartArray<AbstractMesh>;
  91743. protected _globalPosition: Vector3;
  91744. /** @hidden */
  91745. _computedViewMatrix: Matrix;
  91746. private _doNotComputeProjectionMatrix;
  91747. private _transformMatrix;
  91748. private _frustumPlanes;
  91749. private _refreshFrustumPlanes;
  91750. private _storedFov;
  91751. private _stateStored;
  91752. /**
  91753. * Instantiates a new camera object.
  91754. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91755. * @see http://doc.babylonjs.com/features/cameras
  91756. * @param name Defines the name of the camera in the scene
  91757. * @param position Defines the position of the camera
  91758. * @param scene Defines the scene the camera belongs too
  91759. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91760. */
  91761. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91762. /**
  91763. * Store current camera state (fov, position, etc..)
  91764. * @returns the camera
  91765. */
  91766. storeState(): Camera;
  91767. /**
  91768. * Restores the camera state values if it has been stored. You must call storeState() first
  91769. */
  91770. protected _restoreStateValues(): boolean;
  91771. /**
  91772. * Restored camera state. You must call storeState() first.
  91773. * @returns true if restored and false otherwise
  91774. */
  91775. restoreState(): boolean;
  91776. /**
  91777. * Gets the class name of the camera.
  91778. * @returns the class name
  91779. */
  91780. getClassName(): string;
  91781. /** @hidden */
  91782. readonly _isCamera: boolean;
  91783. /**
  91784. * Gets a string representation of the camera useful for debug purpose.
  91785. * @param fullDetails Defines that a more verboe level of logging is required
  91786. * @returns the string representation
  91787. */
  91788. toString(fullDetails?: boolean): string;
  91789. /**
  91790. * Gets the current world space position of the camera.
  91791. */
  91792. readonly globalPosition: Vector3;
  91793. /**
  91794. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91795. * @returns the active meshe list
  91796. */
  91797. getActiveMeshes(): SmartArray<AbstractMesh>;
  91798. /**
  91799. * Check wether a mesh is part of the current active mesh list of the camera
  91800. * @param mesh Defines the mesh to check
  91801. * @returns true if active, false otherwise
  91802. */
  91803. isActiveMesh(mesh: Mesh): boolean;
  91804. /**
  91805. * Is this camera ready to be used/rendered
  91806. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91807. * @return true if the camera is ready
  91808. */
  91809. isReady(completeCheck?: boolean): boolean;
  91810. /** @hidden */
  91811. _initCache(): void;
  91812. /** @hidden */
  91813. _updateCache(ignoreParentClass?: boolean): void;
  91814. /** @hidden */
  91815. _isSynchronized(): boolean;
  91816. /** @hidden */
  91817. _isSynchronizedViewMatrix(): boolean;
  91818. /** @hidden */
  91819. _isSynchronizedProjectionMatrix(): boolean;
  91820. /**
  91821. * Attach the input controls to a specific dom element to get the input from.
  91822. * @param element Defines the element the controls should be listened from
  91823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91824. */
  91825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91826. /**
  91827. * Detach the current controls from the specified dom element.
  91828. * @param element Defines the element to stop listening the inputs from
  91829. */
  91830. detachControl(element: HTMLElement): void;
  91831. /**
  91832. * Update the camera state according to the different inputs gathered during the frame.
  91833. */
  91834. update(): void;
  91835. /** @hidden */
  91836. _checkInputs(): void;
  91837. /** @hidden */
  91838. readonly rigCameras: Camera[];
  91839. /**
  91840. * Gets the post process used by the rig cameras
  91841. */
  91842. readonly rigPostProcess: Nullable<PostProcess>;
  91843. /**
  91844. * Internal, gets the first post proces.
  91845. * @returns the first post process to be run on this camera.
  91846. */
  91847. _getFirstPostProcess(): Nullable<PostProcess>;
  91848. private _cascadePostProcessesToRigCams;
  91849. /**
  91850. * Attach a post process to the camera.
  91851. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91852. * @param postProcess The post process to attach to the camera
  91853. * @param insertAt The position of the post process in case several of them are in use in the scene
  91854. * @returns the position the post process has been inserted at
  91855. */
  91856. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91857. /**
  91858. * Detach a post process to the camera.
  91859. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91860. * @param postProcess The post process to detach from the camera
  91861. */
  91862. detachPostProcess(postProcess: PostProcess): void;
  91863. /**
  91864. * Gets the current world matrix of the camera
  91865. */
  91866. getWorldMatrix(): Matrix;
  91867. /** @hidden */
  91868. _getViewMatrix(): Matrix;
  91869. /**
  91870. * Gets the current view matrix of the camera.
  91871. * @param force forces the camera to recompute the matrix without looking at the cached state
  91872. * @returns the view matrix
  91873. */
  91874. getViewMatrix(force?: boolean): Matrix;
  91875. /**
  91876. * Freeze the projection matrix.
  91877. * It will prevent the cache check of the camera projection compute and can speed up perf
  91878. * if no parameter of the camera are meant to change
  91879. * @param projection Defines manually a projection if necessary
  91880. */
  91881. freezeProjectionMatrix(projection?: Matrix): void;
  91882. /**
  91883. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91884. */
  91885. unfreezeProjectionMatrix(): void;
  91886. /**
  91887. * Gets the current projection matrix of the camera.
  91888. * @param force forces the camera to recompute the matrix without looking at the cached state
  91889. * @returns the projection matrix
  91890. */
  91891. getProjectionMatrix(force?: boolean): Matrix;
  91892. /**
  91893. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91894. * @returns a Matrix
  91895. */
  91896. getTransformationMatrix(): Matrix;
  91897. private _updateFrustumPlanes;
  91898. /**
  91899. * Checks if a cullable object (mesh...) is in the camera frustum
  91900. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91901. * @param target The object to check
  91902. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91903. * @returns true if the object is in frustum otherwise false
  91904. */
  91905. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91906. /**
  91907. * Checks if a cullable object (mesh...) is in the camera frustum
  91908. * Unlike isInFrustum this cheks the full bounding box
  91909. * @param target The object to check
  91910. * @returns true if the object is in frustum otherwise false
  91911. */
  91912. isCompletelyInFrustum(target: ICullable): boolean;
  91913. /**
  91914. * Gets a ray in the forward direction from the camera.
  91915. * @param length Defines the length of the ray to create
  91916. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91917. * @param origin Defines the start point of the ray which defaults to the camera position
  91918. * @returns the forward ray
  91919. */
  91920. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91921. /**
  91922. * Releases resources associated with this node.
  91923. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91924. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91925. */
  91926. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91927. /** @hidden */
  91928. _isLeftCamera: boolean;
  91929. /**
  91930. * Gets the left camera of a rig setup in case of Rigged Camera
  91931. */
  91932. readonly isLeftCamera: boolean;
  91933. /** @hidden */
  91934. _isRightCamera: boolean;
  91935. /**
  91936. * Gets the right camera of a rig setup in case of Rigged Camera
  91937. */
  91938. readonly isRightCamera: boolean;
  91939. /**
  91940. * Gets the left camera of a rig setup in case of Rigged Camera
  91941. */
  91942. readonly leftCamera: Nullable<FreeCamera>;
  91943. /**
  91944. * Gets the right camera of a rig setup in case of Rigged Camera
  91945. */
  91946. readonly rightCamera: Nullable<FreeCamera>;
  91947. /**
  91948. * Gets the left camera target of a rig setup in case of Rigged Camera
  91949. * @returns the target position
  91950. */
  91951. getLeftTarget(): Nullable<Vector3>;
  91952. /**
  91953. * Gets the right camera target of a rig setup in case of Rigged Camera
  91954. * @returns the target position
  91955. */
  91956. getRightTarget(): Nullable<Vector3>;
  91957. /**
  91958. * @hidden
  91959. */
  91960. setCameraRigMode(mode: number, rigParams: any): void;
  91961. /** @hidden */
  91962. static _setStereoscopicRigMode(camera: Camera): void;
  91963. /** @hidden */
  91964. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91965. /** @hidden */
  91966. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91967. /** @hidden */
  91968. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91969. /** @hidden */
  91970. _getVRProjectionMatrix(): Matrix;
  91971. protected _updateCameraRotationMatrix(): void;
  91972. protected _updateWebVRCameraRotationMatrix(): void;
  91973. /**
  91974. * This function MUST be overwritten by the different WebVR cameras available.
  91975. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91976. * @hidden
  91977. */
  91978. _getWebVRProjectionMatrix(): Matrix;
  91979. /**
  91980. * This function MUST be overwritten by the different WebVR cameras available.
  91981. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91982. * @hidden
  91983. */
  91984. _getWebVRViewMatrix(): Matrix;
  91985. /** @hidden */
  91986. setCameraRigParameter(name: string, value: any): void;
  91987. /**
  91988. * needs to be overridden by children so sub has required properties to be copied
  91989. * @hidden
  91990. */
  91991. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91992. /**
  91993. * May need to be overridden by children
  91994. * @hidden
  91995. */
  91996. _updateRigCameras(): void;
  91997. /** @hidden */
  91998. _setupInputs(): void;
  91999. /**
  92000. * Serialiaze the camera setup to a json represention
  92001. * @returns the JSON representation
  92002. */
  92003. serialize(): any;
  92004. /**
  92005. * Clones the current camera.
  92006. * @param name The cloned camera name
  92007. * @returns the cloned camera
  92008. */
  92009. clone(name: string): Camera;
  92010. /**
  92011. * Gets the direction of the camera relative to a given local axis.
  92012. * @param localAxis Defines the reference axis to provide a relative direction.
  92013. * @return the direction
  92014. */
  92015. getDirection(localAxis: Vector3): Vector3;
  92016. /**
  92017. * Returns the current camera absolute rotation
  92018. */
  92019. readonly absoluteRotation: Quaternion;
  92020. /**
  92021. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92022. * @param localAxis Defines the reference axis to provide a relative direction.
  92023. * @param result Defines the vector to store the result in
  92024. */
  92025. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92026. /**
  92027. * Gets a camera constructor for a given camera type
  92028. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92029. * @param name The name of the camera the result will be able to instantiate
  92030. * @param scene The scene the result will construct the camera in
  92031. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92032. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92033. * @returns a factory method to construc the camera
  92034. */
  92035. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92036. /**
  92037. * Compute the world matrix of the camera.
  92038. * @returns the camera workd matrix
  92039. */
  92040. computeWorldMatrix(): Matrix;
  92041. /**
  92042. * Parse a JSON and creates the camera from the parsed information
  92043. * @param parsedCamera The JSON to parse
  92044. * @param scene The scene to instantiate the camera in
  92045. * @returns the newly constructed camera
  92046. */
  92047. static Parse(parsedCamera: any, scene: Scene): Camera;
  92048. }
  92049. }
  92050. declare module BABYLON {
  92051. /**
  92052. * Class containing static functions to help procedurally build meshes
  92053. */
  92054. export class DiscBuilder {
  92055. /**
  92056. * Creates a plane polygonal mesh. By default, this is a disc
  92057. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92058. * * 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
  92059. * * 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
  92060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92063. * @param name defines the name of the mesh
  92064. * @param options defines the options used to create the mesh
  92065. * @param scene defines the hosting scene
  92066. * @returns the plane polygonal mesh
  92067. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92068. */
  92069. static CreateDisc(name: string, options: {
  92070. radius?: number;
  92071. tessellation?: number;
  92072. arc?: number;
  92073. updatable?: boolean;
  92074. sideOrientation?: number;
  92075. frontUVs?: Vector4;
  92076. backUVs?: Vector4;
  92077. }, scene?: Nullable<Scene>): Mesh;
  92078. }
  92079. }
  92080. declare module BABYLON {
  92081. /**
  92082. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92083. *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.
  92084. * The SPS is also a particle system. It provides some methods to manage the particles.
  92085. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92086. *
  92087. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92088. */
  92089. export class SolidParticleSystem implements IDisposable {
  92090. /**
  92091. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92092. * Example : var p = SPS.particles[i];
  92093. */
  92094. particles: SolidParticle[];
  92095. /**
  92096. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92097. */
  92098. nbParticles: number;
  92099. /**
  92100. * If the particles must ever face the camera (default false). Useful for planar particles.
  92101. */
  92102. billboard: boolean;
  92103. /**
  92104. * Recompute normals when adding a shape
  92105. */
  92106. recomputeNormals: boolean;
  92107. /**
  92108. * This a counter ofr your own usage. It's not set by any SPS functions.
  92109. */
  92110. counter: number;
  92111. /**
  92112. * The SPS name. This name is also given to the underlying mesh.
  92113. */
  92114. name: string;
  92115. /**
  92116. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92117. */
  92118. mesh: Mesh;
  92119. /**
  92120. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92121. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92122. */
  92123. vars: any;
  92124. /**
  92125. * This array is populated when the SPS is set as 'pickable'.
  92126. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92127. * Each element of this array is an object `{idx: int, faceId: int}`.
  92128. * `idx` is the picked particle index in the `SPS.particles` array
  92129. * `faceId` is the picked face index counted within this particle.
  92130. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92131. */
  92132. pickedParticles: {
  92133. idx: number;
  92134. faceId: number;
  92135. }[];
  92136. /**
  92137. * This array is populated when `enableDepthSort` is set to true.
  92138. * Each element of this array is an instance of the class DepthSortedParticle.
  92139. */
  92140. depthSortedParticles: DepthSortedParticle[];
  92141. /**
  92142. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92143. * @hidden
  92144. */
  92145. _bSphereOnly: boolean;
  92146. /**
  92147. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92148. * @hidden
  92149. */
  92150. _bSphereRadiusFactor: number;
  92151. private _scene;
  92152. private _positions;
  92153. private _indices;
  92154. private _normals;
  92155. private _colors;
  92156. private _uvs;
  92157. private _indices32;
  92158. private _positions32;
  92159. private _normals32;
  92160. private _fixedNormal32;
  92161. private _colors32;
  92162. private _uvs32;
  92163. private _index;
  92164. private _updatable;
  92165. private _pickable;
  92166. private _isVisibilityBoxLocked;
  92167. private _alwaysVisible;
  92168. private _depthSort;
  92169. private _shapeCounter;
  92170. private _copy;
  92171. private _color;
  92172. private _computeParticleColor;
  92173. private _computeParticleTexture;
  92174. private _computeParticleRotation;
  92175. private _computeParticleVertex;
  92176. private _computeBoundingBox;
  92177. private _depthSortParticles;
  92178. private _camera;
  92179. private _mustUnrotateFixedNormals;
  92180. private _particlesIntersect;
  92181. private _needs32Bits;
  92182. /**
  92183. * Creates a SPS (Solid Particle System) object.
  92184. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92185. * @param scene (Scene) is the scene in which the SPS is added.
  92186. * @param options defines the options of the sps e.g.
  92187. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92188. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92189. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92190. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92191. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92192. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92193. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92194. */
  92195. constructor(name: string, scene: Scene, options?: {
  92196. updatable?: boolean;
  92197. isPickable?: boolean;
  92198. enableDepthSort?: boolean;
  92199. particleIntersection?: boolean;
  92200. boundingSphereOnly?: boolean;
  92201. bSphereRadiusFactor?: number;
  92202. });
  92203. /**
  92204. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92205. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92206. * @returns the created mesh
  92207. */
  92208. buildMesh(): Mesh;
  92209. /**
  92210. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92211. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92212. * Thus the particles generated from `digest()` have their property `position` set yet.
  92213. * @param mesh ( Mesh ) is the mesh to be digested
  92214. * @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
  92215. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92216. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92217. * @returns the current SPS
  92218. */
  92219. digest(mesh: Mesh, options?: {
  92220. facetNb?: number;
  92221. number?: number;
  92222. delta?: number;
  92223. }): SolidParticleSystem;
  92224. private _unrotateFixedNormals;
  92225. private _resetCopy;
  92226. private _meshBuilder;
  92227. private _posToShape;
  92228. private _uvsToShapeUV;
  92229. private _addParticle;
  92230. /**
  92231. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92232. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92233. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92234. * @param nb (positive integer) the number of particles to be created from this model
  92235. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92236. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92237. * @returns the number of shapes in the system
  92238. */
  92239. addShape(mesh: Mesh, nb: number, options?: {
  92240. positionFunction?: any;
  92241. vertexFunction?: any;
  92242. }): number;
  92243. private _rebuildParticle;
  92244. /**
  92245. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92246. * @returns the SPS.
  92247. */
  92248. rebuildMesh(): SolidParticleSystem;
  92249. /**
  92250. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92251. * This method calls `updateParticle()` for each particle of the SPS.
  92252. * For an animated SPS, it is usually called within the render loop.
  92253. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92254. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92255. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92256. * @returns the SPS.
  92257. */
  92258. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92259. /**
  92260. * Disposes the SPS.
  92261. */
  92262. dispose(): void;
  92263. /**
  92264. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92265. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92266. * @returns the SPS.
  92267. */
  92268. refreshVisibleSize(): SolidParticleSystem;
  92269. /**
  92270. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92271. * @param size the size (float) of the visibility box
  92272. * note : this doesn't lock the SPS mesh bounding box.
  92273. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92274. */
  92275. setVisibilityBox(size: number): void;
  92276. /**
  92277. * Gets whether the SPS as always visible or not
  92278. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92279. */
  92280. /**
  92281. * Sets the SPS as always visible or not
  92282. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92283. */
  92284. isAlwaysVisible: boolean;
  92285. /**
  92286. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92287. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92288. */
  92289. /**
  92290. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92291. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92292. */
  92293. isVisibilityBoxLocked: boolean;
  92294. /**
  92295. * Tells to `setParticles()` to compute the particle rotations or not.
  92296. * Default value : true. The SPS is faster when it's set to false.
  92297. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92298. */
  92299. /**
  92300. * Gets if `setParticles()` computes the particle rotations or not.
  92301. * Default value : true. The SPS is faster when it's set to false.
  92302. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92303. */
  92304. computeParticleRotation: boolean;
  92305. /**
  92306. * Tells to `setParticles()` to compute the particle colors or not.
  92307. * Default value : true. The SPS is faster when it's set to false.
  92308. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92309. */
  92310. /**
  92311. * Gets if `setParticles()` computes the particle colors or not.
  92312. * Default value : true. The SPS is faster when it's set to false.
  92313. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92314. */
  92315. computeParticleColor: boolean;
  92316. /**
  92317. * Gets if `setParticles()` computes the particle textures or not.
  92318. * Default value : true. The SPS is faster when it's set to false.
  92319. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92320. */
  92321. computeParticleTexture: boolean;
  92322. /**
  92323. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92324. * Default value : false. The SPS is faster when it's set to false.
  92325. * Note : the particle custom vertex positions aren't stored values.
  92326. */
  92327. /**
  92328. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92329. * Default value : false. The SPS is faster when it's set to false.
  92330. * Note : the particle custom vertex positions aren't stored values.
  92331. */
  92332. computeParticleVertex: boolean;
  92333. /**
  92334. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92335. */
  92336. /**
  92337. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92338. */
  92339. computeBoundingBox: boolean;
  92340. /**
  92341. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92342. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92343. * Default : `true`
  92344. */
  92345. /**
  92346. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92347. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92348. * Default : `true`
  92349. */
  92350. depthSortParticles: boolean;
  92351. /**
  92352. * This function does nothing. It may be overwritten to set all the particle first values.
  92353. * The SPS doesn't call this function, you may have to call it by your own.
  92354. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92355. */
  92356. initParticles(): void;
  92357. /**
  92358. * This function does nothing. It may be overwritten to recycle a particle.
  92359. * The SPS doesn't call this function, you may have to call it by your own.
  92360. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92361. * @param particle The particle to recycle
  92362. * @returns the recycled particle
  92363. */
  92364. recycleParticle(particle: SolidParticle): SolidParticle;
  92365. /**
  92366. * Updates a particle : this function should be overwritten by the user.
  92367. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92368. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92369. * @example : just set a particle position or velocity and recycle conditions
  92370. * @param particle The particle to update
  92371. * @returns the updated particle
  92372. */
  92373. updateParticle(particle: SolidParticle): SolidParticle;
  92374. /**
  92375. * Updates a vertex of a particle : it can be overwritten by the user.
  92376. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92377. * @param particle the current particle
  92378. * @param vertex the current index of the current particle
  92379. * @param pt the index of the current vertex in the particle shape
  92380. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92381. * @example : just set a vertex particle position
  92382. * @returns the updated vertex
  92383. */
  92384. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92385. /**
  92386. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92387. * This does nothing and may be overwritten by the user.
  92388. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92389. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92390. * @param update the boolean update value actually passed to setParticles()
  92391. */
  92392. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92393. /**
  92394. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92395. * This will be passed three parameters.
  92396. * This does nothing and may be overwritten by the user.
  92397. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92398. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92399. * @param update the boolean update value actually passed to setParticles()
  92400. */
  92401. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92402. }
  92403. }
  92404. declare module BABYLON {
  92405. /**
  92406. * Represents one particle of a solid particle system.
  92407. */
  92408. export class SolidParticle {
  92409. /**
  92410. * particle global index
  92411. */
  92412. idx: number;
  92413. /**
  92414. * The color of the particle
  92415. */
  92416. color: Nullable<Color4>;
  92417. /**
  92418. * The world space position of the particle.
  92419. */
  92420. position: Vector3;
  92421. /**
  92422. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92423. */
  92424. rotation: Vector3;
  92425. /**
  92426. * The world space rotation quaternion of the particle.
  92427. */
  92428. rotationQuaternion: Nullable<Quaternion>;
  92429. /**
  92430. * The scaling of the particle.
  92431. */
  92432. scaling: Vector3;
  92433. /**
  92434. * The uvs of the particle.
  92435. */
  92436. uvs: Vector4;
  92437. /**
  92438. * The current speed of the particle.
  92439. */
  92440. velocity: Vector3;
  92441. /**
  92442. * The pivot point in the particle local space.
  92443. */
  92444. pivot: Vector3;
  92445. /**
  92446. * Must the particle be translated from its pivot point in its local space ?
  92447. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92448. * Default : false
  92449. */
  92450. translateFromPivot: boolean;
  92451. /**
  92452. * Is the particle active or not ?
  92453. */
  92454. alive: boolean;
  92455. /**
  92456. * Is the particle visible or not ?
  92457. */
  92458. isVisible: boolean;
  92459. /**
  92460. * Index of this particle in the global "positions" array (Internal use)
  92461. * @hidden
  92462. */
  92463. _pos: number;
  92464. /**
  92465. * @hidden Index of this particle in the global "indices" array (Internal use)
  92466. */
  92467. _ind: number;
  92468. /**
  92469. * @hidden ModelShape of this particle (Internal use)
  92470. */
  92471. _model: ModelShape;
  92472. /**
  92473. * ModelShape id of this particle
  92474. */
  92475. shapeId: number;
  92476. /**
  92477. * Index of the particle in its shape id
  92478. */
  92479. idxInShape: number;
  92480. /**
  92481. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92482. */
  92483. _modelBoundingInfo: BoundingInfo;
  92484. /**
  92485. * @hidden Particle BoundingInfo object (Internal use)
  92486. */
  92487. _boundingInfo: BoundingInfo;
  92488. /**
  92489. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92490. */
  92491. _sps: SolidParticleSystem;
  92492. /**
  92493. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92494. */
  92495. _stillInvisible: boolean;
  92496. /**
  92497. * @hidden Last computed particle rotation matrix
  92498. */
  92499. _rotationMatrix: number[];
  92500. /**
  92501. * Parent particle Id, if any.
  92502. * Default null.
  92503. */
  92504. parentId: Nullable<number>;
  92505. /**
  92506. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92507. * The possible values are :
  92508. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92509. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92510. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92511. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92512. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92513. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92514. * */
  92515. cullingStrategy: number;
  92516. /**
  92517. * @hidden Internal global position in the SPS.
  92518. */
  92519. _globalPosition: Vector3;
  92520. /**
  92521. * Creates a Solid Particle object.
  92522. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92523. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92524. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92525. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92526. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92527. * @param shapeId (integer) is the model shape identifier in the SPS.
  92528. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92529. * @param sps defines the sps it is associated to
  92530. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92531. */
  92532. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92533. /**
  92534. * Legacy support, changed scale to scaling
  92535. */
  92536. /**
  92537. * Legacy support, changed scale to scaling
  92538. */
  92539. scale: Vector3;
  92540. /**
  92541. * Legacy support, changed quaternion to rotationQuaternion
  92542. */
  92543. /**
  92544. * Legacy support, changed quaternion to rotationQuaternion
  92545. */
  92546. quaternion: Nullable<Quaternion>;
  92547. /**
  92548. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92549. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92550. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92551. * @returns true if it intersects
  92552. */
  92553. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92554. /**
  92555. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92556. * A particle is in the frustum if its bounding box intersects the frustum
  92557. * @param frustumPlanes defines the frustum to test
  92558. * @returns true if the particle is in the frustum planes
  92559. */
  92560. isInFrustum(frustumPlanes: Plane[]): boolean;
  92561. /**
  92562. * get the rotation matrix of the particle
  92563. * @hidden
  92564. */
  92565. getRotationMatrix(m: Matrix): void;
  92566. }
  92567. /**
  92568. * Represents the shape of the model used by one particle of a solid particle system.
  92569. * SPS internal tool, don't use it manually.
  92570. */
  92571. export class ModelShape {
  92572. /**
  92573. * The shape id
  92574. * @hidden
  92575. */
  92576. shapeID: number;
  92577. /**
  92578. * flat array of model positions (internal use)
  92579. * @hidden
  92580. */
  92581. _shape: Vector3[];
  92582. /**
  92583. * flat array of model UVs (internal use)
  92584. * @hidden
  92585. */
  92586. _shapeUV: number[];
  92587. /**
  92588. * length of the shape in the model indices array (internal use)
  92589. * @hidden
  92590. */
  92591. _indicesLength: number;
  92592. /**
  92593. * Custom position function (internal use)
  92594. * @hidden
  92595. */
  92596. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92597. /**
  92598. * Custom vertex function (internal use)
  92599. * @hidden
  92600. */
  92601. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92602. /**
  92603. * 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.
  92604. * SPS internal tool, don't use it manually.
  92605. * @hidden
  92606. */
  92607. 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>);
  92608. }
  92609. /**
  92610. * Represents a Depth Sorted Particle in the solid particle system.
  92611. */
  92612. export class DepthSortedParticle {
  92613. /**
  92614. * Index of the particle in the "indices" array
  92615. */
  92616. ind: number;
  92617. /**
  92618. * Length of the particle shape in the "indices" array
  92619. */
  92620. indicesLength: number;
  92621. /**
  92622. * Squared distance from the particle to the camera
  92623. */
  92624. sqDistance: number;
  92625. }
  92626. }
  92627. declare module BABYLON {
  92628. /**
  92629. * @hidden
  92630. */
  92631. export class _MeshCollisionData {
  92632. _checkCollisions: boolean;
  92633. _collisionMask: number;
  92634. _collisionGroup: number;
  92635. _collider: Nullable<Collider>;
  92636. _oldPositionForCollisions: Vector3;
  92637. _diffPositionForCollisions: Vector3;
  92638. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92639. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92640. }
  92641. }
  92642. declare module BABYLON {
  92643. /** @hidden */
  92644. class _FacetDataStorage {
  92645. facetPositions: Vector3[];
  92646. facetNormals: Vector3[];
  92647. facetPartitioning: number[][];
  92648. facetNb: number;
  92649. partitioningSubdivisions: number;
  92650. partitioningBBoxRatio: number;
  92651. facetDataEnabled: boolean;
  92652. facetParameters: any;
  92653. bbSize: Vector3;
  92654. subDiv: {
  92655. max: number;
  92656. X: number;
  92657. Y: number;
  92658. Z: number;
  92659. };
  92660. facetDepthSort: boolean;
  92661. facetDepthSortEnabled: boolean;
  92662. depthSortedIndices: IndicesArray;
  92663. depthSortedFacets: {
  92664. ind: number;
  92665. sqDistance: number;
  92666. }[];
  92667. facetDepthSortFunction: (f1: {
  92668. ind: number;
  92669. sqDistance: number;
  92670. }, f2: {
  92671. ind: number;
  92672. sqDistance: number;
  92673. }) => number;
  92674. facetDepthSortFrom: Vector3;
  92675. facetDepthSortOrigin: Vector3;
  92676. invertedMatrix: Matrix;
  92677. }
  92678. /**
  92679. * @hidden
  92680. **/
  92681. class _InternalAbstractMeshDataInfo {
  92682. _hasVertexAlpha: boolean;
  92683. _useVertexColors: boolean;
  92684. _numBoneInfluencers: number;
  92685. _applyFog: boolean;
  92686. _receiveShadows: boolean;
  92687. _facetData: _FacetDataStorage;
  92688. _visibility: number;
  92689. _skeleton: Nullable<Skeleton>;
  92690. _layerMask: number;
  92691. _computeBonesUsingShaders: boolean;
  92692. _isActive: boolean;
  92693. _onlyForInstances: boolean;
  92694. _isActiveIntermediate: boolean;
  92695. _onlyForInstancesIntermediate: boolean;
  92696. }
  92697. /**
  92698. * Class used to store all common mesh properties
  92699. */
  92700. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92701. /** No occlusion */
  92702. static OCCLUSION_TYPE_NONE: number;
  92703. /** Occlusion set to optimisitic */
  92704. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92705. /** Occlusion set to strict */
  92706. static OCCLUSION_TYPE_STRICT: number;
  92707. /** Use an accurante occlusion algorithm */
  92708. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92709. /** Use a conservative occlusion algorithm */
  92710. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92711. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92712. * Test order :
  92713. * Is the bounding sphere outside the frustum ?
  92714. * If not, are the bounding box vertices outside the frustum ?
  92715. * It not, then the cullable object is in the frustum.
  92716. */
  92717. static readonly CULLINGSTRATEGY_STANDARD: number;
  92718. /** Culling strategy : Bounding Sphere Only.
  92719. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92720. * It's also less accurate than the standard because some not visible objects can still be selected.
  92721. * Test : is the bounding sphere outside the frustum ?
  92722. * If not, then the cullable object is in the frustum.
  92723. */
  92724. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92725. /** Culling strategy : Optimistic Inclusion.
  92726. * This in an inclusion test first, then the standard exclusion test.
  92727. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92728. * 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.
  92729. * Anyway, it's as accurate as the standard strategy.
  92730. * Test :
  92731. * Is the cullable object bounding sphere center in the frustum ?
  92732. * If not, apply the default culling strategy.
  92733. */
  92734. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92735. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92736. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92737. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92738. * 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.
  92739. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92740. * Test :
  92741. * Is the cullable object bounding sphere center in the frustum ?
  92742. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92743. */
  92744. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92745. /**
  92746. * No billboard
  92747. */
  92748. static readonly BILLBOARDMODE_NONE: number;
  92749. /** Billboard on X axis */
  92750. static readonly BILLBOARDMODE_X: number;
  92751. /** Billboard on Y axis */
  92752. static readonly BILLBOARDMODE_Y: number;
  92753. /** Billboard on Z axis */
  92754. static readonly BILLBOARDMODE_Z: number;
  92755. /** Billboard on all axes */
  92756. static readonly BILLBOARDMODE_ALL: number;
  92757. /** Billboard on using position instead of orientation */
  92758. static readonly BILLBOARDMODE_USE_POSITION: number;
  92759. /** @hidden */
  92760. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92761. /**
  92762. * The culling strategy to use to check whether the mesh must be rendered or not.
  92763. * This value can be changed at any time and will be used on the next render mesh selection.
  92764. * The possible values are :
  92765. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92766. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92767. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92768. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92769. * Please read each static variable documentation to get details about the culling process.
  92770. * */
  92771. cullingStrategy: number;
  92772. /**
  92773. * Gets the number of facets in the mesh
  92774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92775. */
  92776. readonly facetNb: number;
  92777. /**
  92778. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92780. */
  92781. partitioningSubdivisions: number;
  92782. /**
  92783. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92784. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92786. */
  92787. partitioningBBoxRatio: number;
  92788. /**
  92789. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92790. * Works only for updatable meshes.
  92791. * Doesn't work with multi-materials
  92792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92793. */
  92794. mustDepthSortFacets: boolean;
  92795. /**
  92796. * The location (Vector3) where the facet depth sort must be computed from.
  92797. * By default, the active camera position.
  92798. * Used only when facet depth sort is enabled
  92799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92800. */
  92801. facetDepthSortFrom: Vector3;
  92802. /**
  92803. * gets a boolean indicating if facetData is enabled
  92804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92805. */
  92806. readonly isFacetDataEnabled: boolean;
  92807. /** @hidden */
  92808. _updateNonUniformScalingState(value: boolean): boolean;
  92809. /**
  92810. * An event triggered when this mesh collides with another one
  92811. */
  92812. onCollideObservable: Observable<AbstractMesh>;
  92813. /** Set a function to call when this mesh collides with another one */
  92814. onCollide: () => void;
  92815. /**
  92816. * An event triggered when the collision's position changes
  92817. */
  92818. onCollisionPositionChangeObservable: Observable<Vector3>;
  92819. /** Set a function to call when the collision's position changes */
  92820. onCollisionPositionChange: () => void;
  92821. /**
  92822. * An event triggered when material is changed
  92823. */
  92824. onMaterialChangedObservable: Observable<AbstractMesh>;
  92825. /**
  92826. * Gets or sets the orientation for POV movement & rotation
  92827. */
  92828. definedFacingForward: boolean;
  92829. /** @hidden */
  92830. _occlusionQuery: Nullable<WebGLQuery>;
  92831. /** @hidden */
  92832. _renderingGroup: Nullable<RenderingGroup>;
  92833. /**
  92834. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92835. */
  92836. /**
  92837. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92838. */
  92839. visibility: number;
  92840. /** Gets or sets the alpha index used to sort transparent meshes
  92841. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92842. */
  92843. alphaIndex: number;
  92844. /**
  92845. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92846. */
  92847. isVisible: boolean;
  92848. /**
  92849. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92850. */
  92851. isPickable: boolean;
  92852. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92853. showSubMeshesBoundingBox: boolean;
  92854. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92855. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92856. */
  92857. isBlocker: boolean;
  92858. /**
  92859. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92860. */
  92861. enablePointerMoveEvents: boolean;
  92862. /**
  92863. * Specifies the rendering group id for this mesh (0 by default)
  92864. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92865. */
  92866. renderingGroupId: number;
  92867. private _material;
  92868. /** Gets or sets current material */
  92869. material: Nullable<Material>;
  92870. /**
  92871. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92872. * @see http://doc.babylonjs.com/babylon101/shadows
  92873. */
  92874. receiveShadows: boolean;
  92875. /** Defines color to use when rendering outline */
  92876. outlineColor: Color3;
  92877. /** Define width to use when rendering outline */
  92878. outlineWidth: number;
  92879. /** Defines color to use when rendering overlay */
  92880. overlayColor: Color3;
  92881. /** Defines alpha to use when rendering overlay */
  92882. overlayAlpha: number;
  92883. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92884. hasVertexAlpha: boolean;
  92885. /** 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) */
  92886. useVertexColors: boolean;
  92887. /**
  92888. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92889. */
  92890. computeBonesUsingShaders: boolean;
  92891. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92892. numBoneInfluencers: number;
  92893. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92894. applyFog: boolean;
  92895. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92896. useOctreeForRenderingSelection: boolean;
  92897. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92898. useOctreeForPicking: boolean;
  92899. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92900. useOctreeForCollisions: boolean;
  92901. /**
  92902. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92903. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92904. */
  92905. layerMask: number;
  92906. /**
  92907. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92908. */
  92909. alwaysSelectAsActiveMesh: boolean;
  92910. /**
  92911. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92912. */
  92913. doNotSyncBoundingInfo: boolean;
  92914. /**
  92915. * Gets or sets the current action manager
  92916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92917. */
  92918. actionManager: Nullable<AbstractActionManager>;
  92919. private _meshCollisionData;
  92920. /**
  92921. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92923. */
  92924. ellipsoid: Vector3;
  92925. /**
  92926. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92927. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92928. */
  92929. ellipsoidOffset: Vector3;
  92930. /**
  92931. * Gets or sets a collision mask used to mask collisions (default is -1).
  92932. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92933. */
  92934. collisionMask: number;
  92935. /**
  92936. * Gets or sets the current collision group mask (-1 by default).
  92937. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92938. */
  92939. collisionGroup: number;
  92940. /**
  92941. * Defines edge width used when edgesRenderer is enabled
  92942. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92943. */
  92944. edgesWidth: number;
  92945. /**
  92946. * Defines edge color used when edgesRenderer is enabled
  92947. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92948. */
  92949. edgesColor: Color4;
  92950. /** @hidden */
  92951. _edgesRenderer: Nullable<IEdgesRenderer>;
  92952. /** @hidden */
  92953. _masterMesh: Nullable<AbstractMesh>;
  92954. /** @hidden */
  92955. _boundingInfo: Nullable<BoundingInfo>;
  92956. /** @hidden */
  92957. _renderId: number;
  92958. /**
  92959. * Gets or sets the list of subMeshes
  92960. * @see http://doc.babylonjs.com/how_to/multi_materials
  92961. */
  92962. subMeshes: SubMesh[];
  92963. /** @hidden */
  92964. _intersectionsInProgress: AbstractMesh[];
  92965. /** @hidden */
  92966. _unIndexed: boolean;
  92967. /** @hidden */
  92968. _lightSources: Light[];
  92969. /** Gets the list of lights affecting that mesh */
  92970. readonly lightSources: Light[];
  92971. /** @hidden */
  92972. readonly _positions: Nullable<Vector3[]>;
  92973. /** @hidden */
  92974. _waitingData: {
  92975. lods: Nullable<any>;
  92976. actions: Nullable<any>;
  92977. freezeWorldMatrix: Nullable<boolean>;
  92978. };
  92979. /** @hidden */
  92980. _bonesTransformMatrices: Nullable<Float32Array>;
  92981. /** @hidden */
  92982. _transformMatrixTexture: Nullable<RawTexture>;
  92983. /**
  92984. * Gets or sets a skeleton to apply skining transformations
  92985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92986. */
  92987. skeleton: Nullable<Skeleton>;
  92988. /**
  92989. * An event triggered when the mesh is rebuilt.
  92990. */
  92991. onRebuildObservable: Observable<AbstractMesh>;
  92992. /**
  92993. * Creates a new AbstractMesh
  92994. * @param name defines the name of the mesh
  92995. * @param scene defines the hosting scene
  92996. */
  92997. constructor(name: string, scene?: Nullable<Scene>);
  92998. /**
  92999. * Returns the string "AbstractMesh"
  93000. * @returns "AbstractMesh"
  93001. */
  93002. getClassName(): string;
  93003. /**
  93004. * Gets a string representation of the current mesh
  93005. * @param fullDetails defines a boolean indicating if full details must be included
  93006. * @returns a string representation of the current mesh
  93007. */
  93008. toString(fullDetails?: boolean): string;
  93009. /**
  93010. * @hidden
  93011. */
  93012. protected _getEffectiveParent(): Nullable<Node>;
  93013. /** @hidden */
  93014. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93015. /** @hidden */
  93016. _rebuild(): void;
  93017. /** @hidden */
  93018. _resyncLightSources(): void;
  93019. /** @hidden */
  93020. _resyncLighSource(light: Light): void;
  93021. /** @hidden */
  93022. _unBindEffect(): void;
  93023. /** @hidden */
  93024. _removeLightSource(light: Light, dispose: boolean): void;
  93025. private _markSubMeshesAsDirty;
  93026. /** @hidden */
  93027. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93028. /** @hidden */
  93029. _markSubMeshesAsAttributesDirty(): void;
  93030. /** @hidden */
  93031. _markSubMeshesAsMiscDirty(): void;
  93032. /**
  93033. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93034. */
  93035. scaling: Vector3;
  93036. /**
  93037. * Returns true if the mesh is blocked. Implemented by child classes
  93038. */
  93039. readonly isBlocked: boolean;
  93040. /**
  93041. * Returns the mesh itself by default. Implemented by child classes
  93042. * @param camera defines the camera to use to pick the right LOD level
  93043. * @returns the currentAbstractMesh
  93044. */
  93045. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93046. /**
  93047. * Returns 0 by default. Implemented by child classes
  93048. * @returns an integer
  93049. */
  93050. getTotalVertices(): number;
  93051. /**
  93052. * Returns a positive integer : the total number of indices in this mesh geometry.
  93053. * @returns the numner of indices or zero if the mesh has no geometry.
  93054. */
  93055. getTotalIndices(): number;
  93056. /**
  93057. * Returns null by default. Implemented by child classes
  93058. * @returns null
  93059. */
  93060. getIndices(): Nullable<IndicesArray>;
  93061. /**
  93062. * Returns the array of the requested vertex data kind. Implemented by child classes
  93063. * @param kind defines the vertex data kind to use
  93064. * @returns null
  93065. */
  93066. getVerticesData(kind: string): Nullable<FloatArray>;
  93067. /**
  93068. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93069. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93070. * Note that a new underlying VertexBuffer object is created each call.
  93071. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93072. * @param kind defines vertex data kind:
  93073. * * VertexBuffer.PositionKind
  93074. * * VertexBuffer.UVKind
  93075. * * VertexBuffer.UV2Kind
  93076. * * VertexBuffer.UV3Kind
  93077. * * VertexBuffer.UV4Kind
  93078. * * VertexBuffer.UV5Kind
  93079. * * VertexBuffer.UV6Kind
  93080. * * VertexBuffer.ColorKind
  93081. * * VertexBuffer.MatricesIndicesKind
  93082. * * VertexBuffer.MatricesIndicesExtraKind
  93083. * * VertexBuffer.MatricesWeightsKind
  93084. * * VertexBuffer.MatricesWeightsExtraKind
  93085. * @param data defines the data source
  93086. * @param updatable defines if the data must be flagged as updatable (or static)
  93087. * @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
  93088. * @returns the current mesh
  93089. */
  93090. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93091. /**
  93092. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93093. * If the mesh has no geometry, it is simply returned as it is.
  93094. * @param kind defines vertex data kind:
  93095. * * VertexBuffer.PositionKind
  93096. * * VertexBuffer.UVKind
  93097. * * VertexBuffer.UV2Kind
  93098. * * VertexBuffer.UV3Kind
  93099. * * VertexBuffer.UV4Kind
  93100. * * VertexBuffer.UV5Kind
  93101. * * VertexBuffer.UV6Kind
  93102. * * VertexBuffer.ColorKind
  93103. * * VertexBuffer.MatricesIndicesKind
  93104. * * VertexBuffer.MatricesIndicesExtraKind
  93105. * * VertexBuffer.MatricesWeightsKind
  93106. * * VertexBuffer.MatricesWeightsExtraKind
  93107. * @param data defines the data source
  93108. * @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
  93109. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93110. * @returns the current mesh
  93111. */
  93112. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93113. /**
  93114. * Sets the mesh indices,
  93115. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93116. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93117. * @param totalVertices Defines the total number of vertices
  93118. * @returns the current mesh
  93119. */
  93120. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93121. /**
  93122. * Gets a boolean indicating if specific vertex data is present
  93123. * @param kind defines the vertex data kind to use
  93124. * @returns true is data kind is present
  93125. */
  93126. isVerticesDataPresent(kind: string): boolean;
  93127. /**
  93128. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93129. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93130. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93131. * @returns a BoundingInfo
  93132. */
  93133. getBoundingInfo(): BoundingInfo;
  93134. /**
  93135. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93136. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93137. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93138. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93139. * @returns the current mesh
  93140. */
  93141. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93142. /**
  93143. * Overwrite the current bounding info
  93144. * @param boundingInfo defines the new bounding info
  93145. * @returns the current mesh
  93146. */
  93147. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93148. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93149. readonly useBones: boolean;
  93150. /** @hidden */
  93151. _preActivate(): void;
  93152. /** @hidden */
  93153. _preActivateForIntermediateRendering(renderId: number): void;
  93154. /** @hidden */
  93155. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93156. /** @hidden */
  93157. _postActivate(): void;
  93158. /** @hidden */
  93159. _freeze(): void;
  93160. /** @hidden */
  93161. _unFreeze(): void;
  93162. /**
  93163. * Gets the current world matrix
  93164. * @returns a Matrix
  93165. */
  93166. getWorldMatrix(): Matrix;
  93167. /** @hidden */
  93168. _getWorldMatrixDeterminant(): number;
  93169. /**
  93170. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93171. */
  93172. readonly isAnInstance: boolean;
  93173. /**
  93174. * Gets a boolean indicating if this mesh has instances
  93175. */
  93176. readonly hasInstances: boolean;
  93177. /**
  93178. * Perform relative position change from the point of view of behind the front of the mesh.
  93179. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93180. * Supports definition of mesh facing forward or backward
  93181. * @param amountRight defines the distance on the right axis
  93182. * @param amountUp defines the distance on the up axis
  93183. * @param amountForward defines the distance on the forward axis
  93184. * @returns the current mesh
  93185. */
  93186. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93187. /**
  93188. * Calculate relative position change from the point of view of behind the front of the mesh.
  93189. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93190. * Supports definition of mesh facing forward or backward
  93191. * @param amountRight defines the distance on the right axis
  93192. * @param amountUp defines the distance on the up axis
  93193. * @param amountForward defines the distance on the forward axis
  93194. * @returns the new displacement vector
  93195. */
  93196. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93197. /**
  93198. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93199. * Supports definition of mesh facing forward or backward
  93200. * @param flipBack defines the flip
  93201. * @param twirlClockwise defines the twirl
  93202. * @param tiltRight defines the tilt
  93203. * @returns the current mesh
  93204. */
  93205. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93206. /**
  93207. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93208. * Supports definition of mesh facing forward or backward.
  93209. * @param flipBack defines the flip
  93210. * @param twirlClockwise defines the twirl
  93211. * @param tiltRight defines the tilt
  93212. * @returns the new rotation vector
  93213. */
  93214. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93215. /**
  93216. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93217. * This means the mesh underlying bounding box and sphere are recomputed.
  93218. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93219. * @returns the current mesh
  93220. */
  93221. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93222. /** @hidden */
  93223. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93224. /** @hidden */
  93225. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93226. /** @hidden */
  93227. _updateBoundingInfo(): AbstractMesh;
  93228. /** @hidden */
  93229. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93230. /** @hidden */
  93231. protected _afterComputeWorldMatrix(): void;
  93232. /** @hidden */
  93233. readonly _effectiveMesh: AbstractMesh;
  93234. /**
  93235. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93236. * A mesh is in the frustum if its bounding box intersects the frustum
  93237. * @param frustumPlanes defines the frustum to test
  93238. * @returns true if the mesh is in the frustum planes
  93239. */
  93240. isInFrustum(frustumPlanes: Plane[]): boolean;
  93241. /**
  93242. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93243. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93244. * @param frustumPlanes defines the frustum to test
  93245. * @returns true if the mesh is completely in the frustum planes
  93246. */
  93247. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93248. /**
  93249. * True if the mesh intersects another mesh or a SolidParticle object
  93250. * @param mesh defines a target mesh or SolidParticle to test
  93251. * @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)
  93252. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93253. * @returns true if there is an intersection
  93254. */
  93255. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93256. /**
  93257. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93258. * @param point defines the point to test
  93259. * @returns true if there is an intersection
  93260. */
  93261. intersectsPoint(point: Vector3): boolean;
  93262. /**
  93263. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93264. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93265. */
  93266. checkCollisions: boolean;
  93267. /**
  93268. * Gets Collider object used to compute collisions (not physics)
  93269. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93270. */
  93271. readonly collider: Nullable<Collider>;
  93272. /**
  93273. * Move the mesh using collision engine
  93274. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93275. * @param displacement defines the requested displacement vector
  93276. * @returns the current mesh
  93277. */
  93278. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93279. private _onCollisionPositionChange;
  93280. /** @hidden */
  93281. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93282. /** @hidden */
  93283. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93284. /** @hidden */
  93285. _checkCollision(collider: Collider): AbstractMesh;
  93286. /** @hidden */
  93287. _generatePointsArray(): boolean;
  93288. /**
  93289. * Checks if the passed Ray intersects with the mesh
  93290. * @param ray defines the ray to use
  93291. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93292. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93293. * @returns the picking info
  93294. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93295. */
  93296. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93297. /**
  93298. * Clones the current mesh
  93299. * @param name defines the mesh name
  93300. * @param newParent defines the new mesh parent
  93301. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93302. * @returns the new mesh
  93303. */
  93304. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93305. /**
  93306. * Disposes all the submeshes of the current meshnp
  93307. * @returns the current mesh
  93308. */
  93309. releaseSubMeshes(): AbstractMesh;
  93310. /**
  93311. * Releases resources associated with this abstract mesh.
  93312. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93313. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93314. */
  93315. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93316. /**
  93317. * Adds the passed mesh as a child to the current mesh
  93318. * @param mesh defines the child mesh
  93319. * @returns the current mesh
  93320. */
  93321. addChild(mesh: AbstractMesh): AbstractMesh;
  93322. /**
  93323. * Removes the passed mesh from the current mesh children list
  93324. * @param mesh defines the child mesh
  93325. * @returns the current mesh
  93326. */
  93327. removeChild(mesh: AbstractMesh): AbstractMesh;
  93328. /** @hidden */
  93329. private _initFacetData;
  93330. /**
  93331. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93332. * This method can be called within the render loop.
  93333. * 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
  93334. * @returns the current mesh
  93335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93336. */
  93337. updateFacetData(): AbstractMesh;
  93338. /**
  93339. * Returns the facetLocalNormals array.
  93340. * The normals are expressed in the mesh local spac
  93341. * @returns an array of Vector3
  93342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93343. */
  93344. getFacetLocalNormals(): Vector3[];
  93345. /**
  93346. * Returns the facetLocalPositions array.
  93347. * The facet positions are expressed in the mesh local space
  93348. * @returns an array of Vector3
  93349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93350. */
  93351. getFacetLocalPositions(): Vector3[];
  93352. /**
  93353. * Returns the facetLocalPartioning array
  93354. * @returns an array of array of numbers
  93355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93356. */
  93357. getFacetLocalPartitioning(): number[][];
  93358. /**
  93359. * Returns the i-th facet position in the world system.
  93360. * This method allocates a new Vector3 per call
  93361. * @param i defines the facet index
  93362. * @returns a new Vector3
  93363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93364. */
  93365. getFacetPosition(i: number): Vector3;
  93366. /**
  93367. * Sets the reference Vector3 with the i-th facet position in the world system
  93368. * @param i defines the facet index
  93369. * @param ref defines the target vector
  93370. * @returns the current mesh
  93371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93372. */
  93373. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93374. /**
  93375. * Returns the i-th facet normal in the world system.
  93376. * This method allocates a new Vector3 per call
  93377. * @param i defines the facet index
  93378. * @returns a new Vector3
  93379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93380. */
  93381. getFacetNormal(i: number): Vector3;
  93382. /**
  93383. * Sets the reference Vector3 with the i-th facet normal in the world system
  93384. * @param i defines the facet index
  93385. * @param ref defines the target vector
  93386. * @returns the current mesh
  93387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93388. */
  93389. getFacetNormalToRef(i: number, ref: Vector3): this;
  93390. /**
  93391. * 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)
  93392. * @param x defines x coordinate
  93393. * @param y defines y coordinate
  93394. * @param z defines z coordinate
  93395. * @returns the array of facet indexes
  93396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93397. */
  93398. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93399. /**
  93400. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93401. * @param projected sets as the (x,y,z) world projection on the facet
  93402. * @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
  93403. * @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
  93404. * @param x defines x coordinate
  93405. * @param y defines y coordinate
  93406. * @param z defines z coordinate
  93407. * @returns the face index if found (or null instead)
  93408. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93409. */
  93410. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93411. /**
  93412. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93413. * @param projected sets as the (x,y,z) local projection on the facet
  93414. * @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
  93415. * @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
  93416. * @param x defines x coordinate
  93417. * @param y defines y coordinate
  93418. * @param z defines z coordinate
  93419. * @returns the face index if found (or null instead)
  93420. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93421. */
  93422. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93423. /**
  93424. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93425. * @returns the parameters
  93426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93427. */
  93428. getFacetDataParameters(): any;
  93429. /**
  93430. * Disables the feature FacetData and frees the related memory
  93431. * @returns the current mesh
  93432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93433. */
  93434. disableFacetData(): AbstractMesh;
  93435. /**
  93436. * Updates the AbstractMesh indices array
  93437. * @param indices defines the data source
  93438. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93439. * @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)
  93440. * @returns the current mesh
  93441. */
  93442. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93443. /**
  93444. * Creates new normals data for the mesh
  93445. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93446. * @returns the current mesh
  93447. */
  93448. createNormals(updatable: boolean): AbstractMesh;
  93449. /**
  93450. * Align the mesh with a normal
  93451. * @param normal defines the normal to use
  93452. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93453. * @returns the current mesh
  93454. */
  93455. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93456. /** @hidden */
  93457. _checkOcclusionQuery(): boolean;
  93458. /**
  93459. * Disables the mesh edge rendering mode
  93460. * @returns the currentAbstractMesh
  93461. */
  93462. disableEdgesRendering(): AbstractMesh;
  93463. /**
  93464. * Enables the edge rendering mode on the mesh.
  93465. * This mode makes the mesh edges visible
  93466. * @param epsilon defines the maximal distance between two angles to detect a face
  93467. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93468. * @returns the currentAbstractMesh
  93469. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93470. */
  93471. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93472. }
  93473. }
  93474. declare module BABYLON {
  93475. /**
  93476. * Interface used to define ActionEvent
  93477. */
  93478. export interface IActionEvent {
  93479. /** The mesh or sprite that triggered the action */
  93480. source: any;
  93481. /** The X mouse cursor position at the time of the event */
  93482. pointerX: number;
  93483. /** The Y mouse cursor position at the time of the event */
  93484. pointerY: number;
  93485. /** The mesh that is currently pointed at (can be null) */
  93486. meshUnderPointer: Nullable<AbstractMesh>;
  93487. /** the original (browser) event that triggered the ActionEvent */
  93488. sourceEvent?: any;
  93489. /** additional data for the event */
  93490. additionalData?: any;
  93491. }
  93492. /**
  93493. * ActionEvent is the event being sent when an action is triggered.
  93494. */
  93495. export class ActionEvent implements IActionEvent {
  93496. /** The mesh or sprite that triggered the action */
  93497. source: any;
  93498. /** The X mouse cursor position at the time of the event */
  93499. pointerX: number;
  93500. /** The Y mouse cursor position at the time of the event */
  93501. pointerY: number;
  93502. /** The mesh that is currently pointed at (can be null) */
  93503. meshUnderPointer: Nullable<AbstractMesh>;
  93504. /** the original (browser) event that triggered the ActionEvent */
  93505. sourceEvent?: any;
  93506. /** additional data for the event */
  93507. additionalData?: any;
  93508. /**
  93509. * Creates a new ActionEvent
  93510. * @param source The mesh or sprite that triggered the action
  93511. * @param pointerX The X mouse cursor position at the time of the event
  93512. * @param pointerY The Y mouse cursor position at the time of the event
  93513. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93514. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93515. * @param additionalData additional data for the event
  93516. */
  93517. constructor(
  93518. /** The mesh or sprite that triggered the action */
  93519. source: any,
  93520. /** The X mouse cursor position at the time of the event */
  93521. pointerX: number,
  93522. /** The Y mouse cursor position at the time of the event */
  93523. pointerY: number,
  93524. /** The mesh that is currently pointed at (can be null) */
  93525. meshUnderPointer: Nullable<AbstractMesh>,
  93526. /** the original (browser) event that triggered the ActionEvent */
  93527. sourceEvent?: any,
  93528. /** additional data for the event */
  93529. additionalData?: any);
  93530. /**
  93531. * Helper function to auto-create an ActionEvent from a source mesh.
  93532. * @param source The source mesh that triggered the event
  93533. * @param evt The original (browser) event
  93534. * @param additionalData additional data for the event
  93535. * @returns the new ActionEvent
  93536. */
  93537. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93538. /**
  93539. * Helper function to auto-create an ActionEvent from a source sprite
  93540. * @param source The source sprite that triggered the event
  93541. * @param scene Scene associated with the sprite
  93542. * @param evt The original (browser) event
  93543. * @param additionalData additional data for the event
  93544. * @returns the new ActionEvent
  93545. */
  93546. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93547. /**
  93548. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93549. * @param scene the scene where the event occurred
  93550. * @param evt The original (browser) event
  93551. * @returns the new ActionEvent
  93552. */
  93553. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93554. /**
  93555. * Helper function to auto-create an ActionEvent from a primitive
  93556. * @param prim defines the target primitive
  93557. * @param pointerPos defines the pointer position
  93558. * @param evt The original (browser) event
  93559. * @param additionalData additional data for the event
  93560. * @returns the new ActionEvent
  93561. */
  93562. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93563. }
  93564. }
  93565. declare module BABYLON {
  93566. /**
  93567. * Abstract class used to decouple action Manager from scene and meshes.
  93568. * Do not instantiate.
  93569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93570. */
  93571. export abstract class AbstractActionManager implements IDisposable {
  93572. /** Gets the list of active triggers */
  93573. static Triggers: {
  93574. [key: string]: number;
  93575. };
  93576. /** Gets the cursor to use when hovering items */
  93577. hoverCursor: string;
  93578. /** Gets the list of actions */
  93579. actions: IAction[];
  93580. /**
  93581. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93582. */
  93583. isRecursive: boolean;
  93584. /**
  93585. * Releases all associated resources
  93586. */
  93587. abstract dispose(): void;
  93588. /**
  93589. * Does this action manager has pointer triggers
  93590. */
  93591. abstract readonly hasPointerTriggers: boolean;
  93592. /**
  93593. * Does this action manager has pick triggers
  93594. */
  93595. abstract readonly hasPickTriggers: boolean;
  93596. /**
  93597. * Process a specific trigger
  93598. * @param trigger defines the trigger to process
  93599. * @param evt defines the event details to be processed
  93600. */
  93601. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93602. /**
  93603. * Does this action manager handles actions of any of the given triggers
  93604. * @param triggers defines the triggers to be tested
  93605. * @return a boolean indicating whether one (or more) of the triggers is handled
  93606. */
  93607. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93608. /**
  93609. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93610. * speed.
  93611. * @param triggerA defines the trigger to be tested
  93612. * @param triggerB defines the trigger to be tested
  93613. * @return a boolean indicating whether one (or more) of the triggers is handled
  93614. */
  93615. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93616. /**
  93617. * Does this action manager handles actions of a given trigger
  93618. * @param trigger defines the trigger to be tested
  93619. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93620. * @return whether the trigger is handled
  93621. */
  93622. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93623. /**
  93624. * Serialize this manager to a JSON object
  93625. * @param name defines the property name to store this manager
  93626. * @returns a JSON representation of this manager
  93627. */
  93628. abstract serialize(name: string): any;
  93629. /**
  93630. * Registers an action to this action manager
  93631. * @param action defines the action to be registered
  93632. * @return the action amended (prepared) after registration
  93633. */
  93634. abstract registerAction(action: IAction): Nullable<IAction>;
  93635. /**
  93636. * Unregisters an action to this action manager
  93637. * @param action defines the action to be unregistered
  93638. * @return a boolean indicating whether the action has been unregistered
  93639. */
  93640. abstract unregisterAction(action: IAction): Boolean;
  93641. /**
  93642. * Does exist one action manager with at least one trigger
  93643. **/
  93644. static readonly HasTriggers: boolean;
  93645. /**
  93646. * Does exist one action manager with at least one pick trigger
  93647. **/
  93648. static readonly HasPickTriggers: boolean;
  93649. /**
  93650. * Does exist one action manager that handles actions of a given trigger
  93651. * @param trigger defines the trigger to be tested
  93652. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93653. **/
  93654. static HasSpecificTrigger(trigger: number): boolean;
  93655. }
  93656. }
  93657. declare module BABYLON {
  93658. /**
  93659. * Defines how a node can be built from a string name.
  93660. */
  93661. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93662. /**
  93663. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93664. */
  93665. export class Node implements IBehaviorAware<Node> {
  93666. /** @hidden */
  93667. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93668. private static _NodeConstructors;
  93669. /**
  93670. * Add a new node constructor
  93671. * @param type defines the type name of the node to construct
  93672. * @param constructorFunc defines the constructor function
  93673. */
  93674. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93675. /**
  93676. * Returns a node constructor based on type name
  93677. * @param type defines the type name
  93678. * @param name defines the new node name
  93679. * @param scene defines the hosting scene
  93680. * @param options defines optional options to transmit to constructors
  93681. * @returns the new constructor or null
  93682. */
  93683. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93684. /**
  93685. * Gets or sets the name of the node
  93686. */
  93687. name: string;
  93688. /**
  93689. * Gets or sets the id of the node
  93690. */
  93691. id: string;
  93692. /**
  93693. * Gets or sets the unique id of the node
  93694. */
  93695. uniqueId: number;
  93696. /**
  93697. * Gets or sets a string used to store user defined state for the node
  93698. */
  93699. state: string;
  93700. /**
  93701. * Gets or sets an object used to store user defined information for the node
  93702. */
  93703. metadata: any;
  93704. /**
  93705. * For internal use only. Please do not use.
  93706. */
  93707. reservedDataStore: any;
  93708. /**
  93709. * List of inspectable custom properties (used by the Inspector)
  93710. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93711. */
  93712. inspectableCustomProperties: IInspectable[];
  93713. private _doNotSerialize;
  93714. /**
  93715. * Gets or sets a boolean used to define if the node must be serialized
  93716. */
  93717. doNotSerialize: boolean;
  93718. /** @hidden */
  93719. _isDisposed: boolean;
  93720. /**
  93721. * Gets a list of Animations associated with the node
  93722. */
  93723. animations: Animation[];
  93724. protected _ranges: {
  93725. [name: string]: Nullable<AnimationRange>;
  93726. };
  93727. /**
  93728. * Callback raised when the node is ready to be used
  93729. */
  93730. onReady: Nullable<(node: Node) => void>;
  93731. private _isEnabled;
  93732. private _isParentEnabled;
  93733. private _isReady;
  93734. /** @hidden */
  93735. _currentRenderId: number;
  93736. private _parentUpdateId;
  93737. /** @hidden */
  93738. _childUpdateId: number;
  93739. /** @hidden */
  93740. _waitingParentId: Nullable<string>;
  93741. /** @hidden */
  93742. _scene: Scene;
  93743. /** @hidden */
  93744. _cache: any;
  93745. private _parentNode;
  93746. private _children;
  93747. /** @hidden */
  93748. _worldMatrix: Matrix;
  93749. /** @hidden */
  93750. _worldMatrixDeterminant: number;
  93751. /** @hidden */
  93752. _worldMatrixDeterminantIsDirty: boolean;
  93753. /** @hidden */
  93754. private _sceneRootNodesIndex;
  93755. /**
  93756. * Gets a boolean indicating if the node has been disposed
  93757. * @returns true if the node was disposed
  93758. */
  93759. isDisposed(): boolean;
  93760. /**
  93761. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93762. * @see https://doc.babylonjs.com/how_to/parenting
  93763. */
  93764. parent: Nullable<Node>;
  93765. private addToSceneRootNodes;
  93766. private removeFromSceneRootNodes;
  93767. private _animationPropertiesOverride;
  93768. /**
  93769. * Gets or sets the animation properties override
  93770. */
  93771. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93772. /**
  93773. * Gets a string idenfifying the name of the class
  93774. * @returns "Node" string
  93775. */
  93776. getClassName(): string;
  93777. /** @hidden */
  93778. readonly _isNode: boolean;
  93779. /**
  93780. * An event triggered when the mesh is disposed
  93781. */
  93782. onDisposeObservable: Observable<Node>;
  93783. private _onDisposeObserver;
  93784. /**
  93785. * Sets a callback that will be raised when the node will be disposed
  93786. */
  93787. onDispose: () => void;
  93788. /**
  93789. * Creates a new Node
  93790. * @param name the name and id to be given to this node
  93791. * @param scene the scene this node will be added to
  93792. * @param addToRootNodes the node will be added to scene.rootNodes
  93793. */
  93794. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93795. /**
  93796. * Gets the scene of the node
  93797. * @returns a scene
  93798. */
  93799. getScene(): Scene;
  93800. /**
  93801. * Gets the engine of the node
  93802. * @returns a Engine
  93803. */
  93804. getEngine(): Engine;
  93805. private _behaviors;
  93806. /**
  93807. * Attach a behavior to the node
  93808. * @see http://doc.babylonjs.com/features/behaviour
  93809. * @param behavior defines the behavior to attach
  93810. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93811. * @returns the current Node
  93812. */
  93813. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93814. /**
  93815. * Remove an attached behavior
  93816. * @see http://doc.babylonjs.com/features/behaviour
  93817. * @param behavior defines the behavior to attach
  93818. * @returns the current Node
  93819. */
  93820. removeBehavior(behavior: Behavior<Node>): Node;
  93821. /**
  93822. * Gets the list of attached behaviors
  93823. * @see http://doc.babylonjs.com/features/behaviour
  93824. */
  93825. readonly behaviors: Behavior<Node>[];
  93826. /**
  93827. * Gets an attached behavior by name
  93828. * @param name defines the name of the behavior to look for
  93829. * @see http://doc.babylonjs.com/features/behaviour
  93830. * @returns null if behavior was not found else the requested behavior
  93831. */
  93832. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93833. /**
  93834. * Returns the latest update of the World matrix
  93835. * @returns a Matrix
  93836. */
  93837. getWorldMatrix(): Matrix;
  93838. /** @hidden */
  93839. _getWorldMatrixDeterminant(): number;
  93840. /**
  93841. * Returns directly the latest state of the mesh World matrix.
  93842. * A Matrix is returned.
  93843. */
  93844. readonly worldMatrixFromCache: Matrix;
  93845. /** @hidden */
  93846. _initCache(): void;
  93847. /** @hidden */
  93848. updateCache(force?: boolean): void;
  93849. /** @hidden */
  93850. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93851. /** @hidden */
  93852. _updateCache(ignoreParentClass?: boolean): void;
  93853. /** @hidden */
  93854. _isSynchronized(): boolean;
  93855. /** @hidden */
  93856. _markSyncedWithParent(): void;
  93857. /** @hidden */
  93858. isSynchronizedWithParent(): boolean;
  93859. /** @hidden */
  93860. isSynchronized(): boolean;
  93861. /**
  93862. * Is this node ready to be used/rendered
  93863. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93864. * @return true if the node is ready
  93865. */
  93866. isReady(completeCheck?: boolean): boolean;
  93867. /**
  93868. * Is this node enabled?
  93869. * 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
  93870. * @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
  93871. * @return whether this node (and its parent) is enabled
  93872. */
  93873. isEnabled(checkAncestors?: boolean): boolean;
  93874. /** @hidden */
  93875. protected _syncParentEnabledState(): void;
  93876. /**
  93877. * Set the enabled state of this node
  93878. * @param value defines the new enabled state
  93879. */
  93880. setEnabled(value: boolean): void;
  93881. /**
  93882. * Is this node a descendant of the given node?
  93883. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93884. * @param ancestor defines the parent node to inspect
  93885. * @returns a boolean indicating if this node is a descendant of the given node
  93886. */
  93887. isDescendantOf(ancestor: Node): boolean;
  93888. /** @hidden */
  93889. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93890. /**
  93891. * Will return all nodes that have this node as ascendant
  93892. * @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
  93893. * @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
  93894. * @return all children nodes of all types
  93895. */
  93896. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93897. /**
  93898. * Get all child-meshes of this node
  93899. * @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)
  93900. * @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
  93901. * @returns an array of AbstractMesh
  93902. */
  93903. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93904. /**
  93905. * Get all direct children of this node
  93906. * @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
  93907. * @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)
  93908. * @returns an array of Node
  93909. */
  93910. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93911. /** @hidden */
  93912. _setReady(state: boolean): void;
  93913. /**
  93914. * Get an animation by name
  93915. * @param name defines the name of the animation to look for
  93916. * @returns null if not found else the requested animation
  93917. */
  93918. getAnimationByName(name: string): Nullable<Animation>;
  93919. /**
  93920. * Creates an animation range for this node
  93921. * @param name defines the name of the range
  93922. * @param from defines the starting key
  93923. * @param to defines the end key
  93924. */
  93925. createAnimationRange(name: string, from: number, to: number): void;
  93926. /**
  93927. * Delete a specific animation range
  93928. * @param name defines the name of the range to delete
  93929. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93930. */
  93931. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93932. /**
  93933. * Get an animation range by name
  93934. * @param name defines the name of the animation range to look for
  93935. * @returns null if not found else the requested animation range
  93936. */
  93937. getAnimationRange(name: string): Nullable<AnimationRange>;
  93938. /**
  93939. * Gets the list of all animation ranges defined on this node
  93940. * @returns an array
  93941. */
  93942. getAnimationRanges(): Nullable<AnimationRange>[];
  93943. /**
  93944. * Will start the animation sequence
  93945. * @param name defines the range frames for animation sequence
  93946. * @param loop defines if the animation should loop (false by default)
  93947. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93948. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93949. * @returns the object created for this animation. If range does not exist, it will return null
  93950. */
  93951. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93952. /**
  93953. * Serialize animation ranges into a JSON compatible object
  93954. * @returns serialization object
  93955. */
  93956. serializeAnimationRanges(): any;
  93957. /**
  93958. * Computes the world matrix of the node
  93959. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93960. * @returns the world matrix
  93961. */
  93962. computeWorldMatrix(force?: boolean): Matrix;
  93963. /**
  93964. * Releases resources associated with this node.
  93965. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93966. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93967. */
  93968. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93969. /**
  93970. * Parse animation range data from a serialization object and store them into a given node
  93971. * @param node defines where to store the animation ranges
  93972. * @param parsedNode defines the serialization object to read data from
  93973. * @param scene defines the hosting scene
  93974. */
  93975. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93976. /**
  93977. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93978. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93979. * @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
  93980. * @returns the new bounding vectors
  93981. */
  93982. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93983. min: Vector3;
  93984. max: Vector3;
  93985. };
  93986. }
  93987. }
  93988. declare module BABYLON {
  93989. /**
  93990. * @hidden
  93991. */
  93992. export class _IAnimationState {
  93993. key: number;
  93994. repeatCount: number;
  93995. workValue?: any;
  93996. loopMode?: number;
  93997. offsetValue?: any;
  93998. highLimitValue?: any;
  93999. }
  94000. /**
  94001. * Class used to store any kind of animation
  94002. */
  94003. export class Animation {
  94004. /**Name of the animation */
  94005. name: string;
  94006. /**Property to animate */
  94007. targetProperty: string;
  94008. /**The frames per second of the animation */
  94009. framePerSecond: number;
  94010. /**The data type of the animation */
  94011. dataType: number;
  94012. /**The loop mode of the animation */
  94013. loopMode?: number | undefined;
  94014. /**Specifies if blending should be enabled */
  94015. enableBlending?: boolean | undefined;
  94016. /**
  94017. * Use matrix interpolation instead of using direct key value when animating matrices
  94018. */
  94019. static AllowMatricesInterpolation: boolean;
  94020. /**
  94021. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94022. */
  94023. static AllowMatrixDecomposeForInterpolation: boolean;
  94024. /**
  94025. * Stores the key frames of the animation
  94026. */
  94027. private _keys;
  94028. /**
  94029. * Stores the easing function of the animation
  94030. */
  94031. private _easingFunction;
  94032. /**
  94033. * @hidden Internal use only
  94034. */
  94035. _runtimeAnimations: RuntimeAnimation[];
  94036. /**
  94037. * The set of event that will be linked to this animation
  94038. */
  94039. private _events;
  94040. /**
  94041. * Stores an array of target property paths
  94042. */
  94043. targetPropertyPath: string[];
  94044. /**
  94045. * Stores the blending speed of the animation
  94046. */
  94047. blendingSpeed: number;
  94048. /**
  94049. * Stores the animation ranges for the animation
  94050. */
  94051. private _ranges;
  94052. /**
  94053. * @hidden Internal use
  94054. */
  94055. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94056. /**
  94057. * Sets up an animation
  94058. * @param property The property to animate
  94059. * @param animationType The animation type to apply
  94060. * @param framePerSecond The frames per second of the animation
  94061. * @param easingFunction The easing function used in the animation
  94062. * @returns The created animation
  94063. */
  94064. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94065. /**
  94066. * Create and start an animation on a node
  94067. * @param name defines the name of the global animation that will be run on all nodes
  94068. * @param node defines the root node where the animation will take place
  94069. * @param targetProperty defines property to animate
  94070. * @param framePerSecond defines the number of frame per second yo use
  94071. * @param totalFrame defines the number of frames in total
  94072. * @param from defines the initial value
  94073. * @param to defines the final value
  94074. * @param loopMode defines which loop mode you want to use (off by default)
  94075. * @param easingFunction defines the easing function to use (linear by default)
  94076. * @param onAnimationEnd defines the callback to call when animation end
  94077. * @returns the animatable created for this animation
  94078. */
  94079. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94080. /**
  94081. * Create and start an animation on a node and its descendants
  94082. * @param name defines the name of the global animation that will be run on all nodes
  94083. * @param node defines the root node where the animation will take place
  94084. * @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
  94085. * @param targetProperty defines property to animate
  94086. * @param framePerSecond defines the number of frame per second to use
  94087. * @param totalFrame defines the number of frames in total
  94088. * @param from defines the initial value
  94089. * @param to defines the final value
  94090. * @param loopMode defines which loop mode you want to use (off by default)
  94091. * @param easingFunction defines the easing function to use (linear by default)
  94092. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94093. * @returns the list of animatables created for all nodes
  94094. * @example https://www.babylonjs-playground.com/#MH0VLI
  94095. */
  94096. 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[]>;
  94097. /**
  94098. * Creates a new animation, merges it with the existing animations and starts it
  94099. * @param name Name of the animation
  94100. * @param node Node which contains the scene that begins the animations
  94101. * @param targetProperty Specifies which property to animate
  94102. * @param framePerSecond The frames per second of the animation
  94103. * @param totalFrame The total number of frames
  94104. * @param from The frame at the beginning of the animation
  94105. * @param to The frame at the end of the animation
  94106. * @param loopMode Specifies the loop mode of the animation
  94107. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94108. * @param onAnimationEnd Callback to run once the animation is complete
  94109. * @returns Nullable animation
  94110. */
  94111. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94112. /**
  94113. * Transition property of an host to the target Value
  94114. * @param property The property to transition
  94115. * @param targetValue The target Value of the property
  94116. * @param host The object where the property to animate belongs
  94117. * @param scene Scene used to run the animation
  94118. * @param frameRate Framerate (in frame/s) to use
  94119. * @param transition The transition type we want to use
  94120. * @param duration The duration of the animation, in milliseconds
  94121. * @param onAnimationEnd Callback trigger at the end of the animation
  94122. * @returns Nullable animation
  94123. */
  94124. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94125. /**
  94126. * Return the array of runtime animations currently using this animation
  94127. */
  94128. readonly runtimeAnimations: RuntimeAnimation[];
  94129. /**
  94130. * Specifies if any of the runtime animations are currently running
  94131. */
  94132. readonly hasRunningRuntimeAnimations: boolean;
  94133. /**
  94134. * Initializes the animation
  94135. * @param name Name of the animation
  94136. * @param targetProperty Property to animate
  94137. * @param framePerSecond The frames per second of the animation
  94138. * @param dataType The data type of the animation
  94139. * @param loopMode The loop mode of the animation
  94140. * @param enableBlending Specifies if blending should be enabled
  94141. */
  94142. constructor(
  94143. /**Name of the animation */
  94144. name: string,
  94145. /**Property to animate */
  94146. targetProperty: string,
  94147. /**The frames per second of the animation */
  94148. framePerSecond: number,
  94149. /**The data type of the animation */
  94150. dataType: number,
  94151. /**The loop mode of the animation */
  94152. loopMode?: number | undefined,
  94153. /**Specifies if blending should be enabled */
  94154. enableBlending?: boolean | undefined);
  94155. /**
  94156. * Converts the animation to a string
  94157. * @param fullDetails support for multiple levels of logging within scene loading
  94158. * @returns String form of the animation
  94159. */
  94160. toString(fullDetails?: boolean): string;
  94161. /**
  94162. * Add an event to this animation
  94163. * @param event Event to add
  94164. */
  94165. addEvent(event: AnimationEvent): void;
  94166. /**
  94167. * Remove all events found at the given frame
  94168. * @param frame The frame to remove events from
  94169. */
  94170. removeEvents(frame: number): void;
  94171. /**
  94172. * Retrieves all the events from the animation
  94173. * @returns Events from the animation
  94174. */
  94175. getEvents(): AnimationEvent[];
  94176. /**
  94177. * Creates an animation range
  94178. * @param name Name of the animation range
  94179. * @param from Starting frame of the animation range
  94180. * @param to Ending frame of the animation
  94181. */
  94182. createRange(name: string, from: number, to: number): void;
  94183. /**
  94184. * Deletes an animation range by name
  94185. * @param name Name of the animation range to delete
  94186. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94187. */
  94188. deleteRange(name: string, deleteFrames?: boolean): void;
  94189. /**
  94190. * Gets the animation range by name, or null if not defined
  94191. * @param name Name of the animation range
  94192. * @returns Nullable animation range
  94193. */
  94194. getRange(name: string): Nullable<AnimationRange>;
  94195. /**
  94196. * Gets the key frames from the animation
  94197. * @returns The key frames of the animation
  94198. */
  94199. getKeys(): Array<IAnimationKey>;
  94200. /**
  94201. * Gets the highest frame rate of the animation
  94202. * @returns Highest frame rate of the animation
  94203. */
  94204. getHighestFrame(): number;
  94205. /**
  94206. * Gets the easing function of the animation
  94207. * @returns Easing function of the animation
  94208. */
  94209. getEasingFunction(): IEasingFunction;
  94210. /**
  94211. * Sets the easing function of the animation
  94212. * @param easingFunction A custom mathematical formula for animation
  94213. */
  94214. setEasingFunction(easingFunction: EasingFunction): void;
  94215. /**
  94216. * Interpolates a scalar linearly
  94217. * @param startValue Start value of the animation curve
  94218. * @param endValue End value of the animation curve
  94219. * @param gradient Scalar amount to interpolate
  94220. * @returns Interpolated scalar value
  94221. */
  94222. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94223. /**
  94224. * Interpolates a scalar cubically
  94225. * @param startValue Start value of the animation curve
  94226. * @param outTangent End tangent of the animation
  94227. * @param endValue End value of the animation curve
  94228. * @param inTangent Start tangent of the animation curve
  94229. * @param gradient Scalar amount to interpolate
  94230. * @returns Interpolated scalar value
  94231. */
  94232. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94233. /**
  94234. * Interpolates a quaternion using a spherical linear interpolation
  94235. * @param startValue Start value of the animation curve
  94236. * @param endValue End value of the animation curve
  94237. * @param gradient Scalar amount to interpolate
  94238. * @returns Interpolated quaternion value
  94239. */
  94240. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94241. /**
  94242. * Interpolates a quaternion cubically
  94243. * @param startValue Start value of the animation curve
  94244. * @param outTangent End tangent of the animation curve
  94245. * @param endValue End value of the animation curve
  94246. * @param inTangent Start tangent of the animation curve
  94247. * @param gradient Scalar amount to interpolate
  94248. * @returns Interpolated quaternion value
  94249. */
  94250. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94251. /**
  94252. * Interpolates a Vector3 linearl
  94253. * @param startValue Start value of the animation curve
  94254. * @param endValue End value of the animation curve
  94255. * @param gradient Scalar amount to interpolate
  94256. * @returns Interpolated scalar value
  94257. */
  94258. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94259. /**
  94260. * Interpolates a Vector3 cubically
  94261. * @param startValue Start value of the animation curve
  94262. * @param outTangent End tangent of the animation
  94263. * @param endValue End value of the animation curve
  94264. * @param inTangent Start tangent of the animation curve
  94265. * @param gradient Scalar amount to interpolate
  94266. * @returns InterpolatedVector3 value
  94267. */
  94268. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94269. /**
  94270. * Interpolates a Vector2 linearly
  94271. * @param startValue Start value of the animation curve
  94272. * @param endValue End value of the animation curve
  94273. * @param gradient Scalar amount to interpolate
  94274. * @returns Interpolated Vector2 value
  94275. */
  94276. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94277. /**
  94278. * Interpolates a Vector2 cubically
  94279. * @param startValue Start value of the animation curve
  94280. * @param outTangent End tangent of the animation
  94281. * @param endValue End value of the animation curve
  94282. * @param inTangent Start tangent of the animation curve
  94283. * @param gradient Scalar amount to interpolate
  94284. * @returns Interpolated Vector2 value
  94285. */
  94286. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94287. /**
  94288. * Interpolates a size linearly
  94289. * @param startValue Start value of the animation curve
  94290. * @param endValue End value of the animation curve
  94291. * @param gradient Scalar amount to interpolate
  94292. * @returns Interpolated Size value
  94293. */
  94294. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94295. /**
  94296. * Interpolates a Color3 linearly
  94297. * @param startValue Start value of the animation curve
  94298. * @param endValue End value of the animation curve
  94299. * @param gradient Scalar amount to interpolate
  94300. * @returns Interpolated Color3 value
  94301. */
  94302. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94303. /**
  94304. * @hidden Internal use only
  94305. */
  94306. _getKeyValue(value: any): any;
  94307. /**
  94308. * @hidden Internal use only
  94309. */
  94310. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94311. /**
  94312. * Defines the function to use to interpolate matrices
  94313. * @param startValue defines the start matrix
  94314. * @param endValue defines the end matrix
  94315. * @param gradient defines the gradient between both matrices
  94316. * @param result defines an optional target matrix where to store the interpolation
  94317. * @returns the interpolated matrix
  94318. */
  94319. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94320. /**
  94321. * Makes a copy of the animation
  94322. * @returns Cloned animation
  94323. */
  94324. clone(): Animation;
  94325. /**
  94326. * Sets the key frames of the animation
  94327. * @param values The animation key frames to set
  94328. */
  94329. setKeys(values: Array<IAnimationKey>): void;
  94330. /**
  94331. * Serializes the animation to an object
  94332. * @returns Serialized object
  94333. */
  94334. serialize(): any;
  94335. /**
  94336. * Float animation type
  94337. */
  94338. private static _ANIMATIONTYPE_FLOAT;
  94339. /**
  94340. * Vector3 animation type
  94341. */
  94342. private static _ANIMATIONTYPE_VECTOR3;
  94343. /**
  94344. * Quaternion animation type
  94345. */
  94346. private static _ANIMATIONTYPE_QUATERNION;
  94347. /**
  94348. * Matrix animation type
  94349. */
  94350. private static _ANIMATIONTYPE_MATRIX;
  94351. /**
  94352. * Color3 animation type
  94353. */
  94354. private static _ANIMATIONTYPE_COLOR3;
  94355. /**
  94356. * Vector2 animation type
  94357. */
  94358. private static _ANIMATIONTYPE_VECTOR2;
  94359. /**
  94360. * Size animation type
  94361. */
  94362. private static _ANIMATIONTYPE_SIZE;
  94363. /**
  94364. * Relative Loop Mode
  94365. */
  94366. private static _ANIMATIONLOOPMODE_RELATIVE;
  94367. /**
  94368. * Cycle Loop Mode
  94369. */
  94370. private static _ANIMATIONLOOPMODE_CYCLE;
  94371. /**
  94372. * Constant Loop Mode
  94373. */
  94374. private static _ANIMATIONLOOPMODE_CONSTANT;
  94375. /**
  94376. * Get the float animation type
  94377. */
  94378. static readonly ANIMATIONTYPE_FLOAT: number;
  94379. /**
  94380. * Get the Vector3 animation type
  94381. */
  94382. static readonly ANIMATIONTYPE_VECTOR3: number;
  94383. /**
  94384. * Get the Vector2 animation type
  94385. */
  94386. static readonly ANIMATIONTYPE_VECTOR2: number;
  94387. /**
  94388. * Get the Size animation type
  94389. */
  94390. static readonly ANIMATIONTYPE_SIZE: number;
  94391. /**
  94392. * Get the Quaternion animation type
  94393. */
  94394. static readonly ANIMATIONTYPE_QUATERNION: number;
  94395. /**
  94396. * Get the Matrix animation type
  94397. */
  94398. static readonly ANIMATIONTYPE_MATRIX: number;
  94399. /**
  94400. * Get the Color3 animation type
  94401. */
  94402. static readonly ANIMATIONTYPE_COLOR3: number;
  94403. /**
  94404. * Get the Relative Loop Mode
  94405. */
  94406. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94407. /**
  94408. * Get the Cycle Loop Mode
  94409. */
  94410. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94411. /**
  94412. * Get the Constant Loop Mode
  94413. */
  94414. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94415. /** @hidden */
  94416. static _UniversalLerp(left: any, right: any, amount: number): any;
  94417. /**
  94418. * Parses an animation object and creates an animation
  94419. * @param parsedAnimation Parsed animation object
  94420. * @returns Animation object
  94421. */
  94422. static Parse(parsedAnimation: any): Animation;
  94423. /**
  94424. * Appends the serialized animations from the source animations
  94425. * @param source Source containing the animations
  94426. * @param destination Target to store the animations
  94427. */
  94428. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94429. }
  94430. }
  94431. declare module BABYLON {
  94432. /**
  94433. * Interface containing an array of animations
  94434. */
  94435. export interface IAnimatable {
  94436. /**
  94437. * Array of animations
  94438. */
  94439. animations: Nullable<Array<Animation>>;
  94440. }
  94441. }
  94442. declare module BABYLON {
  94443. /**
  94444. * This represents all the required information to add a fresnel effect on a material:
  94445. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94446. */
  94447. export class FresnelParameters {
  94448. private _isEnabled;
  94449. /**
  94450. * Define if the fresnel effect is enable or not.
  94451. */
  94452. isEnabled: boolean;
  94453. /**
  94454. * Define the color used on edges (grazing angle)
  94455. */
  94456. leftColor: Color3;
  94457. /**
  94458. * Define the color used on center
  94459. */
  94460. rightColor: Color3;
  94461. /**
  94462. * Define bias applied to computed fresnel term
  94463. */
  94464. bias: number;
  94465. /**
  94466. * Defined the power exponent applied to fresnel term
  94467. */
  94468. power: number;
  94469. /**
  94470. * Clones the current fresnel and its valuues
  94471. * @returns a clone fresnel configuration
  94472. */
  94473. clone(): FresnelParameters;
  94474. /**
  94475. * Serializes the current fresnel parameters to a JSON representation.
  94476. * @return the JSON serialization
  94477. */
  94478. serialize(): any;
  94479. /**
  94480. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94481. * @param parsedFresnelParameters Define the JSON representation
  94482. * @returns the parsed parameters
  94483. */
  94484. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94485. }
  94486. }
  94487. declare module BABYLON {
  94488. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94489. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94490. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94491. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94492. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94493. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94494. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94495. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94496. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94497. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94498. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94499. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94500. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94501. /**
  94502. * Decorator used to define property that can be serialized as reference to a camera
  94503. * @param sourceName defines the name of the property to decorate
  94504. */
  94505. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94506. /**
  94507. * Class used to help serialization objects
  94508. */
  94509. export class SerializationHelper {
  94510. /** @hidden */
  94511. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94512. /** @hidden */
  94513. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94514. /** @hidden */
  94515. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94516. /** @hidden */
  94517. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94518. /**
  94519. * Appends the serialized animations from the source animations
  94520. * @param source Source containing the animations
  94521. * @param destination Target to store the animations
  94522. */
  94523. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94524. /**
  94525. * Static function used to serialized a specific entity
  94526. * @param entity defines the entity to serialize
  94527. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94528. * @returns a JSON compatible object representing the serialization of the entity
  94529. */
  94530. static Serialize<T>(entity: T, serializationObject?: any): any;
  94531. /**
  94532. * Creates a new entity from a serialization data object
  94533. * @param creationFunction defines a function used to instanciated the new entity
  94534. * @param source defines the source serialization data
  94535. * @param scene defines the hosting scene
  94536. * @param rootUrl defines the root url for resources
  94537. * @returns a new entity
  94538. */
  94539. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94540. /**
  94541. * Clones an object
  94542. * @param creationFunction defines the function used to instanciate the new object
  94543. * @param source defines the source object
  94544. * @returns the cloned object
  94545. */
  94546. static Clone<T>(creationFunction: () => T, source: T): T;
  94547. /**
  94548. * Instanciates a new object based on a source one (some data will be shared between both object)
  94549. * @param creationFunction defines the function used to instanciate the new object
  94550. * @param source defines the source object
  94551. * @returns the new object
  94552. */
  94553. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94554. }
  94555. }
  94556. declare module BABYLON {
  94557. /**
  94558. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94559. */
  94560. export interface CubeMapInfo {
  94561. /**
  94562. * The pixel array for the front face.
  94563. * This is stored in format, left to right, up to down format.
  94564. */
  94565. front: Nullable<ArrayBufferView>;
  94566. /**
  94567. * The pixel array for the back face.
  94568. * This is stored in format, left to right, up to down format.
  94569. */
  94570. back: Nullable<ArrayBufferView>;
  94571. /**
  94572. * The pixel array for the left face.
  94573. * This is stored in format, left to right, up to down format.
  94574. */
  94575. left: Nullable<ArrayBufferView>;
  94576. /**
  94577. * The pixel array for the right face.
  94578. * This is stored in format, left to right, up to down format.
  94579. */
  94580. right: Nullable<ArrayBufferView>;
  94581. /**
  94582. * The pixel array for the up face.
  94583. * This is stored in format, left to right, up to down format.
  94584. */
  94585. up: Nullable<ArrayBufferView>;
  94586. /**
  94587. * The pixel array for the down face.
  94588. * This is stored in format, left to right, up to down format.
  94589. */
  94590. down: Nullable<ArrayBufferView>;
  94591. /**
  94592. * The size of the cubemap stored.
  94593. *
  94594. * Each faces will be size * size pixels.
  94595. */
  94596. size: number;
  94597. /**
  94598. * The format of the texture.
  94599. *
  94600. * RGBA, RGB.
  94601. */
  94602. format: number;
  94603. /**
  94604. * The type of the texture data.
  94605. *
  94606. * UNSIGNED_INT, FLOAT.
  94607. */
  94608. type: number;
  94609. /**
  94610. * Specifies whether the texture is in gamma space.
  94611. */
  94612. gammaSpace: boolean;
  94613. }
  94614. /**
  94615. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94616. */
  94617. export class PanoramaToCubeMapTools {
  94618. private static FACE_FRONT;
  94619. private static FACE_BACK;
  94620. private static FACE_RIGHT;
  94621. private static FACE_LEFT;
  94622. private static FACE_DOWN;
  94623. private static FACE_UP;
  94624. /**
  94625. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94626. *
  94627. * @param float32Array The source data.
  94628. * @param inputWidth The width of the input panorama.
  94629. * @param inputHeight The height of the input panorama.
  94630. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94631. * @return The cubemap data
  94632. */
  94633. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94634. private static CreateCubemapTexture;
  94635. private static CalcProjectionSpherical;
  94636. }
  94637. }
  94638. declare module BABYLON {
  94639. /**
  94640. * Helper class dealing with the extraction of spherical polynomial dataArray
  94641. * from a cube map.
  94642. */
  94643. export class CubeMapToSphericalPolynomialTools {
  94644. private static FileFaces;
  94645. /**
  94646. * Converts a texture to the according Spherical Polynomial data.
  94647. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94648. *
  94649. * @param texture The texture to extract the information from.
  94650. * @return The Spherical Polynomial data.
  94651. */
  94652. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94653. /**
  94654. * Converts a cubemap to the according Spherical Polynomial data.
  94655. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94656. *
  94657. * @param cubeInfo The Cube map to extract the information from.
  94658. * @return The Spherical Polynomial data.
  94659. */
  94660. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94661. }
  94662. }
  94663. declare module BABYLON {
  94664. /**
  94665. * Class used to manipulate GUIDs
  94666. */
  94667. export class GUID {
  94668. /**
  94669. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94670. * Be aware Math.random() could cause collisions, but:
  94671. * "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"
  94672. * @returns a pseudo random id
  94673. */
  94674. static RandomId(): string;
  94675. }
  94676. }
  94677. declare module BABYLON {
  94678. /**
  94679. * Base class of all the textures in babylon.
  94680. * It groups all the common properties the materials, post process, lights... might need
  94681. * in order to make a correct use of the texture.
  94682. */
  94683. export class BaseTexture implements IAnimatable {
  94684. /**
  94685. * Default anisotropic filtering level for the application.
  94686. * It is set to 4 as a good tradeoff between perf and quality.
  94687. */
  94688. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94689. /**
  94690. * Gets or sets the unique id of the texture
  94691. */
  94692. uniqueId: number;
  94693. /**
  94694. * Define the name of the texture.
  94695. */
  94696. name: string;
  94697. /**
  94698. * Gets or sets an object used to store user defined information.
  94699. */
  94700. metadata: any;
  94701. /**
  94702. * For internal use only. Please do not use.
  94703. */
  94704. reservedDataStore: any;
  94705. private _hasAlpha;
  94706. /**
  94707. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94708. */
  94709. hasAlpha: boolean;
  94710. /**
  94711. * Defines if the alpha value should be determined via the rgb values.
  94712. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94713. */
  94714. getAlphaFromRGB: boolean;
  94715. /**
  94716. * Intensity or strength of the texture.
  94717. * It is commonly used by materials to fine tune the intensity of the texture
  94718. */
  94719. level: number;
  94720. /**
  94721. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94722. * This is part of the texture as textures usually maps to one uv set.
  94723. */
  94724. coordinatesIndex: number;
  94725. private _coordinatesMode;
  94726. /**
  94727. * How a texture is mapped.
  94728. *
  94729. * | Value | Type | Description |
  94730. * | ----- | ----------------------------------- | ----------- |
  94731. * | 0 | EXPLICIT_MODE | |
  94732. * | 1 | SPHERICAL_MODE | |
  94733. * | 2 | PLANAR_MODE | |
  94734. * | 3 | CUBIC_MODE | |
  94735. * | 4 | PROJECTION_MODE | |
  94736. * | 5 | SKYBOX_MODE | |
  94737. * | 6 | INVCUBIC_MODE | |
  94738. * | 7 | EQUIRECTANGULAR_MODE | |
  94739. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94740. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94741. */
  94742. coordinatesMode: number;
  94743. /**
  94744. * | Value | Type | Description |
  94745. * | ----- | ------------------ | ----------- |
  94746. * | 0 | CLAMP_ADDRESSMODE | |
  94747. * | 1 | WRAP_ADDRESSMODE | |
  94748. * | 2 | MIRROR_ADDRESSMODE | |
  94749. */
  94750. wrapU: number;
  94751. /**
  94752. * | Value | Type | Description |
  94753. * | ----- | ------------------ | ----------- |
  94754. * | 0 | CLAMP_ADDRESSMODE | |
  94755. * | 1 | WRAP_ADDRESSMODE | |
  94756. * | 2 | MIRROR_ADDRESSMODE | |
  94757. */
  94758. wrapV: number;
  94759. /**
  94760. * | Value | Type | Description |
  94761. * | ----- | ------------------ | ----------- |
  94762. * | 0 | CLAMP_ADDRESSMODE | |
  94763. * | 1 | WRAP_ADDRESSMODE | |
  94764. * | 2 | MIRROR_ADDRESSMODE | |
  94765. */
  94766. wrapR: number;
  94767. /**
  94768. * With compliant hardware and browser (supporting anisotropic filtering)
  94769. * this defines the level of anisotropic filtering in the texture.
  94770. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94771. */
  94772. anisotropicFilteringLevel: number;
  94773. /**
  94774. * Define if the texture is a cube texture or if false a 2d texture.
  94775. */
  94776. isCube: boolean;
  94777. /**
  94778. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94779. */
  94780. is3D: boolean;
  94781. /**
  94782. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94783. * HDR texture are usually stored in linear space.
  94784. * This only impacts the PBR and Background materials
  94785. */
  94786. gammaSpace: boolean;
  94787. /**
  94788. * Gets or sets whether or not the texture contains RGBD data.
  94789. */
  94790. isRGBD: boolean;
  94791. /**
  94792. * Is Z inverted in the texture (useful in a cube texture).
  94793. */
  94794. invertZ: boolean;
  94795. /**
  94796. * Are mip maps generated for this texture or not.
  94797. */
  94798. readonly noMipmap: boolean;
  94799. /**
  94800. * @hidden
  94801. */
  94802. lodLevelInAlpha: boolean;
  94803. /**
  94804. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94805. */
  94806. lodGenerationOffset: number;
  94807. /**
  94808. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94809. */
  94810. lodGenerationScale: number;
  94811. /**
  94812. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94813. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94814. * average roughness values.
  94815. */
  94816. linearSpecularLOD: boolean;
  94817. /**
  94818. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94819. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94820. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94821. */
  94822. irradianceTexture: Nullable<BaseTexture>;
  94823. /**
  94824. * Define if the texture is a render target.
  94825. */
  94826. isRenderTarget: boolean;
  94827. /**
  94828. * Define the unique id of the texture in the scene.
  94829. */
  94830. readonly uid: string;
  94831. /**
  94832. * Return a string representation of the texture.
  94833. * @returns the texture as a string
  94834. */
  94835. toString(): string;
  94836. /**
  94837. * Get the class name of the texture.
  94838. * @returns "BaseTexture"
  94839. */
  94840. getClassName(): string;
  94841. /**
  94842. * Define the list of animation attached to the texture.
  94843. */
  94844. animations: Animation[];
  94845. /**
  94846. * An event triggered when the texture is disposed.
  94847. */
  94848. onDisposeObservable: Observable<BaseTexture>;
  94849. private _onDisposeObserver;
  94850. /**
  94851. * Callback triggered when the texture has been disposed.
  94852. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94853. */
  94854. onDispose: () => void;
  94855. /**
  94856. * Define the current state of the loading sequence when in delayed load mode.
  94857. */
  94858. delayLoadState: number;
  94859. private _scene;
  94860. /** @hidden */
  94861. _texture: Nullable<InternalTexture>;
  94862. private _uid;
  94863. /**
  94864. * Define if the texture is preventinga material to render or not.
  94865. * If not and the texture is not ready, the engine will use a default black texture instead.
  94866. */
  94867. readonly isBlocking: boolean;
  94868. /**
  94869. * Instantiates a new BaseTexture.
  94870. * Base class of all the textures in babylon.
  94871. * It groups all the common properties the materials, post process, lights... might need
  94872. * in order to make a correct use of the texture.
  94873. * @param scene Define the scene the texture blongs to
  94874. */
  94875. constructor(scene: Nullable<Scene>);
  94876. /**
  94877. * Get the scene the texture belongs to.
  94878. * @returns the scene or null if undefined
  94879. */
  94880. getScene(): Nullable<Scene>;
  94881. /**
  94882. * Get the texture transform matrix used to offset tile the texture for istance.
  94883. * @returns the transformation matrix
  94884. */
  94885. getTextureMatrix(): Matrix;
  94886. /**
  94887. * Get the texture reflection matrix used to rotate/transform the reflection.
  94888. * @returns the reflection matrix
  94889. */
  94890. getReflectionTextureMatrix(): Matrix;
  94891. /**
  94892. * Get the underlying lower level texture from Babylon.
  94893. * @returns the insternal texture
  94894. */
  94895. getInternalTexture(): Nullable<InternalTexture>;
  94896. /**
  94897. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94898. * @returns true if ready or not blocking
  94899. */
  94900. isReadyOrNotBlocking(): boolean;
  94901. /**
  94902. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94903. * @returns true if fully ready
  94904. */
  94905. isReady(): boolean;
  94906. private _cachedSize;
  94907. /**
  94908. * Get the size of the texture.
  94909. * @returns the texture size.
  94910. */
  94911. getSize(): ISize;
  94912. /**
  94913. * Get the base size of the texture.
  94914. * It can be different from the size if the texture has been resized for POT for instance
  94915. * @returns the base size
  94916. */
  94917. getBaseSize(): ISize;
  94918. /**
  94919. * Update the sampling mode of the texture.
  94920. * Default is Trilinear mode.
  94921. *
  94922. * | Value | Type | Description |
  94923. * | ----- | ------------------ | ----------- |
  94924. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94925. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94926. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94927. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94928. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94929. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94930. * | 7 | NEAREST_LINEAR | |
  94931. * | 8 | NEAREST_NEAREST | |
  94932. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94933. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94934. * | 11 | LINEAR_LINEAR | |
  94935. * | 12 | LINEAR_NEAREST | |
  94936. *
  94937. * > _mag_: magnification filter (close to the viewer)
  94938. * > _min_: minification filter (far from the viewer)
  94939. * > _mip_: filter used between mip map levels
  94940. *@param samplingMode Define the new sampling mode of the texture
  94941. */
  94942. updateSamplingMode(samplingMode: number): void;
  94943. /**
  94944. * Scales the texture if is `canRescale()`
  94945. * @param ratio the resize factor we want to use to rescale
  94946. */
  94947. scale(ratio: number): void;
  94948. /**
  94949. * Get if the texture can rescale.
  94950. */
  94951. readonly canRescale: boolean;
  94952. /** @hidden */
  94953. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94954. /** @hidden */
  94955. _rebuild(): void;
  94956. /**
  94957. * Triggers the load sequence in delayed load mode.
  94958. */
  94959. delayLoad(): void;
  94960. /**
  94961. * Clones the texture.
  94962. * @returns the cloned texture
  94963. */
  94964. clone(): Nullable<BaseTexture>;
  94965. /**
  94966. * Get the texture underlying type (INT, FLOAT...)
  94967. */
  94968. readonly textureType: number;
  94969. /**
  94970. * Get the texture underlying format (RGB, RGBA...)
  94971. */
  94972. readonly textureFormat: number;
  94973. /**
  94974. * Indicates that textures need to be re-calculated for all materials
  94975. */
  94976. protected _markAllSubMeshesAsTexturesDirty(): void;
  94977. /**
  94978. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94979. * This will returns an RGBA array buffer containing either in values (0-255) or
  94980. * float values (0-1) depending of the underlying buffer type.
  94981. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94982. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94983. * @param buffer defines a user defined buffer to fill with data (can be null)
  94984. * @returns The Array buffer containing the pixels data.
  94985. */
  94986. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94987. /**
  94988. * Release and destroy the underlying lower level texture aka internalTexture.
  94989. */
  94990. releaseInternalTexture(): void;
  94991. /**
  94992. * Get the polynomial representation of the texture data.
  94993. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94994. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94995. */
  94996. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94997. /** @hidden */
  94998. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94999. /** @hidden */
  95000. readonly _lodTextureMid: Nullable<BaseTexture>;
  95001. /** @hidden */
  95002. readonly _lodTextureLow: Nullable<BaseTexture>;
  95003. /**
  95004. * Dispose the texture and release its associated resources.
  95005. */
  95006. dispose(): void;
  95007. /**
  95008. * Serialize the texture into a JSON representation that can be parsed later on.
  95009. * @returns the JSON representation of the texture
  95010. */
  95011. serialize(): any;
  95012. /**
  95013. * Helper function to be called back once a list of texture contains only ready textures.
  95014. * @param textures Define the list of textures to wait for
  95015. * @param callback Define the callback triggered once the entire list will be ready
  95016. */
  95017. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95018. }
  95019. }
  95020. declare module BABYLON {
  95021. /**
  95022. * Options to be used when creating an effect.
  95023. */
  95024. export class EffectCreationOptions {
  95025. /**
  95026. * Atrributes that will be used in the shader.
  95027. */
  95028. attributes: string[];
  95029. /**
  95030. * Uniform varible names that will be set in the shader.
  95031. */
  95032. uniformsNames: string[];
  95033. /**
  95034. * Uniform buffer varible names that will be set in the shader.
  95035. */
  95036. uniformBuffersNames: string[];
  95037. /**
  95038. * Sampler texture variable names that will be set in the shader.
  95039. */
  95040. samplers: string[];
  95041. /**
  95042. * Define statements that will be set in the shader.
  95043. */
  95044. defines: any;
  95045. /**
  95046. * Possible fallbacks for this effect to improve performance when needed.
  95047. */
  95048. fallbacks: Nullable<IEffectFallbacks>;
  95049. /**
  95050. * Callback that will be called when the shader is compiled.
  95051. */
  95052. onCompiled: Nullable<(effect: Effect) => void>;
  95053. /**
  95054. * Callback that will be called if an error occurs during shader compilation.
  95055. */
  95056. onError: Nullable<(effect: Effect, errors: string) => void>;
  95057. /**
  95058. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95059. */
  95060. indexParameters?: any;
  95061. /**
  95062. * Max number of lights that can be used in the shader.
  95063. */
  95064. maxSimultaneousLights?: number;
  95065. /**
  95066. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95067. */
  95068. transformFeedbackVaryings?: Nullable<string[]>;
  95069. }
  95070. /**
  95071. * Effect containing vertex and fragment shader that can be executed on an object.
  95072. */
  95073. export class Effect implements IDisposable {
  95074. /**
  95075. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95076. */
  95077. static ShadersRepository: string;
  95078. /**
  95079. * Name of the effect.
  95080. */
  95081. name: any;
  95082. /**
  95083. * String container all the define statements that should be set on the shader.
  95084. */
  95085. defines: string;
  95086. /**
  95087. * Callback that will be called when the shader is compiled.
  95088. */
  95089. onCompiled: Nullable<(effect: Effect) => void>;
  95090. /**
  95091. * Callback that will be called if an error occurs during shader compilation.
  95092. */
  95093. onError: Nullable<(effect: Effect, errors: string) => void>;
  95094. /**
  95095. * Callback that will be called when effect is bound.
  95096. */
  95097. onBind: Nullable<(effect: Effect) => void>;
  95098. /**
  95099. * Unique ID of the effect.
  95100. */
  95101. uniqueId: number;
  95102. /**
  95103. * Observable that will be called when the shader is compiled.
  95104. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95105. */
  95106. onCompileObservable: Observable<Effect>;
  95107. /**
  95108. * Observable that will be called if an error occurs during shader compilation.
  95109. */
  95110. onErrorObservable: Observable<Effect>;
  95111. /** @hidden */
  95112. _onBindObservable: Nullable<Observable<Effect>>;
  95113. /**
  95114. * Observable that will be called when effect is bound.
  95115. */
  95116. readonly onBindObservable: Observable<Effect>;
  95117. /** @hidden */
  95118. _bonesComputationForcedToCPU: boolean;
  95119. private static _uniqueIdSeed;
  95120. private _engine;
  95121. private _uniformBuffersNames;
  95122. private _uniformsNames;
  95123. private _samplerList;
  95124. private _samplers;
  95125. private _isReady;
  95126. private _compilationError;
  95127. private _attributesNames;
  95128. private _attributes;
  95129. private _uniforms;
  95130. /**
  95131. * Key for the effect.
  95132. * @hidden
  95133. */
  95134. _key: string;
  95135. private _indexParameters;
  95136. private _fallbacks;
  95137. private _vertexSourceCode;
  95138. private _fragmentSourceCode;
  95139. private _vertexSourceCodeOverride;
  95140. private _fragmentSourceCodeOverride;
  95141. private _transformFeedbackVaryings;
  95142. /**
  95143. * Compiled shader to webGL program.
  95144. * @hidden
  95145. */
  95146. _pipelineContext: Nullable<IPipelineContext>;
  95147. private _valueCache;
  95148. private static _baseCache;
  95149. /**
  95150. * Instantiates an effect.
  95151. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95152. * @param baseName Name of the effect.
  95153. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95154. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95155. * @param samplers List of sampler variables that will be passed to the shader.
  95156. * @param engine Engine to be used to render the effect
  95157. * @param defines Define statements to be added to the shader.
  95158. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95159. * @param onCompiled Callback that will be called when the shader is compiled.
  95160. * @param onError Callback that will be called if an error occurs during shader compilation.
  95161. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95162. */
  95163. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  95164. private _useFinalCode;
  95165. /**
  95166. * Unique key for this effect
  95167. */
  95168. readonly key: string;
  95169. /**
  95170. * If the effect has been compiled and prepared.
  95171. * @returns if the effect is compiled and prepared.
  95172. */
  95173. isReady(): boolean;
  95174. private _isReadyInternal;
  95175. /**
  95176. * The engine the effect was initialized with.
  95177. * @returns the engine.
  95178. */
  95179. getEngine(): Engine;
  95180. /**
  95181. * The pipeline context for this effect
  95182. * @returns the associated pipeline context
  95183. */
  95184. getPipelineContext(): Nullable<IPipelineContext>;
  95185. /**
  95186. * The set of names of attribute variables for the shader.
  95187. * @returns An array of attribute names.
  95188. */
  95189. getAttributesNames(): string[];
  95190. /**
  95191. * Returns the attribute at the given index.
  95192. * @param index The index of the attribute.
  95193. * @returns The location of the attribute.
  95194. */
  95195. getAttributeLocation(index: number): number;
  95196. /**
  95197. * Returns the attribute based on the name of the variable.
  95198. * @param name of the attribute to look up.
  95199. * @returns the attribute location.
  95200. */
  95201. getAttributeLocationByName(name: string): number;
  95202. /**
  95203. * The number of attributes.
  95204. * @returns the numnber of attributes.
  95205. */
  95206. getAttributesCount(): number;
  95207. /**
  95208. * Gets the index of a uniform variable.
  95209. * @param uniformName of the uniform to look up.
  95210. * @returns the index.
  95211. */
  95212. getUniformIndex(uniformName: string): number;
  95213. /**
  95214. * Returns the attribute based on the name of the variable.
  95215. * @param uniformName of the uniform to look up.
  95216. * @returns the location of the uniform.
  95217. */
  95218. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95219. /**
  95220. * Returns an array of sampler variable names
  95221. * @returns The array of sampler variable neames.
  95222. */
  95223. getSamplers(): string[];
  95224. /**
  95225. * The error from the last compilation.
  95226. * @returns the error string.
  95227. */
  95228. getCompilationError(): string;
  95229. /**
  95230. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95231. * @param func The callback to be used.
  95232. */
  95233. executeWhenCompiled(func: (effect: Effect) => void): void;
  95234. private _checkIsReady;
  95235. /** @hidden */
  95236. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  95237. /** @hidden */
  95238. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  95239. /** @hidden */
  95240. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  95241. /**
  95242. * Recompiles the webGL program
  95243. * @param vertexSourceCode The source code for the vertex shader.
  95244. * @param fragmentSourceCode The source code for the fragment shader.
  95245. * @param onCompiled Callback called when completed.
  95246. * @param onError Callback called on error.
  95247. * @hidden
  95248. */
  95249. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95250. /**
  95251. * Prepares the effect
  95252. * @hidden
  95253. */
  95254. _prepareEffect(): void;
  95255. private _processCompilationErrors;
  95256. /**
  95257. * Checks if the effect is supported. (Must be called after compilation)
  95258. */
  95259. readonly isSupported: boolean;
  95260. /**
  95261. * Binds a texture to the engine to be used as output of the shader.
  95262. * @param channel Name of the output variable.
  95263. * @param texture Texture to bind.
  95264. * @hidden
  95265. */
  95266. _bindTexture(channel: string, texture: InternalTexture): void;
  95267. /**
  95268. * Sets a texture on the engine to be used in the shader.
  95269. * @param channel Name of the sampler variable.
  95270. * @param texture Texture to set.
  95271. */
  95272. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95273. /**
  95274. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95275. * @param channel Name of the sampler variable.
  95276. * @param texture Texture to set.
  95277. */
  95278. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95279. /**
  95280. * Sets an array of textures on the engine to be used in the shader.
  95281. * @param channel Name of the variable.
  95282. * @param textures Textures to set.
  95283. */
  95284. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95285. /**
  95286. * 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)
  95287. * @param channel Name of the sampler variable.
  95288. * @param postProcess Post process to get the input texture from.
  95289. */
  95290. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95291. /**
  95292. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95293. * 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)
  95294. * @param channel Name of the sampler variable.
  95295. * @param postProcess Post process to get the output texture from.
  95296. */
  95297. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95298. /** @hidden */
  95299. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95300. /** @hidden */
  95301. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95302. /** @hidden */
  95303. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95304. /** @hidden */
  95305. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95306. /**
  95307. * Binds a buffer to a uniform.
  95308. * @param buffer Buffer to bind.
  95309. * @param name Name of the uniform variable to bind to.
  95310. */
  95311. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95312. /**
  95313. * Binds block to a uniform.
  95314. * @param blockName Name of the block to bind.
  95315. * @param index Index to bind.
  95316. */
  95317. bindUniformBlock(blockName: string, index: number): void;
  95318. /**
  95319. * Sets an interger value on a uniform variable.
  95320. * @param uniformName Name of the variable.
  95321. * @param value Value to be set.
  95322. * @returns this effect.
  95323. */
  95324. setInt(uniformName: string, value: number): Effect;
  95325. /**
  95326. * Sets an int array on a uniform variable.
  95327. * @param uniformName Name of the variable.
  95328. * @param array array to be set.
  95329. * @returns this effect.
  95330. */
  95331. setIntArray(uniformName: string, array: Int32Array): Effect;
  95332. /**
  95333. * 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)
  95334. * @param uniformName Name of the variable.
  95335. * @param array array to be set.
  95336. * @returns this effect.
  95337. */
  95338. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95339. /**
  95340. * 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)
  95341. * @param uniformName Name of the variable.
  95342. * @param array array to be set.
  95343. * @returns this effect.
  95344. */
  95345. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95346. /**
  95347. * 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)
  95348. * @param uniformName Name of the variable.
  95349. * @param array array to be set.
  95350. * @returns this effect.
  95351. */
  95352. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95353. /**
  95354. * Sets an float array on a uniform variable.
  95355. * @param uniformName Name of the variable.
  95356. * @param array array to be set.
  95357. * @returns this effect.
  95358. */
  95359. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95360. /**
  95361. * 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)
  95362. * @param uniformName Name of the variable.
  95363. * @param array array to be set.
  95364. * @returns this effect.
  95365. */
  95366. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95367. /**
  95368. * 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)
  95369. * @param uniformName Name of the variable.
  95370. * @param array array to be set.
  95371. * @returns this effect.
  95372. */
  95373. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95374. /**
  95375. * 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)
  95376. * @param uniformName Name of the variable.
  95377. * @param array array to be set.
  95378. * @returns this effect.
  95379. */
  95380. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95381. /**
  95382. * Sets an array on a uniform variable.
  95383. * @param uniformName Name of the variable.
  95384. * @param array array to be set.
  95385. * @returns this effect.
  95386. */
  95387. setArray(uniformName: string, array: number[]): Effect;
  95388. /**
  95389. * 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)
  95390. * @param uniformName Name of the variable.
  95391. * @param array array to be set.
  95392. * @returns this effect.
  95393. */
  95394. setArray2(uniformName: string, array: number[]): Effect;
  95395. /**
  95396. * 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)
  95397. * @param uniformName Name of the variable.
  95398. * @param array array to be set.
  95399. * @returns this effect.
  95400. */
  95401. setArray3(uniformName: string, array: number[]): Effect;
  95402. /**
  95403. * 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)
  95404. * @param uniformName Name of the variable.
  95405. * @param array array to be set.
  95406. * @returns this effect.
  95407. */
  95408. setArray4(uniformName: string, array: number[]): Effect;
  95409. /**
  95410. * Sets matrices on a uniform variable.
  95411. * @param uniformName Name of the variable.
  95412. * @param matrices matrices to be set.
  95413. * @returns this effect.
  95414. */
  95415. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95416. /**
  95417. * Sets matrix on a uniform variable.
  95418. * @param uniformName Name of the variable.
  95419. * @param matrix matrix to be set.
  95420. * @returns this effect.
  95421. */
  95422. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95423. /**
  95424. * 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)
  95425. * @param uniformName Name of the variable.
  95426. * @param matrix matrix to be set.
  95427. * @returns this effect.
  95428. */
  95429. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95430. /**
  95431. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95432. * @param uniformName Name of the variable.
  95433. * @param matrix matrix to be set.
  95434. * @returns this effect.
  95435. */
  95436. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95437. /**
  95438. * Sets a float on a uniform variable.
  95439. * @param uniformName Name of the variable.
  95440. * @param value value to be set.
  95441. * @returns this effect.
  95442. */
  95443. setFloat(uniformName: string, value: number): Effect;
  95444. /**
  95445. * Sets a boolean on a uniform variable.
  95446. * @param uniformName Name of the variable.
  95447. * @param bool value to be set.
  95448. * @returns this effect.
  95449. */
  95450. setBool(uniformName: string, bool: boolean): Effect;
  95451. /**
  95452. * Sets a Vector2 on a uniform variable.
  95453. * @param uniformName Name of the variable.
  95454. * @param vector2 vector2 to be set.
  95455. * @returns this effect.
  95456. */
  95457. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95458. /**
  95459. * Sets a float2 on a uniform variable.
  95460. * @param uniformName Name of the variable.
  95461. * @param x First float in float2.
  95462. * @param y Second float in float2.
  95463. * @returns this effect.
  95464. */
  95465. setFloat2(uniformName: string, x: number, y: number): Effect;
  95466. /**
  95467. * Sets a Vector3 on a uniform variable.
  95468. * @param uniformName Name of the variable.
  95469. * @param vector3 Value to be set.
  95470. * @returns this effect.
  95471. */
  95472. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95473. /**
  95474. * Sets a float3 on a uniform variable.
  95475. * @param uniformName Name of the variable.
  95476. * @param x First float in float3.
  95477. * @param y Second float in float3.
  95478. * @param z Third float in float3.
  95479. * @returns this effect.
  95480. */
  95481. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95482. /**
  95483. * Sets a Vector4 on a uniform variable.
  95484. * @param uniformName Name of the variable.
  95485. * @param vector4 Value to be set.
  95486. * @returns this effect.
  95487. */
  95488. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95489. /**
  95490. * Sets a float4 on a uniform variable.
  95491. * @param uniformName Name of the variable.
  95492. * @param x First float in float4.
  95493. * @param y Second float in float4.
  95494. * @param z Third float in float4.
  95495. * @param w Fourth float in float4.
  95496. * @returns this effect.
  95497. */
  95498. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95499. /**
  95500. * Sets a Color3 on a uniform variable.
  95501. * @param uniformName Name of the variable.
  95502. * @param color3 Value to be set.
  95503. * @returns this effect.
  95504. */
  95505. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95506. /**
  95507. * Sets a Color4 on a uniform variable.
  95508. * @param uniformName Name of the variable.
  95509. * @param color3 Value to be set.
  95510. * @param alpha Alpha value to be set.
  95511. * @returns this effect.
  95512. */
  95513. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95514. /**
  95515. * Sets a Color4 on a uniform variable
  95516. * @param uniformName defines the name of the variable
  95517. * @param color4 defines the value to be set
  95518. * @returns this effect.
  95519. */
  95520. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95521. /** Release all associated resources */
  95522. dispose(): void;
  95523. /**
  95524. * This function will add a new shader to the shader store
  95525. * @param name the name of the shader
  95526. * @param pixelShader optional pixel shader content
  95527. * @param vertexShader optional vertex shader content
  95528. */
  95529. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95530. /**
  95531. * Store of each shader (The can be looked up using effect.key)
  95532. */
  95533. static ShadersStore: {
  95534. [key: string]: string;
  95535. };
  95536. /**
  95537. * Store of each included file for a shader (The can be looked up using effect.key)
  95538. */
  95539. static IncludesShadersStore: {
  95540. [key: string]: string;
  95541. };
  95542. /**
  95543. * Resets the cache of effects.
  95544. */
  95545. static ResetCache(): void;
  95546. }
  95547. }
  95548. declare module BABYLON {
  95549. /**
  95550. * Class used to describe the capabilities of the engine relatively to the current browser
  95551. */
  95552. export class EngineCapabilities {
  95553. /** Maximum textures units per fragment shader */
  95554. maxTexturesImageUnits: number;
  95555. /** Maximum texture units per vertex shader */
  95556. maxVertexTextureImageUnits: number;
  95557. /** Maximum textures units in the entire pipeline */
  95558. maxCombinedTexturesImageUnits: number;
  95559. /** Maximum texture size */
  95560. maxTextureSize: number;
  95561. /** Maximum cube texture size */
  95562. maxCubemapTextureSize: number;
  95563. /** Maximum render texture size */
  95564. maxRenderTextureSize: number;
  95565. /** Maximum number of vertex attributes */
  95566. maxVertexAttribs: number;
  95567. /** Maximum number of varyings */
  95568. maxVaryingVectors: number;
  95569. /** Maximum number of uniforms per vertex shader */
  95570. maxVertexUniformVectors: number;
  95571. /** Maximum number of uniforms per fragment shader */
  95572. maxFragmentUniformVectors: number;
  95573. /** Defines if standard derivates (dx/dy) are supported */
  95574. standardDerivatives: boolean;
  95575. /** Defines if s3tc texture compression is supported */
  95576. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95577. /** Defines if pvrtc texture compression is supported */
  95578. pvrtc: any;
  95579. /** Defines if etc1 texture compression is supported */
  95580. etc1: any;
  95581. /** Defines if etc2 texture compression is supported */
  95582. etc2: any;
  95583. /** Defines if astc texture compression is supported */
  95584. astc: any;
  95585. /** Defines if float textures are supported */
  95586. textureFloat: boolean;
  95587. /** Defines if vertex array objects are supported */
  95588. vertexArrayObject: boolean;
  95589. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95590. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95591. /** Gets the maximum level of anisotropy supported */
  95592. maxAnisotropy: number;
  95593. /** Defines if instancing is supported */
  95594. instancedArrays: boolean;
  95595. /** Defines if 32 bits indices are supported */
  95596. uintIndices: boolean;
  95597. /** Defines if high precision shaders are supported */
  95598. highPrecisionShaderSupported: boolean;
  95599. /** Defines if depth reading in the fragment shader is supported */
  95600. fragmentDepthSupported: boolean;
  95601. /** Defines if float texture linear filtering is supported*/
  95602. textureFloatLinearFiltering: boolean;
  95603. /** Defines if rendering to float textures is supported */
  95604. textureFloatRender: boolean;
  95605. /** Defines if half float textures are supported*/
  95606. textureHalfFloat: boolean;
  95607. /** Defines if half float texture linear filtering is supported*/
  95608. textureHalfFloatLinearFiltering: boolean;
  95609. /** Defines if rendering to half float textures is supported */
  95610. textureHalfFloatRender: boolean;
  95611. /** Defines if textureLOD shader command is supported */
  95612. textureLOD: boolean;
  95613. /** Defines if draw buffers extension is supported */
  95614. drawBuffersExtension: boolean;
  95615. /** Defines if depth textures are supported */
  95616. depthTextureExtension: boolean;
  95617. /** Defines if float color buffer are supported */
  95618. colorBufferFloat: boolean;
  95619. /** Gets disjoint timer query extension (null if not supported) */
  95620. timerQuery: EXT_disjoint_timer_query;
  95621. /** Defines if timestamp can be used with timer query */
  95622. canUseTimestampForTimerQuery: boolean;
  95623. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95624. multiview: any;
  95625. /** Function used to let the system compiles shaders in background */
  95626. parallelShaderCompile: {
  95627. COMPLETION_STATUS_KHR: number;
  95628. };
  95629. /** Max number of texture samples for MSAA */
  95630. maxMSAASamples: number;
  95631. /** Defines if the blend min max extension is supported */
  95632. blendMinMax: boolean;
  95633. }
  95634. }
  95635. declare module BABYLON {
  95636. /**
  95637. * @hidden
  95638. **/
  95639. export class DepthCullingState {
  95640. private _isDepthTestDirty;
  95641. private _isDepthMaskDirty;
  95642. private _isDepthFuncDirty;
  95643. private _isCullFaceDirty;
  95644. private _isCullDirty;
  95645. private _isZOffsetDirty;
  95646. private _isFrontFaceDirty;
  95647. private _depthTest;
  95648. private _depthMask;
  95649. private _depthFunc;
  95650. private _cull;
  95651. private _cullFace;
  95652. private _zOffset;
  95653. private _frontFace;
  95654. /**
  95655. * Initializes the state.
  95656. */
  95657. constructor();
  95658. readonly isDirty: boolean;
  95659. zOffset: number;
  95660. cullFace: Nullable<number>;
  95661. cull: Nullable<boolean>;
  95662. depthFunc: Nullable<number>;
  95663. depthMask: boolean;
  95664. depthTest: boolean;
  95665. frontFace: Nullable<number>;
  95666. reset(): void;
  95667. apply(gl: WebGLRenderingContext): void;
  95668. }
  95669. }
  95670. declare module BABYLON {
  95671. /**
  95672. * @hidden
  95673. **/
  95674. export class StencilState {
  95675. /** 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 */
  95676. static readonly ALWAYS: number;
  95677. /** Passed to stencilOperation to specify that stencil value must be kept */
  95678. static readonly KEEP: number;
  95679. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95680. static readonly REPLACE: number;
  95681. private _isStencilTestDirty;
  95682. private _isStencilMaskDirty;
  95683. private _isStencilFuncDirty;
  95684. private _isStencilOpDirty;
  95685. private _stencilTest;
  95686. private _stencilMask;
  95687. private _stencilFunc;
  95688. private _stencilFuncRef;
  95689. private _stencilFuncMask;
  95690. private _stencilOpStencilFail;
  95691. private _stencilOpDepthFail;
  95692. private _stencilOpStencilDepthPass;
  95693. readonly isDirty: boolean;
  95694. stencilFunc: number;
  95695. stencilFuncRef: number;
  95696. stencilFuncMask: number;
  95697. stencilOpStencilFail: number;
  95698. stencilOpDepthFail: number;
  95699. stencilOpStencilDepthPass: number;
  95700. stencilMask: number;
  95701. stencilTest: boolean;
  95702. constructor();
  95703. reset(): void;
  95704. apply(gl: WebGLRenderingContext): void;
  95705. }
  95706. }
  95707. declare module BABYLON {
  95708. /**
  95709. * @hidden
  95710. **/
  95711. export class AlphaState {
  95712. private _isAlphaBlendDirty;
  95713. private _isBlendFunctionParametersDirty;
  95714. private _isBlendEquationParametersDirty;
  95715. private _isBlendConstantsDirty;
  95716. private _alphaBlend;
  95717. private _blendFunctionParameters;
  95718. private _blendEquationParameters;
  95719. private _blendConstants;
  95720. /**
  95721. * Initializes the state.
  95722. */
  95723. constructor();
  95724. readonly isDirty: boolean;
  95725. alphaBlend: boolean;
  95726. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95727. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95728. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95729. reset(): void;
  95730. apply(gl: WebGLRenderingContext): void;
  95731. }
  95732. }
  95733. declare module BABYLON {
  95734. /** @hidden */
  95735. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95736. attributeProcessor(attribute: string): string;
  95737. varyingProcessor(varying: string, isFragment: boolean): string;
  95738. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95739. }
  95740. }
  95741. declare module BABYLON {
  95742. /**
  95743. * Interface for attribute information associated with buffer instanciation
  95744. */
  95745. export class InstancingAttributeInfo {
  95746. /**
  95747. * Index/offset of the attribute in the vertex shader
  95748. */
  95749. index: number;
  95750. /**
  95751. * size of the attribute, 1, 2, 3 or 4
  95752. */
  95753. attributeSize: number;
  95754. /**
  95755. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95756. * default is FLOAT
  95757. */
  95758. attribyteType: number;
  95759. /**
  95760. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95761. */
  95762. normalized: boolean;
  95763. /**
  95764. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95765. */
  95766. offset: number;
  95767. /**
  95768. * Name of the GLSL attribute, for debugging purpose only
  95769. */
  95770. attributeName: string;
  95771. }
  95772. }
  95773. declare module BABYLON {
  95774. interface ThinEngine {
  95775. /**
  95776. * Update a video texture
  95777. * @param texture defines the texture to update
  95778. * @param video defines the video element to use
  95779. * @param invertY defines if data must be stored with Y axis inverted
  95780. */
  95781. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95782. }
  95783. }
  95784. declare module BABYLON {
  95785. /**
  95786. * Settings for finer control over video usage
  95787. */
  95788. export interface VideoTextureSettings {
  95789. /**
  95790. * Applies `autoplay` to video, if specified
  95791. */
  95792. autoPlay?: boolean;
  95793. /**
  95794. * Applies `loop` to video, if specified
  95795. */
  95796. loop?: boolean;
  95797. /**
  95798. * Automatically updates internal texture from video at every frame in the render loop
  95799. */
  95800. autoUpdateTexture: boolean;
  95801. /**
  95802. * Image src displayed during the video loading or until the user interacts with the video.
  95803. */
  95804. poster?: string;
  95805. }
  95806. /**
  95807. * If you want to display a video in your scene, this is the special texture for that.
  95808. * This special texture works similar to other textures, with the exception of a few parameters.
  95809. * @see https://doc.babylonjs.com/how_to/video_texture
  95810. */
  95811. export class VideoTexture extends Texture {
  95812. /**
  95813. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95814. */
  95815. readonly autoUpdateTexture: boolean;
  95816. /**
  95817. * The video instance used by the texture internally
  95818. */
  95819. readonly video: HTMLVideoElement;
  95820. private _onUserActionRequestedObservable;
  95821. /**
  95822. * Event triggerd when a dom action is required by the user to play the video.
  95823. * This happens due to recent changes in browser policies preventing video to auto start.
  95824. */
  95825. readonly onUserActionRequestedObservable: Observable<Texture>;
  95826. private _generateMipMaps;
  95827. private _engine;
  95828. private _stillImageCaptured;
  95829. private _displayingPosterTexture;
  95830. private _settings;
  95831. private _createInternalTextureOnEvent;
  95832. private _frameId;
  95833. /**
  95834. * Creates a video texture.
  95835. * If you want to display a video in your scene, this is the special texture for that.
  95836. * This special texture works similar to other textures, with the exception of a few parameters.
  95837. * @see https://doc.babylonjs.com/how_to/video_texture
  95838. * @param name optional name, will detect from video source, if not defined
  95839. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95840. * @param scene is obviously the current scene.
  95841. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95842. * @param invertY is false by default but can be used to invert video on Y axis
  95843. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95844. * @param settings allows finer control over video usage
  95845. */
  95846. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95847. private _getName;
  95848. private _getVideo;
  95849. private _createInternalTexture;
  95850. private reset;
  95851. /**
  95852. * @hidden Internal method to initiate `update`.
  95853. */
  95854. _rebuild(): void;
  95855. /**
  95856. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95857. */
  95858. update(): void;
  95859. /**
  95860. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95861. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95862. */
  95863. updateTexture(isVisible: boolean): void;
  95864. protected _updateInternalTexture: () => void;
  95865. /**
  95866. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95867. * @param url New url.
  95868. */
  95869. updateURL(url: string): void;
  95870. /**
  95871. * Dispose the texture and release its associated resources.
  95872. */
  95873. dispose(): void;
  95874. /**
  95875. * Creates a video texture straight from a stream.
  95876. * @param scene Define the scene the texture should be created in
  95877. * @param stream Define the stream the texture should be created from
  95878. * @returns The created video texture as a promise
  95879. */
  95880. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95881. /**
  95882. * Creates a video texture straight from your WebCam video feed.
  95883. * @param scene Define the scene the texture should be created in
  95884. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95885. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95886. * @returns The created video texture as a promise
  95887. */
  95888. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95889. minWidth: number;
  95890. maxWidth: number;
  95891. minHeight: number;
  95892. maxHeight: number;
  95893. deviceId: string;
  95894. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95895. /**
  95896. * Creates a video texture straight from your WebCam video feed.
  95897. * @param scene Define the scene the texture should be created in
  95898. * @param onReady Define a callback to triggered once the texture will be ready
  95899. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95900. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95901. */
  95902. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95903. minWidth: number;
  95904. maxWidth: number;
  95905. minHeight: number;
  95906. maxHeight: number;
  95907. deviceId: string;
  95908. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95909. }
  95910. }
  95911. declare module BABYLON {
  95912. /**
  95913. * Defines the interface used by objects working like Scene
  95914. * @hidden
  95915. */
  95916. interface ISceneLike {
  95917. _addPendingData(data: any): void;
  95918. _removePendingData(data: any): void;
  95919. offlineProvider: IOfflineProvider;
  95920. }
  95921. /** Interface defining initialization parameters for Engine class */
  95922. export interface EngineOptions extends WebGLContextAttributes {
  95923. /**
  95924. * Defines if the engine should no exceed a specified device ratio
  95925. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95926. */
  95927. limitDeviceRatio?: number;
  95928. /**
  95929. * Defines if webvr should be enabled automatically
  95930. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95931. */
  95932. autoEnableWebVR?: boolean;
  95933. /**
  95934. * Defines if webgl2 should be turned off even if supported
  95935. * @see http://doc.babylonjs.com/features/webgl2
  95936. */
  95937. disableWebGL2Support?: boolean;
  95938. /**
  95939. * Defines if webaudio should be initialized as well
  95940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95941. */
  95942. audioEngine?: boolean;
  95943. /**
  95944. * Defines if animations should run using a deterministic lock step
  95945. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95946. */
  95947. deterministicLockstep?: boolean;
  95948. /** Defines the maximum steps to use with deterministic lock step mode */
  95949. lockstepMaxSteps?: number;
  95950. /**
  95951. * Defines that engine should ignore context lost events
  95952. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95953. */
  95954. doNotHandleContextLost?: boolean;
  95955. /**
  95956. * Defines that engine should ignore modifying touch action attribute and style
  95957. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95958. */
  95959. doNotHandleTouchAction?: boolean;
  95960. /**
  95961. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95962. */
  95963. useHighPrecisionFloats?: boolean;
  95964. }
  95965. /**
  95966. * The base engine class (root of all engines)
  95967. */
  95968. export class ThinEngine {
  95969. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95970. static ExceptionList: ({
  95971. key: string;
  95972. capture: string;
  95973. captureConstraint: number;
  95974. targets: string[];
  95975. } | {
  95976. key: string;
  95977. capture: null;
  95978. captureConstraint: null;
  95979. targets: string[];
  95980. })[];
  95981. /** @hidden */
  95982. static _TextureLoaders: IInternalTextureLoader[];
  95983. /**
  95984. * Returns the current npm package of the sdk
  95985. */
  95986. static readonly NpmPackage: string;
  95987. /**
  95988. * Returns the current version of the framework
  95989. */
  95990. static readonly Version: string;
  95991. /**
  95992. * Returns a string describing the current engine
  95993. */
  95994. readonly description: string;
  95995. /**
  95996. * Gets or sets the epsilon value used by collision engine
  95997. */
  95998. static CollisionsEpsilon: number;
  95999. /**
  96000. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96001. */
  96002. static ShadersRepository: string;
  96003. /** @hidden */
  96004. _shaderProcessor: IShaderProcessor;
  96005. /**
  96006. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96007. */
  96008. forcePOTTextures: boolean;
  96009. /**
  96010. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96011. */
  96012. isFullscreen: boolean;
  96013. /**
  96014. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96015. */
  96016. cullBackFaces: boolean;
  96017. /**
  96018. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96019. */
  96020. renderEvenInBackground: boolean;
  96021. /**
  96022. * Gets or sets a boolean indicating that cache can be kept between frames
  96023. */
  96024. preventCacheWipeBetweenFrames: boolean;
  96025. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96026. validateShaderPrograms: boolean;
  96027. /**
  96028. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96029. */
  96030. disableUniformBuffers: boolean;
  96031. /** @hidden */
  96032. _uniformBuffers: UniformBuffer[];
  96033. /**
  96034. * Gets a boolean indicating that the engine supports uniform buffers
  96035. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96036. */
  96037. readonly supportsUniformBuffers: boolean;
  96038. /** @hidden */
  96039. _gl: WebGLRenderingContext;
  96040. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96041. protected _windowIsBackground: boolean;
  96042. protected _webGLVersion: number;
  96043. protected _highPrecisionShadersAllowed: boolean;
  96044. /** @hidden */
  96045. readonly _shouldUseHighPrecisionShader: boolean;
  96046. /**
  96047. * Gets a boolean indicating that only power of 2 textures are supported
  96048. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96049. */
  96050. readonly needPOTTextures: boolean;
  96051. /** @hidden */
  96052. _badOS: boolean;
  96053. /** @hidden */
  96054. _badDesktopOS: boolean;
  96055. private _hardwareScalingLevel;
  96056. /** @hidden */
  96057. _caps: EngineCapabilities;
  96058. private _isStencilEnable;
  96059. protected _colorWrite: boolean;
  96060. private _glVersion;
  96061. private _glRenderer;
  96062. private _glVendor;
  96063. /** @hidden */
  96064. _videoTextureSupported: boolean;
  96065. protected _renderingQueueLaunched: boolean;
  96066. protected _activeRenderLoops: (() => void)[];
  96067. /**
  96068. * Observable signaled when a context lost event is raised
  96069. */
  96070. onContextLostObservable: Observable<ThinEngine>;
  96071. /**
  96072. * Observable signaled when a context restored event is raised
  96073. */
  96074. onContextRestoredObservable: Observable<ThinEngine>;
  96075. private _onContextLost;
  96076. private _onContextRestored;
  96077. protected _contextWasLost: boolean;
  96078. /** @hidden */
  96079. _doNotHandleContextLost: boolean;
  96080. /**
  96081. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96083. */
  96084. doNotHandleContextLost: boolean;
  96085. /**
  96086. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96087. */
  96088. disableVertexArrayObjects: boolean;
  96089. /** @hidden */
  96090. protected _depthCullingState: DepthCullingState;
  96091. /** @hidden */
  96092. protected _stencilState: StencilState;
  96093. /** @hidden */
  96094. protected _alphaState: AlphaState;
  96095. /** @hidden */
  96096. _internalTexturesCache: InternalTexture[];
  96097. /** @hidden */
  96098. protected _activeChannel: number;
  96099. private _currentTextureChannel;
  96100. /** @hidden */
  96101. protected _boundTexturesCache: {
  96102. [key: string]: Nullable<InternalTexture>;
  96103. };
  96104. /** @hidden */
  96105. protected _currentEffect: Nullable<Effect>;
  96106. /** @hidden */
  96107. protected _currentProgram: Nullable<WebGLProgram>;
  96108. private _compiledEffects;
  96109. private _vertexAttribArraysEnabled;
  96110. /** @hidden */
  96111. protected _cachedViewport: Nullable<IViewportLike>;
  96112. private _cachedVertexArrayObject;
  96113. /** @hidden */
  96114. protected _cachedVertexBuffers: any;
  96115. /** @hidden */
  96116. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96117. /** @hidden */
  96118. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96119. /** @hidden */
  96120. _currentRenderTarget: Nullable<InternalTexture>;
  96121. private _uintIndicesCurrentlySet;
  96122. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96123. /** @hidden */
  96124. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96125. private _currentBufferPointers;
  96126. private _currentInstanceLocations;
  96127. private _currentInstanceBuffers;
  96128. private _textureUnits;
  96129. /** @hidden */
  96130. _workingCanvas: Nullable<HTMLCanvasElement>;
  96131. /** @hidden */
  96132. _workingContext: Nullable<CanvasRenderingContext2D>;
  96133. /** @hidden */
  96134. _bindedRenderFunction: any;
  96135. private _vaoRecordInProgress;
  96136. private _mustWipeVertexAttributes;
  96137. private _emptyTexture;
  96138. private _emptyCubeTexture;
  96139. private _emptyTexture3D;
  96140. /** @hidden */
  96141. _frameHandler: number;
  96142. private _nextFreeTextureSlots;
  96143. private _maxSimultaneousTextures;
  96144. private _activeRequests;
  96145. protected _texturesSupported: string[];
  96146. /** @hidden */
  96147. _textureFormatInUse: Nullable<string>;
  96148. protected readonly _supportsHardwareTextureRescaling: boolean;
  96149. /**
  96150. * Gets the list of texture formats supported
  96151. */
  96152. readonly texturesSupported: Array<string>;
  96153. /**
  96154. * Gets the list of texture formats in use
  96155. */
  96156. readonly textureFormatInUse: Nullable<string>;
  96157. /**
  96158. * Gets the current viewport
  96159. */
  96160. readonly currentViewport: Nullable<IViewportLike>;
  96161. /**
  96162. * Gets the default empty texture
  96163. */
  96164. readonly emptyTexture: InternalTexture;
  96165. /**
  96166. * Gets the default empty 3D texture
  96167. */
  96168. readonly emptyTexture3D: InternalTexture;
  96169. /**
  96170. * Gets the default empty cube texture
  96171. */
  96172. readonly emptyCubeTexture: InternalTexture;
  96173. /**
  96174. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96175. */
  96176. readonly premultipliedAlpha: boolean;
  96177. /**
  96178. * Creates a new engine
  96179. * @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
  96180. * @param antialias defines enable antialiasing (default: false)
  96181. * @param options defines further options to be sent to the getContext() function
  96182. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96183. */
  96184. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96185. private _rebuildInternalTextures;
  96186. private _rebuildEffects;
  96187. /**
  96188. * Gets a boolean indicating if all created effects are ready
  96189. * @returns true if all effects are ready
  96190. */
  96191. areAllEffectsReady(): boolean;
  96192. protected _rebuildBuffers(): void;
  96193. private _initGLContext;
  96194. /**
  96195. * Gets version of the current webGL context
  96196. */
  96197. readonly webGLVersion: number;
  96198. /**
  96199. * Gets a string idenfifying the name of the class
  96200. * @returns "Engine" string
  96201. */
  96202. getClassName(): string;
  96203. /**
  96204. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96205. */
  96206. readonly isStencilEnable: boolean;
  96207. /** @hidden */
  96208. _prepareWorkingCanvas(): void;
  96209. /**
  96210. * Reset the texture cache to empty state
  96211. */
  96212. resetTextureCache(): void;
  96213. /**
  96214. * Gets an object containing information about the current webGL context
  96215. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96216. */
  96217. getGlInfo(): {
  96218. vendor: string;
  96219. renderer: string;
  96220. version: string;
  96221. };
  96222. /**
  96223. * Defines the hardware scaling level.
  96224. * By default the hardware scaling level is computed from the window device ratio.
  96225. * 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.
  96226. * @param level defines the level to use
  96227. */
  96228. setHardwareScalingLevel(level: number): void;
  96229. /**
  96230. * Gets the current hardware scaling level.
  96231. * By default the hardware scaling level is computed from the window device ratio.
  96232. * 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.
  96233. * @returns a number indicating the current hardware scaling level
  96234. */
  96235. getHardwareScalingLevel(): number;
  96236. /**
  96237. * Gets the list of loaded textures
  96238. * @returns an array containing all loaded textures
  96239. */
  96240. getLoadedTexturesCache(): InternalTexture[];
  96241. /**
  96242. * Gets the object containing all engine capabilities
  96243. * @returns the EngineCapabilities object
  96244. */
  96245. getCaps(): EngineCapabilities;
  96246. /**
  96247. * stop executing a render loop function and remove it from the execution array
  96248. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96249. */
  96250. stopRenderLoop(renderFunction?: () => void): void;
  96251. /** @hidden */
  96252. _renderLoop(): void;
  96253. /**
  96254. * Gets the HTML canvas attached with the current webGL context
  96255. * @returns a HTML canvas
  96256. */
  96257. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96258. /**
  96259. * Gets host window
  96260. * @returns the host window object
  96261. */
  96262. getHostWindow(): Window;
  96263. /**
  96264. * Gets the current render width
  96265. * @param useScreen defines if screen size must be used (or the current render target if any)
  96266. * @returns a number defining the current render width
  96267. */
  96268. getRenderWidth(useScreen?: boolean): number;
  96269. /**
  96270. * Gets the current render height
  96271. * @param useScreen defines if screen size must be used (or the current render target if any)
  96272. * @returns a number defining the current render height
  96273. */
  96274. getRenderHeight(useScreen?: boolean): number;
  96275. /**
  96276. * Can be used to override the current requestAnimationFrame requester.
  96277. * @hidden
  96278. */
  96279. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96280. /**
  96281. * Register and execute a render loop. The engine can have more than one render function
  96282. * @param renderFunction defines the function to continuously execute
  96283. */
  96284. runRenderLoop(renderFunction: () => void): void;
  96285. /**
  96286. * Clear the current render buffer or the current render target (if any is set up)
  96287. * @param color defines the color to use
  96288. * @param backBuffer defines if the back buffer must be cleared
  96289. * @param depth defines if the depth buffer must be cleared
  96290. * @param stencil defines if the stencil buffer must be cleared
  96291. */
  96292. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96293. private _viewportCached;
  96294. /** @hidden */
  96295. _viewport(x: number, y: number, width: number, height: number): void;
  96296. /**
  96297. * Set the WebGL's viewport
  96298. * @param viewport defines the viewport element to be used
  96299. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96300. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96301. */
  96302. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96303. /**
  96304. * Begin a new frame
  96305. */
  96306. beginFrame(): void;
  96307. /**
  96308. * Enf the current frame
  96309. */
  96310. endFrame(): void;
  96311. /**
  96312. * Resize the view according to the canvas' size
  96313. */
  96314. resize(): void;
  96315. /**
  96316. * Force a specific size of the canvas
  96317. * @param width defines the new canvas' width
  96318. * @param height defines the new canvas' height
  96319. */
  96320. setSize(width: number, height: number): void;
  96321. /**
  96322. * Binds the frame buffer to the specified texture.
  96323. * @param texture The texture to render to or null for the default canvas
  96324. * @param faceIndex The face of the texture to render to in case of cube texture
  96325. * @param requiredWidth The width of the target to render to
  96326. * @param requiredHeight The height of the target to render to
  96327. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96328. * @param depthStencilTexture The depth stencil texture to use to render
  96329. * @param lodLevel defines le lod level to bind to the frame buffer
  96330. */
  96331. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96332. /** @hidden */
  96333. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96334. /**
  96335. * Unbind the current render target texture from the webGL context
  96336. * @param texture defines the render target texture to unbind
  96337. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96338. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96339. */
  96340. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96341. /**
  96342. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96343. */
  96344. flushFramebuffer(): void;
  96345. /**
  96346. * Unbind the current render target and bind the default framebuffer
  96347. */
  96348. restoreDefaultFramebuffer(): void;
  96349. private _resetVertexBufferBinding;
  96350. /**
  96351. * Creates a vertex buffer
  96352. * @param data the data for the vertex buffer
  96353. * @returns the new WebGL static buffer
  96354. */
  96355. createVertexBuffer(data: DataArray): DataBuffer;
  96356. private _createVertexBuffer;
  96357. /**
  96358. * Creates a dynamic vertex buffer
  96359. * @param data the data for the dynamic vertex buffer
  96360. * @returns the new WebGL dynamic buffer
  96361. */
  96362. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96363. /**
  96364. * Updates a dynamic vertex buffer.
  96365. * @param vertexBuffer the vertex buffer to update
  96366. * @param data the data used to update the vertex buffer
  96367. * @param byteOffset the byte offset of the data
  96368. * @param byteLength the byte length of the data
  96369. */
  96370. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96371. protected _resetIndexBufferBinding(): void;
  96372. /**
  96373. * Creates a new index buffer
  96374. * @param indices defines the content of the index buffer
  96375. * @param updatable defines if the index buffer must be updatable
  96376. * @returns a new webGL buffer
  96377. */
  96378. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96379. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96380. /**
  96381. * Bind a webGL buffer to the webGL context
  96382. * @param buffer defines the buffer to bind
  96383. */
  96384. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96385. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96386. private bindBuffer;
  96387. /**
  96388. * update the bound buffer with the given data
  96389. * @param data defines the data to update
  96390. */
  96391. updateArrayBuffer(data: Float32Array): void;
  96392. private _vertexAttribPointer;
  96393. private _bindIndexBufferWithCache;
  96394. private _bindVertexBuffersAttributes;
  96395. /**
  96396. * Records a vertex array object
  96397. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96398. * @param vertexBuffers defines the list of vertex buffers to store
  96399. * @param indexBuffer defines the index buffer to store
  96400. * @param effect defines the effect to store
  96401. * @returns the new vertex array object
  96402. */
  96403. recordVertexArrayObject(vertexBuffers: {
  96404. [key: string]: VertexBuffer;
  96405. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96406. /**
  96407. * Bind a specific vertex array object
  96408. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96409. * @param vertexArrayObject defines the vertex array object to bind
  96410. * @param indexBuffer defines the index buffer to bind
  96411. */
  96412. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96413. /**
  96414. * Bind webGl buffers directly to the webGL context
  96415. * @param vertexBuffer defines the vertex buffer to bind
  96416. * @param indexBuffer defines the index buffer to bind
  96417. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96418. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96419. * @param effect defines the effect associated with the vertex buffer
  96420. */
  96421. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96422. private _unbindVertexArrayObject;
  96423. /**
  96424. * Bind a list of vertex buffers to the webGL context
  96425. * @param vertexBuffers defines the list of vertex buffers to bind
  96426. * @param indexBuffer defines the index buffer to bind
  96427. * @param effect defines the effect associated with the vertex buffers
  96428. */
  96429. bindBuffers(vertexBuffers: {
  96430. [key: string]: Nullable<VertexBuffer>;
  96431. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96432. /**
  96433. * Unbind all instance attributes
  96434. */
  96435. unbindInstanceAttributes(): void;
  96436. /**
  96437. * Release and free the memory of a vertex array object
  96438. * @param vao defines the vertex array object to delete
  96439. */
  96440. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96441. /** @hidden */
  96442. _releaseBuffer(buffer: DataBuffer): boolean;
  96443. protected _deleteBuffer(buffer: DataBuffer): void;
  96444. /**
  96445. * Creates a webGL buffer to use with instanciation
  96446. * @param capacity defines the size of the buffer
  96447. * @returns the webGL buffer
  96448. */
  96449. createInstancesBuffer(capacity: number): DataBuffer;
  96450. /**
  96451. * Delete a webGL buffer used with instanciation
  96452. * @param buffer defines the webGL buffer to delete
  96453. */
  96454. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96455. /**
  96456. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96457. * @param instancesBuffer defines the webGL buffer to update and bind
  96458. * @param data defines the data to store in the buffer
  96459. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96460. */
  96461. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96462. /**
  96463. * Apply all cached states (depth, culling, stencil and alpha)
  96464. */
  96465. applyStates(): void;
  96466. /**
  96467. * Send a draw order
  96468. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96469. * @param indexStart defines the starting index
  96470. * @param indexCount defines the number of index to draw
  96471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96472. */
  96473. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96474. /**
  96475. * Draw a list of points
  96476. * @param verticesStart defines the index of first vertex to draw
  96477. * @param verticesCount defines the count of vertices to draw
  96478. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96479. */
  96480. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96481. /**
  96482. * Draw a list of unindexed primitives
  96483. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96484. * @param verticesStart defines the index of first vertex to draw
  96485. * @param verticesCount defines the count of vertices to draw
  96486. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96487. */
  96488. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96489. /**
  96490. * Draw a list of indexed primitives
  96491. * @param fillMode defines the primitive to use
  96492. * @param indexStart defines the starting index
  96493. * @param indexCount defines the number of index to draw
  96494. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96495. */
  96496. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96497. /**
  96498. * Draw a list of unindexed primitives
  96499. * @param fillMode defines the primitive to use
  96500. * @param verticesStart defines the index of first vertex to draw
  96501. * @param verticesCount defines the count of vertices to draw
  96502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96503. */
  96504. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96505. private _drawMode;
  96506. /** @hidden */
  96507. protected _reportDrawCall(): void;
  96508. /** @hidden */
  96509. _releaseEffect(effect: Effect): void;
  96510. /** @hidden */
  96511. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96512. /**
  96513. * Create a new effect (used to store vertex/fragment shaders)
  96514. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96515. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96516. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96517. * @param samplers defines an array of string used to represent textures
  96518. * @param defines defines the string containing the defines to use to compile the shaders
  96519. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96520. * @param onCompiled defines a function to call when the effect creation is successful
  96521. * @param onError defines a function to call when the effect creation has failed
  96522. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96523. * @returns the new Effect
  96524. */
  96525. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96526. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96527. private _compileShader;
  96528. private _compileRawShader;
  96529. /**
  96530. * Directly creates a webGL program
  96531. * @param pipelineContext defines the pipeline context to attach to
  96532. * @param vertexCode defines the vertex shader code to use
  96533. * @param fragmentCode defines the fragment shader code to use
  96534. * @param context defines the webGL context to use (if not set, the current one will be used)
  96535. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96536. * @returns the new webGL program
  96537. */
  96538. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96539. /**
  96540. * Creates a webGL program
  96541. * @param pipelineContext defines the pipeline context to attach to
  96542. * @param vertexCode defines the vertex shader code to use
  96543. * @param fragmentCode defines the fragment shader code to use
  96544. * @param defines defines the string containing the defines to use to compile the shaders
  96545. * @param context defines the webGL context to use (if not set, the current one will be used)
  96546. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96547. * @returns the new webGL program
  96548. */
  96549. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96550. /**
  96551. * Creates a new pipeline context
  96552. * @returns the new pipeline
  96553. */
  96554. createPipelineContext(): IPipelineContext;
  96555. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96556. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96557. /** @hidden */
  96558. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96559. /** @hidden */
  96560. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96561. /** @hidden */
  96562. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96563. /**
  96564. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96565. * @param pipelineContext defines the pipeline context to use
  96566. * @param uniformsNames defines the list of uniform names
  96567. * @returns an array of webGL uniform locations
  96568. */
  96569. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96570. /**
  96571. * Gets the lsit of active attributes for a given webGL program
  96572. * @param pipelineContext defines the pipeline context to use
  96573. * @param attributesNames defines the list of attribute names to get
  96574. * @returns an array of indices indicating the offset of each attribute
  96575. */
  96576. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96577. /**
  96578. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96579. * @param effect defines the effect to activate
  96580. */
  96581. enableEffect(effect: Nullable<Effect>): void;
  96582. /**
  96583. * Set the value of an uniform to an array of int32
  96584. * @param uniform defines the webGL uniform location where to store the value
  96585. * @param array defines the array of int32 to store
  96586. */
  96587. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96588. /**
  96589. * Set the value of an uniform to an array of int32 (stored as vec2)
  96590. * @param uniform defines the webGL uniform location where to store the value
  96591. * @param array defines the array of int32 to store
  96592. */
  96593. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96594. /**
  96595. * Set the value of an uniform to an array of int32 (stored as vec3)
  96596. * @param uniform defines the webGL uniform location where to store the value
  96597. * @param array defines the array of int32 to store
  96598. */
  96599. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96600. /**
  96601. * Set the value of an uniform to an array of int32 (stored as vec4)
  96602. * @param uniform defines the webGL uniform location where to store the value
  96603. * @param array defines the array of int32 to store
  96604. */
  96605. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96606. /**
  96607. * Set the value of an uniform to an array of float32
  96608. * @param uniform defines the webGL uniform location where to store the value
  96609. * @param array defines the array of float32 to store
  96610. */
  96611. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96612. /**
  96613. * Set the value of an uniform to an array of float32 (stored as vec2)
  96614. * @param uniform defines the webGL uniform location where to store the value
  96615. * @param array defines the array of float32 to store
  96616. */
  96617. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96618. /**
  96619. * Set the value of an uniform to an array of float32 (stored as vec3)
  96620. * @param uniform defines the webGL uniform location where to store the value
  96621. * @param array defines the array of float32 to store
  96622. */
  96623. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96624. /**
  96625. * Set the value of an uniform to an array of float32 (stored as vec4)
  96626. * @param uniform defines the webGL uniform location where to store the value
  96627. * @param array defines the array of float32 to store
  96628. */
  96629. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96630. /**
  96631. * Set the value of an uniform to an array of number
  96632. * @param uniform defines the webGL uniform location where to store the value
  96633. * @param array defines the array of number to store
  96634. */
  96635. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96636. /**
  96637. * Set the value of an uniform to an array of number (stored as vec2)
  96638. * @param uniform defines the webGL uniform location where to store the value
  96639. * @param array defines the array of number to store
  96640. */
  96641. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96642. /**
  96643. * Set the value of an uniform to an array of number (stored as vec3)
  96644. * @param uniform defines the webGL uniform location where to store the value
  96645. * @param array defines the array of number to store
  96646. */
  96647. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96648. /**
  96649. * Set the value of an uniform to an array of number (stored as vec4)
  96650. * @param uniform defines the webGL uniform location where to store the value
  96651. * @param array defines the array of number to store
  96652. */
  96653. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96654. /**
  96655. * Set the value of an uniform to an array of float32 (stored as matrices)
  96656. * @param uniform defines the webGL uniform location where to store the value
  96657. * @param matrices defines the array of float32 to store
  96658. */
  96659. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96660. /**
  96661. * Set the value of an uniform to a matrix (3x3)
  96662. * @param uniform defines the webGL uniform location where to store the value
  96663. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96664. */
  96665. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96666. /**
  96667. * Set the value of an uniform to a matrix (2x2)
  96668. * @param uniform defines the webGL uniform location where to store the value
  96669. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96670. */
  96671. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96672. /**
  96673. * Set the value of an uniform to a number (int)
  96674. * @param uniform defines the webGL uniform location where to store the value
  96675. * @param value defines the int number to store
  96676. */
  96677. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96678. /**
  96679. * Set the value of an uniform to a number (float)
  96680. * @param uniform defines the webGL uniform location where to store the value
  96681. * @param value defines the float number to store
  96682. */
  96683. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96684. /**
  96685. * Set the value of an uniform to a vec2
  96686. * @param uniform defines the webGL uniform location where to store the value
  96687. * @param x defines the 1st component of the value
  96688. * @param y defines the 2nd component of the value
  96689. */
  96690. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96691. /**
  96692. * Set the value of an uniform to a vec3
  96693. * @param uniform defines the webGL uniform location where to store the value
  96694. * @param x defines the 1st component of the value
  96695. * @param y defines the 2nd component of the value
  96696. * @param z defines the 3rd component of the value
  96697. */
  96698. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96699. /**
  96700. * Set the value of an uniform to a boolean
  96701. * @param uniform defines the webGL uniform location where to store the value
  96702. * @param bool defines the boolean to store
  96703. */
  96704. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96705. /**
  96706. * Set the value of an uniform to a vec4
  96707. * @param uniform defines the webGL uniform location where to store the value
  96708. * @param x defines the 1st component of the value
  96709. * @param y defines the 2nd component of the value
  96710. * @param z defines the 3rd component of the value
  96711. * @param w defines the 4th component of the value
  96712. */
  96713. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96714. /**
  96715. * Sets a Color4 on a uniform variable
  96716. * @param uniform defines the uniform location
  96717. * @param color4 defines the value to be set
  96718. */
  96719. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96720. /**
  96721. * Gets the depth culling state manager
  96722. */
  96723. readonly depthCullingState: DepthCullingState;
  96724. /**
  96725. * Gets the alpha state manager
  96726. */
  96727. readonly alphaState: AlphaState;
  96728. /**
  96729. * Gets the stencil state manager
  96730. */
  96731. readonly stencilState: StencilState;
  96732. /**
  96733. * Clears the list of texture accessible through engine.
  96734. * This can help preventing texture load conflict due to name collision.
  96735. */
  96736. clearInternalTexturesCache(): void;
  96737. /**
  96738. * Force the entire cache to be cleared
  96739. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96740. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96741. */
  96742. wipeCaches(bruteForce?: boolean): void;
  96743. /** @hidden */
  96744. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96745. min: number;
  96746. mag: number;
  96747. };
  96748. /** @hidden */
  96749. _createTexture(): WebGLTexture;
  96750. /**
  96751. * Usually called from Texture.ts.
  96752. * Passed information to create a WebGLTexture
  96753. * @param urlArg defines a value which contains one of the following:
  96754. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96755. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96756. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96758. * @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)
  96759. * @param scene needed for loading to the correct scene
  96760. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96761. * @param onLoad optional callback to be called upon successful completion
  96762. * @param onError optional callback to be called upon failure
  96763. * @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
  96764. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96765. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96766. * @param forcedExtension defines the extension to use to pick the right loader
  96767. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96768. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96769. */
  96770. 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;
  96771. /**
  96772. * @hidden
  96773. */
  96774. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96775. /**
  96776. * Creates a raw texture
  96777. * @param data defines the data to store in the texture
  96778. * @param width defines the width of the texture
  96779. * @param height defines the height of the texture
  96780. * @param format defines the format of the data
  96781. * @param generateMipMaps defines if the engine should generate the mip levels
  96782. * @param invertY defines if data must be stored with Y axis inverted
  96783. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96784. * @param compression defines the compression used (null by default)
  96785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96786. * @returns the raw texture inside an InternalTexture
  96787. */
  96788. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96789. /**
  96790. * Creates a new raw cube texture
  96791. * @param data defines the array of data to use to create each face
  96792. * @param size defines the size of the textures
  96793. * @param format defines the format of the data
  96794. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96795. * @param generateMipMaps defines if the engine should generate the mip levels
  96796. * @param invertY defines if data must be stored with Y axis inverted
  96797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96798. * @param compression defines the compression used (null by default)
  96799. * @returns the cube texture as an InternalTexture
  96800. */
  96801. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96802. /**
  96803. * Creates a new raw 3D texture
  96804. * @param data defines the data used to create the texture
  96805. * @param width defines the width of the texture
  96806. * @param height defines the height of the texture
  96807. * @param depth defines the depth of the texture
  96808. * @param format defines the format of the texture
  96809. * @param generateMipMaps defines if the engine must generate mip levels
  96810. * @param invertY defines if data must be stored with Y axis inverted
  96811. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96812. * @param compression defines the compressed used (can be null)
  96813. * @param textureType defines the compressed used (can be null)
  96814. * @returns a new raw 3D texture (stored in an InternalTexture)
  96815. */
  96816. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96817. private _unpackFlipYCached;
  96818. /**
  96819. * In case you are sharing the context with other applications, it might
  96820. * be interested to not cache the unpack flip y state to ensure a consistent
  96821. * value would be set.
  96822. */
  96823. enableUnpackFlipYCached: boolean;
  96824. /** @hidden */
  96825. _unpackFlipY(value: boolean): void;
  96826. /** @hidden */
  96827. _getUnpackAlignement(): number;
  96828. /**
  96829. * Update the sampling mode of a given texture
  96830. * @param samplingMode defines the required sampling mode
  96831. * @param texture defines the texture to update
  96832. */
  96833. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96834. /**
  96835. * Updates a depth texture Comparison Mode and Function.
  96836. * If the comparison Function is equal to 0, the mode will be set to none.
  96837. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96838. * @param texture The texture to set the comparison function for
  96839. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96840. */
  96841. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96842. /** @hidden */
  96843. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96844. width: number;
  96845. height: number;
  96846. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96847. /**
  96848. * Creates a depth stencil texture.
  96849. * This is only available in WebGL 2 or with the depth texture extension available.
  96850. * @param size The size of face edge in the texture.
  96851. * @param options The options defining the texture.
  96852. * @returns The texture
  96853. */
  96854. createDepthStencilTexture(size: number | {
  96855. width: number;
  96856. height: number;
  96857. }, options: DepthTextureCreationOptions): InternalTexture;
  96858. /**
  96859. * Creates a depth stencil texture.
  96860. * This is only available in WebGL 2 or with the depth texture extension available.
  96861. * @param size The size of face edge in the texture.
  96862. * @param options The options defining the texture.
  96863. * @returns The texture
  96864. */
  96865. private _createDepthStencilTexture;
  96866. /** @hidden */
  96867. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96868. /** @hidden */
  96869. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96870. /** @hidden */
  96871. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96872. /** @hidden */
  96873. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96874. /**
  96875. * @hidden
  96876. */
  96877. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96878. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96879. private _prepareWebGLTexture;
  96880. /** @hidden */
  96881. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96882. /** @hidden */
  96883. _releaseFramebufferObjects(texture: InternalTexture): void;
  96884. /** @hidden */
  96885. _releaseTexture(texture: InternalTexture): void;
  96886. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96887. protected _setProgram(program: WebGLProgram): void;
  96888. protected _boundUniforms: {
  96889. [key: number]: WebGLUniformLocation;
  96890. };
  96891. /**
  96892. * Binds an effect to the webGL context
  96893. * @param effect defines the effect to bind
  96894. */
  96895. bindSamplers(effect: Effect): void;
  96896. private _activateCurrentTexture;
  96897. /** @hidden */
  96898. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96899. /** @hidden */
  96900. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96901. /**
  96902. * Unbind all textures from the webGL context
  96903. */
  96904. unbindAllTextures(): void;
  96905. /**
  96906. * Sets a texture to the according uniform.
  96907. * @param channel The texture channel
  96908. * @param uniform The uniform to set
  96909. * @param texture The texture to apply
  96910. */
  96911. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96912. private _bindSamplerUniformToChannel;
  96913. private _getTextureWrapMode;
  96914. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96915. /**
  96916. * Sets an array of texture to the webGL context
  96917. * @param channel defines the channel where the texture array must be set
  96918. * @param uniform defines the associated uniform location
  96919. * @param textures defines the array of textures to bind
  96920. */
  96921. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96922. /** @hidden */
  96923. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96924. private _setTextureParameterFloat;
  96925. private _setTextureParameterInteger;
  96926. /**
  96927. * Unbind all vertex attributes from the webGL context
  96928. */
  96929. unbindAllAttributes(): void;
  96930. /**
  96931. * 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
  96932. */
  96933. releaseEffects(): void;
  96934. /**
  96935. * Dispose and release all associated resources
  96936. */
  96937. dispose(): void;
  96938. /**
  96939. * Attach a new callback raised when context lost event is fired
  96940. * @param callback defines the callback to call
  96941. */
  96942. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96943. /**
  96944. * Attach a new callback raised when context restored event is fired
  96945. * @param callback defines the callback to call
  96946. */
  96947. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96948. /**
  96949. * Get the current error code of the webGL context
  96950. * @returns the error code
  96951. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96952. */
  96953. getError(): number;
  96954. private _canRenderToFloatFramebuffer;
  96955. private _canRenderToHalfFloatFramebuffer;
  96956. private _canRenderToFramebuffer;
  96957. /** @hidden */
  96958. _getWebGLTextureType(type: number): number;
  96959. /** @hidden */
  96960. _getInternalFormat(format: number): number;
  96961. /** @hidden */
  96962. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96963. /** @hidden */
  96964. _getRGBAMultiSampleBufferFormat(type: number): number;
  96965. /** @hidden */
  96966. _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;
  96967. /**
  96968. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96969. * @returns true if the engine can be created
  96970. * @ignorenaming
  96971. */
  96972. static isSupported(): boolean;
  96973. /**
  96974. * Find the next highest power of two.
  96975. * @param x Number to start search from.
  96976. * @return Next highest power of two.
  96977. */
  96978. static CeilingPOT(x: number): number;
  96979. /**
  96980. * Find the next lowest power of two.
  96981. * @param x Number to start search from.
  96982. * @return Next lowest power of two.
  96983. */
  96984. static FloorPOT(x: number): number;
  96985. /**
  96986. * Find the nearest power of two.
  96987. * @param x Number to start search from.
  96988. * @return Next nearest power of two.
  96989. */
  96990. static NearestPOT(x: number): number;
  96991. /**
  96992. * Get the closest exponent of two
  96993. * @param value defines the value to approximate
  96994. * @param max defines the maximum value to return
  96995. * @param mode defines how to define the closest value
  96996. * @returns closest exponent of two of the given value
  96997. */
  96998. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96999. /**
  97000. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97001. * @param func - the function to be called
  97002. * @param requester - the object that will request the next frame. Falls back to window.
  97003. * @returns frame number
  97004. */
  97005. static QueueNewFrame(func: () => void, requester?: any): number;
  97006. }
  97007. }
  97008. declare module BABYLON {
  97009. /**
  97010. * Defines the source of the internal texture
  97011. */
  97012. export enum InternalTextureSource {
  97013. /**
  97014. * The source of the texture data is unknown
  97015. */
  97016. Unknown = 0,
  97017. /**
  97018. * Texture data comes from an URL
  97019. */
  97020. Url = 1,
  97021. /**
  97022. * Texture data is only used for temporary storage
  97023. */
  97024. Temp = 2,
  97025. /**
  97026. * Texture data comes from raw data (ArrayBuffer)
  97027. */
  97028. Raw = 3,
  97029. /**
  97030. * Texture content is dynamic (video or dynamic texture)
  97031. */
  97032. Dynamic = 4,
  97033. /**
  97034. * Texture content is generated by rendering to it
  97035. */
  97036. RenderTarget = 5,
  97037. /**
  97038. * Texture content is part of a multi render target process
  97039. */
  97040. MultiRenderTarget = 6,
  97041. /**
  97042. * Texture data comes from a cube data file
  97043. */
  97044. Cube = 7,
  97045. /**
  97046. * Texture data comes from a raw cube data
  97047. */
  97048. CubeRaw = 8,
  97049. /**
  97050. * Texture data come from a prefiltered cube data file
  97051. */
  97052. CubePrefiltered = 9,
  97053. /**
  97054. * Texture content is raw 3D data
  97055. */
  97056. Raw3D = 10,
  97057. /**
  97058. * Texture content is a depth texture
  97059. */
  97060. Depth = 11,
  97061. /**
  97062. * Texture data comes from a raw cube data encoded with RGBD
  97063. */
  97064. CubeRawRGBD = 12
  97065. }
  97066. /**
  97067. * Class used to store data associated with WebGL texture data for the engine
  97068. * This class should not be used directly
  97069. */
  97070. export class InternalTexture {
  97071. /** @hidden */
  97072. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97073. /**
  97074. * Defines if the texture is ready
  97075. */
  97076. isReady: boolean;
  97077. /**
  97078. * Defines if the texture is a cube texture
  97079. */
  97080. isCube: boolean;
  97081. /**
  97082. * Defines if the texture contains 3D data
  97083. */
  97084. is3D: boolean;
  97085. /**
  97086. * Defines if the texture contains multiview data
  97087. */
  97088. isMultiview: boolean;
  97089. /**
  97090. * Gets the URL used to load this texture
  97091. */
  97092. url: string;
  97093. /**
  97094. * Gets the sampling mode of the texture
  97095. */
  97096. samplingMode: number;
  97097. /**
  97098. * Gets a boolean indicating if the texture needs mipmaps generation
  97099. */
  97100. generateMipMaps: boolean;
  97101. /**
  97102. * Gets the number of samples used by the texture (WebGL2+ only)
  97103. */
  97104. samples: number;
  97105. /**
  97106. * Gets the type of the texture (int, float...)
  97107. */
  97108. type: number;
  97109. /**
  97110. * Gets the format of the texture (RGB, RGBA...)
  97111. */
  97112. format: number;
  97113. /**
  97114. * Observable called when the texture is loaded
  97115. */
  97116. onLoadedObservable: Observable<InternalTexture>;
  97117. /**
  97118. * Gets the width of the texture
  97119. */
  97120. width: number;
  97121. /**
  97122. * Gets the height of the texture
  97123. */
  97124. height: number;
  97125. /**
  97126. * Gets the depth of the texture
  97127. */
  97128. depth: number;
  97129. /**
  97130. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97131. */
  97132. baseWidth: number;
  97133. /**
  97134. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97135. */
  97136. baseHeight: number;
  97137. /**
  97138. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97139. */
  97140. baseDepth: number;
  97141. /**
  97142. * Gets a boolean indicating if the texture is inverted on Y axis
  97143. */
  97144. invertY: boolean;
  97145. /** @hidden */
  97146. _invertVScale: boolean;
  97147. /** @hidden */
  97148. _associatedChannel: number;
  97149. /** @hidden */
  97150. _source: InternalTextureSource;
  97151. /** @hidden */
  97152. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97153. /** @hidden */
  97154. _bufferView: Nullable<ArrayBufferView>;
  97155. /** @hidden */
  97156. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97157. /** @hidden */
  97158. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97159. /** @hidden */
  97160. _size: number;
  97161. /** @hidden */
  97162. _extension: string;
  97163. /** @hidden */
  97164. _files: Nullable<string[]>;
  97165. /** @hidden */
  97166. _workingCanvas: Nullable<HTMLCanvasElement>;
  97167. /** @hidden */
  97168. _workingContext: Nullable<CanvasRenderingContext2D>;
  97169. /** @hidden */
  97170. _framebuffer: Nullable<WebGLFramebuffer>;
  97171. /** @hidden */
  97172. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97173. /** @hidden */
  97174. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97175. /** @hidden */
  97176. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97177. /** @hidden */
  97178. _attachments: Nullable<number[]>;
  97179. /** @hidden */
  97180. _cachedCoordinatesMode: Nullable<number>;
  97181. /** @hidden */
  97182. _cachedWrapU: Nullable<number>;
  97183. /** @hidden */
  97184. _cachedWrapV: Nullable<number>;
  97185. /** @hidden */
  97186. _cachedWrapR: Nullable<number>;
  97187. /** @hidden */
  97188. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97189. /** @hidden */
  97190. _isDisabled: boolean;
  97191. /** @hidden */
  97192. _compression: Nullable<string>;
  97193. /** @hidden */
  97194. _generateStencilBuffer: boolean;
  97195. /** @hidden */
  97196. _generateDepthBuffer: boolean;
  97197. /** @hidden */
  97198. _comparisonFunction: number;
  97199. /** @hidden */
  97200. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97201. /** @hidden */
  97202. _lodGenerationScale: number;
  97203. /** @hidden */
  97204. _lodGenerationOffset: number;
  97205. /** @hidden */
  97206. _colorTextureArray: Nullable<WebGLTexture>;
  97207. /** @hidden */
  97208. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97209. /** @hidden */
  97210. _lodTextureHigh: Nullable<BaseTexture>;
  97211. /** @hidden */
  97212. _lodTextureMid: Nullable<BaseTexture>;
  97213. /** @hidden */
  97214. _lodTextureLow: Nullable<BaseTexture>;
  97215. /** @hidden */
  97216. _isRGBD: boolean;
  97217. /** @hidden */
  97218. _linearSpecularLOD: boolean;
  97219. /** @hidden */
  97220. _irradianceTexture: Nullable<BaseTexture>;
  97221. /** @hidden */
  97222. _webGLTexture: Nullable<WebGLTexture>;
  97223. /** @hidden */
  97224. _references: number;
  97225. private _engine;
  97226. /**
  97227. * Gets the Engine the texture belongs to.
  97228. * @returns The babylon engine
  97229. */
  97230. getEngine(): ThinEngine;
  97231. /**
  97232. * Gets the data source type of the texture
  97233. */
  97234. readonly source: InternalTextureSource;
  97235. /**
  97236. * Creates a new InternalTexture
  97237. * @param engine defines the engine to use
  97238. * @param source defines the type of data that will be used
  97239. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97240. */
  97241. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97242. /**
  97243. * Increments the number of references (ie. the number of Texture that point to it)
  97244. */
  97245. incrementReferences(): void;
  97246. /**
  97247. * Change the size of the texture (not the size of the content)
  97248. * @param width defines the new width
  97249. * @param height defines the new height
  97250. * @param depth defines the new depth (1 by default)
  97251. */
  97252. updateSize(width: int, height: int, depth?: int): void;
  97253. /** @hidden */
  97254. _rebuild(): void;
  97255. /** @hidden */
  97256. _swapAndDie(target: InternalTexture): void;
  97257. /**
  97258. * Dispose the current allocated resources
  97259. */
  97260. dispose(): void;
  97261. }
  97262. }
  97263. declare module BABYLON {
  97264. /**
  97265. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97267. */
  97268. export class Analyser {
  97269. /**
  97270. * Gets or sets the smoothing
  97271. * @ignorenaming
  97272. */
  97273. SMOOTHING: number;
  97274. /**
  97275. * Gets or sets the FFT table size
  97276. * @ignorenaming
  97277. */
  97278. FFT_SIZE: number;
  97279. /**
  97280. * Gets or sets the bar graph amplitude
  97281. * @ignorenaming
  97282. */
  97283. BARGRAPHAMPLITUDE: number;
  97284. /**
  97285. * Gets or sets the position of the debug canvas
  97286. * @ignorenaming
  97287. */
  97288. DEBUGCANVASPOS: {
  97289. x: number;
  97290. y: number;
  97291. };
  97292. /**
  97293. * Gets or sets the debug canvas size
  97294. * @ignorenaming
  97295. */
  97296. DEBUGCANVASSIZE: {
  97297. width: number;
  97298. height: number;
  97299. };
  97300. private _byteFreqs;
  97301. private _byteTime;
  97302. private _floatFreqs;
  97303. private _webAudioAnalyser;
  97304. private _debugCanvas;
  97305. private _debugCanvasContext;
  97306. private _scene;
  97307. private _registerFunc;
  97308. private _audioEngine;
  97309. /**
  97310. * Creates a new analyser
  97311. * @param scene defines hosting scene
  97312. */
  97313. constructor(scene: Scene);
  97314. /**
  97315. * Get the number of data values you will have to play with for the visualization
  97316. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97317. * @returns a number
  97318. */
  97319. getFrequencyBinCount(): number;
  97320. /**
  97321. * Gets the current frequency data as a byte array
  97322. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97323. * @returns a Uint8Array
  97324. */
  97325. getByteFrequencyData(): Uint8Array;
  97326. /**
  97327. * Gets the current waveform as a byte array
  97328. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97329. * @returns a Uint8Array
  97330. */
  97331. getByteTimeDomainData(): Uint8Array;
  97332. /**
  97333. * Gets the current frequency data as a float array
  97334. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97335. * @returns a Float32Array
  97336. */
  97337. getFloatFrequencyData(): Float32Array;
  97338. /**
  97339. * Renders the debug canvas
  97340. */
  97341. drawDebugCanvas(): void;
  97342. /**
  97343. * Stops rendering the debug canvas and removes it
  97344. */
  97345. stopDebugCanvas(): void;
  97346. /**
  97347. * Connects two audio nodes
  97348. * @param inputAudioNode defines first node to connect
  97349. * @param outputAudioNode defines second node to connect
  97350. */
  97351. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97352. /**
  97353. * Releases all associated resources
  97354. */
  97355. dispose(): void;
  97356. }
  97357. }
  97358. declare module BABYLON {
  97359. /**
  97360. * This represents an audio engine and it is responsible
  97361. * to play, synchronize and analyse sounds throughout the application.
  97362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97363. */
  97364. export interface IAudioEngine extends IDisposable {
  97365. /**
  97366. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97367. */
  97368. readonly canUseWebAudio: boolean;
  97369. /**
  97370. * Gets the current AudioContext if available.
  97371. */
  97372. readonly audioContext: Nullable<AudioContext>;
  97373. /**
  97374. * The master gain node defines the global audio volume of your audio engine.
  97375. */
  97376. readonly masterGain: GainNode;
  97377. /**
  97378. * Gets whether or not mp3 are supported by your browser.
  97379. */
  97380. readonly isMP3supported: boolean;
  97381. /**
  97382. * Gets whether or not ogg are supported by your browser.
  97383. */
  97384. readonly isOGGsupported: boolean;
  97385. /**
  97386. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97387. * @ignoreNaming
  97388. */
  97389. WarnedWebAudioUnsupported: boolean;
  97390. /**
  97391. * Defines if the audio engine relies on a custom unlocked button.
  97392. * In this case, the embedded button will not be displayed.
  97393. */
  97394. useCustomUnlockedButton: boolean;
  97395. /**
  97396. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97397. */
  97398. readonly unlocked: boolean;
  97399. /**
  97400. * Event raised when audio has been unlocked on the browser.
  97401. */
  97402. onAudioUnlockedObservable: Observable<AudioEngine>;
  97403. /**
  97404. * Event raised when audio has been locked on the browser.
  97405. */
  97406. onAudioLockedObservable: Observable<AudioEngine>;
  97407. /**
  97408. * Flags the audio engine in Locked state.
  97409. * This happens due to new browser policies preventing audio to autoplay.
  97410. */
  97411. lock(): void;
  97412. /**
  97413. * Unlocks the audio engine once a user action has been done on the dom.
  97414. * This is helpful to resume play once browser policies have been satisfied.
  97415. */
  97416. unlock(): void;
  97417. }
  97418. /**
  97419. * This represents the default audio engine used in babylon.
  97420. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97422. */
  97423. export class AudioEngine implements IAudioEngine {
  97424. private _audioContext;
  97425. private _audioContextInitialized;
  97426. private _muteButton;
  97427. private _hostElement;
  97428. /**
  97429. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97430. */
  97431. canUseWebAudio: boolean;
  97432. /**
  97433. * The master gain node defines the global audio volume of your audio engine.
  97434. */
  97435. masterGain: GainNode;
  97436. /**
  97437. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97438. * @ignoreNaming
  97439. */
  97440. WarnedWebAudioUnsupported: boolean;
  97441. /**
  97442. * Gets whether or not mp3 are supported by your browser.
  97443. */
  97444. isMP3supported: boolean;
  97445. /**
  97446. * Gets whether or not ogg are supported by your browser.
  97447. */
  97448. isOGGsupported: boolean;
  97449. /**
  97450. * Gets whether audio has been unlocked on the device.
  97451. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97452. * a user interaction has happened.
  97453. */
  97454. unlocked: boolean;
  97455. /**
  97456. * Defines if the audio engine relies on a custom unlocked button.
  97457. * In this case, the embedded button will not be displayed.
  97458. */
  97459. useCustomUnlockedButton: boolean;
  97460. /**
  97461. * Event raised when audio has been unlocked on the browser.
  97462. */
  97463. onAudioUnlockedObservable: Observable<AudioEngine>;
  97464. /**
  97465. * Event raised when audio has been locked on the browser.
  97466. */
  97467. onAudioLockedObservable: Observable<AudioEngine>;
  97468. /**
  97469. * Gets the current AudioContext if available.
  97470. */
  97471. readonly audioContext: Nullable<AudioContext>;
  97472. private _connectedAnalyser;
  97473. /**
  97474. * Instantiates a new audio engine.
  97475. *
  97476. * There should be only one per page as some browsers restrict the number
  97477. * of audio contexts you can create.
  97478. * @param hostElement defines the host element where to display the mute icon if necessary
  97479. */
  97480. constructor(hostElement?: Nullable<HTMLElement>);
  97481. /**
  97482. * Flags the audio engine in Locked state.
  97483. * This happens due to new browser policies preventing audio to autoplay.
  97484. */
  97485. lock(): void;
  97486. /**
  97487. * Unlocks the audio engine once a user action has been done on the dom.
  97488. * This is helpful to resume play once browser policies have been satisfied.
  97489. */
  97490. unlock(): void;
  97491. private _resumeAudioContext;
  97492. private _initializeAudioContext;
  97493. private _tryToRun;
  97494. private _triggerRunningState;
  97495. private _triggerSuspendedState;
  97496. private _displayMuteButton;
  97497. private _moveButtonToTopLeft;
  97498. private _onResize;
  97499. private _hideMuteButton;
  97500. /**
  97501. * Destroy and release the resources associated with the audio ccontext.
  97502. */
  97503. dispose(): void;
  97504. /**
  97505. * Gets the global volume sets on the master gain.
  97506. * @returns the global volume if set or -1 otherwise
  97507. */
  97508. getGlobalVolume(): number;
  97509. /**
  97510. * Sets the global volume of your experience (sets on the master gain).
  97511. * @param newVolume Defines the new global volume of the application
  97512. */
  97513. setGlobalVolume(newVolume: number): void;
  97514. /**
  97515. * Connect the audio engine to an audio analyser allowing some amazing
  97516. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97518. * @param analyser The analyser to connect to the engine
  97519. */
  97520. connectToAnalyser(analyser: Analyser): void;
  97521. }
  97522. }
  97523. declare module BABYLON {
  97524. /**
  97525. * Interface used to present a loading screen while loading a scene
  97526. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97527. */
  97528. export interface ILoadingScreen {
  97529. /**
  97530. * Function called to display the loading screen
  97531. */
  97532. displayLoadingUI: () => void;
  97533. /**
  97534. * Function called to hide the loading screen
  97535. */
  97536. hideLoadingUI: () => void;
  97537. /**
  97538. * Gets or sets the color to use for the background
  97539. */
  97540. loadingUIBackgroundColor: string;
  97541. /**
  97542. * Gets or sets the text to display while loading
  97543. */
  97544. loadingUIText: string;
  97545. }
  97546. /**
  97547. * Class used for the default loading screen
  97548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97549. */
  97550. export class DefaultLoadingScreen implements ILoadingScreen {
  97551. private _renderingCanvas;
  97552. private _loadingText;
  97553. private _loadingDivBackgroundColor;
  97554. private _loadingDiv;
  97555. private _loadingTextDiv;
  97556. /** Gets or sets the logo url to use for the default loading screen */
  97557. static DefaultLogoUrl: string;
  97558. /** Gets or sets the spinner url to use for the default loading screen */
  97559. static DefaultSpinnerUrl: string;
  97560. /**
  97561. * Creates a new default loading screen
  97562. * @param _renderingCanvas defines the canvas used to render the scene
  97563. * @param _loadingText defines the default text to display
  97564. * @param _loadingDivBackgroundColor defines the default background color
  97565. */
  97566. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97567. /**
  97568. * Function called to display the loading screen
  97569. */
  97570. displayLoadingUI(): void;
  97571. /**
  97572. * Function called to hide the loading screen
  97573. */
  97574. hideLoadingUI(): void;
  97575. /**
  97576. * Gets or sets the text to display while loading
  97577. */
  97578. loadingUIText: string;
  97579. /**
  97580. * Gets or sets the color to use for the background
  97581. */
  97582. loadingUIBackgroundColor: string;
  97583. private _resizeLoadingUI;
  97584. }
  97585. }
  97586. declare module BABYLON {
  97587. /**
  97588. * Interface for any object that can request an animation frame
  97589. */
  97590. export interface ICustomAnimationFrameRequester {
  97591. /**
  97592. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97593. */
  97594. renderFunction?: Function;
  97595. /**
  97596. * Called to request the next frame to render to
  97597. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97598. */
  97599. requestAnimationFrame: Function;
  97600. /**
  97601. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97602. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97603. */
  97604. requestID?: number;
  97605. }
  97606. }
  97607. declare module BABYLON {
  97608. /**
  97609. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97610. */
  97611. export class PerformanceMonitor {
  97612. private _enabled;
  97613. private _rollingFrameTime;
  97614. private _lastFrameTimeMs;
  97615. /**
  97616. * constructor
  97617. * @param frameSampleSize The number of samples required to saturate the sliding window
  97618. */
  97619. constructor(frameSampleSize?: number);
  97620. /**
  97621. * Samples current frame
  97622. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97623. */
  97624. sampleFrame(timeMs?: number): void;
  97625. /**
  97626. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97627. */
  97628. readonly averageFrameTime: number;
  97629. /**
  97630. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97631. */
  97632. readonly averageFrameTimeVariance: number;
  97633. /**
  97634. * Returns the frame time of the most recent frame
  97635. */
  97636. readonly instantaneousFrameTime: number;
  97637. /**
  97638. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97639. */
  97640. readonly averageFPS: number;
  97641. /**
  97642. * Returns the average framerate in frames per second using the most recent frame time
  97643. */
  97644. readonly instantaneousFPS: number;
  97645. /**
  97646. * Returns true if enough samples have been taken to completely fill the sliding window
  97647. */
  97648. readonly isSaturated: boolean;
  97649. /**
  97650. * Enables contributions to the sliding window sample set
  97651. */
  97652. enable(): void;
  97653. /**
  97654. * Disables contributions to the sliding window sample set
  97655. * Samples will not be interpolated over the disabled period
  97656. */
  97657. disable(): void;
  97658. /**
  97659. * Returns true if sampling is enabled
  97660. */
  97661. readonly isEnabled: boolean;
  97662. /**
  97663. * Resets performance monitor
  97664. */
  97665. reset(): void;
  97666. }
  97667. /**
  97668. * RollingAverage
  97669. *
  97670. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97671. */
  97672. export class RollingAverage {
  97673. /**
  97674. * Current average
  97675. */
  97676. average: number;
  97677. /**
  97678. * Current variance
  97679. */
  97680. variance: number;
  97681. protected _samples: Array<number>;
  97682. protected _sampleCount: number;
  97683. protected _pos: number;
  97684. protected _m2: number;
  97685. /**
  97686. * constructor
  97687. * @param length The number of samples required to saturate the sliding window
  97688. */
  97689. constructor(length: number);
  97690. /**
  97691. * Adds a sample to the sample set
  97692. * @param v The sample value
  97693. */
  97694. add(v: number): void;
  97695. /**
  97696. * Returns previously added values or null if outside of history or outside the sliding window domain
  97697. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97698. * @return Value previously recorded with add() or null if outside of range
  97699. */
  97700. history(i: number): number;
  97701. /**
  97702. * Returns true if enough samples have been taken to completely fill the sliding window
  97703. * @return true if sample-set saturated
  97704. */
  97705. isSaturated(): boolean;
  97706. /**
  97707. * Resets the rolling average (equivalent to 0 samples taken so far)
  97708. */
  97709. reset(): void;
  97710. /**
  97711. * Wraps a value around the sample range boundaries
  97712. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97713. * @return Wrapped position in sample range
  97714. */
  97715. protected _wrapPosition(i: number): number;
  97716. }
  97717. }
  97718. declare module BABYLON {
  97719. /**
  97720. * This class is used to track a performance counter which is number based.
  97721. * The user has access to many properties which give statistics of different nature.
  97722. *
  97723. * The implementer can track two kinds of Performance Counter: time and count.
  97724. * 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.
  97725. * 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.
  97726. */
  97727. export class PerfCounter {
  97728. /**
  97729. * Gets or sets a global boolean to turn on and off all the counters
  97730. */
  97731. static Enabled: boolean;
  97732. /**
  97733. * Returns the smallest value ever
  97734. */
  97735. readonly min: number;
  97736. /**
  97737. * Returns the biggest value ever
  97738. */
  97739. readonly max: number;
  97740. /**
  97741. * Returns the average value since the performance counter is running
  97742. */
  97743. readonly average: number;
  97744. /**
  97745. * Returns the average value of the last second the counter was monitored
  97746. */
  97747. readonly lastSecAverage: number;
  97748. /**
  97749. * Returns the current value
  97750. */
  97751. readonly current: number;
  97752. /**
  97753. * Gets the accumulated total
  97754. */
  97755. readonly total: number;
  97756. /**
  97757. * Gets the total value count
  97758. */
  97759. readonly count: number;
  97760. /**
  97761. * Creates a new counter
  97762. */
  97763. constructor();
  97764. /**
  97765. * Call this method to start monitoring a new frame.
  97766. * 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.
  97767. */
  97768. fetchNewFrame(): void;
  97769. /**
  97770. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  97771. * @param newCount the count value to add to the monitored count
  97772. * @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.
  97773. */
  97774. addCount(newCount: number, fetchResult: boolean): void;
  97775. /**
  97776. * Start monitoring this performance counter
  97777. */
  97778. beginMonitoring(): void;
  97779. /**
  97780. * Compute the time lapsed since the previous beginMonitoring() call.
  97781. * @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
  97782. */
  97783. endMonitoring(newFrame?: boolean): void;
  97784. private _fetchResult;
  97785. private _startMonitoringTime;
  97786. private _min;
  97787. private _max;
  97788. private _average;
  97789. private _current;
  97790. private _totalValueCount;
  97791. private _totalAccumulated;
  97792. private _lastSecAverage;
  97793. private _lastSecAccumulated;
  97794. private _lastSecTime;
  97795. private _lastSecValueCount;
  97796. }
  97797. }
  97798. declare module BABYLON {
  97799. /**
  97800. * Defines the interface used by display changed events
  97801. */
  97802. export interface IDisplayChangedEventArgs {
  97803. /** Gets the vrDisplay object (if any) */
  97804. vrDisplay: Nullable<any>;
  97805. /** Gets a boolean indicating if webVR is supported */
  97806. vrSupported: boolean;
  97807. }
  97808. /**
  97809. * Defines the interface used by objects containing a viewport (like a camera)
  97810. */
  97811. interface IViewportOwnerLike {
  97812. /**
  97813. * Gets or sets the viewport
  97814. */
  97815. viewport: IViewportLike;
  97816. }
  97817. /**
  97818. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97819. */
  97820. export class Engine extends ThinEngine {
  97821. /** Defines that alpha blending is disabled */
  97822. static readonly ALPHA_DISABLE: number;
  97823. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97824. static readonly ALPHA_ADD: number;
  97825. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97826. static readonly ALPHA_COMBINE: number;
  97827. /** Defines that alpha blending to DEST - SRC * DEST */
  97828. static readonly ALPHA_SUBTRACT: number;
  97829. /** Defines that alpha blending to SRC * DEST */
  97830. static readonly ALPHA_MULTIPLY: number;
  97831. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97832. static readonly ALPHA_MAXIMIZED: number;
  97833. /** Defines that alpha blending to SRC + DEST */
  97834. static readonly ALPHA_ONEONE: number;
  97835. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97836. static readonly ALPHA_PREMULTIPLIED: number;
  97837. /**
  97838. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97839. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97840. */
  97841. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97842. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97843. static readonly ALPHA_INTERPOLATE: number;
  97844. /**
  97845. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97846. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97847. */
  97848. static readonly ALPHA_SCREENMODE: number;
  97849. /** Defines that the ressource is not delayed*/
  97850. static readonly DELAYLOADSTATE_NONE: number;
  97851. /** Defines that the ressource was successfully delay loaded */
  97852. static readonly DELAYLOADSTATE_LOADED: number;
  97853. /** Defines that the ressource is currently delay loading */
  97854. static readonly DELAYLOADSTATE_LOADING: number;
  97855. /** Defines that the ressource is delayed and has not started loading */
  97856. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97857. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97858. static readonly NEVER: number;
  97859. /** 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 */
  97860. static readonly ALWAYS: number;
  97861. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97862. static readonly LESS: number;
  97863. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97864. static readonly EQUAL: number;
  97865. /** 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 */
  97866. static readonly LEQUAL: number;
  97867. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97868. static readonly GREATER: number;
  97869. /** 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 */
  97870. static readonly GEQUAL: number;
  97871. /** 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 */
  97872. static readonly NOTEQUAL: number;
  97873. /** Passed to stencilOperation to specify that stencil value must be kept */
  97874. static readonly KEEP: number;
  97875. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97876. static readonly REPLACE: number;
  97877. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97878. static readonly INCR: number;
  97879. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97880. static readonly DECR: number;
  97881. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97882. static readonly INVERT: number;
  97883. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97884. static readonly INCR_WRAP: number;
  97885. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97886. static readonly DECR_WRAP: number;
  97887. /** Texture is not repeating outside of 0..1 UVs */
  97888. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97889. /** Texture is repeating outside of 0..1 UVs */
  97890. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97891. /** Texture is repeating and mirrored */
  97892. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97893. /** ALPHA */
  97894. static readonly TEXTUREFORMAT_ALPHA: number;
  97895. /** LUMINANCE */
  97896. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97897. /** LUMINANCE_ALPHA */
  97898. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97899. /** RGB */
  97900. static readonly TEXTUREFORMAT_RGB: number;
  97901. /** RGBA */
  97902. static readonly TEXTUREFORMAT_RGBA: number;
  97903. /** RED */
  97904. static readonly TEXTUREFORMAT_RED: number;
  97905. /** RED (2nd reference) */
  97906. static readonly TEXTUREFORMAT_R: number;
  97907. /** RG */
  97908. static readonly TEXTUREFORMAT_RG: number;
  97909. /** RED_INTEGER */
  97910. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97911. /** RED_INTEGER (2nd reference) */
  97912. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97913. /** RG_INTEGER */
  97914. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97915. /** RGB_INTEGER */
  97916. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97917. /** RGBA_INTEGER */
  97918. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97919. /** UNSIGNED_BYTE */
  97920. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97921. /** UNSIGNED_BYTE (2nd reference) */
  97922. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97923. /** FLOAT */
  97924. static readonly TEXTURETYPE_FLOAT: number;
  97925. /** HALF_FLOAT */
  97926. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97927. /** BYTE */
  97928. static readonly TEXTURETYPE_BYTE: number;
  97929. /** SHORT */
  97930. static readonly TEXTURETYPE_SHORT: number;
  97931. /** UNSIGNED_SHORT */
  97932. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97933. /** INT */
  97934. static readonly TEXTURETYPE_INT: number;
  97935. /** UNSIGNED_INT */
  97936. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97937. /** UNSIGNED_SHORT_4_4_4_4 */
  97938. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97939. /** UNSIGNED_SHORT_5_5_5_1 */
  97940. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97941. /** UNSIGNED_SHORT_5_6_5 */
  97942. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97943. /** UNSIGNED_INT_2_10_10_10_REV */
  97944. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97945. /** UNSIGNED_INT_24_8 */
  97946. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97947. /** UNSIGNED_INT_10F_11F_11F_REV */
  97948. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97949. /** UNSIGNED_INT_5_9_9_9_REV */
  97950. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97951. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97952. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97953. /** nearest is mag = nearest and min = nearest and mip = linear */
  97954. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97955. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97956. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97957. /** Trilinear is mag = linear and min = linear and mip = linear */
  97958. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97959. /** nearest is mag = nearest and min = nearest and mip = linear */
  97960. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97961. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97962. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97963. /** Trilinear is mag = linear and min = linear and mip = linear */
  97964. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97965. /** mag = nearest and min = nearest and mip = nearest */
  97966. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97967. /** mag = nearest and min = linear and mip = nearest */
  97968. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97969. /** mag = nearest and min = linear and mip = linear */
  97970. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97971. /** mag = nearest and min = linear and mip = none */
  97972. static readonly TEXTURE_NEAREST_LINEAR: number;
  97973. /** mag = nearest and min = nearest and mip = none */
  97974. static readonly TEXTURE_NEAREST_NEAREST: number;
  97975. /** mag = linear and min = nearest and mip = nearest */
  97976. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97977. /** mag = linear and min = nearest and mip = linear */
  97978. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97979. /** mag = linear and min = linear and mip = none */
  97980. static readonly TEXTURE_LINEAR_LINEAR: number;
  97981. /** mag = linear and min = nearest and mip = none */
  97982. static readonly TEXTURE_LINEAR_NEAREST: number;
  97983. /** Explicit coordinates mode */
  97984. static readonly TEXTURE_EXPLICIT_MODE: number;
  97985. /** Spherical coordinates mode */
  97986. static readonly TEXTURE_SPHERICAL_MODE: number;
  97987. /** Planar coordinates mode */
  97988. static readonly TEXTURE_PLANAR_MODE: number;
  97989. /** Cubic coordinates mode */
  97990. static readonly TEXTURE_CUBIC_MODE: number;
  97991. /** Projection coordinates mode */
  97992. static readonly TEXTURE_PROJECTION_MODE: number;
  97993. /** Skybox coordinates mode */
  97994. static readonly TEXTURE_SKYBOX_MODE: number;
  97995. /** Inverse Cubic coordinates mode */
  97996. static readonly TEXTURE_INVCUBIC_MODE: number;
  97997. /** Equirectangular coordinates mode */
  97998. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97999. /** Equirectangular Fixed coordinates mode */
  98000. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98001. /** Equirectangular Fixed Mirrored coordinates mode */
  98002. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98003. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98004. static readonly SCALEMODE_FLOOR: number;
  98005. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98006. static readonly SCALEMODE_NEAREST: number;
  98007. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98008. static readonly SCALEMODE_CEILING: number;
  98009. /**
  98010. * Returns the current npm package of the sdk
  98011. */
  98012. static readonly NpmPackage: string;
  98013. /**
  98014. * Returns the current version of the framework
  98015. */
  98016. static readonly Version: string;
  98017. /** Gets the list of created engines */
  98018. static readonly Instances: Engine[];
  98019. /**
  98020. * Gets the latest created engine
  98021. */
  98022. static readonly LastCreatedEngine: Nullable<Engine>;
  98023. /**
  98024. * Gets the latest created scene
  98025. */
  98026. static readonly LastCreatedScene: Nullable<Scene>;
  98027. /**
  98028. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98029. * @param flag defines which part of the materials must be marked as dirty
  98030. * @param predicate defines a predicate used to filter which materials should be affected
  98031. */
  98032. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98033. /**
  98034. * Method called to create the default loading screen.
  98035. * This can be overriden in your own app.
  98036. * @param canvas The rendering canvas element
  98037. * @returns The loading screen
  98038. */
  98039. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98040. /**
  98041. * Method called to create the default rescale post process on each engine.
  98042. */
  98043. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98044. /**
  98045. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98046. **/
  98047. enableOfflineSupport: boolean;
  98048. /**
  98049. * 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)
  98050. **/
  98051. disableManifestCheck: boolean;
  98052. /**
  98053. * Gets the list of created scenes
  98054. */
  98055. scenes: Scene[];
  98056. /**
  98057. * Event raised when a new scene is created
  98058. */
  98059. onNewSceneAddedObservable: Observable<Scene>;
  98060. /**
  98061. * Gets the list of created postprocesses
  98062. */
  98063. postProcesses: PostProcess[];
  98064. /**
  98065. * Gets a boolean indicating if the pointer is currently locked
  98066. */
  98067. isPointerLock: boolean;
  98068. /**
  98069. * Observable event triggered each time the rendering canvas is resized
  98070. */
  98071. onResizeObservable: Observable<Engine>;
  98072. /**
  98073. * Observable event triggered each time the canvas loses focus
  98074. */
  98075. onCanvasBlurObservable: Observable<Engine>;
  98076. /**
  98077. * Observable event triggered each time the canvas gains focus
  98078. */
  98079. onCanvasFocusObservable: Observable<Engine>;
  98080. /**
  98081. * Observable event triggered each time the canvas receives pointerout event
  98082. */
  98083. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98084. /**
  98085. * Observable event triggered before each texture is initialized
  98086. */
  98087. onBeforeTextureInitObservable: Observable<Texture>;
  98088. /**
  98089. * Observable raised when the engine begins a new frame
  98090. */
  98091. onBeginFrameObservable: Observable<Engine>;
  98092. /**
  98093. * If set, will be used to request the next animation frame for the render loop
  98094. */
  98095. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98096. /**
  98097. * Observable raised when the engine ends the current frame
  98098. */
  98099. onEndFrameObservable: Observable<Engine>;
  98100. /**
  98101. * Observable raised when the engine is about to compile a shader
  98102. */
  98103. onBeforeShaderCompilationObservable: Observable<Engine>;
  98104. /**
  98105. * Observable raised when the engine has jsut compiled a shader
  98106. */
  98107. onAfterShaderCompilationObservable: Observable<Engine>;
  98108. /**
  98109. * Gets the audio engine
  98110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98111. * @ignorenaming
  98112. */
  98113. static audioEngine: IAudioEngine;
  98114. /**
  98115. * Default AudioEngine factory responsible of creating the Audio Engine.
  98116. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98117. */
  98118. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98119. /**
  98120. * Default offline support factory responsible of creating a tool used to store data locally.
  98121. * By default, this will create a Database object if the workload has been embedded.
  98122. */
  98123. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98124. private _loadingScreen;
  98125. private _pointerLockRequested;
  98126. private _dummyFramebuffer;
  98127. private _rescalePostProcess;
  98128. /** @hidden */
  98129. protected _alphaMode: number;
  98130. /** @hidden */
  98131. protected _alphaEquation: number;
  98132. private _deterministicLockstep;
  98133. private _lockstepMaxSteps;
  98134. protected readonly _supportsHardwareTextureRescaling: boolean;
  98135. private _fps;
  98136. private _deltaTime;
  98137. /** @hidden */
  98138. _drawCalls: PerfCounter;
  98139. /**
  98140. * Turn this value on if you want to pause FPS computation when in background
  98141. */
  98142. disablePerformanceMonitorInBackground: boolean;
  98143. private _performanceMonitor;
  98144. /**
  98145. * Gets the performance monitor attached to this engine
  98146. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98147. */
  98148. readonly performanceMonitor: PerformanceMonitor;
  98149. private _onFocus;
  98150. private _onBlur;
  98151. private _onCanvasPointerOut;
  98152. private _onCanvasBlur;
  98153. private _onCanvasFocus;
  98154. private _onFullscreenChange;
  98155. private _onPointerLockChange;
  98156. /**
  98157. * Creates a new engine
  98158. * @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
  98159. * @param antialias defines enable antialiasing (default: false)
  98160. * @param options defines further options to be sent to the getContext() function
  98161. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98162. */
  98163. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98164. /**
  98165. * Gets current aspect ratio
  98166. * @param viewportOwner defines the camera to use to get the aspect ratio
  98167. * @param useScreen defines if screen size must be used (or the current render target if any)
  98168. * @returns a number defining the aspect ratio
  98169. */
  98170. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98171. /**
  98172. * Gets current screen aspect ratio
  98173. * @returns a number defining the aspect ratio
  98174. */
  98175. getScreenAspectRatio(): number;
  98176. /**
  98177. * Gets host document
  98178. * @returns the host document object
  98179. */
  98180. getHostDocument(): Document;
  98181. /**
  98182. * Gets the client rect of the HTML canvas attached with the current webGL context
  98183. * @returns a client rectanglee
  98184. */
  98185. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98186. /**
  98187. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98189. * @returns true if engine is in deterministic lock step mode
  98190. */
  98191. isDeterministicLockStep(): boolean;
  98192. /**
  98193. * Gets the max steps when engine is running in deterministic lock step
  98194. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98195. * @returns the max steps
  98196. */
  98197. getLockstepMaxSteps(): number;
  98198. /**
  98199. * Force the mipmap generation for the given render target texture
  98200. * @param texture defines the render target texture to use
  98201. */
  98202. generateMipMapsForCubemap(texture: InternalTexture): void;
  98203. /** States */
  98204. /**
  98205. * Set various states to the webGL context
  98206. * @param culling defines backface culling state
  98207. * @param zOffset defines the value to apply to zOffset (0 by default)
  98208. * @param force defines if states must be applied even if cache is up to date
  98209. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98210. */
  98211. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98212. /**
  98213. * Set the z offset to apply to current rendering
  98214. * @param value defines the offset to apply
  98215. */
  98216. setZOffset(value: number): void;
  98217. /**
  98218. * Gets the current value of the zOffset
  98219. * @returns the current zOffset state
  98220. */
  98221. getZOffset(): number;
  98222. /**
  98223. * Enable or disable depth buffering
  98224. * @param enable defines the state to set
  98225. */
  98226. setDepthBuffer(enable: boolean): void;
  98227. /**
  98228. * Gets a boolean indicating if depth writing is enabled
  98229. * @returns the current depth writing state
  98230. */
  98231. getDepthWrite(): boolean;
  98232. /**
  98233. * Enable or disable depth writing
  98234. * @param enable defines the state to set
  98235. */
  98236. setDepthWrite(enable: boolean): void;
  98237. /**
  98238. * Enable or disable color writing
  98239. * @param enable defines the state to set
  98240. */
  98241. setColorWrite(enable: boolean): void;
  98242. /**
  98243. * Gets a boolean indicating if color writing is enabled
  98244. * @returns the current color writing state
  98245. */
  98246. getColorWrite(): boolean;
  98247. /**
  98248. * Sets alpha constants used by some alpha blending modes
  98249. * @param r defines the red component
  98250. * @param g defines the green component
  98251. * @param b defines the blue component
  98252. * @param a defines the alpha component
  98253. */
  98254. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98255. /**
  98256. * Sets the current alpha mode
  98257. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98258. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98259. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98260. */
  98261. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98262. /**
  98263. * Gets the current alpha mode
  98264. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98265. * @returns the current alpha mode
  98266. */
  98267. getAlphaMode(): number;
  98268. /**
  98269. * Sets the current alpha equation
  98270. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98271. */
  98272. setAlphaEquation(equation: number): void;
  98273. /**
  98274. * Gets the current alpha equation.
  98275. * @returns the current alpha equation
  98276. */
  98277. getAlphaEquation(): number;
  98278. /**
  98279. * Gets a boolean indicating if stencil buffer is enabled
  98280. * @returns the current stencil buffer state
  98281. */
  98282. getStencilBuffer(): boolean;
  98283. /**
  98284. * Enable or disable the stencil buffer
  98285. * @param enable defines if the stencil buffer must be enabled or disabled
  98286. */
  98287. setStencilBuffer(enable: boolean): void;
  98288. /**
  98289. * Gets the current stencil mask
  98290. * @returns a number defining the new stencil mask to use
  98291. */
  98292. getStencilMask(): number;
  98293. /**
  98294. * Sets the current stencil mask
  98295. * @param mask defines the new stencil mask to use
  98296. */
  98297. setStencilMask(mask: number): void;
  98298. /**
  98299. * Gets the current stencil function
  98300. * @returns a number defining the stencil function to use
  98301. */
  98302. getStencilFunction(): number;
  98303. /**
  98304. * Gets the current stencil reference value
  98305. * @returns a number defining the stencil reference value to use
  98306. */
  98307. getStencilFunctionReference(): number;
  98308. /**
  98309. * Gets the current stencil mask
  98310. * @returns a number defining the stencil mask to use
  98311. */
  98312. getStencilFunctionMask(): number;
  98313. /**
  98314. * Sets the current stencil function
  98315. * @param stencilFunc defines the new stencil function to use
  98316. */
  98317. setStencilFunction(stencilFunc: number): void;
  98318. /**
  98319. * Sets the current stencil reference
  98320. * @param reference defines the new stencil reference to use
  98321. */
  98322. setStencilFunctionReference(reference: number): void;
  98323. /**
  98324. * Sets the current stencil mask
  98325. * @param mask defines the new stencil mask to use
  98326. */
  98327. setStencilFunctionMask(mask: number): void;
  98328. /**
  98329. * Gets the current stencil operation when stencil fails
  98330. * @returns a number defining stencil operation to use when stencil fails
  98331. */
  98332. getStencilOperationFail(): number;
  98333. /**
  98334. * Gets the current stencil operation when depth fails
  98335. * @returns a number defining stencil operation to use when depth fails
  98336. */
  98337. getStencilOperationDepthFail(): number;
  98338. /**
  98339. * Gets the current stencil operation when stencil passes
  98340. * @returns a number defining stencil operation to use when stencil passes
  98341. */
  98342. getStencilOperationPass(): number;
  98343. /**
  98344. * Sets the stencil operation to use when stencil fails
  98345. * @param operation defines the stencil operation to use when stencil fails
  98346. */
  98347. setStencilOperationFail(operation: number): void;
  98348. /**
  98349. * Sets the stencil operation to use when depth fails
  98350. * @param operation defines the stencil operation to use when depth fails
  98351. */
  98352. setStencilOperationDepthFail(operation: number): void;
  98353. /**
  98354. * Sets the stencil operation to use when stencil passes
  98355. * @param operation defines the stencil operation to use when stencil passes
  98356. */
  98357. setStencilOperationPass(operation: number): void;
  98358. /**
  98359. * Sets a boolean indicating if the dithering state is enabled or disabled
  98360. * @param value defines the dithering state
  98361. */
  98362. setDitheringState(value: boolean): void;
  98363. /**
  98364. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98365. * @param value defines the rasterizer state
  98366. */
  98367. setRasterizerState(value: boolean): void;
  98368. /**
  98369. * Gets the current depth function
  98370. * @returns a number defining the depth function
  98371. */
  98372. getDepthFunction(): Nullable<number>;
  98373. /**
  98374. * Sets the current depth function
  98375. * @param depthFunc defines the function to use
  98376. */
  98377. setDepthFunction(depthFunc: number): void;
  98378. /**
  98379. * Sets the current depth function to GREATER
  98380. */
  98381. setDepthFunctionToGreater(): void;
  98382. /**
  98383. * Sets the current depth function to GEQUAL
  98384. */
  98385. setDepthFunctionToGreaterOrEqual(): void;
  98386. /**
  98387. * Sets the current depth function to LESS
  98388. */
  98389. setDepthFunctionToLess(): void;
  98390. /**
  98391. * Sets the current depth function to LEQUAL
  98392. */
  98393. setDepthFunctionToLessOrEqual(): void;
  98394. private _cachedStencilBuffer;
  98395. private _cachedStencilFunction;
  98396. private _cachedStencilMask;
  98397. private _cachedStencilOperationPass;
  98398. private _cachedStencilOperationFail;
  98399. private _cachedStencilOperationDepthFail;
  98400. private _cachedStencilReference;
  98401. /**
  98402. * Caches the the state of the stencil buffer
  98403. */
  98404. cacheStencilState(): void;
  98405. /**
  98406. * Restores the state of the stencil buffer
  98407. */
  98408. restoreStencilState(): void;
  98409. /**
  98410. * Directly set the WebGL Viewport
  98411. * @param x defines the x coordinate of the viewport (in screen space)
  98412. * @param y defines the y coordinate of the viewport (in screen space)
  98413. * @param width defines the width of the viewport (in screen space)
  98414. * @param height defines the height of the viewport (in screen space)
  98415. * @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
  98416. */
  98417. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98418. /**
  98419. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98420. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98421. * @param y defines the y-coordinate of the corner of the clear rectangle
  98422. * @param width defines the width of the clear rectangle
  98423. * @param height defines the height of the clear rectangle
  98424. * @param clearColor defines the clear color
  98425. */
  98426. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98427. /**
  98428. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98429. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98430. * @param y defines the y-coordinate of the corner of the clear rectangle
  98431. * @param width defines the width of the clear rectangle
  98432. * @param height defines the height of the clear rectangle
  98433. */
  98434. enableScissor(x: number, y: number, width: number, height: number): void;
  98435. /**
  98436. * Disable previously set scissor test rectangle
  98437. */
  98438. disableScissor(): void;
  98439. protected _reportDrawCall(): void;
  98440. /**
  98441. * Initializes a webVR display and starts listening to display change events
  98442. * The onVRDisplayChangedObservable will be notified upon these changes
  98443. * @returns The onVRDisplayChangedObservable
  98444. */
  98445. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98446. /** @hidden */
  98447. _prepareVRComponent(): void;
  98448. /** @hidden */
  98449. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98450. /** @hidden */
  98451. _submitVRFrame(): void;
  98452. /**
  98453. * Call this function to leave webVR mode
  98454. * Will do nothing if webVR is not supported or if there is no webVR device
  98455. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98456. */
  98457. disableVR(): void;
  98458. /**
  98459. * Gets a boolean indicating that the system is in VR mode and is presenting
  98460. * @returns true if VR mode is engaged
  98461. */
  98462. isVRPresenting(): boolean;
  98463. /** @hidden */
  98464. _requestVRFrame(): void;
  98465. /** @hidden */
  98466. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98467. /**
  98468. * Gets the source code of the vertex shader associated with a specific webGL program
  98469. * @param program defines the program to use
  98470. * @returns a string containing the source code of the vertex shader associated with the program
  98471. */
  98472. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98473. /**
  98474. * Gets the source code of the fragment shader associated with a specific webGL program
  98475. * @param program defines the program to use
  98476. * @returns a string containing the source code of the fragment shader associated with the program
  98477. */
  98478. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98479. /**
  98480. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98481. * @param x defines the x coordinate of the rectangle where pixels must be read
  98482. * @param y defines the y coordinate of the rectangle where pixels must be read
  98483. * @param width defines the width of the rectangle where pixels must be read
  98484. * @param height defines the height of the rectangle where pixels must be read
  98485. * @returns a Uint8Array containing RGBA colors
  98486. */
  98487. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98488. /**
  98489. * Sets a depth stencil texture from a render target to the according uniform.
  98490. * @param channel The texture channel
  98491. * @param uniform The uniform to set
  98492. * @param texture The render target texture containing the depth stencil texture to apply
  98493. */
  98494. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98495. /**
  98496. * Sets a texture to the webGL context from a postprocess
  98497. * @param channel defines the channel to use
  98498. * @param postProcess defines the source postprocess
  98499. */
  98500. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98501. /**
  98502. * Binds the output of the passed in post process to the texture channel specified
  98503. * @param channel The channel the texture should be bound to
  98504. * @param postProcess The post process which's output should be bound
  98505. */
  98506. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98507. /** @hidden */
  98508. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98509. protected _rebuildBuffers(): void;
  98510. _renderLoop(): void;
  98511. /**
  98512. * Toggle full screen mode
  98513. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98514. */
  98515. switchFullscreen(requestPointerLock: boolean): void;
  98516. /**
  98517. * Enters full screen mode
  98518. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98519. */
  98520. enterFullscreen(requestPointerLock: boolean): void;
  98521. /**
  98522. * Exits full screen mode
  98523. */
  98524. exitFullscreen(): void;
  98525. /**
  98526. * Enters Pointerlock mode
  98527. */
  98528. enterPointerlock(): void;
  98529. /**
  98530. * Exits Pointerlock mode
  98531. */
  98532. exitPointerlock(): void;
  98533. /**
  98534. * Begin a new frame
  98535. */
  98536. beginFrame(): void;
  98537. /**
  98538. * Enf the current frame
  98539. */
  98540. endFrame(): void;
  98541. resize(): void;
  98542. /**
  98543. * Set the compressed texture format to use, based on the formats you have, and the formats
  98544. * supported by the hardware / browser.
  98545. *
  98546. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98547. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98548. * to API arguments needed to compressed textures. This puts the burden on the container
  98549. * generator to house the arcane code for determining these for current & future formats.
  98550. *
  98551. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98552. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98553. *
  98554. * Note: The result of this call is not taken into account when a texture is base64.
  98555. *
  98556. * @param formatsAvailable defines the list of those format families you have created
  98557. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98558. *
  98559. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98560. * @returns The extension selected.
  98561. */
  98562. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98563. /**
  98564. * Force a specific size of the canvas
  98565. * @param width defines the new canvas' width
  98566. * @param height defines the new canvas' height
  98567. */
  98568. setSize(width: number, height: number): void;
  98569. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98570. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98571. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98572. _releaseTexture(texture: InternalTexture): void;
  98573. /**
  98574. * @hidden
  98575. * Rescales a texture
  98576. * @param source input texutre
  98577. * @param destination destination texture
  98578. * @param scene scene to use to render the resize
  98579. * @param internalFormat format to use when resizing
  98580. * @param onComplete callback to be called when resize has completed
  98581. */
  98582. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98583. /**
  98584. * Gets the current framerate
  98585. * @returns a number representing the framerate
  98586. */
  98587. getFps(): number;
  98588. /**
  98589. * Gets the time spent between current and previous frame
  98590. * @returns a number representing the delta time in ms
  98591. */
  98592. getDeltaTime(): number;
  98593. private _measureFps;
  98594. /**
  98595. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98596. * @param renderTarget The render target to set the frame buffer for
  98597. */
  98598. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98599. /**
  98600. * Update a dynamic index buffer
  98601. * @param indexBuffer defines the target index buffer
  98602. * @param indices defines the data to update
  98603. * @param offset defines the offset in the target index buffer where update should start
  98604. */
  98605. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98606. /**
  98607. * Updates the sample count of a render target texture
  98608. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98609. * @param texture defines the texture to update
  98610. * @param samples defines the sample count to set
  98611. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98612. */
  98613. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98614. /** @hidden */
  98615. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98616. dispose(): void;
  98617. private _disableTouchAction;
  98618. /**
  98619. * Display the loading screen
  98620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98621. */
  98622. displayLoadingUI(): void;
  98623. /**
  98624. * Hide the loading screen
  98625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98626. */
  98627. hideLoadingUI(): void;
  98628. /**
  98629. * Gets the current loading screen object
  98630. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98631. */
  98632. /**
  98633. * Sets the current loading screen object
  98634. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98635. */
  98636. loadingScreen: ILoadingScreen;
  98637. /**
  98638. * Sets the current loading screen text
  98639. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98640. */
  98641. loadingUIText: string;
  98642. /**
  98643. * Sets the current loading screen background color
  98644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98645. */
  98646. loadingUIBackgroundColor: string;
  98647. /** Pointerlock and fullscreen */
  98648. /**
  98649. * Ask the browser to promote the current element to pointerlock mode
  98650. * @param element defines the DOM element to promote
  98651. */
  98652. static _RequestPointerlock(element: HTMLElement): void;
  98653. /**
  98654. * Asks the browser to exit pointerlock mode
  98655. */
  98656. static _ExitPointerlock(): void;
  98657. /**
  98658. * Ask the browser to promote the current element to fullscreen rendering mode
  98659. * @param element defines the DOM element to promote
  98660. */
  98661. static _RequestFullscreen(element: HTMLElement): void;
  98662. /**
  98663. * Asks the browser to exit fullscreen mode
  98664. */
  98665. static _ExitFullscreen(): void;
  98666. }
  98667. }
  98668. declare module BABYLON {
  98669. /**
  98670. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98671. * during the life time of the application.
  98672. */
  98673. export class EngineStore {
  98674. /** Gets the list of created engines */
  98675. static Instances: Engine[];
  98676. /** @hidden */
  98677. static _LastCreatedScene: Nullable<Scene>;
  98678. /**
  98679. * Gets the latest created engine
  98680. */
  98681. static readonly LastCreatedEngine: Nullable<Engine>;
  98682. /**
  98683. * Gets the latest created scene
  98684. */
  98685. static readonly LastCreatedScene: Nullable<Scene>;
  98686. /**
  98687. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98688. * @ignorenaming
  98689. */
  98690. static UseFallbackTexture: boolean;
  98691. /**
  98692. * Texture content used if a texture cannot loaded
  98693. * @ignorenaming
  98694. */
  98695. static FallbackTexture: string;
  98696. }
  98697. }
  98698. declare module BABYLON {
  98699. /**
  98700. * Helper class that provides a small promise polyfill
  98701. */
  98702. export class PromisePolyfill {
  98703. /**
  98704. * Static function used to check if the polyfill is required
  98705. * If this is the case then the function will inject the polyfill to window.Promise
  98706. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98707. */
  98708. static Apply(force?: boolean): void;
  98709. }
  98710. }
  98711. declare module BABYLON {
  98712. /**
  98713. * Interface for screenshot methods with describe argument called `size` as object with options
  98714. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98715. */
  98716. export interface IScreenshotSize {
  98717. /**
  98718. * number in pixels for canvas height
  98719. */
  98720. height?: number;
  98721. /**
  98722. * multiplier allowing render at a higher or lower resolution
  98723. * If value is defined then height and width will be ignored and taken from camera
  98724. */
  98725. precision?: number;
  98726. /**
  98727. * number in pixels for canvas width
  98728. */
  98729. width?: number;
  98730. }
  98731. }
  98732. declare module BABYLON {
  98733. interface IColor4Like {
  98734. r: float;
  98735. g: float;
  98736. b: float;
  98737. a: float;
  98738. }
  98739. /**
  98740. * Class containing a set of static utilities functions
  98741. */
  98742. export class Tools {
  98743. /**
  98744. * Gets or sets the base URL to use to load assets
  98745. */
  98746. static BaseUrl: string;
  98747. /**
  98748. * Enable/Disable Custom HTTP Request Headers globally.
  98749. * default = false
  98750. * @see CustomRequestHeaders
  98751. */
  98752. static UseCustomRequestHeaders: boolean;
  98753. /**
  98754. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98755. * i.e. when loading files, where the server/service expects an Authorization header
  98756. */
  98757. static CustomRequestHeaders: {
  98758. [key: string]: string;
  98759. };
  98760. /**
  98761. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98762. */
  98763. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98764. /**
  98765. * Default behaviour for cors in the application.
  98766. * It can be a string if the expected behavior is identical in the entire app.
  98767. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98768. */
  98769. static CorsBehavior: string | ((url: string | string[]) => string);
  98770. /**
  98771. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98772. * @ignorenaming
  98773. */
  98774. static UseFallbackTexture: boolean;
  98775. /**
  98776. * Use this object to register external classes like custom textures or material
  98777. * to allow the laoders to instantiate them
  98778. */
  98779. static RegisteredExternalClasses: {
  98780. [key: string]: Object;
  98781. };
  98782. /**
  98783. * Texture content used if a texture cannot loaded
  98784. * @ignorenaming
  98785. */
  98786. static fallbackTexture: string;
  98787. /**
  98788. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98789. * @param u defines the coordinate on X axis
  98790. * @param v defines the coordinate on Y axis
  98791. * @param width defines the width of the source data
  98792. * @param height defines the height of the source data
  98793. * @param pixels defines the source byte array
  98794. * @param color defines the output color
  98795. */
  98796. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98797. /**
  98798. * Interpolates between a and b via alpha
  98799. * @param a The lower value (returned when alpha = 0)
  98800. * @param b The upper value (returned when alpha = 1)
  98801. * @param alpha The interpolation-factor
  98802. * @return The mixed value
  98803. */
  98804. static Mix(a: number, b: number, alpha: number): number;
  98805. /**
  98806. * Tries to instantiate a new object from a given class name
  98807. * @param className defines the class name to instantiate
  98808. * @returns the new object or null if the system was not able to do the instantiation
  98809. */
  98810. static Instantiate(className: string): any;
  98811. /**
  98812. * Provides a slice function that will work even on IE
  98813. * @param data defines the array to slice
  98814. * @param start defines the start of the data (optional)
  98815. * @param end defines the end of the data (optional)
  98816. * @returns the new sliced array
  98817. */
  98818. static Slice<T>(data: T, start?: number, end?: number): T;
  98819. /**
  98820. * Polyfill for setImmediate
  98821. * @param action defines the action to execute after the current execution block
  98822. */
  98823. static SetImmediate(action: () => void): void;
  98824. /**
  98825. * Function indicating if a number is an exponent of 2
  98826. * @param value defines the value to test
  98827. * @returns true if the value is an exponent of 2
  98828. */
  98829. static IsExponentOfTwo(value: number): boolean;
  98830. private static _tmpFloatArray;
  98831. /**
  98832. * Returns the nearest 32-bit single precision float representation of a Number
  98833. * @param value A Number. If the parameter is of a different type, it will get converted
  98834. * to a number or to NaN if it cannot be converted
  98835. * @returns number
  98836. */
  98837. static FloatRound(value: number): number;
  98838. /**
  98839. * Extracts the filename from a path
  98840. * @param path defines the path to use
  98841. * @returns the filename
  98842. */
  98843. static GetFilename(path: string): string;
  98844. /**
  98845. * Extracts the "folder" part of a path (everything before the filename).
  98846. * @param uri The URI to extract the info from
  98847. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98848. * @returns The "folder" part of the path
  98849. */
  98850. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98851. /**
  98852. * Extracts text content from a DOM element hierarchy
  98853. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98854. */
  98855. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98856. /**
  98857. * Convert an angle in radians to degrees
  98858. * @param angle defines the angle to convert
  98859. * @returns the angle in degrees
  98860. */
  98861. static ToDegrees(angle: number): number;
  98862. /**
  98863. * Convert an angle in degrees to radians
  98864. * @param angle defines the angle to convert
  98865. * @returns the angle in radians
  98866. */
  98867. static ToRadians(angle: number): number;
  98868. /**
  98869. * Encode a buffer to a base64 string
  98870. * @param buffer defines the buffer to encode
  98871. * @returns the encoded string
  98872. */
  98873. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98874. /**
  98875. * Returns an array if obj is not an array
  98876. * @param obj defines the object to evaluate as an array
  98877. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98878. * @returns either obj directly if obj is an array or a new array containing obj
  98879. */
  98880. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98881. /**
  98882. * Gets the pointer prefix to use
  98883. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98884. */
  98885. static GetPointerPrefix(): string;
  98886. /**
  98887. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98888. * @param url define the url we are trying
  98889. * @param element define the dom element where to configure the cors policy
  98890. */
  98891. static SetCorsBehavior(url: string | string[], element: {
  98892. crossOrigin: string | null;
  98893. }): void;
  98894. /**
  98895. * Removes unwanted characters from an url
  98896. * @param url defines the url to clean
  98897. * @returns the cleaned url
  98898. */
  98899. static CleanUrl(url: string): string;
  98900. /**
  98901. * Gets or sets a function used to pre-process url before using them to load assets
  98902. */
  98903. static PreprocessUrl: (url: string) => string;
  98904. /**
  98905. * Loads an image as an HTMLImageElement.
  98906. * @param input url string, ArrayBuffer, or Blob to load
  98907. * @param onLoad callback called when the image successfully loads
  98908. * @param onError callback called when the image fails to load
  98909. * @param offlineProvider offline provider for caching
  98910. * @returns the HTMLImageElement of the loaded image
  98911. */
  98912. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98913. /**
  98914. * Loads a file
  98915. * @param url url string, ArrayBuffer, or Blob to load
  98916. * @param onSuccess callback called when the file successfully loads
  98917. * @param onProgress callback called while file is loading (if the server supports this mode)
  98918. * @param offlineProvider defines the offline provider for caching
  98919. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98920. * @param onError callback called when the file fails to load
  98921. * @returns a file request object
  98922. */
  98923. 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;
  98924. /**
  98925. * Loads a file from a url
  98926. * @param url the file url to load
  98927. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98928. */
  98929. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98930. /**
  98931. * Load a script (identified by an url). When the url returns, the
  98932. * content of this file is added into a new script element, attached to the DOM (body element)
  98933. * @param scriptUrl defines the url of the script to laod
  98934. * @param onSuccess defines the callback called when the script is loaded
  98935. * @param onError defines the callback to call if an error occurs
  98936. * @param scriptId defines the id of the script element
  98937. */
  98938. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98939. /**
  98940. * Load an asynchronous script (identified by an url). When the url returns, the
  98941. * content of this file is added into a new script element, attached to the DOM (body element)
  98942. * @param scriptUrl defines the url of the script to laod
  98943. * @param scriptId defines the id of the script element
  98944. * @returns a promise request object
  98945. */
  98946. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98947. /**
  98948. * Loads a file from a blob
  98949. * @param fileToLoad defines the blob to use
  98950. * @param callback defines the callback to call when data is loaded
  98951. * @param progressCallback defines the callback to call during loading process
  98952. * @returns a file request object
  98953. */
  98954. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98955. /**
  98956. * Loads a file
  98957. * @param fileToLoad defines the file to load
  98958. * @param callback defines the callback to call when data is loaded
  98959. * @param progressCallBack defines the callback to call during loading process
  98960. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98961. * @returns a file request object
  98962. */
  98963. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98964. /**
  98965. * Creates a data url from a given string content
  98966. * @param content defines the content to convert
  98967. * @returns the new data url link
  98968. */
  98969. static FileAsURL(content: string): string;
  98970. /**
  98971. * Format the given number to a specific decimal format
  98972. * @param value defines the number to format
  98973. * @param decimals defines the number of decimals to use
  98974. * @returns the formatted string
  98975. */
  98976. static Format(value: number, decimals?: number): string;
  98977. /**
  98978. * Tries to copy an object by duplicating every property
  98979. * @param source defines the source object
  98980. * @param destination defines the target object
  98981. * @param doNotCopyList defines a list of properties to avoid
  98982. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98983. */
  98984. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98985. /**
  98986. * Gets a boolean indicating if the given object has no own property
  98987. * @param obj defines the object to test
  98988. * @returns true if object has no own property
  98989. */
  98990. static IsEmpty(obj: any): boolean;
  98991. /**
  98992. * Function used to register events at window level
  98993. * @param windowElement defines the Window object to use
  98994. * @param events defines the events to register
  98995. */
  98996. static RegisterTopRootEvents(windowElement: Window, events: {
  98997. name: string;
  98998. handler: Nullable<(e: FocusEvent) => any>;
  98999. }[]): void;
  99000. /**
  99001. * Function used to unregister events from window level
  99002. * @param windowElement defines the Window object to use
  99003. * @param events defines the events to unregister
  99004. */
  99005. static UnregisterTopRootEvents(windowElement: Window, events: {
  99006. name: string;
  99007. handler: Nullable<(e: FocusEvent) => any>;
  99008. }[]): void;
  99009. /**
  99010. * @ignore
  99011. */
  99012. static _ScreenshotCanvas: HTMLCanvasElement;
  99013. /**
  99014. * Dumps the current bound framebuffer
  99015. * @param width defines the rendering width
  99016. * @param height defines the rendering height
  99017. * @param engine defines the hosting engine
  99018. * @param successCallback defines the callback triggered once the data are available
  99019. * @param mimeType defines the mime type of the result
  99020. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99021. */
  99022. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99023. /**
  99024. * Converts the canvas data to blob.
  99025. * This acts as a polyfill for browsers not supporting the to blob function.
  99026. * @param canvas Defines the canvas to extract the data from
  99027. * @param successCallback Defines the callback triggered once the data are available
  99028. * @param mimeType Defines the mime type of the result
  99029. */
  99030. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99031. /**
  99032. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99033. * @param successCallback defines the callback triggered once the data are available
  99034. * @param mimeType defines the mime type of the result
  99035. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99036. */
  99037. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99038. /**
  99039. * Downloads a blob in the browser
  99040. * @param blob defines the blob to download
  99041. * @param fileName defines the name of the downloaded file
  99042. */
  99043. static Download(blob: Blob, fileName: string): void;
  99044. /**
  99045. * Captures a screenshot of the current rendering
  99046. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99047. * @param engine defines the rendering engine
  99048. * @param camera defines the source camera
  99049. * @param size This parameter can be set to a single number or to an object with the
  99050. * following (optional) properties: precision, width, height. If a single number is passed,
  99051. * it will be used for both width and height. If an object is passed, the screenshot size
  99052. * will be derived from the parameters. The precision property is a multiplier allowing
  99053. * rendering at a higher or lower resolution
  99054. * @param successCallback defines the callback receives a single parameter which contains the
  99055. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99056. * src parameter of an <img> to display it
  99057. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99058. * Check your browser for supported MIME types
  99059. */
  99060. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99061. /**
  99062. * Captures a screenshot of the current rendering
  99063. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99064. * @param engine defines the rendering engine
  99065. * @param camera defines the source camera
  99066. * @param size This parameter can be set to a single number or to an object with the
  99067. * following (optional) properties: precision, width, height. If a single number is passed,
  99068. * it will be used for both width and height. If an object is passed, the screenshot size
  99069. * will be derived from the parameters. The precision property is a multiplier allowing
  99070. * rendering at a higher or lower resolution
  99071. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99072. * Check your browser for supported MIME types
  99073. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99074. * to the src parameter of an <img> to display it
  99075. */
  99076. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99077. /**
  99078. * Generates an image screenshot from the specified camera.
  99079. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99080. * @param engine The engine to use for rendering
  99081. * @param camera The camera to use for rendering
  99082. * @param size This parameter can be set to a single number or to an object with the
  99083. * following (optional) properties: precision, width, height. If a single number is passed,
  99084. * it will be used for both width and height. If an object is passed, the screenshot size
  99085. * will be derived from the parameters. The precision property is a multiplier allowing
  99086. * rendering at a higher or lower resolution
  99087. * @param successCallback The callback receives a single parameter which contains the
  99088. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99089. * src parameter of an <img> to display it
  99090. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99091. * Check your browser for supported MIME types
  99092. * @param samples Texture samples (default: 1)
  99093. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99094. * @param fileName A name for for the downloaded file.
  99095. */
  99096. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99097. /**
  99098. * Generates an image screenshot from the specified camera.
  99099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99100. * @param engine The engine to use for rendering
  99101. * @param camera The camera to use for rendering
  99102. * @param size This parameter can be set to a single number or to an object with the
  99103. * following (optional) properties: precision, width, height. If a single number is passed,
  99104. * it will be used for both width and height. If an object is passed, the screenshot size
  99105. * will be derived from the parameters. The precision property is a multiplier allowing
  99106. * rendering at a higher or lower resolution
  99107. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99108. * Check your browser for supported MIME types
  99109. * @param samples Texture samples (default: 1)
  99110. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99111. * @param fileName A name for for the downloaded file.
  99112. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99113. * to the src parameter of an <img> to display it
  99114. */
  99115. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99116. /**
  99117. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99118. * Be aware Math.random() could cause collisions, but:
  99119. * "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"
  99120. * @returns a pseudo random id
  99121. */
  99122. static RandomId(): string;
  99123. /**
  99124. * Test if the given uri is a base64 string
  99125. * @param uri The uri to test
  99126. * @return True if the uri is a base64 string or false otherwise
  99127. */
  99128. static IsBase64(uri: string): boolean;
  99129. /**
  99130. * Decode the given base64 uri.
  99131. * @param uri The uri to decode
  99132. * @return The decoded base64 data.
  99133. */
  99134. static DecodeBase64(uri: string): ArrayBuffer;
  99135. /**
  99136. * Gets the absolute url.
  99137. * @param url the input url
  99138. * @return the absolute url
  99139. */
  99140. static GetAbsoluteUrl(url: string): string;
  99141. /**
  99142. * No log
  99143. */
  99144. static readonly NoneLogLevel: number;
  99145. /**
  99146. * Only message logs
  99147. */
  99148. static readonly MessageLogLevel: number;
  99149. /**
  99150. * Only warning logs
  99151. */
  99152. static readonly WarningLogLevel: number;
  99153. /**
  99154. * Only error logs
  99155. */
  99156. static readonly ErrorLogLevel: number;
  99157. /**
  99158. * All logs
  99159. */
  99160. static readonly AllLogLevel: number;
  99161. /**
  99162. * Gets a value indicating the number of loading errors
  99163. * @ignorenaming
  99164. */
  99165. static readonly errorsCount: number;
  99166. /**
  99167. * Callback called when a new log is added
  99168. */
  99169. static OnNewCacheEntry: (entry: string) => void;
  99170. /**
  99171. * Log a message to the console
  99172. * @param message defines the message to log
  99173. */
  99174. static Log(message: string): void;
  99175. /**
  99176. * Write a warning message to the console
  99177. * @param message defines the message to log
  99178. */
  99179. static Warn(message: string): void;
  99180. /**
  99181. * Write an error message to the console
  99182. * @param message defines the message to log
  99183. */
  99184. static Error(message: string): void;
  99185. /**
  99186. * Gets current log cache (list of logs)
  99187. */
  99188. static readonly LogCache: string;
  99189. /**
  99190. * Clears the log cache
  99191. */
  99192. static ClearLogCache(): void;
  99193. /**
  99194. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99195. */
  99196. static LogLevels: number;
  99197. /**
  99198. * Checks if the window object exists
  99199. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99200. */
  99201. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99202. /**
  99203. * No performance log
  99204. */
  99205. static readonly PerformanceNoneLogLevel: number;
  99206. /**
  99207. * Use user marks to log performance
  99208. */
  99209. static readonly PerformanceUserMarkLogLevel: number;
  99210. /**
  99211. * Log performance to the console
  99212. */
  99213. static readonly PerformanceConsoleLogLevel: number;
  99214. private static _performance;
  99215. /**
  99216. * Sets the current performance log level
  99217. */
  99218. static PerformanceLogLevel: number;
  99219. private static _StartPerformanceCounterDisabled;
  99220. private static _EndPerformanceCounterDisabled;
  99221. private static _StartUserMark;
  99222. private static _EndUserMark;
  99223. private static _StartPerformanceConsole;
  99224. private static _EndPerformanceConsole;
  99225. /**
  99226. * Starts a performance counter
  99227. */
  99228. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99229. /**
  99230. * Ends a specific performance coutner
  99231. */
  99232. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99233. /**
  99234. * Gets either window.performance.now() if supported or Date.now() else
  99235. */
  99236. static readonly Now: number;
  99237. /**
  99238. * This method will return the name of the class used to create the instance of the given object.
  99239. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99240. * @param object the object to get the class name from
  99241. * @param isType defines if the object is actually a type
  99242. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99243. */
  99244. static GetClassName(object: any, isType?: boolean): string;
  99245. /**
  99246. * Gets the first element of an array satisfying a given predicate
  99247. * @param array defines the array to browse
  99248. * @param predicate defines the predicate to use
  99249. * @returns null if not found or the element
  99250. */
  99251. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99252. /**
  99253. * This method will return the name of the full name of the class, including its owning module (if any).
  99254. * 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).
  99255. * @param object the object to get the class name from
  99256. * @param isType defines if the object is actually a type
  99257. * @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.
  99258. * @ignorenaming
  99259. */
  99260. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99261. /**
  99262. * Returns a promise that resolves after the given amount of time.
  99263. * @param delay Number of milliseconds to delay
  99264. * @returns Promise that resolves after the given amount of time
  99265. */
  99266. static DelayAsync(delay: number): Promise<void>;
  99267. }
  99268. /**
  99269. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99270. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99271. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99272. * @param name The name of the class, case should be preserved
  99273. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99274. */
  99275. export function className(name: string, module?: string): (target: Object) => void;
  99276. /**
  99277. * An implementation of a loop for asynchronous functions.
  99278. */
  99279. export class AsyncLoop {
  99280. /**
  99281. * Defines the number of iterations for the loop
  99282. */
  99283. iterations: number;
  99284. /**
  99285. * Defines the current index of the loop.
  99286. */
  99287. index: number;
  99288. private _done;
  99289. private _fn;
  99290. private _successCallback;
  99291. /**
  99292. * Constructor.
  99293. * @param iterations the number of iterations.
  99294. * @param func the function to run each iteration
  99295. * @param successCallback the callback that will be called upon succesful execution
  99296. * @param offset starting offset.
  99297. */
  99298. constructor(
  99299. /**
  99300. * Defines the number of iterations for the loop
  99301. */
  99302. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99303. /**
  99304. * Execute the next iteration. Must be called after the last iteration was finished.
  99305. */
  99306. executeNext(): void;
  99307. /**
  99308. * Break the loop and run the success callback.
  99309. */
  99310. breakLoop(): void;
  99311. /**
  99312. * Create and run an async loop.
  99313. * @param iterations the number of iterations.
  99314. * @param fn the function to run each iteration
  99315. * @param successCallback the callback that will be called upon succesful execution
  99316. * @param offset starting offset.
  99317. * @returns the created async loop object
  99318. */
  99319. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99320. /**
  99321. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99322. * @param iterations total number of iterations
  99323. * @param syncedIterations number of synchronous iterations in each async iteration.
  99324. * @param fn the function to call each iteration.
  99325. * @param callback a success call back that will be called when iterating stops.
  99326. * @param breakFunction a break condition (optional)
  99327. * @param timeout timeout settings for the setTimeout function. default - 0.
  99328. * @returns the created async loop object
  99329. */
  99330. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99331. }
  99332. }
  99333. declare module BABYLON {
  99334. /**
  99335. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99336. * The underlying implementation relies on an associative array to ensure the best performances.
  99337. * The value can be anything including 'null' but except 'undefined'
  99338. */
  99339. export class StringDictionary<T> {
  99340. /**
  99341. * This will clear this dictionary and copy the content from the 'source' one.
  99342. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99343. * @param source the dictionary to take the content from and copy to this dictionary
  99344. */
  99345. copyFrom(source: StringDictionary<T>): void;
  99346. /**
  99347. * Get a value based from its key
  99348. * @param key the given key to get the matching value from
  99349. * @return the value if found, otherwise undefined is returned
  99350. */
  99351. get(key: string): T | undefined;
  99352. /**
  99353. * Get a value from its key or add it if it doesn't exist.
  99354. * This method will ensure you that a given key/data will be present in the dictionary.
  99355. * @param key the given key to get the matching value from
  99356. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99357. * The factory will only be invoked if there's no data for the given key.
  99358. * @return the value corresponding to the key.
  99359. */
  99360. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99361. /**
  99362. * Get a value from its key if present in the dictionary otherwise add it
  99363. * @param key the key to get the value from
  99364. * @param val if there's no such key/value pair in the dictionary add it with this value
  99365. * @return the value corresponding to the key
  99366. */
  99367. getOrAdd(key: string, val: T): T;
  99368. /**
  99369. * Check if there's a given key in the dictionary
  99370. * @param key the key to check for
  99371. * @return true if the key is present, false otherwise
  99372. */
  99373. contains(key: string): boolean;
  99374. /**
  99375. * Add a new key and its corresponding value
  99376. * @param key the key to add
  99377. * @param value the value corresponding to the key
  99378. * @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
  99379. */
  99380. add(key: string, value: T): boolean;
  99381. /**
  99382. * Update a specific value associated to a key
  99383. * @param key defines the key to use
  99384. * @param value defines the value to store
  99385. * @returns true if the value was updated (or false if the key was not found)
  99386. */
  99387. set(key: string, value: T): boolean;
  99388. /**
  99389. * Get the element of the given key and remove it from the dictionary
  99390. * @param key defines the key to search
  99391. * @returns the value associated with the key or null if not found
  99392. */
  99393. getAndRemove(key: string): Nullable<T>;
  99394. /**
  99395. * Remove a key/value from the dictionary.
  99396. * @param key the key to remove
  99397. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99398. */
  99399. remove(key: string): boolean;
  99400. /**
  99401. * Clear the whole content of the dictionary
  99402. */
  99403. clear(): void;
  99404. /**
  99405. * Gets the current count
  99406. */
  99407. readonly count: number;
  99408. /**
  99409. * Execute a callback on each key/val of the dictionary.
  99410. * Note that you can remove any element in this dictionary in the callback implementation
  99411. * @param callback the callback to execute on a given key/value pair
  99412. */
  99413. forEach(callback: (key: string, val: T) => void): void;
  99414. /**
  99415. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99416. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99417. * Note that you can remove any element in this dictionary in the callback implementation
  99418. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99419. * @returns the first item
  99420. */
  99421. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99422. private _count;
  99423. private _data;
  99424. }
  99425. }
  99426. declare module BABYLON {
  99427. /** @hidden */
  99428. export interface ICollisionCoordinator {
  99429. createCollider(): Collider;
  99430. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99431. init(scene: Scene): void;
  99432. }
  99433. /** @hidden */
  99434. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99435. private _scene;
  99436. private _scaledPosition;
  99437. private _scaledVelocity;
  99438. private _finalPosition;
  99439. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99440. createCollider(): Collider;
  99441. init(scene: Scene): void;
  99442. private _collideWithWorld;
  99443. }
  99444. }
  99445. declare module BABYLON {
  99446. /**
  99447. * Class used to manage all inputs for the scene.
  99448. */
  99449. export class InputManager {
  99450. /** The distance in pixel that you have to move to prevent some events */
  99451. static DragMovementThreshold: number;
  99452. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99453. static LongPressDelay: number;
  99454. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99455. static DoubleClickDelay: number;
  99456. /** If you need to check double click without raising a single click at first click, enable this flag */
  99457. static ExclusiveDoubleClickMode: boolean;
  99458. private _wheelEventName;
  99459. private _onPointerMove;
  99460. private _onPointerDown;
  99461. private _onPointerUp;
  99462. private _initClickEvent;
  99463. private _initActionManager;
  99464. private _delayedSimpleClick;
  99465. private _delayedSimpleClickTimeout;
  99466. private _previousDelayedSimpleClickTimeout;
  99467. private _meshPickProceed;
  99468. private _previousButtonPressed;
  99469. private _currentPickResult;
  99470. private _previousPickResult;
  99471. private _totalPointersPressed;
  99472. private _doubleClickOccured;
  99473. private _pointerOverMesh;
  99474. private _pickedDownMesh;
  99475. private _pickedUpMesh;
  99476. private _pointerX;
  99477. private _pointerY;
  99478. private _unTranslatedPointerX;
  99479. private _unTranslatedPointerY;
  99480. private _startingPointerPosition;
  99481. private _previousStartingPointerPosition;
  99482. private _startingPointerTime;
  99483. private _previousStartingPointerTime;
  99484. private _pointerCaptures;
  99485. private _onKeyDown;
  99486. private _onKeyUp;
  99487. private _onCanvasFocusObserver;
  99488. private _onCanvasBlurObserver;
  99489. private _scene;
  99490. /**
  99491. * Creates a new InputManager
  99492. * @param scene defines the hosting scene
  99493. */
  99494. constructor(scene: Scene);
  99495. /**
  99496. * Gets the mesh that is currently under the pointer
  99497. */
  99498. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99499. /**
  99500. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99501. */
  99502. readonly unTranslatedPointer: Vector2;
  99503. /**
  99504. * Gets or sets the current on-screen X position of the pointer
  99505. */
  99506. pointerX: number;
  99507. /**
  99508. * Gets or sets the current on-screen Y position of the pointer
  99509. */
  99510. pointerY: number;
  99511. private _updatePointerPosition;
  99512. private _processPointerMove;
  99513. private _setRayOnPointerInfo;
  99514. private _checkPrePointerObservable;
  99515. /**
  99516. * Use this method to simulate a pointer move on a mesh
  99517. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99518. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99519. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99520. */
  99521. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99522. /**
  99523. * Use this method to simulate a pointer down on a mesh
  99524. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99525. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99526. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99527. */
  99528. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99529. private _processPointerDown;
  99530. /** @hidden */
  99531. _isPointerSwiping(): boolean;
  99532. /**
  99533. * Use this method to simulate a pointer up on a mesh
  99534. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99535. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99536. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99537. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99538. */
  99539. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99540. private _processPointerUp;
  99541. /**
  99542. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99543. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99544. * @returns true if the pointer was captured
  99545. */
  99546. isPointerCaptured(pointerId?: number): boolean;
  99547. /**
  99548. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99549. * @param attachUp defines if you want to attach events to pointerup
  99550. * @param attachDown defines if you want to attach events to pointerdown
  99551. * @param attachMove defines if you want to attach events to pointermove
  99552. */
  99553. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99554. /**
  99555. * Detaches all event handlers
  99556. */
  99557. detachControl(): void;
  99558. /**
  99559. * Force the value of meshUnderPointer
  99560. * @param mesh defines the mesh to use
  99561. */
  99562. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99563. /**
  99564. * Gets the mesh under the pointer
  99565. * @returns a Mesh or null if no mesh is under the pointer
  99566. */
  99567. getPointerOverMesh(): Nullable<AbstractMesh>;
  99568. }
  99569. }
  99570. declare module BABYLON {
  99571. /**
  99572. * Helper class used to generate session unique ID
  99573. */
  99574. export class UniqueIdGenerator {
  99575. private static _UniqueIdCounter;
  99576. /**
  99577. * Gets an unique (relatively to the current scene) Id
  99578. */
  99579. static readonly UniqueId: number;
  99580. }
  99581. }
  99582. declare module BABYLON {
  99583. /**
  99584. * This class defines the direct association between an animation and a target
  99585. */
  99586. export class TargetedAnimation {
  99587. /**
  99588. * Animation to perform
  99589. */
  99590. animation: Animation;
  99591. /**
  99592. * Target to animate
  99593. */
  99594. target: any;
  99595. /**
  99596. * Serialize the object
  99597. * @returns the JSON object representing the current entity
  99598. */
  99599. serialize(): any;
  99600. }
  99601. /**
  99602. * Use this class to create coordinated animations on multiple targets
  99603. */
  99604. export class AnimationGroup implements IDisposable {
  99605. /** The name of the animation group */
  99606. name: string;
  99607. private _scene;
  99608. private _targetedAnimations;
  99609. private _animatables;
  99610. private _from;
  99611. private _to;
  99612. private _isStarted;
  99613. private _isPaused;
  99614. private _speedRatio;
  99615. private _loopAnimation;
  99616. /**
  99617. * Gets or sets the unique id of the node
  99618. */
  99619. uniqueId: number;
  99620. /**
  99621. * This observable will notify when one animation have ended
  99622. */
  99623. onAnimationEndObservable: Observable<TargetedAnimation>;
  99624. /**
  99625. * Observer raised when one animation loops
  99626. */
  99627. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99628. /**
  99629. * This observable will notify when all animations have ended.
  99630. */
  99631. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99632. /**
  99633. * This observable will notify when all animations have paused.
  99634. */
  99635. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99636. /**
  99637. * This observable will notify when all animations are playing.
  99638. */
  99639. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99640. /**
  99641. * Gets the first frame
  99642. */
  99643. readonly from: number;
  99644. /**
  99645. * Gets the last frame
  99646. */
  99647. readonly to: number;
  99648. /**
  99649. * Define if the animations are started
  99650. */
  99651. readonly isStarted: boolean;
  99652. /**
  99653. * Gets a value indicating that the current group is playing
  99654. */
  99655. readonly isPlaying: boolean;
  99656. /**
  99657. * Gets or sets the speed ratio to use for all animations
  99658. */
  99659. /**
  99660. * Gets or sets the speed ratio to use for all animations
  99661. */
  99662. speedRatio: number;
  99663. /**
  99664. * Gets or sets if all animations should loop or not
  99665. */
  99666. loopAnimation: boolean;
  99667. /**
  99668. * Gets the targeted animations for this animation group
  99669. */
  99670. readonly targetedAnimations: Array<TargetedAnimation>;
  99671. /**
  99672. * returning the list of animatables controlled by this animation group.
  99673. */
  99674. readonly animatables: Array<Animatable>;
  99675. /**
  99676. * Instantiates a new Animation Group.
  99677. * This helps managing several animations at once.
  99678. * @see http://doc.babylonjs.com/how_to/group
  99679. * @param name Defines the name of the group
  99680. * @param scene Defines the scene the group belongs to
  99681. */
  99682. constructor(
  99683. /** The name of the animation group */
  99684. name: string, scene?: Nullable<Scene>);
  99685. /**
  99686. * Add an animation (with its target) in the group
  99687. * @param animation defines the animation we want to add
  99688. * @param target defines the target of the animation
  99689. * @returns the TargetedAnimation object
  99690. */
  99691. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99692. /**
  99693. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99694. * It can add constant keys at begin or end
  99695. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99696. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99697. * @returns the animation group
  99698. */
  99699. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99700. /**
  99701. * Start all animations on given targets
  99702. * @param loop defines if animations must loop
  99703. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99704. * @param from defines the from key (optional)
  99705. * @param to defines the to key (optional)
  99706. * @returns the current animation group
  99707. */
  99708. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99709. /**
  99710. * Pause all animations
  99711. * @returns the animation group
  99712. */
  99713. pause(): AnimationGroup;
  99714. /**
  99715. * Play all animations to initial state
  99716. * This function will start() the animations if they were not started or will restart() them if they were paused
  99717. * @param loop defines if animations must loop
  99718. * @returns the animation group
  99719. */
  99720. play(loop?: boolean): AnimationGroup;
  99721. /**
  99722. * Reset all animations to initial state
  99723. * @returns the animation group
  99724. */
  99725. reset(): AnimationGroup;
  99726. /**
  99727. * Restart animations from key 0
  99728. * @returns the animation group
  99729. */
  99730. restart(): AnimationGroup;
  99731. /**
  99732. * Stop all animations
  99733. * @returns the animation group
  99734. */
  99735. stop(): AnimationGroup;
  99736. /**
  99737. * Set animation weight for all animatables
  99738. * @param weight defines the weight to use
  99739. * @return the animationGroup
  99740. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99741. */
  99742. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99743. /**
  99744. * Synchronize and normalize all animatables with a source animatable
  99745. * @param root defines the root animatable to synchronize with
  99746. * @return the animationGroup
  99747. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99748. */
  99749. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99750. /**
  99751. * Goes to a specific frame in this animation group
  99752. * @param frame the frame number to go to
  99753. * @return the animationGroup
  99754. */
  99755. goToFrame(frame: number): AnimationGroup;
  99756. /**
  99757. * Dispose all associated resources
  99758. */
  99759. dispose(): void;
  99760. private _checkAnimationGroupEnded;
  99761. /**
  99762. * Clone the current animation group and returns a copy
  99763. * @param newName defines the name of the new group
  99764. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99765. * @returns the new aniamtion group
  99766. */
  99767. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99768. /**
  99769. * Serializes the animationGroup to an object
  99770. * @returns Serialized object
  99771. */
  99772. serialize(): any;
  99773. /**
  99774. * Returns a new AnimationGroup object parsed from the source provided.
  99775. * @param parsedAnimationGroup defines the source
  99776. * @param scene defines the scene that will receive the animationGroup
  99777. * @returns a new AnimationGroup
  99778. */
  99779. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99780. /**
  99781. * Returns the string "AnimationGroup"
  99782. * @returns "AnimationGroup"
  99783. */
  99784. getClassName(): string;
  99785. /**
  99786. * Creates a detailled string about the object
  99787. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99788. * @returns a string representing the object
  99789. */
  99790. toString(fullDetails?: boolean): string;
  99791. }
  99792. }
  99793. declare module BABYLON {
  99794. /**
  99795. * Define an interface for all classes that will hold resources
  99796. */
  99797. export interface IDisposable {
  99798. /**
  99799. * Releases all held resources
  99800. */
  99801. dispose(): void;
  99802. }
  99803. /** Interface defining initialization parameters for Scene class */
  99804. export interface SceneOptions {
  99805. /**
  99806. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99807. * It will improve performance when the number of geometries becomes important.
  99808. */
  99809. useGeometryUniqueIdsMap?: boolean;
  99810. /**
  99811. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99812. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99813. */
  99814. useMaterialMeshMap?: boolean;
  99815. /**
  99816. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99817. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99818. */
  99819. useClonedMeshhMap?: boolean;
  99820. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99821. virtual?: boolean;
  99822. }
  99823. /**
  99824. * Represents a scene to be rendered by the engine.
  99825. * @see http://doc.babylonjs.com/features/scene
  99826. */
  99827. export class Scene extends AbstractScene implements IAnimatable {
  99828. /** The fog is deactivated */
  99829. static readonly FOGMODE_NONE: number;
  99830. /** The fog density is following an exponential function */
  99831. static readonly FOGMODE_EXP: number;
  99832. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99833. static readonly FOGMODE_EXP2: number;
  99834. /** The fog density is following a linear function. */
  99835. static readonly FOGMODE_LINEAR: number;
  99836. /**
  99837. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99838. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99839. */
  99840. static MinDeltaTime: number;
  99841. /**
  99842. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99843. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99844. */
  99845. static MaxDeltaTime: number;
  99846. /**
  99847. * Factory used to create the default material.
  99848. * @param name The name of the material to create
  99849. * @param scene The scene to create the material for
  99850. * @returns The default material
  99851. */
  99852. static DefaultMaterialFactory(scene: Scene): Material;
  99853. /**
  99854. * Factory used to create the a collision coordinator.
  99855. * @returns The collision coordinator
  99856. */
  99857. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99858. /** @hidden */
  99859. _inputManager: InputManager;
  99860. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99861. cameraToUseForPointers: Nullable<Camera>;
  99862. /** @hidden */
  99863. readonly _isScene: boolean;
  99864. /**
  99865. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99866. */
  99867. autoClear: boolean;
  99868. /**
  99869. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99870. */
  99871. autoClearDepthAndStencil: boolean;
  99872. /**
  99873. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99874. */
  99875. clearColor: Color4;
  99876. /**
  99877. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99878. */
  99879. ambientColor: Color3;
  99880. /**
  99881. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99882. * It should only be one of the following (if not the default embedded one):
  99883. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99884. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99885. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99886. * The material properties need to be setup according to the type of texture in use.
  99887. */
  99888. environmentBRDFTexture: BaseTexture;
  99889. /** @hidden */
  99890. protected _environmentTexture: Nullable<BaseTexture>;
  99891. /**
  99892. * Texture used in all pbr material as the reflection texture.
  99893. * As in the majority of the scene they are the same (exception for multi room and so on),
  99894. * this is easier to reference from here than from all the materials.
  99895. */
  99896. /**
  99897. * Texture used in all pbr material as the reflection texture.
  99898. * As in the majority of the scene they are the same (exception for multi room and so on),
  99899. * this is easier to set here than in all the materials.
  99900. */
  99901. environmentTexture: Nullable<BaseTexture>;
  99902. /** @hidden */
  99903. protected _environmentIntensity: number;
  99904. /**
  99905. * Intensity of the environment in all pbr material.
  99906. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99907. * As in the majority of the scene they are the same (exception for multi room and so on),
  99908. * this is easier to reference from here than from all the materials.
  99909. */
  99910. /**
  99911. * Intensity of the environment in all pbr material.
  99912. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99913. * As in the majority of the scene they are the same (exception for multi room and so on),
  99914. * this is easier to set here than in all the materials.
  99915. */
  99916. environmentIntensity: number;
  99917. /** @hidden */
  99918. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99919. /**
  99920. * Default image processing configuration used either in the rendering
  99921. * Forward main pass or through the imageProcessingPostProcess if present.
  99922. * As in the majority of the scene they are the same (exception for multi camera),
  99923. * this is easier to reference from here than from all the materials and post process.
  99924. *
  99925. * No setter as we it is a shared configuration, you can set the values instead.
  99926. */
  99927. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99928. private _forceWireframe;
  99929. /**
  99930. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99931. */
  99932. forceWireframe: boolean;
  99933. private _forcePointsCloud;
  99934. /**
  99935. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99936. */
  99937. forcePointsCloud: boolean;
  99938. /**
  99939. * Gets or sets the active clipplane 1
  99940. */
  99941. clipPlane: Nullable<Plane>;
  99942. /**
  99943. * Gets or sets the active clipplane 2
  99944. */
  99945. clipPlane2: Nullable<Plane>;
  99946. /**
  99947. * Gets or sets the active clipplane 3
  99948. */
  99949. clipPlane3: Nullable<Plane>;
  99950. /**
  99951. * Gets or sets the active clipplane 4
  99952. */
  99953. clipPlane4: Nullable<Plane>;
  99954. /**
  99955. * Gets or sets a boolean indicating if animations are enabled
  99956. */
  99957. animationsEnabled: boolean;
  99958. private _animationPropertiesOverride;
  99959. /**
  99960. * Gets or sets the animation properties override
  99961. */
  99962. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99963. /**
  99964. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99965. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99966. */
  99967. useConstantAnimationDeltaTime: boolean;
  99968. /**
  99969. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99970. * Please note that it requires to run a ray cast through the scene on every frame
  99971. */
  99972. constantlyUpdateMeshUnderPointer: boolean;
  99973. /**
  99974. * Defines the HTML cursor to use when hovering over interactive elements
  99975. */
  99976. hoverCursor: string;
  99977. /**
  99978. * Defines the HTML default cursor to use (empty by default)
  99979. */
  99980. defaultCursor: string;
  99981. /**
  99982. * This is used to call preventDefault() on pointer down
  99983. * in order to block unwanted artifacts like system double clicks
  99984. */
  99985. preventDefaultOnPointerDown: boolean;
  99986. /**
  99987. * This is used to call preventDefault() on pointer up
  99988. * in order to block unwanted artifacts like system double clicks
  99989. */
  99990. preventDefaultOnPointerUp: boolean;
  99991. /**
  99992. * Gets or sets user defined metadata
  99993. */
  99994. metadata: any;
  99995. /**
  99996. * For internal use only. Please do not use.
  99997. */
  99998. reservedDataStore: any;
  99999. /**
  100000. * Gets the name of the plugin used to load this scene (null by default)
  100001. */
  100002. loadingPluginName: string;
  100003. /**
  100004. * Use this array to add regular expressions used to disable offline support for specific urls
  100005. */
  100006. disableOfflineSupportExceptionRules: RegExp[];
  100007. /**
  100008. * An event triggered when the scene is disposed.
  100009. */
  100010. onDisposeObservable: Observable<Scene>;
  100011. private _onDisposeObserver;
  100012. /** Sets a function to be executed when this scene is disposed. */
  100013. onDispose: () => void;
  100014. /**
  100015. * An event triggered before rendering the scene (right after animations and physics)
  100016. */
  100017. onBeforeRenderObservable: Observable<Scene>;
  100018. private _onBeforeRenderObserver;
  100019. /** Sets a function to be executed before rendering this scene */
  100020. beforeRender: Nullable<() => void>;
  100021. /**
  100022. * An event triggered after rendering the scene
  100023. */
  100024. onAfterRenderObservable: Observable<Scene>;
  100025. /**
  100026. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100027. */
  100028. onAfterRenderCameraObservable: Observable<Camera>;
  100029. private _onAfterRenderObserver;
  100030. /** Sets a function to be executed after rendering this scene */
  100031. afterRender: Nullable<() => void>;
  100032. /**
  100033. * An event triggered before animating the scene
  100034. */
  100035. onBeforeAnimationsObservable: Observable<Scene>;
  100036. /**
  100037. * An event triggered after animations processing
  100038. */
  100039. onAfterAnimationsObservable: Observable<Scene>;
  100040. /**
  100041. * An event triggered before draw calls are ready to be sent
  100042. */
  100043. onBeforeDrawPhaseObservable: Observable<Scene>;
  100044. /**
  100045. * An event triggered after draw calls have been sent
  100046. */
  100047. onAfterDrawPhaseObservable: Observable<Scene>;
  100048. /**
  100049. * An event triggered when the scene is ready
  100050. */
  100051. onReadyObservable: Observable<Scene>;
  100052. /**
  100053. * An event triggered before rendering a camera
  100054. */
  100055. onBeforeCameraRenderObservable: Observable<Camera>;
  100056. private _onBeforeCameraRenderObserver;
  100057. /** Sets a function to be executed before rendering a camera*/
  100058. beforeCameraRender: () => void;
  100059. /**
  100060. * An event triggered after rendering a camera
  100061. */
  100062. onAfterCameraRenderObservable: Observable<Camera>;
  100063. private _onAfterCameraRenderObserver;
  100064. /** Sets a function to be executed after rendering a camera*/
  100065. afterCameraRender: () => void;
  100066. /**
  100067. * An event triggered when active meshes evaluation is about to start
  100068. */
  100069. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100070. /**
  100071. * An event triggered when active meshes evaluation is done
  100072. */
  100073. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100074. /**
  100075. * An event triggered when particles rendering is about to start
  100076. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100077. */
  100078. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100079. /**
  100080. * An event triggered when particles rendering is done
  100081. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100082. */
  100083. onAfterParticlesRenderingObservable: Observable<Scene>;
  100084. /**
  100085. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100086. */
  100087. onDataLoadedObservable: Observable<Scene>;
  100088. /**
  100089. * An event triggered when a camera is created
  100090. */
  100091. onNewCameraAddedObservable: Observable<Camera>;
  100092. /**
  100093. * An event triggered when a camera is removed
  100094. */
  100095. onCameraRemovedObservable: Observable<Camera>;
  100096. /**
  100097. * An event triggered when a light is created
  100098. */
  100099. onNewLightAddedObservable: Observable<Light>;
  100100. /**
  100101. * An event triggered when a light is removed
  100102. */
  100103. onLightRemovedObservable: Observable<Light>;
  100104. /**
  100105. * An event triggered when a geometry is created
  100106. */
  100107. onNewGeometryAddedObservable: Observable<Geometry>;
  100108. /**
  100109. * An event triggered when a geometry is removed
  100110. */
  100111. onGeometryRemovedObservable: Observable<Geometry>;
  100112. /**
  100113. * An event triggered when a transform node is created
  100114. */
  100115. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100116. /**
  100117. * An event triggered when a transform node is removed
  100118. */
  100119. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100120. /**
  100121. * An event triggered when a mesh is created
  100122. */
  100123. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100124. /**
  100125. * An event triggered when a mesh is removed
  100126. */
  100127. onMeshRemovedObservable: Observable<AbstractMesh>;
  100128. /**
  100129. * An event triggered when a skeleton is created
  100130. */
  100131. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100132. /**
  100133. * An event triggered when a skeleton is removed
  100134. */
  100135. onSkeletonRemovedObservable: Observable<Skeleton>;
  100136. /**
  100137. * An event triggered when a material is created
  100138. */
  100139. onNewMaterialAddedObservable: Observable<Material>;
  100140. /**
  100141. * An event triggered when a material is removed
  100142. */
  100143. onMaterialRemovedObservable: Observable<Material>;
  100144. /**
  100145. * An event triggered when a texture is created
  100146. */
  100147. onNewTextureAddedObservable: Observable<BaseTexture>;
  100148. /**
  100149. * An event triggered when a texture is removed
  100150. */
  100151. onTextureRemovedObservable: Observable<BaseTexture>;
  100152. /**
  100153. * An event triggered when render targets are about to be rendered
  100154. * Can happen multiple times per frame.
  100155. */
  100156. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100157. /**
  100158. * An event triggered when render targets were rendered.
  100159. * Can happen multiple times per frame.
  100160. */
  100161. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100162. /**
  100163. * An event triggered before calculating deterministic simulation step
  100164. */
  100165. onBeforeStepObservable: Observable<Scene>;
  100166. /**
  100167. * An event triggered after calculating deterministic simulation step
  100168. */
  100169. onAfterStepObservable: Observable<Scene>;
  100170. /**
  100171. * An event triggered when the activeCamera property is updated
  100172. */
  100173. onActiveCameraChanged: Observable<Scene>;
  100174. /**
  100175. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100176. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100177. * 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)
  100178. */
  100179. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100180. /**
  100181. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100182. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100183. * 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)
  100184. */
  100185. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100186. /**
  100187. * This Observable will when a mesh has been imported into the scene.
  100188. */
  100189. onMeshImportedObservable: Observable<AbstractMesh>;
  100190. /**
  100191. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100192. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100193. */
  100194. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100195. /** @hidden */
  100196. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100197. /**
  100198. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100199. */
  100200. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100201. /**
  100202. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100203. */
  100204. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100205. /**
  100206. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100207. */
  100208. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100209. /** Callback called when a pointer move is detected */
  100210. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100211. /** Callback called when a pointer down is detected */
  100212. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100213. /** Callback called when a pointer up is detected */
  100214. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100215. /** Callback called when a pointer pick is detected */
  100216. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100217. /**
  100218. * 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).
  100219. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100220. */
  100221. onPrePointerObservable: Observable<PointerInfoPre>;
  100222. /**
  100223. * Observable event triggered each time an input event is received from the rendering canvas
  100224. */
  100225. onPointerObservable: Observable<PointerInfo>;
  100226. /**
  100227. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100228. */
  100229. readonly unTranslatedPointer: Vector2;
  100230. /**
  100231. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100232. */
  100233. static DragMovementThreshold: number;
  100234. /**
  100235. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100236. */
  100237. static LongPressDelay: number;
  100238. /**
  100239. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100240. */
  100241. static DoubleClickDelay: number;
  100242. /** If you need to check double click without raising a single click at first click, enable this flag */
  100243. static ExclusiveDoubleClickMode: boolean;
  100244. /** @hidden */
  100245. _mirroredCameraPosition: Nullable<Vector3>;
  100246. /**
  100247. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100248. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100249. */
  100250. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100251. /**
  100252. * Observable event triggered each time an keyboard event is received from the hosting window
  100253. */
  100254. onKeyboardObservable: Observable<KeyboardInfo>;
  100255. private _useRightHandedSystem;
  100256. /**
  100257. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100258. */
  100259. useRightHandedSystem: boolean;
  100260. private _timeAccumulator;
  100261. private _currentStepId;
  100262. private _currentInternalStep;
  100263. /**
  100264. * Sets the step Id used by deterministic lock step
  100265. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100266. * @param newStepId defines the step Id
  100267. */
  100268. setStepId(newStepId: number): void;
  100269. /**
  100270. * Gets the step Id used by deterministic lock step
  100271. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100272. * @returns the step Id
  100273. */
  100274. getStepId(): number;
  100275. /**
  100276. * Gets the internal step used by deterministic lock step
  100277. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100278. * @returns the internal step
  100279. */
  100280. getInternalStep(): number;
  100281. private _fogEnabled;
  100282. /**
  100283. * Gets or sets a boolean indicating if fog is enabled on this scene
  100284. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100285. * (Default is true)
  100286. */
  100287. fogEnabled: boolean;
  100288. private _fogMode;
  100289. /**
  100290. * Gets or sets the fog mode to use
  100291. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100292. * | mode | value |
  100293. * | --- | --- |
  100294. * | FOGMODE_NONE | 0 |
  100295. * | FOGMODE_EXP | 1 |
  100296. * | FOGMODE_EXP2 | 2 |
  100297. * | FOGMODE_LINEAR | 3 |
  100298. */
  100299. fogMode: number;
  100300. /**
  100301. * Gets or sets the fog color to use
  100302. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100303. * (Default is Color3(0.2, 0.2, 0.3))
  100304. */
  100305. fogColor: Color3;
  100306. /**
  100307. * Gets or sets the fog density to use
  100308. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100309. * (Default is 0.1)
  100310. */
  100311. fogDensity: number;
  100312. /**
  100313. * Gets or sets the fog start distance to use
  100314. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100315. * (Default is 0)
  100316. */
  100317. fogStart: number;
  100318. /**
  100319. * Gets or sets the fog end distance to use
  100320. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100321. * (Default is 1000)
  100322. */
  100323. fogEnd: number;
  100324. private _shadowsEnabled;
  100325. /**
  100326. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100327. */
  100328. shadowsEnabled: boolean;
  100329. private _lightsEnabled;
  100330. /**
  100331. * Gets or sets a boolean indicating if lights are enabled on this scene
  100332. */
  100333. lightsEnabled: boolean;
  100334. /** All of the active cameras added to this scene. */
  100335. activeCameras: Camera[];
  100336. /** @hidden */
  100337. _activeCamera: Nullable<Camera>;
  100338. /** Gets or sets the current active camera */
  100339. activeCamera: Nullable<Camera>;
  100340. private _defaultMaterial;
  100341. /** The default material used on meshes when no material is affected */
  100342. /** The default material used on meshes when no material is affected */
  100343. defaultMaterial: Material;
  100344. private _texturesEnabled;
  100345. /**
  100346. * Gets or sets a boolean indicating if textures are enabled on this scene
  100347. */
  100348. texturesEnabled: boolean;
  100349. /**
  100350. * Gets or sets a boolean indicating if particles are enabled on this scene
  100351. */
  100352. particlesEnabled: boolean;
  100353. /**
  100354. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100355. */
  100356. spritesEnabled: boolean;
  100357. private _skeletonsEnabled;
  100358. /**
  100359. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100360. */
  100361. skeletonsEnabled: boolean;
  100362. /**
  100363. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100364. */
  100365. lensFlaresEnabled: boolean;
  100366. /**
  100367. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100369. */
  100370. collisionsEnabled: boolean;
  100371. private _collisionCoordinator;
  100372. /** @hidden */
  100373. readonly collisionCoordinator: ICollisionCoordinator;
  100374. /**
  100375. * Defines the gravity applied to this scene (used only for collisions)
  100376. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100377. */
  100378. gravity: Vector3;
  100379. /**
  100380. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100381. */
  100382. postProcessesEnabled: boolean;
  100383. /**
  100384. * The list of postprocesses added to the scene
  100385. */
  100386. postProcesses: PostProcess[];
  100387. /**
  100388. * Gets the current postprocess manager
  100389. */
  100390. postProcessManager: PostProcessManager;
  100391. /**
  100392. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100393. */
  100394. renderTargetsEnabled: boolean;
  100395. /**
  100396. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100397. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100398. */
  100399. dumpNextRenderTargets: boolean;
  100400. /**
  100401. * The list of user defined render targets added to the scene
  100402. */
  100403. customRenderTargets: RenderTargetTexture[];
  100404. /**
  100405. * Defines if texture loading must be delayed
  100406. * If true, textures will only be loaded when they need to be rendered
  100407. */
  100408. useDelayedTextureLoading: boolean;
  100409. /**
  100410. * Gets the list of meshes imported to the scene through SceneLoader
  100411. */
  100412. importedMeshesFiles: String[];
  100413. /**
  100414. * Gets or sets a boolean indicating if probes are enabled on this scene
  100415. */
  100416. probesEnabled: boolean;
  100417. /**
  100418. * Gets or sets the current offline provider to use to store scene data
  100419. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100420. */
  100421. offlineProvider: IOfflineProvider;
  100422. /**
  100423. * Gets or sets the action manager associated with the scene
  100424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100425. */
  100426. actionManager: AbstractActionManager;
  100427. private _meshesForIntersections;
  100428. /**
  100429. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100430. */
  100431. proceduralTexturesEnabled: boolean;
  100432. private _engine;
  100433. private _totalVertices;
  100434. /** @hidden */
  100435. _activeIndices: PerfCounter;
  100436. /** @hidden */
  100437. _activeParticles: PerfCounter;
  100438. /** @hidden */
  100439. _activeBones: PerfCounter;
  100440. private _animationRatio;
  100441. /** @hidden */
  100442. _animationTimeLast: number;
  100443. /** @hidden */
  100444. _animationTime: number;
  100445. /**
  100446. * Gets or sets a general scale for animation speed
  100447. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100448. */
  100449. animationTimeScale: number;
  100450. /** @hidden */
  100451. _cachedMaterial: Nullable<Material>;
  100452. /** @hidden */
  100453. _cachedEffect: Nullable<Effect>;
  100454. /** @hidden */
  100455. _cachedVisibility: Nullable<number>;
  100456. private _renderId;
  100457. private _frameId;
  100458. private _executeWhenReadyTimeoutId;
  100459. private _intermediateRendering;
  100460. private _viewUpdateFlag;
  100461. private _projectionUpdateFlag;
  100462. /** @hidden */
  100463. _toBeDisposed: Nullable<IDisposable>[];
  100464. private _activeRequests;
  100465. /** @hidden */
  100466. _pendingData: any[];
  100467. private _isDisposed;
  100468. /**
  100469. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100470. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100471. */
  100472. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100473. private _activeMeshes;
  100474. private _processedMaterials;
  100475. private _renderTargets;
  100476. /** @hidden */
  100477. _activeParticleSystems: SmartArray<IParticleSystem>;
  100478. private _activeSkeletons;
  100479. private _softwareSkinnedMeshes;
  100480. private _renderingManager;
  100481. /** @hidden */
  100482. _activeAnimatables: Animatable[];
  100483. private _transformMatrix;
  100484. private _sceneUbo;
  100485. /** @hidden */
  100486. _viewMatrix: Matrix;
  100487. private _projectionMatrix;
  100488. /** @hidden */
  100489. _forcedViewPosition: Nullable<Vector3>;
  100490. /** @hidden */
  100491. _frustumPlanes: Plane[];
  100492. /**
  100493. * Gets the list of frustum planes (built from the active camera)
  100494. */
  100495. readonly frustumPlanes: Plane[];
  100496. /**
  100497. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100498. * This is useful if there are more lights that the maximum simulteanous authorized
  100499. */
  100500. requireLightSorting: boolean;
  100501. /** @hidden */
  100502. readonly useMaterialMeshMap: boolean;
  100503. /** @hidden */
  100504. readonly useClonedMeshhMap: boolean;
  100505. private _externalData;
  100506. private _uid;
  100507. /**
  100508. * @hidden
  100509. * Backing store of defined scene components.
  100510. */
  100511. _components: ISceneComponent[];
  100512. /**
  100513. * @hidden
  100514. * Backing store of defined scene components.
  100515. */
  100516. _serializableComponents: ISceneSerializableComponent[];
  100517. /**
  100518. * List of components to register on the next registration step.
  100519. */
  100520. private _transientComponents;
  100521. /**
  100522. * Registers the transient components if needed.
  100523. */
  100524. private _registerTransientComponents;
  100525. /**
  100526. * @hidden
  100527. * Add a component to the scene.
  100528. * Note that the ccomponent could be registered on th next frame if this is called after
  100529. * the register component stage.
  100530. * @param component Defines the component to add to the scene
  100531. */
  100532. _addComponent(component: ISceneComponent): void;
  100533. /**
  100534. * @hidden
  100535. * Gets a component from the scene.
  100536. * @param name defines the name of the component to retrieve
  100537. * @returns the component or null if not present
  100538. */
  100539. _getComponent(name: string): Nullable<ISceneComponent>;
  100540. /**
  100541. * @hidden
  100542. * Defines the actions happening before camera updates.
  100543. */
  100544. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100545. /**
  100546. * @hidden
  100547. * Defines the actions happening before clear the canvas.
  100548. */
  100549. _beforeClearStage: Stage<SimpleStageAction>;
  100550. /**
  100551. * @hidden
  100552. * Defines the actions when collecting render targets for the frame.
  100553. */
  100554. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100555. /**
  100556. * @hidden
  100557. * Defines the actions happening for one camera in the frame.
  100558. */
  100559. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100560. /**
  100561. * @hidden
  100562. * Defines the actions happening during the per mesh ready checks.
  100563. */
  100564. _isReadyForMeshStage: Stage<MeshStageAction>;
  100565. /**
  100566. * @hidden
  100567. * Defines the actions happening before evaluate active mesh checks.
  100568. */
  100569. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100570. /**
  100571. * @hidden
  100572. * Defines the actions happening during the evaluate sub mesh checks.
  100573. */
  100574. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100575. /**
  100576. * @hidden
  100577. * Defines the actions happening during the active mesh stage.
  100578. */
  100579. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100580. /**
  100581. * @hidden
  100582. * Defines the actions happening during the per camera render target step.
  100583. */
  100584. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100585. /**
  100586. * @hidden
  100587. * Defines the actions happening just before the active camera is drawing.
  100588. */
  100589. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100590. /**
  100591. * @hidden
  100592. * Defines the actions happening just before a render target is drawing.
  100593. */
  100594. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100595. /**
  100596. * @hidden
  100597. * Defines the actions happening just before a rendering group is drawing.
  100598. */
  100599. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100600. /**
  100601. * @hidden
  100602. * Defines the actions happening just before a mesh is drawing.
  100603. */
  100604. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100605. /**
  100606. * @hidden
  100607. * Defines the actions happening just after a mesh has been drawn.
  100608. */
  100609. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100610. /**
  100611. * @hidden
  100612. * Defines the actions happening just after a rendering group has been drawn.
  100613. */
  100614. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100615. /**
  100616. * @hidden
  100617. * Defines the actions happening just after the active camera has been drawn.
  100618. */
  100619. _afterCameraDrawStage: Stage<CameraStageAction>;
  100620. /**
  100621. * @hidden
  100622. * Defines the actions happening just after a render target has been drawn.
  100623. */
  100624. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100625. /**
  100626. * @hidden
  100627. * Defines the actions happening just after rendering all cameras and computing intersections.
  100628. */
  100629. _afterRenderStage: Stage<SimpleStageAction>;
  100630. /**
  100631. * @hidden
  100632. * Defines the actions happening when a pointer move event happens.
  100633. */
  100634. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100635. /**
  100636. * @hidden
  100637. * Defines the actions happening when a pointer down event happens.
  100638. */
  100639. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100640. /**
  100641. * @hidden
  100642. * Defines the actions happening when a pointer up event happens.
  100643. */
  100644. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100645. /**
  100646. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100647. */
  100648. private geometriesByUniqueId;
  100649. /**
  100650. * Creates a new Scene
  100651. * @param engine defines the engine to use to render this scene
  100652. * @param options defines the scene options
  100653. */
  100654. constructor(engine: Engine, options?: SceneOptions);
  100655. /**
  100656. * Gets a string idenfifying the name of the class
  100657. * @returns "Scene" string
  100658. */
  100659. getClassName(): string;
  100660. private _defaultMeshCandidates;
  100661. /**
  100662. * @hidden
  100663. */
  100664. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100665. private _defaultSubMeshCandidates;
  100666. /**
  100667. * @hidden
  100668. */
  100669. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100670. /**
  100671. * Sets the default candidate providers for the scene.
  100672. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100673. * and getCollidingSubMeshCandidates to their default function
  100674. */
  100675. setDefaultCandidateProviders(): void;
  100676. /**
  100677. * Gets the mesh that is currently under the pointer
  100678. */
  100679. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100680. /**
  100681. * Gets or sets the current on-screen X position of the pointer
  100682. */
  100683. pointerX: number;
  100684. /**
  100685. * Gets or sets the current on-screen Y position of the pointer
  100686. */
  100687. pointerY: number;
  100688. /**
  100689. * Gets the cached material (ie. the latest rendered one)
  100690. * @returns the cached material
  100691. */
  100692. getCachedMaterial(): Nullable<Material>;
  100693. /**
  100694. * Gets the cached effect (ie. the latest rendered one)
  100695. * @returns the cached effect
  100696. */
  100697. getCachedEffect(): Nullable<Effect>;
  100698. /**
  100699. * Gets the cached visibility state (ie. the latest rendered one)
  100700. * @returns the cached visibility state
  100701. */
  100702. getCachedVisibility(): Nullable<number>;
  100703. /**
  100704. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100705. * @param material defines the current material
  100706. * @param effect defines the current effect
  100707. * @param visibility defines the current visibility state
  100708. * @returns true if one parameter is not cached
  100709. */
  100710. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100711. /**
  100712. * Gets the engine associated with the scene
  100713. * @returns an Engine
  100714. */
  100715. getEngine(): Engine;
  100716. /**
  100717. * Gets the total number of vertices rendered per frame
  100718. * @returns the total number of vertices rendered per frame
  100719. */
  100720. getTotalVertices(): number;
  100721. /**
  100722. * Gets the performance counter for total vertices
  100723. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100724. */
  100725. readonly totalVerticesPerfCounter: PerfCounter;
  100726. /**
  100727. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100728. * @returns the total number of active indices rendered per frame
  100729. */
  100730. getActiveIndices(): number;
  100731. /**
  100732. * Gets the performance counter for active indices
  100733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100734. */
  100735. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100736. /**
  100737. * Gets the total number of active particles rendered per frame
  100738. * @returns the total number of active particles rendered per frame
  100739. */
  100740. getActiveParticles(): number;
  100741. /**
  100742. * Gets the performance counter for active particles
  100743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100744. */
  100745. readonly activeParticlesPerfCounter: PerfCounter;
  100746. /**
  100747. * Gets the total number of active bones rendered per frame
  100748. * @returns the total number of active bones rendered per frame
  100749. */
  100750. getActiveBones(): number;
  100751. /**
  100752. * Gets the performance counter for active bones
  100753. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100754. */
  100755. readonly activeBonesPerfCounter: PerfCounter;
  100756. /**
  100757. * Gets the array of active meshes
  100758. * @returns an array of AbstractMesh
  100759. */
  100760. getActiveMeshes(): SmartArray<AbstractMesh>;
  100761. /**
  100762. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100763. * @returns a number
  100764. */
  100765. getAnimationRatio(): number;
  100766. /**
  100767. * Gets an unique Id for the current render phase
  100768. * @returns a number
  100769. */
  100770. getRenderId(): number;
  100771. /**
  100772. * Gets an unique Id for the current frame
  100773. * @returns a number
  100774. */
  100775. getFrameId(): number;
  100776. /** Call this function if you want to manually increment the render Id*/
  100777. incrementRenderId(): void;
  100778. private _createUbo;
  100779. /**
  100780. * Use this method to simulate a pointer move on a mesh
  100781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100784. * @returns the current scene
  100785. */
  100786. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100787. /**
  100788. * Use this method to simulate a pointer down on a mesh
  100789. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100790. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100791. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100792. * @returns the current scene
  100793. */
  100794. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100795. /**
  100796. * Use this method to simulate a pointer up on a mesh
  100797. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100798. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100799. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100800. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100801. * @returns the current scene
  100802. */
  100803. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100804. /**
  100805. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100806. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100807. * @returns true if the pointer was captured
  100808. */
  100809. isPointerCaptured(pointerId?: number): boolean;
  100810. /**
  100811. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100812. * @param attachUp defines if you want to attach events to pointerup
  100813. * @param attachDown defines if you want to attach events to pointerdown
  100814. * @param attachMove defines if you want to attach events to pointermove
  100815. */
  100816. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100817. /** Detaches all event handlers*/
  100818. detachControl(): void;
  100819. /**
  100820. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100821. * Delay loaded resources are not taking in account
  100822. * @return true if all required resources are ready
  100823. */
  100824. isReady(): boolean;
  100825. /** Resets all cached information relative to material (including effect and visibility) */
  100826. resetCachedMaterial(): void;
  100827. /**
  100828. * Registers a function to be called before every frame render
  100829. * @param func defines the function to register
  100830. */
  100831. registerBeforeRender(func: () => void): void;
  100832. /**
  100833. * Unregisters a function called before every frame render
  100834. * @param func defines the function to unregister
  100835. */
  100836. unregisterBeforeRender(func: () => void): void;
  100837. /**
  100838. * Registers a function to be called after every frame render
  100839. * @param func defines the function to register
  100840. */
  100841. registerAfterRender(func: () => void): void;
  100842. /**
  100843. * Unregisters a function called after every frame render
  100844. * @param func defines the function to unregister
  100845. */
  100846. unregisterAfterRender(func: () => void): void;
  100847. private _executeOnceBeforeRender;
  100848. /**
  100849. * The provided function will run before render once and will be disposed afterwards.
  100850. * A timeout delay can be provided so that the function will be executed in N ms.
  100851. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100852. * @param func The function to be executed.
  100853. * @param timeout optional delay in ms
  100854. */
  100855. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100856. /** @hidden */
  100857. _addPendingData(data: any): void;
  100858. /** @hidden */
  100859. _removePendingData(data: any): void;
  100860. /**
  100861. * Returns the number of items waiting to be loaded
  100862. * @returns the number of items waiting to be loaded
  100863. */
  100864. getWaitingItemsCount(): number;
  100865. /**
  100866. * Returns a boolean indicating if the scene is still loading data
  100867. */
  100868. readonly isLoading: boolean;
  100869. /**
  100870. * Registers a function to be executed when the scene is ready
  100871. * @param {Function} func - the function to be executed
  100872. */
  100873. executeWhenReady(func: () => void): void;
  100874. /**
  100875. * Returns a promise that resolves when the scene is ready
  100876. * @returns A promise that resolves when the scene is ready
  100877. */
  100878. whenReadyAsync(): Promise<void>;
  100879. /** @hidden */
  100880. _checkIsReady(): void;
  100881. /**
  100882. * Gets all animatable attached to the scene
  100883. */
  100884. readonly animatables: Animatable[];
  100885. /**
  100886. * Resets the last animation time frame.
  100887. * Useful to override when animations start running when loading a scene for the first time.
  100888. */
  100889. resetLastAnimationTimeFrame(): void;
  100890. /**
  100891. * Gets the current view matrix
  100892. * @returns a Matrix
  100893. */
  100894. getViewMatrix(): Matrix;
  100895. /**
  100896. * Gets the current projection matrix
  100897. * @returns a Matrix
  100898. */
  100899. getProjectionMatrix(): Matrix;
  100900. /**
  100901. * Gets the current transform matrix
  100902. * @returns a Matrix made of View * Projection
  100903. */
  100904. getTransformMatrix(): Matrix;
  100905. /**
  100906. * Sets the current transform matrix
  100907. * @param viewL defines the View matrix to use
  100908. * @param projectionL defines the Projection matrix to use
  100909. * @param viewR defines the right View matrix to use (if provided)
  100910. * @param projectionR defines the right Projection matrix to use (if provided)
  100911. */
  100912. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100913. /**
  100914. * Gets the uniform buffer used to store scene data
  100915. * @returns a UniformBuffer
  100916. */
  100917. getSceneUniformBuffer(): UniformBuffer;
  100918. /**
  100919. * Gets an unique (relatively to the current scene) Id
  100920. * @returns an unique number for the scene
  100921. */
  100922. getUniqueId(): number;
  100923. /**
  100924. * Add a mesh to the list of scene's meshes
  100925. * @param newMesh defines the mesh to add
  100926. * @param recursive if all child meshes should also be added to the scene
  100927. */
  100928. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100929. /**
  100930. * Remove a mesh for the list of scene's meshes
  100931. * @param toRemove defines the mesh to remove
  100932. * @param recursive if all child meshes should also be removed from the scene
  100933. * @returns the index where the mesh was in the mesh list
  100934. */
  100935. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100936. /**
  100937. * Add a transform node to the list of scene's transform nodes
  100938. * @param newTransformNode defines the transform node to add
  100939. */
  100940. addTransformNode(newTransformNode: TransformNode): void;
  100941. /**
  100942. * Remove a transform node for the list of scene's transform nodes
  100943. * @param toRemove defines the transform node to remove
  100944. * @returns the index where the transform node was in the transform node list
  100945. */
  100946. removeTransformNode(toRemove: TransformNode): number;
  100947. /**
  100948. * Remove a skeleton for the list of scene's skeletons
  100949. * @param toRemove defines the skeleton to remove
  100950. * @returns the index where the skeleton was in the skeleton list
  100951. */
  100952. removeSkeleton(toRemove: Skeleton): number;
  100953. /**
  100954. * Remove a morph target for the list of scene's morph targets
  100955. * @param toRemove defines the morph target to remove
  100956. * @returns the index where the morph target was in the morph target list
  100957. */
  100958. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100959. /**
  100960. * Remove a light for the list of scene's lights
  100961. * @param toRemove defines the light to remove
  100962. * @returns the index where the light was in the light list
  100963. */
  100964. removeLight(toRemove: Light): number;
  100965. /**
  100966. * Remove a camera for the list of scene's cameras
  100967. * @param toRemove defines the camera to remove
  100968. * @returns the index where the camera was in the camera list
  100969. */
  100970. removeCamera(toRemove: Camera): number;
  100971. /**
  100972. * Remove a particle system for the list of scene's particle systems
  100973. * @param toRemove defines the particle system to remove
  100974. * @returns the index where the particle system was in the particle system list
  100975. */
  100976. removeParticleSystem(toRemove: IParticleSystem): number;
  100977. /**
  100978. * Remove a animation for the list of scene's animations
  100979. * @param toRemove defines the animation to remove
  100980. * @returns the index where the animation was in the animation list
  100981. */
  100982. removeAnimation(toRemove: Animation): number;
  100983. /**
  100984. * Will stop the animation of the given target
  100985. * @param target - the target
  100986. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100987. * @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)
  100988. */
  100989. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100990. /**
  100991. * Removes the given animation group from this scene.
  100992. * @param toRemove The animation group to remove
  100993. * @returns The index of the removed animation group
  100994. */
  100995. removeAnimationGroup(toRemove: AnimationGroup): number;
  100996. /**
  100997. * Removes the given multi-material from this scene.
  100998. * @param toRemove The multi-material to remove
  100999. * @returns The index of the removed multi-material
  101000. */
  101001. removeMultiMaterial(toRemove: MultiMaterial): number;
  101002. /**
  101003. * Removes the given material from this scene.
  101004. * @param toRemove The material to remove
  101005. * @returns The index of the removed material
  101006. */
  101007. removeMaterial(toRemove: Material): number;
  101008. /**
  101009. * Removes the given action manager from this scene.
  101010. * @param toRemove The action manager to remove
  101011. * @returns The index of the removed action manager
  101012. */
  101013. removeActionManager(toRemove: AbstractActionManager): number;
  101014. /**
  101015. * Removes the given texture from this scene.
  101016. * @param toRemove The texture to remove
  101017. * @returns The index of the removed texture
  101018. */
  101019. removeTexture(toRemove: BaseTexture): number;
  101020. /**
  101021. * Adds the given light to this scene
  101022. * @param newLight The light to add
  101023. */
  101024. addLight(newLight: Light): void;
  101025. /**
  101026. * Sorts the list list based on light priorities
  101027. */
  101028. sortLightsByPriority(): void;
  101029. /**
  101030. * Adds the given camera to this scene
  101031. * @param newCamera The camera to add
  101032. */
  101033. addCamera(newCamera: Camera): void;
  101034. /**
  101035. * Adds the given skeleton to this scene
  101036. * @param newSkeleton The skeleton to add
  101037. */
  101038. addSkeleton(newSkeleton: Skeleton): void;
  101039. /**
  101040. * Adds the given particle system to this scene
  101041. * @param newParticleSystem The particle system to add
  101042. */
  101043. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101044. /**
  101045. * Adds the given animation to this scene
  101046. * @param newAnimation The animation to add
  101047. */
  101048. addAnimation(newAnimation: Animation): void;
  101049. /**
  101050. * Adds the given animation group to this scene.
  101051. * @param newAnimationGroup The animation group to add
  101052. */
  101053. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101054. /**
  101055. * Adds the given multi-material to this scene
  101056. * @param newMultiMaterial The multi-material to add
  101057. */
  101058. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101059. /**
  101060. * Adds the given material to this scene
  101061. * @param newMaterial The material to add
  101062. */
  101063. addMaterial(newMaterial: Material): void;
  101064. /**
  101065. * Adds the given morph target to this scene
  101066. * @param newMorphTargetManager The morph target to add
  101067. */
  101068. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101069. /**
  101070. * Adds the given geometry to this scene
  101071. * @param newGeometry The geometry to add
  101072. */
  101073. addGeometry(newGeometry: Geometry): void;
  101074. /**
  101075. * Adds the given action manager to this scene
  101076. * @param newActionManager The action manager to add
  101077. */
  101078. addActionManager(newActionManager: AbstractActionManager): void;
  101079. /**
  101080. * Adds the given texture to this scene.
  101081. * @param newTexture The texture to add
  101082. */
  101083. addTexture(newTexture: BaseTexture): void;
  101084. /**
  101085. * Switch active camera
  101086. * @param newCamera defines the new active camera
  101087. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101088. */
  101089. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101090. /**
  101091. * sets the active camera of the scene using its ID
  101092. * @param id defines the camera's ID
  101093. * @return the new active camera or null if none found.
  101094. */
  101095. setActiveCameraByID(id: string): Nullable<Camera>;
  101096. /**
  101097. * sets the active camera of the scene using its name
  101098. * @param name defines the camera's name
  101099. * @returns the new active camera or null if none found.
  101100. */
  101101. setActiveCameraByName(name: string): Nullable<Camera>;
  101102. /**
  101103. * get an animation group using its name
  101104. * @param name defines the material's name
  101105. * @return the animation group or null if none found.
  101106. */
  101107. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101108. /**
  101109. * Get a material using its unique id
  101110. * @param uniqueId defines the material's unique id
  101111. * @return the material or null if none found.
  101112. */
  101113. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101114. /**
  101115. * get a material using its id
  101116. * @param id defines the material's ID
  101117. * @return the material or null if none found.
  101118. */
  101119. getMaterialByID(id: string): Nullable<Material>;
  101120. /**
  101121. * Gets a the last added material using a given id
  101122. * @param id defines the material's ID
  101123. * @return the last material with the given id or null if none found.
  101124. */
  101125. getLastMaterialByID(id: string): Nullable<Material>;
  101126. /**
  101127. * Gets a material using its name
  101128. * @param name defines the material's name
  101129. * @return the material or null if none found.
  101130. */
  101131. getMaterialByName(name: string): Nullable<Material>;
  101132. /**
  101133. * Get a texture using its unique id
  101134. * @param uniqueId defines the texture's unique id
  101135. * @return the texture or null if none found.
  101136. */
  101137. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101138. /**
  101139. * Gets a camera using its id
  101140. * @param id defines the id to look for
  101141. * @returns the camera or null if not found
  101142. */
  101143. getCameraByID(id: string): Nullable<Camera>;
  101144. /**
  101145. * Gets a camera using its unique id
  101146. * @param uniqueId defines the unique id to look for
  101147. * @returns the camera or null if not found
  101148. */
  101149. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101150. /**
  101151. * Gets a camera using its name
  101152. * @param name defines the camera's name
  101153. * @return the camera or null if none found.
  101154. */
  101155. getCameraByName(name: string): Nullable<Camera>;
  101156. /**
  101157. * Gets a bone using its id
  101158. * @param id defines the bone's id
  101159. * @return the bone or null if not found
  101160. */
  101161. getBoneByID(id: string): Nullable<Bone>;
  101162. /**
  101163. * Gets a bone using its id
  101164. * @param name defines the bone's name
  101165. * @return the bone or null if not found
  101166. */
  101167. getBoneByName(name: string): Nullable<Bone>;
  101168. /**
  101169. * Gets a light node using its name
  101170. * @param name defines the the light's name
  101171. * @return the light or null if none found.
  101172. */
  101173. getLightByName(name: string): Nullable<Light>;
  101174. /**
  101175. * Gets a light node using its id
  101176. * @param id defines the light's id
  101177. * @return the light or null if none found.
  101178. */
  101179. getLightByID(id: string): Nullable<Light>;
  101180. /**
  101181. * Gets a light node using its scene-generated unique ID
  101182. * @param uniqueId defines the light's unique id
  101183. * @return the light or null if none found.
  101184. */
  101185. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101186. /**
  101187. * Gets a particle system by id
  101188. * @param id defines the particle system id
  101189. * @return the corresponding system or null if none found
  101190. */
  101191. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101192. /**
  101193. * Gets a geometry using its ID
  101194. * @param id defines the geometry's id
  101195. * @return the geometry or null if none found.
  101196. */
  101197. getGeometryByID(id: string): Nullable<Geometry>;
  101198. private _getGeometryByUniqueID;
  101199. /**
  101200. * Add a new geometry to this scene
  101201. * @param geometry defines the geometry to be added to the scene.
  101202. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101203. * @return a boolean defining if the geometry was added or not
  101204. */
  101205. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101206. /**
  101207. * Removes an existing geometry
  101208. * @param geometry defines the geometry to be removed from the scene
  101209. * @return a boolean defining if the geometry was removed or not
  101210. */
  101211. removeGeometry(geometry: Geometry): boolean;
  101212. /**
  101213. * Gets the list of geometries attached to the scene
  101214. * @returns an array of Geometry
  101215. */
  101216. getGeometries(): Geometry[];
  101217. /**
  101218. * Gets the first added mesh found of a given ID
  101219. * @param id defines the id to search for
  101220. * @return the mesh found or null if not found at all
  101221. */
  101222. getMeshByID(id: string): Nullable<AbstractMesh>;
  101223. /**
  101224. * Gets a list of meshes using their id
  101225. * @param id defines the id to search for
  101226. * @returns a list of meshes
  101227. */
  101228. getMeshesByID(id: string): Array<AbstractMesh>;
  101229. /**
  101230. * Gets the first added transform node found of a given ID
  101231. * @param id defines the id to search for
  101232. * @return the found transform node or null if not found at all.
  101233. */
  101234. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101235. /**
  101236. * Gets a transform node with its auto-generated unique id
  101237. * @param uniqueId efines the unique id to search for
  101238. * @return the found transform node or null if not found at all.
  101239. */
  101240. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101241. /**
  101242. * Gets a list of transform nodes using their id
  101243. * @param id defines the id to search for
  101244. * @returns a list of transform nodes
  101245. */
  101246. getTransformNodesByID(id: string): Array<TransformNode>;
  101247. /**
  101248. * Gets a mesh with its auto-generated unique id
  101249. * @param uniqueId defines the unique id to search for
  101250. * @return the found mesh or null if not found at all.
  101251. */
  101252. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101253. /**
  101254. * Gets a the last added mesh using a given id
  101255. * @param id defines the id to search for
  101256. * @return the found mesh or null if not found at all.
  101257. */
  101258. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101259. /**
  101260. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101261. * @param id defines the id to search for
  101262. * @return the found node or null if not found at all
  101263. */
  101264. getLastEntryByID(id: string): Nullable<Node>;
  101265. /**
  101266. * Gets a node (Mesh, Camera, Light) using a given id
  101267. * @param id defines the id to search for
  101268. * @return the found node or null if not found at all
  101269. */
  101270. getNodeByID(id: string): Nullable<Node>;
  101271. /**
  101272. * Gets a node (Mesh, Camera, Light) using a given name
  101273. * @param name defines the name to search for
  101274. * @return the found node or null if not found at all.
  101275. */
  101276. getNodeByName(name: string): Nullable<Node>;
  101277. /**
  101278. * Gets a mesh using a given name
  101279. * @param name defines the name to search for
  101280. * @return the found mesh or null if not found at all.
  101281. */
  101282. getMeshByName(name: string): Nullable<AbstractMesh>;
  101283. /**
  101284. * Gets a transform node using a given name
  101285. * @param name defines the name to search for
  101286. * @return the found transform node or null if not found at all.
  101287. */
  101288. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101289. /**
  101290. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101291. * @param id defines the id to search for
  101292. * @return the found skeleton or null if not found at all.
  101293. */
  101294. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101295. /**
  101296. * Gets a skeleton using a given auto generated unique id
  101297. * @param uniqueId defines the unique id to search for
  101298. * @return the found skeleton or null if not found at all.
  101299. */
  101300. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101301. /**
  101302. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101303. * @param id defines the id to search for
  101304. * @return the found skeleton or null if not found at all.
  101305. */
  101306. getSkeletonById(id: string): Nullable<Skeleton>;
  101307. /**
  101308. * Gets a skeleton using a given name
  101309. * @param name defines the name to search for
  101310. * @return the found skeleton or null if not found at all.
  101311. */
  101312. getSkeletonByName(name: string): Nullable<Skeleton>;
  101313. /**
  101314. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101315. * @param id defines the id to search for
  101316. * @return the found morph target manager or null if not found at all.
  101317. */
  101318. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101319. /**
  101320. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101321. * @param id defines the id to search for
  101322. * @return the found morph target or null if not found at all.
  101323. */
  101324. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101325. /**
  101326. * Gets a boolean indicating if the given mesh is active
  101327. * @param mesh defines the mesh to look for
  101328. * @returns true if the mesh is in the active list
  101329. */
  101330. isActiveMesh(mesh: AbstractMesh): boolean;
  101331. /**
  101332. * Return a unique id as a string which can serve as an identifier for the scene
  101333. */
  101334. readonly uid: string;
  101335. /**
  101336. * Add an externaly attached data from its key.
  101337. * This method call will fail and return false, if such key already exists.
  101338. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101339. * @param key the unique key that identifies the data
  101340. * @param data the data object to associate to the key for this Engine instance
  101341. * @return true if no such key were already present and the data was added successfully, false otherwise
  101342. */
  101343. addExternalData<T>(key: string, data: T): boolean;
  101344. /**
  101345. * Get an externaly attached data from its key
  101346. * @param key the unique key that identifies the data
  101347. * @return the associated data, if present (can be null), or undefined if not present
  101348. */
  101349. getExternalData<T>(key: string): Nullable<T>;
  101350. /**
  101351. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101352. * @param key the unique key that identifies the data
  101353. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101354. * @return the associated data, can be null if the factory returned null.
  101355. */
  101356. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101357. /**
  101358. * Remove an externaly attached data from the Engine instance
  101359. * @param key the unique key that identifies the data
  101360. * @return true if the data was successfully removed, false if it doesn't exist
  101361. */
  101362. removeExternalData(key: string): boolean;
  101363. private _evaluateSubMesh;
  101364. /**
  101365. * Clear the processed materials smart array preventing retention point in material dispose.
  101366. */
  101367. freeProcessedMaterials(): void;
  101368. private _preventFreeActiveMeshesAndRenderingGroups;
  101369. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101370. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101371. * when disposing several meshes in a row or a hierarchy of meshes.
  101372. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101373. */
  101374. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101375. /**
  101376. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101377. */
  101378. freeActiveMeshes(): void;
  101379. /**
  101380. * Clear the info related to rendering groups preventing retention points during dispose.
  101381. */
  101382. freeRenderingGroups(): void;
  101383. /** @hidden */
  101384. _isInIntermediateRendering(): boolean;
  101385. /**
  101386. * Lambda returning the list of potentially active meshes.
  101387. */
  101388. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101389. /**
  101390. * Lambda returning the list of potentially active sub meshes.
  101391. */
  101392. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101393. /**
  101394. * Lambda returning the list of potentially intersecting sub meshes.
  101395. */
  101396. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101397. /**
  101398. * Lambda returning the list of potentially colliding sub meshes.
  101399. */
  101400. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101401. private _activeMeshesFrozen;
  101402. /**
  101403. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101404. * @returns the current scene
  101405. */
  101406. freezeActiveMeshes(): Scene;
  101407. /**
  101408. * Use this function to restart evaluating active meshes on every frame
  101409. * @returns the current scene
  101410. */
  101411. unfreezeActiveMeshes(): Scene;
  101412. private _evaluateActiveMeshes;
  101413. private _activeMesh;
  101414. /**
  101415. * Update the transform matrix to update from the current active camera
  101416. * @param force defines a boolean used to force the update even if cache is up to date
  101417. */
  101418. updateTransformMatrix(force?: boolean): void;
  101419. private _bindFrameBuffer;
  101420. /** @hidden */
  101421. _allowPostProcessClearColor: boolean;
  101422. /** @hidden */
  101423. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101424. private _processSubCameras;
  101425. private _checkIntersections;
  101426. /** @hidden */
  101427. _advancePhysicsEngineStep(step: number): void;
  101428. /**
  101429. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101430. */
  101431. getDeterministicFrameTime: () => number;
  101432. /** @hidden */
  101433. _animate(): void;
  101434. /** Execute all animations (for a frame) */
  101435. animate(): void;
  101436. /**
  101437. * Render the scene
  101438. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101439. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101440. */
  101441. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101442. /**
  101443. * Freeze all materials
  101444. * A frozen material will not be updatable but should be faster to render
  101445. */
  101446. freezeMaterials(): void;
  101447. /**
  101448. * Unfreeze all materials
  101449. * A frozen material will not be updatable but should be faster to render
  101450. */
  101451. unfreezeMaterials(): void;
  101452. /**
  101453. * Releases all held ressources
  101454. */
  101455. dispose(): void;
  101456. /**
  101457. * Gets if the scene is already disposed
  101458. */
  101459. readonly isDisposed: boolean;
  101460. /**
  101461. * Call this function to reduce memory footprint of the scene.
  101462. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101463. */
  101464. clearCachedVertexData(): void;
  101465. /**
  101466. * This function will remove the local cached buffer data from texture.
  101467. * It will save memory but will prevent the texture from being rebuilt
  101468. */
  101469. cleanCachedTextureBuffer(): void;
  101470. /**
  101471. * Get the world extend vectors with an optional filter
  101472. *
  101473. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101474. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101475. */
  101476. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101477. min: Vector3;
  101478. max: Vector3;
  101479. };
  101480. /**
  101481. * Creates a ray that can be used to pick in the scene
  101482. * @param x defines the x coordinate of the origin (on-screen)
  101483. * @param y defines the y coordinate of the origin (on-screen)
  101484. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101485. * @param camera defines the camera to use for the picking
  101486. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101487. * @returns a Ray
  101488. */
  101489. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101490. /**
  101491. * Creates a ray that can be used to pick in the scene
  101492. * @param x defines the x coordinate of the origin (on-screen)
  101493. * @param y defines the y coordinate of the origin (on-screen)
  101494. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101495. * @param result defines the ray where to store the picking ray
  101496. * @param camera defines the camera to use for the picking
  101497. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101498. * @returns the current scene
  101499. */
  101500. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101501. /**
  101502. * Creates a ray that can be used to pick in the scene
  101503. * @param x defines the x coordinate of the origin (on-screen)
  101504. * @param y defines the y coordinate of the origin (on-screen)
  101505. * @param camera defines the camera to use for the picking
  101506. * @returns a Ray
  101507. */
  101508. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101509. /**
  101510. * Creates a ray that can be used to pick in the scene
  101511. * @param x defines the x coordinate of the origin (on-screen)
  101512. * @param y defines the y coordinate of the origin (on-screen)
  101513. * @param result defines the ray where to store the picking ray
  101514. * @param camera defines the camera to use for the picking
  101515. * @returns the current scene
  101516. */
  101517. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101518. /** Launch a ray to try to pick a mesh in the scene
  101519. * @param x position on screen
  101520. * @param y position on screen
  101521. * @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
  101522. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101523. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101525. * @returns a PickingInfo
  101526. */
  101527. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101528. /** Use the given ray to pick a mesh in the scene
  101529. * @param ray The ray to use to pick meshes
  101530. * @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
  101531. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101532. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101533. * @returns a PickingInfo
  101534. */
  101535. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101536. /**
  101537. * Launch a ray to try to pick a mesh in the scene
  101538. * @param x X position on screen
  101539. * @param y Y position on screen
  101540. * @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
  101541. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101542. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101543. * @returns an array of PickingInfo
  101544. */
  101545. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101546. /**
  101547. * Launch a ray to try to pick a mesh in the scene
  101548. * @param ray Ray to use
  101549. * @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
  101550. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101551. * @returns an array of PickingInfo
  101552. */
  101553. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101554. /**
  101555. * Force the value of meshUnderPointer
  101556. * @param mesh defines the mesh to use
  101557. */
  101558. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101559. /**
  101560. * Gets the mesh under the pointer
  101561. * @returns a Mesh or null if no mesh is under the pointer
  101562. */
  101563. getPointerOverMesh(): Nullable<AbstractMesh>;
  101564. /** @hidden */
  101565. _rebuildGeometries(): void;
  101566. /** @hidden */
  101567. _rebuildTextures(): void;
  101568. private _getByTags;
  101569. /**
  101570. * Get a list of meshes by tags
  101571. * @param tagsQuery defines the tags query to use
  101572. * @param forEach defines a predicate used to filter results
  101573. * @returns an array of Mesh
  101574. */
  101575. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101576. /**
  101577. * Get a list of cameras by tags
  101578. * @param tagsQuery defines the tags query to use
  101579. * @param forEach defines a predicate used to filter results
  101580. * @returns an array of Camera
  101581. */
  101582. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101583. /**
  101584. * Get a list of lights by tags
  101585. * @param tagsQuery defines the tags query to use
  101586. * @param forEach defines a predicate used to filter results
  101587. * @returns an array of Light
  101588. */
  101589. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101590. /**
  101591. * Get a list of materials by tags
  101592. * @param tagsQuery defines the tags query to use
  101593. * @param forEach defines a predicate used to filter results
  101594. * @returns an array of Material
  101595. */
  101596. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101597. /**
  101598. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101599. * This allowed control for front to back rendering or reversly depending of the special needs.
  101600. *
  101601. * @param renderingGroupId The rendering group id corresponding to its index
  101602. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101603. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101604. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101605. */
  101606. 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;
  101607. /**
  101608. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101609. *
  101610. * @param renderingGroupId The rendering group id corresponding to its index
  101611. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101612. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101613. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101614. */
  101615. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101616. /**
  101617. * Gets the current auto clear configuration for one rendering group of the rendering
  101618. * manager.
  101619. * @param index the rendering group index to get the information for
  101620. * @returns The auto clear setup for the requested rendering group
  101621. */
  101622. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101623. private _blockMaterialDirtyMechanism;
  101624. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101625. blockMaterialDirtyMechanism: boolean;
  101626. /**
  101627. * Will flag all materials as dirty to trigger new shader compilation
  101628. * @param flag defines the flag used to specify which material part must be marked as dirty
  101629. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101630. */
  101631. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101632. /** @hidden */
  101633. _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;
  101634. /** @hidden */
  101635. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101636. }
  101637. }
  101638. declare module BABYLON {
  101639. /**
  101640. * Set of assets to keep when moving a scene into an asset container.
  101641. */
  101642. export class KeepAssets extends AbstractScene {
  101643. }
  101644. /**
  101645. * Container with a set of assets that can be added or removed from a scene.
  101646. */
  101647. export class AssetContainer extends AbstractScene {
  101648. /**
  101649. * The scene the AssetContainer belongs to.
  101650. */
  101651. scene: Scene;
  101652. /**
  101653. * Instantiates an AssetContainer.
  101654. * @param scene The scene the AssetContainer belongs to.
  101655. */
  101656. constructor(scene: Scene);
  101657. /**
  101658. * Adds all the assets from the container to the scene.
  101659. */
  101660. addAllToScene(): void;
  101661. /**
  101662. * Removes all the assets in the container from the scene
  101663. */
  101664. removeAllFromScene(): void;
  101665. /**
  101666. * Disposes all the assets in the container
  101667. */
  101668. dispose(): void;
  101669. private _moveAssets;
  101670. /**
  101671. * Removes all the assets contained in the scene and adds them to the container.
  101672. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101673. */
  101674. moveAllFromScene(keepAssets?: KeepAssets): void;
  101675. /**
  101676. * 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.
  101677. * @returns the root mesh
  101678. */
  101679. createRootMesh(): Mesh;
  101680. }
  101681. }
  101682. declare module BABYLON {
  101683. /**
  101684. * Defines how the parser contract is defined.
  101685. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101686. */
  101687. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101688. /**
  101689. * Defines how the individual parser contract is defined.
  101690. * These parser can parse an individual asset
  101691. */
  101692. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101693. /**
  101694. * Base class of the scene acting as a container for the different elements composing a scene.
  101695. * This class is dynamically extended by the different components of the scene increasing
  101696. * flexibility and reducing coupling
  101697. */
  101698. export abstract class AbstractScene {
  101699. /**
  101700. * Stores the list of available parsers in the application.
  101701. */
  101702. private static _BabylonFileParsers;
  101703. /**
  101704. * Stores the list of available individual parsers in the application.
  101705. */
  101706. private static _IndividualBabylonFileParsers;
  101707. /**
  101708. * Adds a parser in the list of available ones
  101709. * @param name Defines the name of the parser
  101710. * @param parser Defines the parser to add
  101711. */
  101712. static AddParser(name: string, parser: BabylonFileParser): void;
  101713. /**
  101714. * Gets a general parser from the list of avaialble ones
  101715. * @param name Defines the name of the parser
  101716. * @returns the requested parser or null
  101717. */
  101718. static GetParser(name: string): Nullable<BabylonFileParser>;
  101719. /**
  101720. * Adds n individual parser in the list of available ones
  101721. * @param name Defines the name of the parser
  101722. * @param parser Defines the parser to add
  101723. */
  101724. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101725. /**
  101726. * Gets an individual parser from the list of avaialble ones
  101727. * @param name Defines the name of the parser
  101728. * @returns the requested parser or null
  101729. */
  101730. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101731. /**
  101732. * Parser json data and populate both a scene and its associated container object
  101733. * @param jsonData Defines the data to parse
  101734. * @param scene Defines the scene to parse the data for
  101735. * @param container Defines the container attached to the parsing sequence
  101736. * @param rootUrl Defines the root url of the data
  101737. */
  101738. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101739. /**
  101740. * Gets the list of root nodes (ie. nodes with no parent)
  101741. */
  101742. rootNodes: Node[];
  101743. /** All of the cameras added to this scene
  101744. * @see http://doc.babylonjs.com/babylon101/cameras
  101745. */
  101746. cameras: Camera[];
  101747. /**
  101748. * All of the lights added to this scene
  101749. * @see http://doc.babylonjs.com/babylon101/lights
  101750. */
  101751. lights: Light[];
  101752. /**
  101753. * All of the (abstract) meshes added to this scene
  101754. */
  101755. meshes: AbstractMesh[];
  101756. /**
  101757. * The list of skeletons added to the scene
  101758. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101759. */
  101760. skeletons: Skeleton[];
  101761. /**
  101762. * All of the particle systems added to this scene
  101763. * @see http://doc.babylonjs.com/babylon101/particles
  101764. */
  101765. particleSystems: IParticleSystem[];
  101766. /**
  101767. * Gets a list of Animations associated with the scene
  101768. */
  101769. animations: Animation[];
  101770. /**
  101771. * All of the animation groups added to this scene
  101772. * @see http://doc.babylonjs.com/how_to/group
  101773. */
  101774. animationGroups: AnimationGroup[];
  101775. /**
  101776. * All of the multi-materials added to this scene
  101777. * @see http://doc.babylonjs.com/how_to/multi_materials
  101778. */
  101779. multiMaterials: MultiMaterial[];
  101780. /**
  101781. * All of the materials added to this scene
  101782. * In the context of a Scene, it is not supposed to be modified manually.
  101783. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101784. * Note also that the order of the Material wihin the array is not significant and might change.
  101785. * @see http://doc.babylonjs.com/babylon101/materials
  101786. */
  101787. materials: Material[];
  101788. /**
  101789. * The list of morph target managers added to the scene
  101790. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101791. */
  101792. morphTargetManagers: MorphTargetManager[];
  101793. /**
  101794. * The list of geometries used in the scene.
  101795. */
  101796. geometries: Geometry[];
  101797. /**
  101798. * All of the tranform nodes added to this scene
  101799. * In the context of a Scene, it is not supposed to be modified manually.
  101800. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101801. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101802. * @see http://doc.babylonjs.com/how_to/transformnode
  101803. */
  101804. transformNodes: TransformNode[];
  101805. /**
  101806. * ActionManagers available on the scene.
  101807. */
  101808. actionManagers: AbstractActionManager[];
  101809. /**
  101810. * Textures to keep.
  101811. */
  101812. textures: BaseTexture[];
  101813. /**
  101814. * Environment texture for the scene
  101815. */
  101816. environmentTexture: Nullable<BaseTexture>;
  101817. }
  101818. }
  101819. declare module BABYLON {
  101820. /**
  101821. * Interface used to define options for Sound class
  101822. */
  101823. export interface ISoundOptions {
  101824. /**
  101825. * Does the sound autoplay once loaded.
  101826. */
  101827. autoplay?: boolean;
  101828. /**
  101829. * Does the sound loop after it finishes playing once.
  101830. */
  101831. loop?: boolean;
  101832. /**
  101833. * Sound's volume
  101834. */
  101835. volume?: number;
  101836. /**
  101837. * Is it a spatial sound?
  101838. */
  101839. spatialSound?: boolean;
  101840. /**
  101841. * Maximum distance to hear that sound
  101842. */
  101843. maxDistance?: number;
  101844. /**
  101845. * Uses user defined attenuation function
  101846. */
  101847. useCustomAttenuation?: boolean;
  101848. /**
  101849. * Define the roll off factor of spatial sounds.
  101850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101851. */
  101852. rolloffFactor?: number;
  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 distance attenuation model the sound will follow.
  101860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101861. */
  101862. distanceModel?: string;
  101863. /**
  101864. * Defines the playback speed (1 by default)
  101865. */
  101866. playbackRate?: number;
  101867. /**
  101868. * Defines if the sound is from a streaming source
  101869. */
  101870. streaming?: boolean;
  101871. /**
  101872. * Defines an optional length (in seconds) inside the sound file
  101873. */
  101874. length?: number;
  101875. /**
  101876. * Defines an optional offset (in seconds) inside the sound file
  101877. */
  101878. offset?: number;
  101879. /**
  101880. * If true, URLs will not be required to state the audio file codec to use.
  101881. */
  101882. skipCodecCheck?: boolean;
  101883. }
  101884. /**
  101885. * Defines a sound that can be played in the application.
  101886. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101888. */
  101889. export class Sound {
  101890. /**
  101891. * The name of the sound in the scene.
  101892. */
  101893. name: string;
  101894. /**
  101895. * Does the sound autoplay once loaded.
  101896. */
  101897. autoplay: boolean;
  101898. /**
  101899. * Does the sound loop after it finishes playing once.
  101900. */
  101901. loop: boolean;
  101902. /**
  101903. * Does the sound use a custom attenuation curve to simulate the falloff
  101904. * happening when the source gets further away from the camera.
  101905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101906. */
  101907. useCustomAttenuation: boolean;
  101908. /**
  101909. * The sound track id this sound belongs to.
  101910. */
  101911. soundTrackId: number;
  101912. /**
  101913. * Is this sound currently played.
  101914. */
  101915. isPlaying: boolean;
  101916. /**
  101917. * Is this sound currently paused.
  101918. */
  101919. isPaused: boolean;
  101920. /**
  101921. * Does this sound enables spatial sound.
  101922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101923. */
  101924. spatialSound: boolean;
  101925. /**
  101926. * Define the reference distance the sound should be heard perfectly.
  101927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101928. */
  101929. refDistance: number;
  101930. /**
  101931. * Define the roll off factor of spatial sounds.
  101932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101933. */
  101934. rolloffFactor: number;
  101935. /**
  101936. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101938. */
  101939. maxDistance: number;
  101940. /**
  101941. * Define the distance attenuation model the sound will follow.
  101942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101943. */
  101944. distanceModel: string;
  101945. /**
  101946. * @hidden
  101947. * Back Compat
  101948. **/
  101949. onended: () => any;
  101950. /**
  101951. * Observable event when the current playing sound finishes.
  101952. */
  101953. onEndedObservable: Observable<Sound>;
  101954. private _panningModel;
  101955. private _playbackRate;
  101956. private _streaming;
  101957. private _startTime;
  101958. private _startOffset;
  101959. private _position;
  101960. /** @hidden */
  101961. _positionInEmitterSpace: boolean;
  101962. private _localDirection;
  101963. private _volume;
  101964. private _isReadyToPlay;
  101965. private _isDirectional;
  101966. private _readyToPlayCallback;
  101967. private _audioBuffer;
  101968. private _soundSource;
  101969. private _streamingSource;
  101970. private _soundPanner;
  101971. private _soundGain;
  101972. private _inputAudioNode;
  101973. private _outputAudioNode;
  101974. private _coneInnerAngle;
  101975. private _coneOuterAngle;
  101976. private _coneOuterGain;
  101977. private _scene;
  101978. private _connectedTransformNode;
  101979. private _customAttenuationFunction;
  101980. private _registerFunc;
  101981. private _isOutputConnected;
  101982. private _htmlAudioElement;
  101983. private _urlType;
  101984. private _length?;
  101985. private _offset?;
  101986. /** @hidden */
  101987. static _SceneComponentInitialization: (scene: Scene) => void;
  101988. /**
  101989. * Create a sound and attach it to a scene
  101990. * @param name Name of your sound
  101991. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101992. * @param scene defines the scene the sound belongs to
  101993. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101994. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101995. */
  101996. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101997. /**
  101998. * Release the sound and its associated resources
  101999. */
  102000. dispose(): void;
  102001. /**
  102002. * Gets if the sounds is ready to be played or not.
  102003. * @returns true if ready, otherwise false
  102004. */
  102005. isReady(): boolean;
  102006. private _soundLoaded;
  102007. /**
  102008. * Sets the data of the sound from an audiobuffer
  102009. * @param audioBuffer The audioBuffer containing the data
  102010. */
  102011. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102012. /**
  102013. * Updates the current sounds options such as maxdistance, loop...
  102014. * @param options A JSON object containing values named as the object properties
  102015. */
  102016. updateOptions(options: ISoundOptions): void;
  102017. private _createSpatialParameters;
  102018. private _updateSpatialParameters;
  102019. /**
  102020. * Switch the panning model to HRTF:
  102021. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102023. */
  102024. switchPanningModelToHRTF(): void;
  102025. /**
  102026. * Switch the panning model to Equal Power:
  102027. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102029. */
  102030. switchPanningModelToEqualPower(): void;
  102031. private _switchPanningModel;
  102032. /**
  102033. * Connect this sound to a sound track audio node like gain...
  102034. * @param soundTrackAudioNode the sound track audio node to connect to
  102035. */
  102036. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102037. /**
  102038. * Transform this sound into a directional source
  102039. * @param coneInnerAngle Size of the inner cone in degree
  102040. * @param coneOuterAngle Size of the outer cone in degree
  102041. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102042. */
  102043. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102044. /**
  102045. * Gets or sets the inner angle for the directional cone.
  102046. */
  102047. /**
  102048. * Gets or sets the inner angle for the directional cone.
  102049. */
  102050. directionalConeInnerAngle: number;
  102051. /**
  102052. * Gets or sets the outer angle for the directional cone.
  102053. */
  102054. /**
  102055. * Gets or sets the outer angle for the directional cone.
  102056. */
  102057. directionalConeOuterAngle: number;
  102058. /**
  102059. * Sets the position of the emitter if spatial sound is enabled
  102060. * @param newPosition Defines the new posisiton
  102061. */
  102062. setPosition(newPosition: Vector3): void;
  102063. /**
  102064. * Sets the local direction of the emitter if spatial sound is enabled
  102065. * @param newLocalDirection Defines the new local direction
  102066. */
  102067. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102068. private _updateDirection;
  102069. /** @hidden */
  102070. updateDistanceFromListener(): void;
  102071. /**
  102072. * Sets a new custom attenuation function for the sound.
  102073. * @param callback Defines the function used for the attenuation
  102074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102075. */
  102076. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102077. /**
  102078. * Play the sound
  102079. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102080. * @param offset (optional) Start the sound at a specific time in seconds
  102081. * @param length (optional) Sound duration (in seconds)
  102082. */
  102083. play(time?: number, offset?: number, length?: number): void;
  102084. private _onended;
  102085. /**
  102086. * Stop the sound
  102087. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102088. */
  102089. stop(time?: number): void;
  102090. /**
  102091. * Put the sound in pause
  102092. */
  102093. pause(): void;
  102094. /**
  102095. * Sets a dedicated volume for this sounds
  102096. * @param newVolume Define the new volume of the sound
  102097. * @param time Define time for gradual change to new volume
  102098. */
  102099. setVolume(newVolume: number, time?: number): void;
  102100. /**
  102101. * Set the sound play back rate
  102102. * @param newPlaybackRate Define the playback rate the sound should be played at
  102103. */
  102104. setPlaybackRate(newPlaybackRate: number): void;
  102105. /**
  102106. * Gets the volume of the sound.
  102107. * @returns the volume of the sound
  102108. */
  102109. getVolume(): number;
  102110. /**
  102111. * Attach the sound to a dedicated mesh
  102112. * @param transformNode The transform node to connect the sound with
  102113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102114. */
  102115. attachToMesh(transformNode: TransformNode): void;
  102116. /**
  102117. * Detach the sound from the previously attached mesh
  102118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102119. */
  102120. detachFromMesh(): void;
  102121. private _onRegisterAfterWorldMatrixUpdate;
  102122. /**
  102123. * Clone the current sound in the scene.
  102124. * @returns the new sound clone
  102125. */
  102126. clone(): Nullable<Sound>;
  102127. /**
  102128. * Gets the current underlying audio buffer containing the data
  102129. * @returns the audio buffer
  102130. */
  102131. getAudioBuffer(): Nullable<AudioBuffer>;
  102132. /**
  102133. * Serializes the Sound in a JSON representation
  102134. * @returns the JSON representation of the sound
  102135. */
  102136. serialize(): any;
  102137. /**
  102138. * Parse a JSON representation of a sound to innstantiate in a given scene
  102139. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102140. * @param scene Define the scene the new parsed sound should be created in
  102141. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102142. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102143. * @returns the newly parsed sound
  102144. */
  102145. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102146. }
  102147. }
  102148. declare module BABYLON {
  102149. /**
  102150. * This defines an action helpful to play a defined sound on a triggered action.
  102151. */
  102152. export class PlaySoundAction extends Action {
  102153. private _sound;
  102154. /**
  102155. * Instantiate the action
  102156. * @param triggerOptions defines the trigger options
  102157. * @param sound defines the sound to play
  102158. * @param condition defines the trigger related conditions
  102159. */
  102160. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102161. /** @hidden */
  102162. _prepare(): void;
  102163. /**
  102164. * Execute the action and play the sound.
  102165. */
  102166. execute(): void;
  102167. /**
  102168. * Serializes the actions and its related information.
  102169. * @param parent defines the object to serialize in
  102170. * @returns the serialized object
  102171. */
  102172. serialize(parent: any): any;
  102173. }
  102174. /**
  102175. * This defines an action helpful to stop a defined sound on a triggered action.
  102176. */
  102177. export class StopSoundAction extends Action {
  102178. private _sound;
  102179. /**
  102180. * Instantiate the action
  102181. * @param triggerOptions defines the trigger options
  102182. * @param sound defines the sound to stop
  102183. * @param condition defines the trigger related conditions
  102184. */
  102185. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102186. /** @hidden */
  102187. _prepare(): void;
  102188. /**
  102189. * Execute the action and stop the sound.
  102190. */
  102191. execute(): void;
  102192. /**
  102193. * Serializes the actions and its related information.
  102194. * @param parent defines the object to serialize in
  102195. * @returns the serialized object
  102196. */
  102197. serialize(parent: any): any;
  102198. }
  102199. }
  102200. declare module BABYLON {
  102201. /**
  102202. * This defines an action responsible to change the value of a property
  102203. * by interpolating between its current value and the newly set one once triggered.
  102204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102205. */
  102206. export class InterpolateValueAction extends Action {
  102207. /**
  102208. * Defines the path of the property where the value should be interpolated
  102209. */
  102210. propertyPath: string;
  102211. /**
  102212. * Defines the target value at the end of the interpolation.
  102213. */
  102214. value: any;
  102215. /**
  102216. * Defines the time it will take for the property to interpolate to the value.
  102217. */
  102218. duration: number;
  102219. /**
  102220. * Defines if the other scene animations should be stopped when the action has been triggered
  102221. */
  102222. stopOtherAnimations?: boolean;
  102223. /**
  102224. * Defines a callback raised once the interpolation animation has been done.
  102225. */
  102226. onInterpolationDone?: () => void;
  102227. /**
  102228. * Observable triggered once the interpolation animation has been done.
  102229. */
  102230. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102231. private _target;
  102232. private _effectiveTarget;
  102233. private _property;
  102234. /**
  102235. * Instantiate the action
  102236. * @param triggerOptions defines the trigger options
  102237. * @param target defines the object containing the value to interpolate
  102238. * @param propertyPath defines the path to the property in the target object
  102239. * @param value defines the target value at the end of the interpolation
  102240. * @param duration deines the time it will take for the property to interpolate to the value.
  102241. * @param condition defines the trigger related conditions
  102242. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102243. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102244. */
  102245. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102246. /** @hidden */
  102247. _prepare(): void;
  102248. /**
  102249. * Execute the action starts the value interpolation.
  102250. */
  102251. execute(): void;
  102252. /**
  102253. * Serializes the actions and its related information.
  102254. * @param parent defines the object to serialize in
  102255. * @returns the serialized object
  102256. */
  102257. serialize(parent: any): any;
  102258. }
  102259. }
  102260. declare module BABYLON {
  102261. /**
  102262. * Options allowed during the creation of a sound track.
  102263. */
  102264. export interface ISoundTrackOptions {
  102265. /**
  102266. * The volume the sound track should take during creation
  102267. */
  102268. volume?: number;
  102269. /**
  102270. * Define if the sound track is the main sound track of the scene
  102271. */
  102272. mainTrack?: boolean;
  102273. }
  102274. /**
  102275. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102276. * It will be also used in a future release to apply effects on a specific track.
  102277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102278. */
  102279. export class SoundTrack {
  102280. /**
  102281. * The unique identifier of the sound track in the scene.
  102282. */
  102283. id: number;
  102284. /**
  102285. * The list of sounds included in the sound track.
  102286. */
  102287. soundCollection: Array<Sound>;
  102288. private _outputAudioNode;
  102289. private _scene;
  102290. private _isMainTrack;
  102291. private _connectedAnalyser;
  102292. private _options;
  102293. private _isInitialized;
  102294. /**
  102295. * Creates a new sound track.
  102296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102297. * @param scene Define the scene the sound track belongs to
  102298. * @param options
  102299. */
  102300. constructor(scene: Scene, options?: ISoundTrackOptions);
  102301. private _initializeSoundTrackAudioGraph;
  102302. /**
  102303. * Release the sound track and its associated resources
  102304. */
  102305. dispose(): void;
  102306. /**
  102307. * Adds a sound to this sound track
  102308. * @param sound define the cound to add
  102309. * @ignoreNaming
  102310. */
  102311. AddSound(sound: Sound): void;
  102312. /**
  102313. * Removes a sound to this sound track
  102314. * @param sound define the cound to remove
  102315. * @ignoreNaming
  102316. */
  102317. RemoveSound(sound: Sound): void;
  102318. /**
  102319. * Set a global volume for the full sound track.
  102320. * @param newVolume Define the new volume of the sound track
  102321. */
  102322. setVolume(newVolume: number): void;
  102323. /**
  102324. * Switch the panning model to HRTF:
  102325. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102327. */
  102328. switchPanningModelToHRTF(): void;
  102329. /**
  102330. * Switch the panning model to Equal Power:
  102331. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102333. */
  102334. switchPanningModelToEqualPower(): void;
  102335. /**
  102336. * Connect the sound track to an audio analyser allowing some amazing
  102337. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102338. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102339. * @param analyser The analyser to connect to the engine
  102340. */
  102341. connectToAnalyser(analyser: Analyser): void;
  102342. }
  102343. }
  102344. declare module BABYLON {
  102345. interface AbstractScene {
  102346. /**
  102347. * The list of sounds used in the scene.
  102348. */
  102349. sounds: Nullable<Array<Sound>>;
  102350. }
  102351. interface Scene {
  102352. /**
  102353. * @hidden
  102354. * Backing field
  102355. */
  102356. _mainSoundTrack: SoundTrack;
  102357. /**
  102358. * The main sound track played by the scene.
  102359. * It cotains your primary collection of sounds.
  102360. */
  102361. mainSoundTrack: SoundTrack;
  102362. /**
  102363. * The list of sound tracks added to the scene
  102364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102365. */
  102366. soundTracks: Nullable<Array<SoundTrack>>;
  102367. /**
  102368. * Gets a sound using a given name
  102369. * @param name defines the name to search for
  102370. * @return the found sound or null if not found at all.
  102371. */
  102372. getSoundByName(name: string): Nullable<Sound>;
  102373. /**
  102374. * Gets or sets if audio support is enabled
  102375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102376. */
  102377. audioEnabled: boolean;
  102378. /**
  102379. * Gets or sets if audio will be output to headphones
  102380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102381. */
  102382. headphone: boolean;
  102383. /**
  102384. * Gets or sets custom audio listener position provider
  102385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102386. */
  102387. audioListenerPositionProvider: Nullable<() => Vector3>;
  102388. }
  102389. /**
  102390. * Defines the sound scene component responsible to manage any sounds
  102391. * in a given scene.
  102392. */
  102393. export class AudioSceneComponent implements ISceneSerializableComponent {
  102394. /**
  102395. * The component name helpfull to identify the component in the list of scene components.
  102396. */
  102397. readonly name: string;
  102398. /**
  102399. * The scene the component belongs to.
  102400. */
  102401. scene: Scene;
  102402. private _audioEnabled;
  102403. /**
  102404. * Gets whether audio is enabled or not.
  102405. * Please use related enable/disable method to switch state.
  102406. */
  102407. readonly audioEnabled: boolean;
  102408. private _headphone;
  102409. /**
  102410. * Gets whether audio is outputing to headphone or not.
  102411. * Please use the according Switch methods to change output.
  102412. */
  102413. readonly headphone: boolean;
  102414. private _audioListenerPositionProvider;
  102415. /**
  102416. * Gets the current audio listener position provider
  102417. */
  102418. /**
  102419. * Sets a custom listener position for all sounds in the scene
  102420. * By default, this is the position of the first active camera
  102421. */
  102422. audioListenerPositionProvider: Nullable<() => Vector3>;
  102423. /**
  102424. * Creates a new instance of the component for the given scene
  102425. * @param scene Defines the scene to register the component in
  102426. */
  102427. constructor(scene: Scene);
  102428. /**
  102429. * Registers the component in a given scene
  102430. */
  102431. register(): void;
  102432. /**
  102433. * Rebuilds the elements related to this component in case of
  102434. * context lost for instance.
  102435. */
  102436. rebuild(): void;
  102437. /**
  102438. * Serializes the component data to the specified json object
  102439. * @param serializationObject The object to serialize to
  102440. */
  102441. serialize(serializationObject: any): void;
  102442. /**
  102443. * Adds all the elements from the container to the scene
  102444. * @param container the container holding the elements
  102445. */
  102446. addFromContainer(container: AbstractScene): void;
  102447. /**
  102448. * Removes all the elements in the container from the scene
  102449. * @param container contains the elements to remove
  102450. * @param dispose if the removed element should be disposed (default: false)
  102451. */
  102452. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102453. /**
  102454. * Disposes the component and the associated ressources.
  102455. */
  102456. dispose(): void;
  102457. /**
  102458. * Disables audio in the associated scene.
  102459. */
  102460. disableAudio(): void;
  102461. /**
  102462. * Enables audio in the associated scene.
  102463. */
  102464. enableAudio(): void;
  102465. /**
  102466. * Switch audio to headphone output.
  102467. */
  102468. switchAudioModeForHeadphones(): void;
  102469. /**
  102470. * Switch audio to normal speakers.
  102471. */
  102472. switchAudioModeForNormalSpeakers(): void;
  102473. private _afterRender;
  102474. }
  102475. }
  102476. declare module BABYLON {
  102477. /**
  102478. * Wraps one or more Sound objects and selects one with random weight for playback.
  102479. */
  102480. export class WeightedSound {
  102481. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102482. loop: boolean;
  102483. private _coneInnerAngle;
  102484. private _coneOuterAngle;
  102485. private _volume;
  102486. /** A Sound is currently playing. */
  102487. isPlaying: boolean;
  102488. /** A Sound is currently paused. */
  102489. isPaused: boolean;
  102490. private _sounds;
  102491. private _weights;
  102492. private _currentIndex?;
  102493. /**
  102494. * Creates a new WeightedSound from the list of sounds given.
  102495. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102496. * @param sounds Array of Sounds that will be selected from.
  102497. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102498. */
  102499. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102500. /**
  102501. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102502. */
  102503. /**
  102504. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102505. */
  102506. directionalConeInnerAngle: number;
  102507. /**
  102508. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102509. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102510. */
  102511. /**
  102512. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102513. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102514. */
  102515. directionalConeOuterAngle: number;
  102516. /**
  102517. * Playback volume.
  102518. */
  102519. /**
  102520. * Playback volume.
  102521. */
  102522. volume: number;
  102523. private _onended;
  102524. /**
  102525. * Suspend playback
  102526. */
  102527. pause(): void;
  102528. /**
  102529. * Stop playback
  102530. */
  102531. stop(): void;
  102532. /**
  102533. * Start playback.
  102534. * @param startOffset Position the clip head at a specific time in seconds.
  102535. */
  102536. play(startOffset?: number): void;
  102537. }
  102538. }
  102539. declare module BABYLON {
  102540. /**
  102541. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102542. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102543. */
  102544. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102545. /**
  102546. * Gets the name of the behavior.
  102547. */
  102548. readonly name: string;
  102549. /**
  102550. * The easing function used by animations
  102551. */
  102552. static EasingFunction: BackEase;
  102553. /**
  102554. * The easing mode used by animations
  102555. */
  102556. static EasingMode: number;
  102557. /**
  102558. * The duration of the animation, in milliseconds
  102559. */
  102560. transitionDuration: number;
  102561. /**
  102562. * Length of the distance animated by the transition when lower radius is reached
  102563. */
  102564. lowerRadiusTransitionRange: number;
  102565. /**
  102566. * Length of the distance animated by the transition when upper radius is reached
  102567. */
  102568. upperRadiusTransitionRange: number;
  102569. private _autoTransitionRange;
  102570. /**
  102571. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102572. */
  102573. /**
  102574. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102575. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102576. */
  102577. autoTransitionRange: boolean;
  102578. private _attachedCamera;
  102579. private _onAfterCheckInputsObserver;
  102580. private _onMeshTargetChangedObserver;
  102581. /**
  102582. * Initializes the behavior.
  102583. */
  102584. init(): void;
  102585. /**
  102586. * Attaches the behavior to its arc rotate camera.
  102587. * @param camera Defines the camera to attach the behavior to
  102588. */
  102589. attach(camera: ArcRotateCamera): void;
  102590. /**
  102591. * Detaches the behavior from its current arc rotate camera.
  102592. */
  102593. detach(): void;
  102594. private _radiusIsAnimating;
  102595. private _radiusBounceTransition;
  102596. private _animatables;
  102597. private _cachedWheelPrecision;
  102598. /**
  102599. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102600. * @param radiusLimit The limit to check against.
  102601. * @return Bool to indicate if at limit.
  102602. */
  102603. private _isRadiusAtLimit;
  102604. /**
  102605. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102606. * @param radiusDelta The delta by which to animate to. Can be negative.
  102607. */
  102608. private _applyBoundRadiusAnimation;
  102609. /**
  102610. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102611. */
  102612. protected _clearAnimationLocks(): void;
  102613. /**
  102614. * Stops and removes all animations that have been applied to the camera
  102615. */
  102616. stopAllAnimations(): void;
  102617. }
  102618. }
  102619. declare module BABYLON {
  102620. /**
  102621. * 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.
  102622. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102623. */
  102624. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102625. /**
  102626. * Gets the name of the behavior.
  102627. */
  102628. readonly name: string;
  102629. private _mode;
  102630. private _radiusScale;
  102631. private _positionScale;
  102632. private _defaultElevation;
  102633. private _elevationReturnTime;
  102634. private _elevationReturnWaitTime;
  102635. private _zoomStopsAnimation;
  102636. private _framingTime;
  102637. /**
  102638. * The easing function used by animations
  102639. */
  102640. static EasingFunction: ExponentialEase;
  102641. /**
  102642. * The easing mode used by animations
  102643. */
  102644. static EasingMode: number;
  102645. /**
  102646. * Sets the current mode used by the behavior
  102647. */
  102648. /**
  102649. * Gets current mode used by the behavior.
  102650. */
  102651. mode: number;
  102652. /**
  102653. * Sets the scale applied to the radius (1 by default)
  102654. */
  102655. /**
  102656. * Gets the scale applied to the radius
  102657. */
  102658. radiusScale: number;
  102659. /**
  102660. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102661. */
  102662. /**
  102663. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102664. */
  102665. positionScale: number;
  102666. /**
  102667. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102668. * behaviour is triggered, in radians.
  102669. */
  102670. /**
  102671. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102672. * behaviour is triggered, in radians.
  102673. */
  102674. defaultElevation: number;
  102675. /**
  102676. * Sets the time (in milliseconds) taken to return to the default beta position.
  102677. * Negative value indicates camera should not return to default.
  102678. */
  102679. /**
  102680. * Gets the time (in milliseconds) taken to return to the default beta position.
  102681. * Negative value indicates camera should not return to default.
  102682. */
  102683. elevationReturnTime: number;
  102684. /**
  102685. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102686. */
  102687. /**
  102688. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102689. */
  102690. elevationReturnWaitTime: number;
  102691. /**
  102692. * Sets the flag that indicates if user zooming should stop animation.
  102693. */
  102694. /**
  102695. * Gets the flag that indicates if user zooming should stop animation.
  102696. */
  102697. zoomStopsAnimation: boolean;
  102698. /**
  102699. * Sets the transition time when framing the mesh, in milliseconds
  102700. */
  102701. /**
  102702. * Gets the transition time when framing the mesh, in milliseconds
  102703. */
  102704. framingTime: number;
  102705. /**
  102706. * Define if the behavior should automatically change the configured
  102707. * camera limits and sensibilities.
  102708. */
  102709. autoCorrectCameraLimitsAndSensibility: boolean;
  102710. private _onPrePointerObservableObserver;
  102711. private _onAfterCheckInputsObserver;
  102712. private _onMeshTargetChangedObserver;
  102713. private _attachedCamera;
  102714. private _isPointerDown;
  102715. private _lastInteractionTime;
  102716. /**
  102717. * Initializes the behavior.
  102718. */
  102719. init(): void;
  102720. /**
  102721. * Attaches the behavior to its arc rotate camera.
  102722. * @param camera Defines the camera to attach the behavior to
  102723. */
  102724. attach(camera: ArcRotateCamera): void;
  102725. /**
  102726. * Detaches the behavior from its current arc rotate camera.
  102727. */
  102728. detach(): void;
  102729. private _animatables;
  102730. private _betaIsAnimating;
  102731. private _betaTransition;
  102732. private _radiusTransition;
  102733. private _vectorTransition;
  102734. /**
  102735. * Targets the given mesh and updates zoom level accordingly.
  102736. * @param mesh The mesh to target.
  102737. * @param radius Optional. If a cached radius position already exists, overrides default.
  102738. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102739. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102740. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102741. */
  102742. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102743. /**
  102744. * Targets the given mesh with its children and updates zoom level accordingly.
  102745. * @param mesh The mesh to target.
  102746. * @param radius Optional. If a cached radius position already exists, overrides default.
  102747. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102748. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102749. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102750. */
  102751. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102752. /**
  102753. * Targets the given meshes with their children and updates zoom level accordingly.
  102754. * @param meshes The mesh to target.
  102755. * @param radius Optional. If a cached radius position already exists, overrides default.
  102756. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102757. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102758. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102759. */
  102760. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102761. /**
  102762. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102763. * @param minimumWorld Determines the smaller position of the bounding box extend
  102764. * @param maximumWorld Determines the bigger position of the bounding box extend
  102765. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102766. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102767. */
  102768. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102769. /**
  102770. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102771. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102772. * frustum width.
  102773. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102774. * to fully enclose the mesh in the viewing frustum.
  102775. */
  102776. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102777. /**
  102778. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102779. * is automatically returned to its default position (expected to be above ground plane).
  102780. */
  102781. private _maintainCameraAboveGround;
  102782. /**
  102783. * Returns the frustum slope based on the canvas ratio and camera FOV
  102784. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102785. */
  102786. private _getFrustumSlope;
  102787. /**
  102788. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102789. */
  102790. private _clearAnimationLocks;
  102791. /**
  102792. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102793. */
  102794. private _applyUserInteraction;
  102795. /**
  102796. * Stops and removes all animations that have been applied to the camera
  102797. */
  102798. stopAllAnimations(): void;
  102799. /**
  102800. * Gets a value indicating if the user is moving the camera
  102801. */
  102802. readonly isUserIsMoving: boolean;
  102803. /**
  102804. * The camera can move all the way towards the mesh.
  102805. */
  102806. static IgnoreBoundsSizeMode: number;
  102807. /**
  102808. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102809. */
  102810. static FitFrustumSidesMode: number;
  102811. }
  102812. }
  102813. declare module BABYLON {
  102814. /**
  102815. * Base class for Camera Pointer Inputs.
  102816. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102817. * for example usage.
  102818. */
  102819. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102820. /**
  102821. * Defines the camera the input is attached to.
  102822. */
  102823. abstract camera: Camera;
  102824. /**
  102825. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102826. */
  102827. protected _altKey: boolean;
  102828. protected _ctrlKey: boolean;
  102829. protected _metaKey: boolean;
  102830. protected _shiftKey: boolean;
  102831. /**
  102832. * Which mouse buttons were pressed at time of last mouse event.
  102833. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102834. */
  102835. protected _buttonsPressed: number;
  102836. /**
  102837. * Defines the buttons associated with the input to handle camera move.
  102838. */
  102839. buttons: number[];
  102840. /**
  102841. * Attach the input controls to a specific dom element to get the input from.
  102842. * @param element Defines the element the controls should be listened from
  102843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102844. */
  102845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102846. /**
  102847. * Detach the current controls from the specified dom element.
  102848. * @param element Defines the element to stop listening the inputs from
  102849. */
  102850. detachControl(element: Nullable<HTMLElement>): void;
  102851. /**
  102852. * Gets the class name of the current input.
  102853. * @returns the class name
  102854. */
  102855. getClassName(): string;
  102856. /**
  102857. * Get the friendly name associated with the input class.
  102858. * @returns the input friendly name
  102859. */
  102860. getSimpleName(): string;
  102861. /**
  102862. * Called on pointer POINTERDOUBLETAP event.
  102863. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102864. */
  102865. protected onDoubleTap(type: string): void;
  102866. /**
  102867. * Called on pointer POINTERMOVE event if only a single touch is active.
  102868. * Override this method to provide functionality.
  102869. */
  102870. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102871. /**
  102872. * Called on pointer POINTERMOVE event if multiple touches are active.
  102873. * Override this method to provide functionality.
  102874. */
  102875. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102876. /**
  102877. * Called on JS contextmenu event.
  102878. * Override this method to provide functionality.
  102879. */
  102880. protected onContextMenu(evt: PointerEvent): void;
  102881. /**
  102882. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102883. * press.
  102884. * Override this method to provide functionality.
  102885. */
  102886. protected onButtonDown(evt: PointerEvent): void;
  102887. /**
  102888. * Called each time a new POINTERUP event occurs. Ie, for each button
  102889. * release.
  102890. * Override this method to provide functionality.
  102891. */
  102892. protected onButtonUp(evt: PointerEvent): void;
  102893. /**
  102894. * Called when window becomes inactive.
  102895. * Override this method to provide functionality.
  102896. */
  102897. protected onLostFocus(): void;
  102898. private _pointerInput;
  102899. private _observer;
  102900. private _onLostFocus;
  102901. private pointA;
  102902. private pointB;
  102903. }
  102904. }
  102905. declare module BABYLON {
  102906. /**
  102907. * Manage the pointers inputs to control an arc rotate camera.
  102908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102909. */
  102910. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102911. /**
  102912. * Defines the camera the input is attached to.
  102913. */
  102914. camera: ArcRotateCamera;
  102915. /**
  102916. * Gets the class name of the current input.
  102917. * @returns the class name
  102918. */
  102919. getClassName(): string;
  102920. /**
  102921. * Defines the buttons associated with the input to handle camera move.
  102922. */
  102923. buttons: number[];
  102924. /**
  102925. * Defines the pointer angular sensibility along the X axis or how fast is
  102926. * the camera rotating.
  102927. */
  102928. angularSensibilityX: number;
  102929. /**
  102930. * Defines the pointer angular sensibility along the Y axis or how fast is
  102931. * the camera rotating.
  102932. */
  102933. angularSensibilityY: number;
  102934. /**
  102935. * Defines the pointer pinch precision or how fast is the camera zooming.
  102936. */
  102937. pinchPrecision: number;
  102938. /**
  102939. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102940. * from 0.
  102941. * It defines the percentage of current camera.radius to use as delta when
  102942. * pinch zoom is used.
  102943. */
  102944. pinchDeltaPercentage: number;
  102945. /**
  102946. * Defines the pointer panning sensibility or how fast is the camera moving.
  102947. */
  102948. panningSensibility: number;
  102949. /**
  102950. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102951. */
  102952. multiTouchPanning: boolean;
  102953. /**
  102954. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102955. * zoom (pinch) through multitouch.
  102956. */
  102957. multiTouchPanAndZoom: boolean;
  102958. /**
  102959. * Revers pinch action direction.
  102960. */
  102961. pinchInwards: boolean;
  102962. private _isPanClick;
  102963. private _twoFingerActivityCount;
  102964. private _isPinching;
  102965. /**
  102966. * Called on pointer POINTERMOVE event if only a single touch is active.
  102967. */
  102968. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102969. /**
  102970. * Called on pointer POINTERDOUBLETAP event.
  102971. */
  102972. protected onDoubleTap(type: string): void;
  102973. /**
  102974. * Called on pointer POINTERMOVE event if multiple touches are active.
  102975. */
  102976. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102977. /**
  102978. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102979. * press.
  102980. */
  102981. protected onButtonDown(evt: PointerEvent): void;
  102982. /**
  102983. * Called each time a new POINTERUP event occurs. Ie, for each button
  102984. * release.
  102985. */
  102986. protected onButtonUp(evt: PointerEvent): void;
  102987. /**
  102988. * Called when window becomes inactive.
  102989. */
  102990. protected onLostFocus(): void;
  102991. }
  102992. }
  102993. declare module BABYLON {
  102994. /**
  102995. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102997. */
  102998. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102999. /**
  103000. * Defines the camera the input is attached to.
  103001. */
  103002. camera: ArcRotateCamera;
  103003. /**
  103004. * Defines the list of key codes associated with the up action (increase alpha)
  103005. */
  103006. keysUp: number[];
  103007. /**
  103008. * Defines the list of key codes associated with the down action (decrease alpha)
  103009. */
  103010. keysDown: number[];
  103011. /**
  103012. * Defines the list of key codes associated with the left action (increase beta)
  103013. */
  103014. keysLeft: number[];
  103015. /**
  103016. * Defines the list of key codes associated with the right action (decrease beta)
  103017. */
  103018. keysRight: number[];
  103019. /**
  103020. * Defines the list of key codes associated with the reset action.
  103021. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103022. */
  103023. keysReset: number[];
  103024. /**
  103025. * Defines the panning sensibility of the inputs.
  103026. * (How fast is the camera paning)
  103027. */
  103028. panningSensibility: number;
  103029. /**
  103030. * Defines the zooming sensibility of the inputs.
  103031. * (How fast is the camera zooming)
  103032. */
  103033. zoomingSensibility: number;
  103034. /**
  103035. * Defines wether maintaining the alt key down switch the movement mode from
  103036. * orientation to zoom.
  103037. */
  103038. useAltToZoom: boolean;
  103039. /**
  103040. * Rotation speed of the camera
  103041. */
  103042. angularSpeed: number;
  103043. private _keys;
  103044. private _ctrlPressed;
  103045. private _altPressed;
  103046. private _onCanvasBlurObserver;
  103047. private _onKeyboardObserver;
  103048. private _engine;
  103049. private _scene;
  103050. /**
  103051. * Attach the input controls to a specific dom element to get the input from.
  103052. * @param element Defines the element the controls should be listened from
  103053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103054. */
  103055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103056. /**
  103057. * Detach the current controls from the specified dom element.
  103058. * @param element Defines the element to stop listening the inputs from
  103059. */
  103060. detachControl(element: Nullable<HTMLElement>): void;
  103061. /**
  103062. * Update the current camera state depending on the inputs that have been used this frame.
  103063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103064. */
  103065. checkInputs(): void;
  103066. /**
  103067. * Gets the class name of the current intput.
  103068. * @returns the class name
  103069. */
  103070. getClassName(): string;
  103071. /**
  103072. * Get the friendly name associated with the input class.
  103073. * @returns the input friendly name
  103074. */
  103075. getSimpleName(): string;
  103076. }
  103077. }
  103078. declare module BABYLON {
  103079. /**
  103080. * Manage the mouse wheel inputs to control an arc rotate camera.
  103081. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103082. */
  103083. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103084. /**
  103085. * Defines the camera the input is attached to.
  103086. */
  103087. camera: ArcRotateCamera;
  103088. /**
  103089. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103090. */
  103091. wheelPrecision: number;
  103092. /**
  103093. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103094. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103095. */
  103096. wheelDeltaPercentage: number;
  103097. private _wheel;
  103098. private _observer;
  103099. private computeDeltaFromMouseWheelLegacyEvent;
  103100. /**
  103101. * Attach the input controls to a specific dom element to get the input from.
  103102. * @param element Defines the element the controls should be listened from
  103103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103104. */
  103105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103106. /**
  103107. * Detach the current controls from the specified dom element.
  103108. * @param element Defines the element to stop listening the inputs from
  103109. */
  103110. detachControl(element: Nullable<HTMLElement>): void;
  103111. /**
  103112. * Gets the class name of the current intput.
  103113. * @returns the class name
  103114. */
  103115. getClassName(): string;
  103116. /**
  103117. * Get the friendly name associated with the input class.
  103118. * @returns the input friendly name
  103119. */
  103120. getSimpleName(): string;
  103121. }
  103122. }
  103123. declare module BABYLON {
  103124. /**
  103125. * Default Inputs manager for the ArcRotateCamera.
  103126. * It groups all the default supported inputs for ease of use.
  103127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103128. */
  103129. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103130. /**
  103131. * Instantiates a new ArcRotateCameraInputsManager.
  103132. * @param camera Defines the camera the inputs belong to
  103133. */
  103134. constructor(camera: ArcRotateCamera);
  103135. /**
  103136. * Add mouse wheel input support to the input manager.
  103137. * @returns the current input manager
  103138. */
  103139. addMouseWheel(): ArcRotateCameraInputsManager;
  103140. /**
  103141. * Add pointers input support to the input manager.
  103142. * @returns the current input manager
  103143. */
  103144. addPointers(): ArcRotateCameraInputsManager;
  103145. /**
  103146. * Add keyboard input support to the input manager.
  103147. * @returns the current input manager
  103148. */
  103149. addKeyboard(): ArcRotateCameraInputsManager;
  103150. }
  103151. }
  103152. declare module BABYLON {
  103153. /**
  103154. * This represents an orbital type of camera.
  103155. *
  103156. * 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.
  103157. * 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.
  103158. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103159. */
  103160. export class ArcRotateCamera extends TargetCamera {
  103161. /**
  103162. * Defines the rotation angle of the camera along the longitudinal axis.
  103163. */
  103164. alpha: number;
  103165. /**
  103166. * Defines the rotation angle of the camera along the latitudinal axis.
  103167. */
  103168. beta: number;
  103169. /**
  103170. * Defines the radius of the camera from it s target point.
  103171. */
  103172. radius: number;
  103173. protected _target: Vector3;
  103174. protected _targetHost: Nullable<AbstractMesh>;
  103175. /**
  103176. * Defines the target point of the camera.
  103177. * The camera looks towards it form the radius distance.
  103178. */
  103179. target: Vector3;
  103180. /**
  103181. * Define the current local position of the camera in the scene
  103182. */
  103183. position: Vector3;
  103184. protected _upVector: Vector3;
  103185. protected _upToYMatrix: Matrix;
  103186. protected _YToUpMatrix: Matrix;
  103187. /**
  103188. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103189. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103190. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103191. */
  103192. upVector: Vector3;
  103193. /**
  103194. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103195. */
  103196. setMatUp(): void;
  103197. /**
  103198. * Current inertia value on the longitudinal axis.
  103199. * The bigger this number the longer it will take for the camera to stop.
  103200. */
  103201. inertialAlphaOffset: number;
  103202. /**
  103203. * Current inertia value on the latitudinal axis.
  103204. * The bigger this number the longer it will take for the camera to stop.
  103205. */
  103206. inertialBetaOffset: number;
  103207. /**
  103208. * Current inertia value on the radius axis.
  103209. * The bigger this number the longer it will take for the camera to stop.
  103210. */
  103211. inertialRadiusOffset: number;
  103212. /**
  103213. * Minimum allowed angle on the longitudinal axis.
  103214. * This can help limiting how the Camera is able to move in the scene.
  103215. */
  103216. lowerAlphaLimit: Nullable<number>;
  103217. /**
  103218. * Maximum allowed angle on the longitudinal axis.
  103219. * This can help limiting how the Camera is able to move in the scene.
  103220. */
  103221. upperAlphaLimit: Nullable<number>;
  103222. /**
  103223. * Minimum allowed angle on the latitudinal axis.
  103224. * This can help limiting how the Camera is able to move in the scene.
  103225. */
  103226. lowerBetaLimit: number;
  103227. /**
  103228. * Maximum allowed angle on the latitudinal axis.
  103229. * This can help limiting how the Camera is able to move in the scene.
  103230. */
  103231. upperBetaLimit: number;
  103232. /**
  103233. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103234. * This can help limiting how the Camera is able to move in the scene.
  103235. */
  103236. lowerRadiusLimit: Nullable<number>;
  103237. /**
  103238. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103239. * This can help limiting how the Camera is able to move in the scene.
  103240. */
  103241. upperRadiusLimit: Nullable<number>;
  103242. /**
  103243. * Defines the current inertia value used during panning of the camera along the X axis.
  103244. */
  103245. inertialPanningX: number;
  103246. /**
  103247. * Defines the current inertia value used during panning of the camera along the Y axis.
  103248. */
  103249. inertialPanningY: number;
  103250. /**
  103251. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103252. * Basically if your fingers moves away from more than this distance you will be considered
  103253. * in pinch mode.
  103254. */
  103255. pinchToPanMaxDistance: number;
  103256. /**
  103257. * Defines the maximum distance the camera can pan.
  103258. * This could help keeping the cammera always in your scene.
  103259. */
  103260. panningDistanceLimit: Nullable<number>;
  103261. /**
  103262. * Defines the target of the camera before paning.
  103263. */
  103264. panningOriginTarget: Vector3;
  103265. /**
  103266. * Defines the value of the inertia used during panning.
  103267. * 0 would mean stop inertia and one would mean no decelleration at all.
  103268. */
  103269. panningInertia: number;
  103270. /**
  103271. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103272. */
  103273. angularSensibilityX: number;
  103274. /**
  103275. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103276. */
  103277. angularSensibilityY: number;
  103278. /**
  103279. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103280. */
  103281. pinchPrecision: number;
  103282. /**
  103283. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103284. * It will be used instead of pinchDeltaPrecision if different from 0.
  103285. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103286. */
  103287. pinchDeltaPercentage: number;
  103288. /**
  103289. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103290. */
  103291. panningSensibility: number;
  103292. /**
  103293. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103294. */
  103295. keysUp: number[];
  103296. /**
  103297. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103298. */
  103299. keysDown: number[];
  103300. /**
  103301. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103302. */
  103303. keysLeft: number[];
  103304. /**
  103305. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103306. */
  103307. keysRight: number[];
  103308. /**
  103309. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103310. */
  103311. wheelPrecision: number;
  103312. /**
  103313. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103314. * It will be used instead of pinchDeltaPrecision if different from 0.
  103315. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103316. */
  103317. wheelDeltaPercentage: number;
  103318. /**
  103319. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103320. */
  103321. zoomOnFactor: number;
  103322. /**
  103323. * Defines a screen offset for the camera position.
  103324. */
  103325. targetScreenOffset: Vector2;
  103326. /**
  103327. * Allows the camera to be completely reversed.
  103328. * If false the camera can not arrive upside down.
  103329. */
  103330. allowUpsideDown: boolean;
  103331. /**
  103332. * Define if double tap/click is used to restore the previously saved state of the camera.
  103333. */
  103334. useInputToRestoreState: boolean;
  103335. /** @hidden */
  103336. _viewMatrix: Matrix;
  103337. /** @hidden */
  103338. _useCtrlForPanning: boolean;
  103339. /** @hidden */
  103340. _panningMouseButton: number;
  103341. /**
  103342. * Defines the input associated to the camera.
  103343. */
  103344. inputs: ArcRotateCameraInputsManager;
  103345. /** @hidden */
  103346. _reset: () => void;
  103347. /**
  103348. * Defines the allowed panning axis.
  103349. */
  103350. panningAxis: Vector3;
  103351. protected _localDirection: Vector3;
  103352. protected _transformedDirection: Vector3;
  103353. private _bouncingBehavior;
  103354. /**
  103355. * Gets the bouncing behavior of the camera if it has been enabled.
  103356. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103357. */
  103358. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103359. /**
  103360. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103362. */
  103363. useBouncingBehavior: boolean;
  103364. private _framingBehavior;
  103365. /**
  103366. * Gets the framing behavior of the camera if it has been enabled.
  103367. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103368. */
  103369. readonly framingBehavior: Nullable<FramingBehavior>;
  103370. /**
  103371. * Defines if the framing behavior of the camera is enabled on the camera.
  103372. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103373. */
  103374. useFramingBehavior: boolean;
  103375. private _autoRotationBehavior;
  103376. /**
  103377. * Gets the auto rotation behavior of the camera if it has been enabled.
  103378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103379. */
  103380. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103381. /**
  103382. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103384. */
  103385. useAutoRotationBehavior: boolean;
  103386. /**
  103387. * Observable triggered when the mesh target has been changed on the camera.
  103388. */
  103389. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103390. /**
  103391. * Event raised when the camera is colliding with a mesh.
  103392. */
  103393. onCollide: (collidedMesh: AbstractMesh) => void;
  103394. /**
  103395. * Defines whether the camera should check collision with the objects oh the scene.
  103396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103397. */
  103398. checkCollisions: boolean;
  103399. /**
  103400. * Defines the collision radius of the camera.
  103401. * This simulates a sphere around the camera.
  103402. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103403. */
  103404. collisionRadius: Vector3;
  103405. protected _collider: Collider;
  103406. protected _previousPosition: Vector3;
  103407. protected _collisionVelocity: Vector3;
  103408. protected _newPosition: Vector3;
  103409. protected _previousAlpha: number;
  103410. protected _previousBeta: number;
  103411. protected _previousRadius: number;
  103412. protected _collisionTriggered: boolean;
  103413. protected _targetBoundingCenter: Nullable<Vector3>;
  103414. private _computationVector;
  103415. /**
  103416. * Instantiates a new ArcRotateCamera in a given scene
  103417. * @param name Defines the name of the camera
  103418. * @param alpha Defines the camera rotation along the logitudinal axis
  103419. * @param beta Defines the camera rotation along the latitudinal axis
  103420. * @param radius Defines the camera distance from its target
  103421. * @param target Defines the camera target
  103422. * @param scene Defines the scene the camera belongs to
  103423. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103424. */
  103425. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103426. /** @hidden */
  103427. _initCache(): void;
  103428. /** @hidden */
  103429. _updateCache(ignoreParentClass?: boolean): void;
  103430. protected _getTargetPosition(): Vector3;
  103431. private _storedAlpha;
  103432. private _storedBeta;
  103433. private _storedRadius;
  103434. private _storedTarget;
  103435. private _storedTargetScreenOffset;
  103436. /**
  103437. * Stores the current state of the camera (alpha, beta, radius and target)
  103438. * @returns the camera itself
  103439. */
  103440. storeState(): Camera;
  103441. /**
  103442. * @hidden
  103443. * Restored camera state. You must call storeState() first
  103444. */
  103445. _restoreStateValues(): boolean;
  103446. /** @hidden */
  103447. _isSynchronizedViewMatrix(): boolean;
  103448. /**
  103449. * Attached controls to the current camera.
  103450. * @param element Defines the element the controls should be listened from
  103451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103452. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103453. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103454. */
  103455. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103456. /**
  103457. * Detach the current controls from the camera.
  103458. * The camera will stop reacting to inputs.
  103459. * @param element Defines the element to stop listening the inputs from
  103460. */
  103461. detachControl(element: HTMLElement): void;
  103462. /** @hidden */
  103463. _checkInputs(): void;
  103464. protected _checkLimits(): void;
  103465. /**
  103466. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103467. */
  103468. rebuildAnglesAndRadius(): void;
  103469. /**
  103470. * Use a position to define the current camera related information like alpha, beta and radius
  103471. * @param position Defines the position to set the camera at
  103472. */
  103473. setPosition(position: Vector3): void;
  103474. /**
  103475. * Defines the target the camera should look at.
  103476. * This will automatically adapt alpha beta and radius to fit within the new target.
  103477. * @param target Defines the new target as a Vector or a mesh
  103478. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103479. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103480. */
  103481. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103482. /** @hidden */
  103483. _getViewMatrix(): Matrix;
  103484. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103485. /**
  103486. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103487. * @param meshes Defines the mesh to zoom on
  103488. * @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)
  103489. */
  103490. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103491. /**
  103492. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103493. * The target will be changed but the radius
  103494. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103495. * @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)
  103496. */
  103497. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103498. min: Vector3;
  103499. max: Vector3;
  103500. distance: number;
  103501. }, doNotUpdateMaxZ?: boolean): void;
  103502. /**
  103503. * @override
  103504. * Override Camera.createRigCamera
  103505. */
  103506. createRigCamera(name: string, cameraIndex: number): Camera;
  103507. /**
  103508. * @hidden
  103509. * @override
  103510. * Override Camera._updateRigCameras
  103511. */
  103512. _updateRigCameras(): void;
  103513. /**
  103514. * Destroy the camera and release the current resources hold by it.
  103515. */
  103516. dispose(): void;
  103517. /**
  103518. * Gets the current object class name.
  103519. * @return the class name
  103520. */
  103521. getClassName(): string;
  103522. }
  103523. }
  103524. declare module BABYLON {
  103525. /**
  103526. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103527. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103528. */
  103529. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103530. /**
  103531. * Gets the name of the behavior.
  103532. */
  103533. readonly name: string;
  103534. private _zoomStopsAnimation;
  103535. private _idleRotationSpeed;
  103536. private _idleRotationWaitTime;
  103537. private _idleRotationSpinupTime;
  103538. /**
  103539. * Sets the flag that indicates if user zooming should stop animation.
  103540. */
  103541. /**
  103542. * Gets the flag that indicates if user zooming should stop animation.
  103543. */
  103544. zoomStopsAnimation: boolean;
  103545. /**
  103546. * Sets the default speed at which the camera rotates around the model.
  103547. */
  103548. /**
  103549. * Gets the default speed at which the camera rotates around the model.
  103550. */
  103551. idleRotationSpeed: number;
  103552. /**
  103553. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103554. */
  103555. /**
  103556. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103557. */
  103558. idleRotationWaitTime: number;
  103559. /**
  103560. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103561. */
  103562. /**
  103563. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103564. */
  103565. idleRotationSpinupTime: number;
  103566. /**
  103567. * Gets a value indicating if the camera is currently rotating because of this behavior
  103568. */
  103569. readonly rotationInProgress: boolean;
  103570. private _onPrePointerObservableObserver;
  103571. private _onAfterCheckInputsObserver;
  103572. private _attachedCamera;
  103573. private _isPointerDown;
  103574. private _lastFrameTime;
  103575. private _lastInteractionTime;
  103576. private _cameraRotationSpeed;
  103577. /**
  103578. * Initializes the behavior.
  103579. */
  103580. init(): void;
  103581. /**
  103582. * Attaches the behavior to its arc rotate camera.
  103583. * @param camera Defines the camera to attach the behavior to
  103584. */
  103585. attach(camera: ArcRotateCamera): void;
  103586. /**
  103587. * Detaches the behavior from its current arc rotate camera.
  103588. */
  103589. detach(): void;
  103590. /**
  103591. * Returns true if user is scrolling.
  103592. * @return true if user is scrolling.
  103593. */
  103594. private _userIsZooming;
  103595. private _lastFrameRadius;
  103596. private _shouldAnimationStopForInteraction;
  103597. /**
  103598. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103599. */
  103600. private _applyUserInteraction;
  103601. private _userIsMoving;
  103602. }
  103603. }
  103604. declare module BABYLON {
  103605. /**
  103606. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103607. */
  103608. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103609. private ui;
  103610. /**
  103611. * The name of the behavior
  103612. */
  103613. name: string;
  103614. /**
  103615. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103616. */
  103617. distanceAwayFromFace: number;
  103618. /**
  103619. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103620. */
  103621. distanceAwayFromBottomOfFace: number;
  103622. private _faceVectors;
  103623. private _target;
  103624. private _scene;
  103625. private _onRenderObserver;
  103626. private _tmpMatrix;
  103627. private _tmpVector;
  103628. /**
  103629. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103630. * @param ui The transform node that should be attched to the mesh
  103631. */
  103632. constructor(ui: TransformNode);
  103633. /**
  103634. * Initializes the behavior
  103635. */
  103636. init(): void;
  103637. private _closestFace;
  103638. private _zeroVector;
  103639. private _lookAtTmpMatrix;
  103640. private _lookAtToRef;
  103641. /**
  103642. * Attaches the AttachToBoxBehavior to the passed in mesh
  103643. * @param target The mesh that the specified node will be attached to
  103644. */
  103645. attach(target: Mesh): void;
  103646. /**
  103647. * Detaches the behavior from the mesh
  103648. */
  103649. detach(): void;
  103650. }
  103651. }
  103652. declare module BABYLON {
  103653. /**
  103654. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103655. */
  103656. export class FadeInOutBehavior implements Behavior<Mesh> {
  103657. /**
  103658. * Time in milliseconds to delay before fading in (Default: 0)
  103659. */
  103660. delay: number;
  103661. /**
  103662. * Time in milliseconds for the mesh to fade in (Default: 300)
  103663. */
  103664. fadeInTime: number;
  103665. private _millisecondsPerFrame;
  103666. private _hovered;
  103667. private _hoverValue;
  103668. private _ownerNode;
  103669. /**
  103670. * Instatiates the FadeInOutBehavior
  103671. */
  103672. constructor();
  103673. /**
  103674. * The name of the behavior
  103675. */
  103676. readonly name: string;
  103677. /**
  103678. * Initializes the behavior
  103679. */
  103680. init(): void;
  103681. /**
  103682. * Attaches the fade behavior on the passed in mesh
  103683. * @param ownerNode The mesh that will be faded in/out once attached
  103684. */
  103685. attach(ownerNode: Mesh): void;
  103686. /**
  103687. * Detaches the behavior from the mesh
  103688. */
  103689. detach(): void;
  103690. /**
  103691. * Triggers the mesh to begin fading in or out
  103692. * @param value if the object should fade in or out (true to fade in)
  103693. */
  103694. fadeIn(value: boolean): void;
  103695. private _update;
  103696. private _setAllVisibility;
  103697. }
  103698. }
  103699. declare module BABYLON {
  103700. /**
  103701. * Class containing a set of static utilities functions for managing Pivots
  103702. * @hidden
  103703. */
  103704. export class PivotTools {
  103705. private static _PivotCached;
  103706. private static _OldPivotPoint;
  103707. private static _PivotTranslation;
  103708. private static _PivotTmpVector;
  103709. /** @hidden */
  103710. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103711. /** @hidden */
  103712. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103713. }
  103714. }
  103715. declare module BABYLON {
  103716. /**
  103717. * Class containing static functions to help procedurally build meshes
  103718. */
  103719. export class PlaneBuilder {
  103720. /**
  103721. * Creates a plane mesh
  103722. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103723. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103724. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103728. * @param name defines the name of the mesh
  103729. * @param options defines the options used to create the mesh
  103730. * @param scene defines the hosting scene
  103731. * @returns the plane mesh
  103732. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103733. */
  103734. static CreatePlane(name: string, options: {
  103735. size?: number;
  103736. width?: number;
  103737. height?: number;
  103738. sideOrientation?: number;
  103739. frontUVs?: Vector4;
  103740. backUVs?: Vector4;
  103741. updatable?: boolean;
  103742. sourcePlane?: Plane;
  103743. }, scene?: Nullable<Scene>): Mesh;
  103744. }
  103745. }
  103746. declare module BABYLON {
  103747. /**
  103748. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103749. */
  103750. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103751. private static _AnyMouseID;
  103752. /**
  103753. * Abstract mesh the behavior is set on
  103754. */
  103755. attachedNode: AbstractMesh;
  103756. private _dragPlane;
  103757. private _scene;
  103758. private _pointerObserver;
  103759. private _beforeRenderObserver;
  103760. private static _planeScene;
  103761. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103762. /**
  103763. * 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)
  103764. */
  103765. maxDragAngle: number;
  103766. /**
  103767. * @hidden
  103768. */
  103769. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103770. /**
  103771. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103772. */
  103773. currentDraggingPointerID: number;
  103774. /**
  103775. * The last position where the pointer hit the drag plane in world space
  103776. */
  103777. lastDragPosition: Vector3;
  103778. /**
  103779. * If the behavior is currently in a dragging state
  103780. */
  103781. dragging: boolean;
  103782. /**
  103783. * 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)
  103784. */
  103785. dragDeltaRatio: number;
  103786. /**
  103787. * If the drag plane orientation should be updated during the dragging (Default: true)
  103788. */
  103789. updateDragPlane: boolean;
  103790. private _debugMode;
  103791. private _moving;
  103792. /**
  103793. * Fires each time the attached mesh is dragged with the pointer
  103794. * * delta between last drag position and current drag position in world space
  103795. * * dragDistance along the drag axis
  103796. * * dragPlaneNormal normal of the current drag plane used during the drag
  103797. * * dragPlanePoint in world space where the drag intersects the drag plane
  103798. */
  103799. onDragObservable: Observable<{
  103800. delta: Vector3;
  103801. dragPlanePoint: Vector3;
  103802. dragPlaneNormal: Vector3;
  103803. dragDistance: number;
  103804. pointerId: number;
  103805. }>;
  103806. /**
  103807. * Fires each time a drag begins (eg. mouse down on mesh)
  103808. */
  103809. onDragStartObservable: Observable<{
  103810. dragPlanePoint: Vector3;
  103811. pointerId: number;
  103812. }>;
  103813. /**
  103814. * Fires each time a drag ends (eg. mouse release after drag)
  103815. */
  103816. onDragEndObservable: Observable<{
  103817. dragPlanePoint: Vector3;
  103818. pointerId: number;
  103819. }>;
  103820. /**
  103821. * If the attached mesh should be moved when dragged
  103822. */
  103823. moveAttached: boolean;
  103824. /**
  103825. * If the drag behavior will react to drag events (Default: true)
  103826. */
  103827. enabled: boolean;
  103828. /**
  103829. * If pointer events should start and release the drag (Default: true)
  103830. */
  103831. startAndReleaseDragOnPointerEvents: boolean;
  103832. /**
  103833. * If camera controls should be detached during the drag
  103834. */
  103835. detachCameraControls: boolean;
  103836. /**
  103837. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103838. */
  103839. useObjectOrienationForDragging: boolean;
  103840. private _options;
  103841. /**
  103842. * Creates a pointer drag behavior that can be attached to a mesh
  103843. * @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)
  103844. */
  103845. constructor(options?: {
  103846. dragAxis?: Vector3;
  103847. dragPlaneNormal?: Vector3;
  103848. });
  103849. /**
  103850. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103851. */
  103852. validateDrag: (targetPosition: Vector3) => boolean;
  103853. /**
  103854. * The name of the behavior
  103855. */
  103856. readonly name: string;
  103857. /**
  103858. * Initializes the behavior
  103859. */
  103860. init(): void;
  103861. private _tmpVector;
  103862. private _alternatePickedPoint;
  103863. private _worldDragAxis;
  103864. private _targetPosition;
  103865. private _attachedElement;
  103866. /**
  103867. * Attaches the drag behavior the passed in mesh
  103868. * @param ownerNode The mesh that will be dragged around once attached
  103869. * @param predicate Predicate to use for pick filtering
  103870. */
  103871. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103872. /**
  103873. * Force relase the drag action by code.
  103874. */
  103875. releaseDrag(): void;
  103876. private _startDragRay;
  103877. private _lastPointerRay;
  103878. /**
  103879. * Simulates the start of a pointer drag event on the behavior
  103880. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103881. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103882. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103883. */
  103884. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103885. private _startDrag;
  103886. private _dragDelta;
  103887. private _moveDrag;
  103888. private _pickWithRayOnDragPlane;
  103889. private _pointA;
  103890. private _pointB;
  103891. private _pointC;
  103892. private _lineA;
  103893. private _lineB;
  103894. private _localAxis;
  103895. private _lookAt;
  103896. private _updateDragPlanePosition;
  103897. /**
  103898. * Detaches the behavior from the mesh
  103899. */
  103900. detach(): void;
  103901. }
  103902. }
  103903. declare module BABYLON {
  103904. /**
  103905. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103906. */
  103907. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103908. private _dragBehaviorA;
  103909. private _dragBehaviorB;
  103910. private _startDistance;
  103911. private _initialScale;
  103912. private _targetScale;
  103913. private _ownerNode;
  103914. private _sceneRenderObserver;
  103915. /**
  103916. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103917. */
  103918. constructor();
  103919. /**
  103920. * The name of the behavior
  103921. */
  103922. readonly name: string;
  103923. /**
  103924. * Initializes the behavior
  103925. */
  103926. init(): void;
  103927. private _getCurrentDistance;
  103928. /**
  103929. * Attaches the scale behavior the passed in mesh
  103930. * @param ownerNode The mesh that will be scaled around once attached
  103931. */
  103932. attach(ownerNode: Mesh): void;
  103933. /**
  103934. * Detaches the behavior from the mesh
  103935. */
  103936. detach(): void;
  103937. }
  103938. }
  103939. declare module BABYLON {
  103940. /**
  103941. * 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
  103942. */
  103943. export class SixDofDragBehavior implements Behavior<Mesh> {
  103944. private static _virtualScene;
  103945. private _ownerNode;
  103946. private _sceneRenderObserver;
  103947. private _scene;
  103948. private _targetPosition;
  103949. private _virtualOriginMesh;
  103950. private _virtualDragMesh;
  103951. private _pointerObserver;
  103952. private _moving;
  103953. private _startingOrientation;
  103954. /**
  103955. * 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)
  103956. */
  103957. private zDragFactor;
  103958. /**
  103959. * If the object should rotate to face the drag origin
  103960. */
  103961. rotateDraggedObject: boolean;
  103962. /**
  103963. * If the behavior is currently in a dragging state
  103964. */
  103965. dragging: boolean;
  103966. /**
  103967. * 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)
  103968. */
  103969. dragDeltaRatio: number;
  103970. /**
  103971. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103972. */
  103973. currentDraggingPointerID: number;
  103974. /**
  103975. * If camera controls should be detached during the drag
  103976. */
  103977. detachCameraControls: boolean;
  103978. /**
  103979. * Fires each time a drag starts
  103980. */
  103981. onDragStartObservable: Observable<{}>;
  103982. /**
  103983. * Fires each time a drag ends (eg. mouse release after drag)
  103984. */
  103985. onDragEndObservable: Observable<{}>;
  103986. /**
  103987. * 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
  103988. */
  103989. constructor();
  103990. /**
  103991. * The name of the behavior
  103992. */
  103993. readonly name: string;
  103994. /**
  103995. * Initializes the behavior
  103996. */
  103997. init(): void;
  103998. /**
  103999. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104000. */
  104001. private readonly _pointerCamera;
  104002. /**
  104003. * Attaches the scale behavior the passed in mesh
  104004. * @param ownerNode The mesh that will be scaled around once attached
  104005. */
  104006. attach(ownerNode: Mesh): void;
  104007. /**
  104008. * Detaches the behavior from the mesh
  104009. */
  104010. detach(): void;
  104011. }
  104012. }
  104013. declare module BABYLON {
  104014. /**
  104015. * Class used to apply inverse kinematics to bones
  104016. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104017. */
  104018. export class BoneIKController {
  104019. private static _tmpVecs;
  104020. private static _tmpQuat;
  104021. private static _tmpMats;
  104022. /**
  104023. * Gets or sets the target mesh
  104024. */
  104025. targetMesh: AbstractMesh;
  104026. /** Gets or sets the mesh used as pole */
  104027. poleTargetMesh: AbstractMesh;
  104028. /**
  104029. * Gets or sets the bone used as pole
  104030. */
  104031. poleTargetBone: Nullable<Bone>;
  104032. /**
  104033. * Gets or sets the target position
  104034. */
  104035. targetPosition: Vector3;
  104036. /**
  104037. * Gets or sets the pole target position
  104038. */
  104039. poleTargetPosition: Vector3;
  104040. /**
  104041. * Gets or sets the pole target local offset
  104042. */
  104043. poleTargetLocalOffset: Vector3;
  104044. /**
  104045. * Gets or sets the pole angle
  104046. */
  104047. poleAngle: number;
  104048. /**
  104049. * Gets or sets the mesh associated with the controller
  104050. */
  104051. mesh: AbstractMesh;
  104052. /**
  104053. * 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)
  104054. */
  104055. slerpAmount: number;
  104056. private _bone1Quat;
  104057. private _bone1Mat;
  104058. private _bone2Ang;
  104059. private _bone1;
  104060. private _bone2;
  104061. private _bone1Length;
  104062. private _bone2Length;
  104063. private _maxAngle;
  104064. private _maxReach;
  104065. private _rightHandedSystem;
  104066. private _bendAxis;
  104067. private _slerping;
  104068. private _adjustRoll;
  104069. /**
  104070. * Gets or sets maximum allowed angle
  104071. */
  104072. maxAngle: number;
  104073. /**
  104074. * Creates a new BoneIKController
  104075. * @param mesh defines the mesh to control
  104076. * @param bone defines the bone to control
  104077. * @param options defines options to set up the controller
  104078. */
  104079. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104080. targetMesh?: AbstractMesh;
  104081. poleTargetMesh?: AbstractMesh;
  104082. poleTargetBone?: Bone;
  104083. poleTargetLocalOffset?: Vector3;
  104084. poleAngle?: number;
  104085. bendAxis?: Vector3;
  104086. maxAngle?: number;
  104087. slerpAmount?: number;
  104088. });
  104089. private _setMaxAngle;
  104090. /**
  104091. * Force the controller to update the bones
  104092. */
  104093. update(): void;
  104094. }
  104095. }
  104096. declare module BABYLON {
  104097. /**
  104098. * Class used to make a bone look toward a point in space
  104099. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104100. */
  104101. export class BoneLookController {
  104102. private static _tmpVecs;
  104103. private static _tmpQuat;
  104104. private static _tmpMats;
  104105. /**
  104106. * The target Vector3 that the bone will look at
  104107. */
  104108. target: Vector3;
  104109. /**
  104110. * The mesh that the bone is attached to
  104111. */
  104112. mesh: AbstractMesh;
  104113. /**
  104114. * The bone that will be looking to the target
  104115. */
  104116. bone: Bone;
  104117. /**
  104118. * The up axis of the coordinate system that is used when the bone is rotated
  104119. */
  104120. upAxis: Vector3;
  104121. /**
  104122. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104123. */
  104124. upAxisSpace: Space;
  104125. /**
  104126. * Used to make an adjustment to the yaw of the bone
  104127. */
  104128. adjustYaw: number;
  104129. /**
  104130. * Used to make an adjustment to the pitch of the bone
  104131. */
  104132. adjustPitch: number;
  104133. /**
  104134. * Used to make an adjustment to the roll of the bone
  104135. */
  104136. adjustRoll: number;
  104137. /**
  104138. * 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)
  104139. */
  104140. slerpAmount: number;
  104141. private _minYaw;
  104142. private _maxYaw;
  104143. private _minPitch;
  104144. private _maxPitch;
  104145. private _minYawSin;
  104146. private _minYawCos;
  104147. private _maxYawSin;
  104148. private _maxYawCos;
  104149. private _midYawConstraint;
  104150. private _minPitchTan;
  104151. private _maxPitchTan;
  104152. private _boneQuat;
  104153. private _slerping;
  104154. private _transformYawPitch;
  104155. private _transformYawPitchInv;
  104156. private _firstFrameSkipped;
  104157. private _yawRange;
  104158. private _fowardAxis;
  104159. /**
  104160. * Gets or sets the minimum yaw angle that the bone can look to
  104161. */
  104162. minYaw: number;
  104163. /**
  104164. * Gets or sets the maximum yaw angle that the bone can look to
  104165. */
  104166. maxYaw: number;
  104167. /**
  104168. * Gets or sets the minimum pitch angle that the bone can look to
  104169. */
  104170. minPitch: number;
  104171. /**
  104172. * Gets or sets the maximum pitch angle that the bone can look to
  104173. */
  104174. maxPitch: number;
  104175. /**
  104176. * Create a BoneLookController
  104177. * @param mesh the mesh that the bone belongs to
  104178. * @param bone the bone that will be looking to the target
  104179. * @param target the target Vector3 to look at
  104180. * @param options optional settings:
  104181. * * maxYaw: the maximum angle the bone will yaw to
  104182. * * minYaw: the minimum angle the bone will yaw to
  104183. * * maxPitch: the maximum angle the bone will pitch to
  104184. * * minPitch: the minimum angle the bone will yaw to
  104185. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104186. * * upAxis: the up axis of the coordinate system
  104187. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104188. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104189. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104190. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104191. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104192. * * adjustRoll: used to make an adjustment to the roll of the bone
  104193. **/
  104194. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104195. maxYaw?: number;
  104196. minYaw?: number;
  104197. maxPitch?: number;
  104198. minPitch?: number;
  104199. slerpAmount?: number;
  104200. upAxis?: Vector3;
  104201. upAxisSpace?: Space;
  104202. yawAxis?: Vector3;
  104203. pitchAxis?: Vector3;
  104204. adjustYaw?: number;
  104205. adjustPitch?: number;
  104206. adjustRoll?: number;
  104207. });
  104208. /**
  104209. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104210. */
  104211. update(): void;
  104212. private _getAngleDiff;
  104213. private _getAngleBetween;
  104214. private _isAngleBetween;
  104215. }
  104216. }
  104217. declare module BABYLON {
  104218. /**
  104219. * Manage the gamepad inputs to control an arc rotate camera.
  104220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104221. */
  104222. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104223. /**
  104224. * Defines the camera the input is attached to.
  104225. */
  104226. camera: ArcRotateCamera;
  104227. /**
  104228. * Defines the gamepad the input is gathering event from.
  104229. */
  104230. gamepad: Nullable<Gamepad>;
  104231. /**
  104232. * Defines the gamepad rotation sensiblity.
  104233. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104234. */
  104235. gamepadRotationSensibility: number;
  104236. /**
  104237. * Defines the gamepad move sensiblity.
  104238. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104239. */
  104240. gamepadMoveSensibility: number;
  104241. private _onGamepadConnectedObserver;
  104242. private _onGamepadDisconnectedObserver;
  104243. /**
  104244. * Attach the input controls to a specific dom element to get the input from.
  104245. * @param element Defines the element the controls should be listened from
  104246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104247. */
  104248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104249. /**
  104250. * Detach the current controls from the specified dom element.
  104251. * @param element Defines the element to stop listening the inputs from
  104252. */
  104253. detachControl(element: Nullable<HTMLElement>): void;
  104254. /**
  104255. * Update the current camera state depending on the inputs that have been used this frame.
  104256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104257. */
  104258. checkInputs(): void;
  104259. /**
  104260. * Gets the class name of the current intput.
  104261. * @returns the class name
  104262. */
  104263. getClassName(): string;
  104264. /**
  104265. * Get the friendly name associated with the input class.
  104266. * @returns the input friendly name
  104267. */
  104268. getSimpleName(): string;
  104269. }
  104270. }
  104271. declare module BABYLON {
  104272. interface ArcRotateCameraInputsManager {
  104273. /**
  104274. * Add orientation input support to the input manager.
  104275. * @returns the current input manager
  104276. */
  104277. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104278. }
  104279. /**
  104280. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104282. */
  104283. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104284. /**
  104285. * Defines the camera the input is attached to.
  104286. */
  104287. camera: ArcRotateCamera;
  104288. /**
  104289. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104290. */
  104291. alphaCorrection: number;
  104292. /**
  104293. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104294. */
  104295. gammaCorrection: number;
  104296. private _alpha;
  104297. private _gamma;
  104298. private _dirty;
  104299. private _deviceOrientationHandler;
  104300. /**
  104301. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104302. */
  104303. constructor();
  104304. /**
  104305. * Attach the input controls to a specific dom element to get the input from.
  104306. * @param element Defines the element the controls should be listened from
  104307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104308. */
  104309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104310. /** @hidden */
  104311. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104312. /**
  104313. * Update the current camera state depending on the inputs that have been used this frame.
  104314. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104315. */
  104316. checkInputs(): void;
  104317. /**
  104318. * Detach the current controls from the specified dom element.
  104319. * @param element Defines the element to stop listening the inputs from
  104320. */
  104321. detachControl(element: Nullable<HTMLElement>): void;
  104322. /**
  104323. * Gets the class name of the current intput.
  104324. * @returns the class name
  104325. */
  104326. getClassName(): string;
  104327. /**
  104328. * Get the friendly name associated with the input class.
  104329. * @returns the input friendly name
  104330. */
  104331. getSimpleName(): string;
  104332. }
  104333. }
  104334. declare module BABYLON {
  104335. /**
  104336. * Listen to mouse events to control the camera.
  104337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104338. */
  104339. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104340. /**
  104341. * Defines the camera the input is attached to.
  104342. */
  104343. camera: FlyCamera;
  104344. /**
  104345. * Defines if touch is enabled. (Default is true.)
  104346. */
  104347. touchEnabled: boolean;
  104348. /**
  104349. * Defines the buttons associated with the input to handle camera rotation.
  104350. */
  104351. buttons: number[];
  104352. /**
  104353. * Assign buttons for Yaw control.
  104354. */
  104355. buttonsYaw: number[];
  104356. /**
  104357. * Assign buttons for Pitch control.
  104358. */
  104359. buttonsPitch: number[];
  104360. /**
  104361. * Assign buttons for Roll control.
  104362. */
  104363. buttonsRoll: number[];
  104364. /**
  104365. * Detect if any button is being pressed while mouse is moved.
  104366. * -1 = Mouse locked.
  104367. * 0 = Left button.
  104368. * 1 = Middle Button.
  104369. * 2 = Right Button.
  104370. */
  104371. activeButton: number;
  104372. /**
  104373. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104374. * Higher values reduce its sensitivity.
  104375. */
  104376. angularSensibility: number;
  104377. private _mousemoveCallback;
  104378. private _observer;
  104379. private _rollObserver;
  104380. private previousPosition;
  104381. private noPreventDefault;
  104382. private element;
  104383. /**
  104384. * Listen to mouse events to control the camera.
  104385. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104387. */
  104388. constructor(touchEnabled?: boolean);
  104389. /**
  104390. * Attach the mouse control to the HTML DOM element.
  104391. * @param element Defines the element that listens to the input events.
  104392. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104393. */
  104394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104395. /**
  104396. * Detach the current controls from the specified dom element.
  104397. * @param element Defines the element to stop listening the inputs from
  104398. */
  104399. detachControl(element: Nullable<HTMLElement>): void;
  104400. /**
  104401. * Gets the class name of the current input.
  104402. * @returns the class name.
  104403. */
  104404. getClassName(): string;
  104405. /**
  104406. * Get the friendly name associated with the input class.
  104407. * @returns the input's friendly name.
  104408. */
  104409. getSimpleName(): string;
  104410. private _pointerInput;
  104411. private _onMouseMove;
  104412. /**
  104413. * Rotate camera by mouse offset.
  104414. */
  104415. private rotateCamera;
  104416. }
  104417. }
  104418. declare module BABYLON {
  104419. /**
  104420. * Default Inputs manager for the FlyCamera.
  104421. * It groups all the default supported inputs for ease of use.
  104422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104423. */
  104424. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104425. /**
  104426. * Instantiates a new FlyCameraInputsManager.
  104427. * @param camera Defines the camera the inputs belong to.
  104428. */
  104429. constructor(camera: FlyCamera);
  104430. /**
  104431. * Add keyboard input support to the input manager.
  104432. * @returns the new FlyCameraKeyboardMoveInput().
  104433. */
  104434. addKeyboard(): FlyCameraInputsManager;
  104435. /**
  104436. * Add mouse input support to the input manager.
  104437. * @param touchEnabled Enable touch screen support.
  104438. * @returns the new FlyCameraMouseInput().
  104439. */
  104440. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104441. }
  104442. }
  104443. declare module BABYLON {
  104444. /**
  104445. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104446. * such as in a 3D Space Shooter or a Flight Simulator.
  104447. */
  104448. export class FlyCamera extends TargetCamera {
  104449. /**
  104450. * Define the collision ellipsoid of the camera.
  104451. * This is helpful for simulating a camera body, like a player's body.
  104452. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104453. */
  104454. ellipsoid: Vector3;
  104455. /**
  104456. * Define an offset for the position of the ellipsoid around the camera.
  104457. * This can be helpful if the camera is attached away from the player's body center,
  104458. * such as at its head.
  104459. */
  104460. ellipsoidOffset: Vector3;
  104461. /**
  104462. * Enable or disable collisions of the camera with the rest of the scene objects.
  104463. */
  104464. checkCollisions: boolean;
  104465. /**
  104466. * Enable or disable gravity on the camera.
  104467. */
  104468. applyGravity: boolean;
  104469. /**
  104470. * Define the current direction the camera is moving to.
  104471. */
  104472. cameraDirection: Vector3;
  104473. /**
  104474. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104475. * This overrides and empties cameraRotation.
  104476. */
  104477. rotationQuaternion: Quaternion;
  104478. /**
  104479. * Track Roll to maintain the wanted Rolling when looking around.
  104480. */
  104481. _trackRoll: number;
  104482. /**
  104483. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104484. */
  104485. rollCorrect: number;
  104486. /**
  104487. * Mimic a banked turn, Rolling the camera when Yawing.
  104488. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104489. */
  104490. bankedTurn: boolean;
  104491. /**
  104492. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104493. */
  104494. bankedTurnLimit: number;
  104495. /**
  104496. * Value of 0 disables the banked Roll.
  104497. * Value of 1 is equal to the Yaw angle in radians.
  104498. */
  104499. bankedTurnMultiplier: number;
  104500. /**
  104501. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104502. */
  104503. inputs: FlyCameraInputsManager;
  104504. /**
  104505. * Gets the input sensibility for mouse input.
  104506. * Higher values reduce sensitivity.
  104507. */
  104508. /**
  104509. * Sets the input sensibility for a mouse input.
  104510. * Higher values reduce sensitivity.
  104511. */
  104512. angularSensibility: number;
  104513. /**
  104514. * Get the keys for camera movement forward.
  104515. */
  104516. /**
  104517. * Set the keys for camera movement forward.
  104518. */
  104519. keysForward: number[];
  104520. /**
  104521. * Get the keys for camera movement backward.
  104522. */
  104523. keysBackward: number[];
  104524. /**
  104525. * Get the keys for camera movement up.
  104526. */
  104527. /**
  104528. * Set the keys for camera movement up.
  104529. */
  104530. keysUp: number[];
  104531. /**
  104532. * Get the keys for camera movement down.
  104533. */
  104534. /**
  104535. * Set the keys for camera movement down.
  104536. */
  104537. keysDown: number[];
  104538. /**
  104539. * Get the keys for camera movement left.
  104540. */
  104541. /**
  104542. * Set the keys for camera movement left.
  104543. */
  104544. keysLeft: number[];
  104545. /**
  104546. * Set the keys for camera movement right.
  104547. */
  104548. /**
  104549. * Set the keys for camera movement right.
  104550. */
  104551. keysRight: number[];
  104552. /**
  104553. * Event raised when the camera collides with a mesh in the scene.
  104554. */
  104555. onCollide: (collidedMesh: AbstractMesh) => void;
  104556. private _collider;
  104557. private _needMoveForGravity;
  104558. private _oldPosition;
  104559. private _diffPosition;
  104560. private _newPosition;
  104561. /** @hidden */
  104562. _localDirection: Vector3;
  104563. /** @hidden */
  104564. _transformedDirection: Vector3;
  104565. /**
  104566. * Instantiates a FlyCamera.
  104567. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104568. * such as in a 3D Space Shooter or a Flight Simulator.
  104569. * @param name Define the name of the camera in the scene.
  104570. * @param position Define the starting position of the camera in the scene.
  104571. * @param scene Define the scene the camera belongs to.
  104572. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104573. */
  104574. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104575. /**
  104576. * Attach a control to the HTML DOM element.
  104577. * @param element Defines the element that listens to the input events.
  104578. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104579. */
  104580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104581. /**
  104582. * Detach a control from the HTML DOM element.
  104583. * The camera will stop reacting to that input.
  104584. * @param element Defines the element that listens to the input events.
  104585. */
  104586. detachControl(element: HTMLElement): void;
  104587. private _collisionMask;
  104588. /**
  104589. * Get the mask that the camera ignores in collision events.
  104590. */
  104591. /**
  104592. * Set the mask that the camera ignores in collision events.
  104593. */
  104594. collisionMask: number;
  104595. /** @hidden */
  104596. _collideWithWorld(displacement: Vector3): void;
  104597. /** @hidden */
  104598. private _onCollisionPositionChange;
  104599. /** @hidden */
  104600. _checkInputs(): void;
  104601. /** @hidden */
  104602. _decideIfNeedsToMove(): boolean;
  104603. /** @hidden */
  104604. _updatePosition(): void;
  104605. /**
  104606. * Restore the Roll to its target value at the rate specified.
  104607. * @param rate - Higher means slower restoring.
  104608. * @hidden
  104609. */
  104610. restoreRoll(rate: number): void;
  104611. /**
  104612. * Destroy the camera and release the current resources held by it.
  104613. */
  104614. dispose(): void;
  104615. /**
  104616. * Get the current object class name.
  104617. * @returns the class name.
  104618. */
  104619. getClassName(): string;
  104620. }
  104621. }
  104622. declare module BABYLON {
  104623. /**
  104624. * Listen to keyboard events to control the camera.
  104625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104626. */
  104627. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104628. /**
  104629. * Defines the camera the input is attached to.
  104630. */
  104631. camera: FlyCamera;
  104632. /**
  104633. * The list of keyboard keys used to control the forward move of the camera.
  104634. */
  104635. keysForward: number[];
  104636. /**
  104637. * The list of keyboard keys used to control the backward move of the camera.
  104638. */
  104639. keysBackward: number[];
  104640. /**
  104641. * The list of keyboard keys used to control the forward move of the camera.
  104642. */
  104643. keysUp: number[];
  104644. /**
  104645. * The list of keyboard keys used to control the backward move of the camera.
  104646. */
  104647. keysDown: number[];
  104648. /**
  104649. * The list of keyboard keys used to control the right strafe move of the camera.
  104650. */
  104651. keysRight: number[];
  104652. /**
  104653. * The list of keyboard keys used to control the left strafe move of the camera.
  104654. */
  104655. keysLeft: number[];
  104656. private _keys;
  104657. private _onCanvasBlurObserver;
  104658. private _onKeyboardObserver;
  104659. private _engine;
  104660. private _scene;
  104661. /**
  104662. * Attach the input controls to a specific dom element to get the input from.
  104663. * @param element Defines the element the controls should be listened from
  104664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104665. */
  104666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104667. /**
  104668. * Detach the current controls from the specified dom element.
  104669. * @param element Defines the element to stop listening the inputs from
  104670. */
  104671. detachControl(element: Nullable<HTMLElement>): void;
  104672. /**
  104673. * Gets the class name of the current intput.
  104674. * @returns the class name
  104675. */
  104676. getClassName(): string;
  104677. /** @hidden */
  104678. _onLostFocus(e: FocusEvent): void;
  104679. /**
  104680. * Get the friendly name associated with the input class.
  104681. * @returns the input friendly name
  104682. */
  104683. getSimpleName(): string;
  104684. /**
  104685. * Update the current camera state depending on the inputs that have been used this frame.
  104686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104687. */
  104688. checkInputs(): void;
  104689. }
  104690. }
  104691. declare module BABYLON {
  104692. /**
  104693. * Manage the mouse wheel inputs to control a follow camera.
  104694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104695. */
  104696. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104697. /**
  104698. * Defines the camera the input is attached to.
  104699. */
  104700. camera: FollowCamera;
  104701. /**
  104702. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104703. */
  104704. axisControlRadius: boolean;
  104705. /**
  104706. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104707. */
  104708. axisControlHeight: boolean;
  104709. /**
  104710. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104711. */
  104712. axisControlRotation: boolean;
  104713. /**
  104714. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104715. * relation to mouseWheel events.
  104716. */
  104717. wheelPrecision: number;
  104718. /**
  104719. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104720. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104721. */
  104722. wheelDeltaPercentage: number;
  104723. private _wheel;
  104724. private _observer;
  104725. /**
  104726. * Attach the input controls to a specific dom element to get the input from.
  104727. * @param element Defines the element the controls should be listened from
  104728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104729. */
  104730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104731. /**
  104732. * Detach the current controls from the specified dom element.
  104733. * @param element Defines the element to stop listening the inputs from
  104734. */
  104735. detachControl(element: Nullable<HTMLElement>): void;
  104736. /**
  104737. * Gets the class name of the current intput.
  104738. * @returns the class name
  104739. */
  104740. getClassName(): string;
  104741. /**
  104742. * Get the friendly name associated with the input class.
  104743. * @returns the input friendly name
  104744. */
  104745. getSimpleName(): string;
  104746. }
  104747. }
  104748. declare module BABYLON {
  104749. /**
  104750. * Manage the pointers inputs to control an follow camera.
  104751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104752. */
  104753. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104754. /**
  104755. * Defines the camera the input is attached to.
  104756. */
  104757. camera: FollowCamera;
  104758. /**
  104759. * Gets the class name of the current input.
  104760. * @returns the class name
  104761. */
  104762. getClassName(): string;
  104763. /**
  104764. * Defines the pointer angular sensibility along the X axis or how fast is
  104765. * the camera rotating.
  104766. * A negative number will reverse the axis direction.
  104767. */
  104768. angularSensibilityX: number;
  104769. /**
  104770. * Defines the pointer angular sensibility along the Y axis or how fast is
  104771. * the camera rotating.
  104772. * A negative number will reverse the axis direction.
  104773. */
  104774. angularSensibilityY: number;
  104775. /**
  104776. * Defines the pointer pinch precision or how fast is the camera zooming.
  104777. * A negative number will reverse the axis direction.
  104778. */
  104779. pinchPrecision: number;
  104780. /**
  104781. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104782. * from 0.
  104783. * It defines the percentage of current camera.radius to use as delta when
  104784. * pinch zoom is used.
  104785. */
  104786. pinchDeltaPercentage: number;
  104787. /**
  104788. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104789. */
  104790. axisXControlRadius: boolean;
  104791. /**
  104792. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104793. */
  104794. axisXControlHeight: boolean;
  104795. /**
  104796. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104797. */
  104798. axisXControlRotation: boolean;
  104799. /**
  104800. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104801. */
  104802. axisYControlRadius: boolean;
  104803. /**
  104804. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104805. */
  104806. axisYControlHeight: boolean;
  104807. /**
  104808. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104809. */
  104810. axisYControlRotation: boolean;
  104811. /**
  104812. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104813. */
  104814. axisPinchControlRadius: boolean;
  104815. /**
  104816. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104817. */
  104818. axisPinchControlHeight: boolean;
  104819. /**
  104820. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104821. */
  104822. axisPinchControlRotation: boolean;
  104823. /**
  104824. * Log error messages if basic misconfiguration has occurred.
  104825. */
  104826. warningEnable: boolean;
  104827. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104828. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104829. private _warningCounter;
  104830. private _warning;
  104831. }
  104832. }
  104833. declare module BABYLON {
  104834. /**
  104835. * Default Inputs manager for the FollowCamera.
  104836. * It groups all the default supported inputs for ease of use.
  104837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104838. */
  104839. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104840. /**
  104841. * Instantiates a new FollowCameraInputsManager.
  104842. * @param camera Defines the camera the inputs belong to
  104843. */
  104844. constructor(camera: FollowCamera);
  104845. /**
  104846. * Add keyboard input support to the input manager.
  104847. * @returns the current input manager
  104848. */
  104849. addKeyboard(): FollowCameraInputsManager;
  104850. /**
  104851. * Add mouse wheel input support to the input manager.
  104852. * @returns the current input manager
  104853. */
  104854. addMouseWheel(): FollowCameraInputsManager;
  104855. /**
  104856. * Add pointers input support to the input manager.
  104857. * @returns the current input manager
  104858. */
  104859. addPointers(): FollowCameraInputsManager;
  104860. /**
  104861. * Add orientation input support to the input manager.
  104862. * @returns the current input manager
  104863. */
  104864. addVRDeviceOrientation(): FollowCameraInputsManager;
  104865. }
  104866. }
  104867. declare module BABYLON {
  104868. /**
  104869. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104870. * an arc rotate version arcFollowCamera are available.
  104871. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104872. */
  104873. export class FollowCamera extends TargetCamera {
  104874. /**
  104875. * Distance the follow camera should follow an object at
  104876. */
  104877. radius: number;
  104878. /**
  104879. * Minimum allowed distance of the camera to the axis of rotation
  104880. * (The camera can not get closer).
  104881. * This can help limiting how the Camera is able to move in the scene.
  104882. */
  104883. lowerRadiusLimit: Nullable<number>;
  104884. /**
  104885. * Maximum allowed distance of the camera to the axis of rotation
  104886. * (The camera can not get further).
  104887. * This can help limiting how the Camera is able to move in the scene.
  104888. */
  104889. upperRadiusLimit: Nullable<number>;
  104890. /**
  104891. * Define a rotation offset between the camera and the object it follows
  104892. */
  104893. rotationOffset: number;
  104894. /**
  104895. * Minimum allowed angle to camera position relative to target object.
  104896. * This can help limiting how the Camera is able to move in the scene.
  104897. */
  104898. lowerRotationOffsetLimit: Nullable<number>;
  104899. /**
  104900. * Maximum allowed angle to camera position relative to target object.
  104901. * This can help limiting how the Camera is able to move in the scene.
  104902. */
  104903. upperRotationOffsetLimit: Nullable<number>;
  104904. /**
  104905. * Define a height offset between the camera and the object it follows.
  104906. * It can help following an object from the top (like a car chaing a plane)
  104907. */
  104908. heightOffset: number;
  104909. /**
  104910. * Minimum allowed height of camera position relative to target object.
  104911. * This can help limiting how the Camera is able to move in the scene.
  104912. */
  104913. lowerHeightOffsetLimit: Nullable<number>;
  104914. /**
  104915. * Maximum allowed height of camera position relative to target object.
  104916. * This can help limiting how the Camera is able to move in the scene.
  104917. */
  104918. upperHeightOffsetLimit: Nullable<number>;
  104919. /**
  104920. * Define how fast the camera can accelerate to follow it s target.
  104921. */
  104922. cameraAcceleration: number;
  104923. /**
  104924. * Define the speed limit of the camera following an object.
  104925. */
  104926. maxCameraSpeed: number;
  104927. /**
  104928. * Define the target of the camera.
  104929. */
  104930. lockedTarget: Nullable<AbstractMesh>;
  104931. /**
  104932. * Defines the input associated with the camera.
  104933. */
  104934. inputs: FollowCameraInputsManager;
  104935. /**
  104936. * Instantiates the follow camera.
  104937. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104938. * @param name Define the name of the camera in the scene
  104939. * @param position Define the position of the camera
  104940. * @param scene Define the scene the camera belong to
  104941. * @param lockedTarget Define the target of the camera
  104942. */
  104943. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104944. private _follow;
  104945. /**
  104946. * Attached controls to the current camera.
  104947. * @param element Defines the element the controls should be listened from
  104948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104949. */
  104950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104951. /**
  104952. * Detach the current controls from the camera.
  104953. * The camera will stop reacting to inputs.
  104954. * @param element Defines the element to stop listening the inputs from
  104955. */
  104956. detachControl(element: HTMLElement): void;
  104957. /** @hidden */
  104958. _checkInputs(): void;
  104959. private _checkLimits;
  104960. /**
  104961. * Gets the camera class name.
  104962. * @returns the class name
  104963. */
  104964. getClassName(): string;
  104965. }
  104966. /**
  104967. * Arc Rotate version of the follow camera.
  104968. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104969. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104970. */
  104971. export class ArcFollowCamera extends TargetCamera {
  104972. /** The longitudinal angle of the camera */
  104973. alpha: number;
  104974. /** The latitudinal angle of the camera */
  104975. beta: number;
  104976. /** The radius of the camera from its target */
  104977. radius: number;
  104978. /** Define the camera target (the messh it should follow) */
  104979. target: Nullable<AbstractMesh>;
  104980. private _cartesianCoordinates;
  104981. /**
  104982. * Instantiates a new ArcFollowCamera
  104983. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104984. * @param name Define the name of the camera
  104985. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104986. * @param beta Define the rotation angle of the camera around the elevation axis
  104987. * @param radius Define the radius of the camera from its target point
  104988. * @param target Define the target of the camera
  104989. * @param scene Define the scene the camera belongs to
  104990. */
  104991. constructor(name: string,
  104992. /** The longitudinal angle of the camera */
  104993. alpha: number,
  104994. /** The latitudinal angle of the camera */
  104995. beta: number,
  104996. /** The radius of the camera from its target */
  104997. radius: number,
  104998. /** Define the camera target (the messh it should follow) */
  104999. target: Nullable<AbstractMesh>, scene: Scene);
  105000. private _follow;
  105001. /** @hidden */
  105002. _checkInputs(): void;
  105003. /**
  105004. * Returns the class name of the object.
  105005. * It is mostly used internally for serialization purposes.
  105006. */
  105007. getClassName(): string;
  105008. }
  105009. }
  105010. declare module BABYLON {
  105011. /**
  105012. * Manage the keyboard inputs to control the movement of a follow camera.
  105013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105014. */
  105015. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105016. /**
  105017. * Defines the camera the input is attached to.
  105018. */
  105019. camera: FollowCamera;
  105020. /**
  105021. * Defines the list of key codes associated with the up action (increase heightOffset)
  105022. */
  105023. keysHeightOffsetIncr: number[];
  105024. /**
  105025. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105026. */
  105027. keysHeightOffsetDecr: number[];
  105028. /**
  105029. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105030. */
  105031. keysHeightOffsetModifierAlt: boolean;
  105032. /**
  105033. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105034. */
  105035. keysHeightOffsetModifierCtrl: boolean;
  105036. /**
  105037. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105038. */
  105039. keysHeightOffsetModifierShift: boolean;
  105040. /**
  105041. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105042. */
  105043. keysRotationOffsetIncr: number[];
  105044. /**
  105045. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105046. */
  105047. keysRotationOffsetDecr: number[];
  105048. /**
  105049. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105050. */
  105051. keysRotationOffsetModifierAlt: boolean;
  105052. /**
  105053. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105054. */
  105055. keysRotationOffsetModifierCtrl: boolean;
  105056. /**
  105057. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105058. */
  105059. keysRotationOffsetModifierShift: boolean;
  105060. /**
  105061. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105062. */
  105063. keysRadiusIncr: number[];
  105064. /**
  105065. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105066. */
  105067. keysRadiusDecr: number[];
  105068. /**
  105069. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105070. */
  105071. keysRadiusModifierAlt: boolean;
  105072. /**
  105073. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105074. */
  105075. keysRadiusModifierCtrl: boolean;
  105076. /**
  105077. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105078. */
  105079. keysRadiusModifierShift: boolean;
  105080. /**
  105081. * Defines the rate of change of heightOffset.
  105082. */
  105083. heightSensibility: number;
  105084. /**
  105085. * Defines the rate of change of rotationOffset.
  105086. */
  105087. rotationSensibility: number;
  105088. /**
  105089. * Defines the rate of change of radius.
  105090. */
  105091. radiusSensibility: number;
  105092. private _keys;
  105093. private _ctrlPressed;
  105094. private _altPressed;
  105095. private _shiftPressed;
  105096. private _onCanvasBlurObserver;
  105097. private _onKeyboardObserver;
  105098. private _engine;
  105099. private _scene;
  105100. /**
  105101. * Attach the input controls to a specific dom element to get the input from.
  105102. * @param element Defines the element the controls should be listened from
  105103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105104. */
  105105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105106. /**
  105107. * Detach the current controls from the specified dom element.
  105108. * @param element Defines the element to stop listening the inputs from
  105109. */
  105110. detachControl(element: Nullable<HTMLElement>): void;
  105111. /**
  105112. * Update the current camera state depending on the inputs that have been used this frame.
  105113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105114. */
  105115. checkInputs(): void;
  105116. /**
  105117. * Gets the class name of the current input.
  105118. * @returns the class name
  105119. */
  105120. getClassName(): string;
  105121. /**
  105122. * Get the friendly name associated with the input class.
  105123. * @returns the input friendly name
  105124. */
  105125. getSimpleName(): string;
  105126. /**
  105127. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105128. * allow modification of the heightOffset value.
  105129. */
  105130. private _modifierHeightOffset;
  105131. /**
  105132. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105133. * allow modification of the rotationOffset value.
  105134. */
  105135. private _modifierRotationOffset;
  105136. /**
  105137. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105138. * allow modification of the radius value.
  105139. */
  105140. private _modifierRadius;
  105141. }
  105142. }
  105143. declare module BABYLON {
  105144. interface FreeCameraInputsManager {
  105145. /**
  105146. * @hidden
  105147. */
  105148. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105149. /**
  105150. * Add orientation input support to the input manager.
  105151. * @returns the current input manager
  105152. */
  105153. addDeviceOrientation(): FreeCameraInputsManager;
  105154. }
  105155. /**
  105156. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105157. * Screen rotation is taken into account.
  105158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105159. */
  105160. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105161. private _camera;
  105162. private _screenOrientationAngle;
  105163. private _constantTranform;
  105164. private _screenQuaternion;
  105165. private _alpha;
  105166. private _beta;
  105167. private _gamma;
  105168. /**
  105169. * Can be used to detect if a device orientation sensor is availible on a device
  105170. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105171. * @returns a promise that will resolve on orientation change
  105172. */
  105173. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105174. /**
  105175. * @hidden
  105176. */
  105177. _onDeviceOrientationChangedObservable: Observable<void>;
  105178. /**
  105179. * Instantiates a new input
  105180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105181. */
  105182. constructor();
  105183. /**
  105184. * Define the camera controlled by the input.
  105185. */
  105186. camera: FreeCamera;
  105187. /**
  105188. * Attach the input controls to a specific dom element to get the input from.
  105189. * @param element Defines the element the controls should be listened from
  105190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105191. */
  105192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105193. private _orientationChanged;
  105194. private _deviceOrientation;
  105195. /**
  105196. * Detach the current controls from the specified dom element.
  105197. * @param element Defines the element to stop listening the inputs from
  105198. */
  105199. detachControl(element: Nullable<HTMLElement>): void;
  105200. /**
  105201. * Update the current camera state depending on the inputs that have been used this frame.
  105202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105203. */
  105204. checkInputs(): void;
  105205. /**
  105206. * Gets the class name of the current intput.
  105207. * @returns the class name
  105208. */
  105209. getClassName(): string;
  105210. /**
  105211. * Get the friendly name associated with the input class.
  105212. * @returns the input friendly name
  105213. */
  105214. getSimpleName(): string;
  105215. }
  105216. }
  105217. declare module BABYLON {
  105218. /**
  105219. * Manage the gamepad inputs to control a free camera.
  105220. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105221. */
  105222. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105223. /**
  105224. * Define the camera the input is attached to.
  105225. */
  105226. camera: FreeCamera;
  105227. /**
  105228. * Define the Gamepad controlling the input
  105229. */
  105230. gamepad: Nullable<Gamepad>;
  105231. /**
  105232. * Defines the gamepad rotation sensiblity.
  105233. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105234. */
  105235. gamepadAngularSensibility: number;
  105236. /**
  105237. * Defines the gamepad move sensiblity.
  105238. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105239. */
  105240. gamepadMoveSensibility: number;
  105241. private _onGamepadConnectedObserver;
  105242. private _onGamepadDisconnectedObserver;
  105243. private _cameraTransform;
  105244. private _deltaTransform;
  105245. private _vector3;
  105246. private _vector2;
  105247. /**
  105248. * Attach the input controls to a specific dom element to get the input from.
  105249. * @param element Defines the element the controls should be listened from
  105250. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105251. */
  105252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105253. /**
  105254. * Detach the current controls from the specified dom element.
  105255. * @param element Defines the element to stop listening the inputs from
  105256. */
  105257. detachControl(element: Nullable<HTMLElement>): void;
  105258. /**
  105259. * Update the current camera state depending on the inputs that have been used this frame.
  105260. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105261. */
  105262. checkInputs(): void;
  105263. /**
  105264. * Gets the class name of the current intput.
  105265. * @returns the class name
  105266. */
  105267. getClassName(): string;
  105268. /**
  105269. * Get the friendly name associated with the input class.
  105270. * @returns the input friendly name
  105271. */
  105272. getSimpleName(): string;
  105273. }
  105274. }
  105275. declare module BABYLON {
  105276. /**
  105277. * Defines the potential axis of a Joystick
  105278. */
  105279. export enum JoystickAxis {
  105280. /** X axis */
  105281. X = 0,
  105282. /** Y axis */
  105283. Y = 1,
  105284. /** Z axis */
  105285. Z = 2
  105286. }
  105287. /**
  105288. * Class used to define virtual joystick (used in touch mode)
  105289. */
  105290. export class VirtualJoystick {
  105291. /**
  105292. * Gets or sets a boolean indicating that left and right values must be inverted
  105293. */
  105294. reverseLeftRight: boolean;
  105295. /**
  105296. * Gets or sets a boolean indicating that up and down values must be inverted
  105297. */
  105298. reverseUpDown: boolean;
  105299. /**
  105300. * Gets the offset value for the position (ie. the change of the position value)
  105301. */
  105302. deltaPosition: Vector3;
  105303. /**
  105304. * Gets a boolean indicating if the virtual joystick was pressed
  105305. */
  105306. pressed: boolean;
  105307. /**
  105308. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105309. */
  105310. static Canvas: Nullable<HTMLCanvasElement>;
  105311. private static _globalJoystickIndex;
  105312. private static vjCanvasContext;
  105313. private static vjCanvasWidth;
  105314. private static vjCanvasHeight;
  105315. private static halfWidth;
  105316. private _action;
  105317. private _axisTargetedByLeftAndRight;
  105318. private _axisTargetedByUpAndDown;
  105319. private _joystickSensibility;
  105320. private _inversedSensibility;
  105321. private _joystickPointerID;
  105322. private _joystickColor;
  105323. private _joystickPointerPos;
  105324. private _joystickPreviousPointerPos;
  105325. private _joystickPointerStartPos;
  105326. private _deltaJoystickVector;
  105327. private _leftJoystick;
  105328. private _touches;
  105329. private _onPointerDownHandlerRef;
  105330. private _onPointerMoveHandlerRef;
  105331. private _onPointerUpHandlerRef;
  105332. private _onResize;
  105333. /**
  105334. * Creates a new virtual joystick
  105335. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105336. */
  105337. constructor(leftJoystick?: boolean);
  105338. /**
  105339. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105340. * @param newJoystickSensibility defines the new sensibility
  105341. */
  105342. setJoystickSensibility(newJoystickSensibility: number): void;
  105343. private _onPointerDown;
  105344. private _onPointerMove;
  105345. private _onPointerUp;
  105346. /**
  105347. * Change the color of the virtual joystick
  105348. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105349. */
  105350. setJoystickColor(newColor: string): void;
  105351. /**
  105352. * Defines a callback to call when the joystick is touched
  105353. * @param action defines the callback
  105354. */
  105355. setActionOnTouch(action: () => any): void;
  105356. /**
  105357. * Defines which axis you'd like to control for left & right
  105358. * @param axis defines the axis to use
  105359. */
  105360. setAxisForLeftRight(axis: JoystickAxis): void;
  105361. /**
  105362. * Defines which axis you'd like to control for up & down
  105363. * @param axis defines the axis to use
  105364. */
  105365. setAxisForUpDown(axis: JoystickAxis): void;
  105366. private _drawVirtualJoystick;
  105367. /**
  105368. * Release internal HTML canvas
  105369. */
  105370. releaseCanvas(): void;
  105371. }
  105372. }
  105373. declare module BABYLON {
  105374. interface FreeCameraInputsManager {
  105375. /**
  105376. * Add virtual joystick input support to the input manager.
  105377. * @returns the current input manager
  105378. */
  105379. addVirtualJoystick(): FreeCameraInputsManager;
  105380. }
  105381. /**
  105382. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105384. */
  105385. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105386. /**
  105387. * Defines the camera the input is attached to.
  105388. */
  105389. camera: FreeCamera;
  105390. private _leftjoystick;
  105391. private _rightjoystick;
  105392. /**
  105393. * Gets the left stick of the virtual joystick.
  105394. * @returns The virtual Joystick
  105395. */
  105396. getLeftJoystick(): VirtualJoystick;
  105397. /**
  105398. * Gets the right stick of the virtual joystick.
  105399. * @returns The virtual Joystick
  105400. */
  105401. getRightJoystick(): VirtualJoystick;
  105402. /**
  105403. * Update the current camera state depending on the inputs that have been used this frame.
  105404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105405. */
  105406. checkInputs(): void;
  105407. /**
  105408. * Attach the input controls to a specific dom element to get the input from.
  105409. * @param element Defines the element the controls should be listened from
  105410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105411. */
  105412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105413. /**
  105414. * Detach the current controls from the specified dom element.
  105415. * @param element Defines the element to stop listening the inputs from
  105416. */
  105417. detachControl(element: Nullable<HTMLElement>): void;
  105418. /**
  105419. * Gets the class name of the current intput.
  105420. * @returns the class name
  105421. */
  105422. getClassName(): string;
  105423. /**
  105424. * Get the friendly name associated with the input class.
  105425. * @returns the input friendly name
  105426. */
  105427. getSimpleName(): string;
  105428. }
  105429. }
  105430. declare module BABYLON {
  105431. /**
  105432. * This represents a FPS type of camera controlled by touch.
  105433. * This is like a universal camera minus the Gamepad controls.
  105434. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105435. */
  105436. export class TouchCamera extends FreeCamera {
  105437. /**
  105438. * Defines the touch sensibility for rotation.
  105439. * The higher the faster.
  105440. */
  105441. touchAngularSensibility: number;
  105442. /**
  105443. * Defines the touch sensibility for move.
  105444. * The higher the faster.
  105445. */
  105446. touchMoveSensibility: number;
  105447. /**
  105448. * Instantiates a new touch camera.
  105449. * This represents a FPS type of camera controlled by touch.
  105450. * This is like a universal camera minus the Gamepad controls.
  105451. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105452. * @param name Define the name of the camera in the scene
  105453. * @param position Define the start position of the camera in the scene
  105454. * @param scene Define the scene the camera belongs to
  105455. */
  105456. constructor(name: string, position: Vector3, scene: Scene);
  105457. /**
  105458. * Gets the current object class name.
  105459. * @return the class name
  105460. */
  105461. getClassName(): string;
  105462. /** @hidden */
  105463. _setupInputs(): void;
  105464. }
  105465. }
  105466. declare module BABYLON {
  105467. /**
  105468. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105469. * being tilted forward or back and left or right.
  105470. */
  105471. export class DeviceOrientationCamera extends FreeCamera {
  105472. private _initialQuaternion;
  105473. private _quaternionCache;
  105474. private _tmpDragQuaternion;
  105475. private _disablePointerInputWhenUsingDeviceOrientation;
  105476. /**
  105477. * Creates a new device orientation camera
  105478. * @param name The name of the camera
  105479. * @param position The start position camera
  105480. * @param scene The scene the camera belongs to
  105481. */
  105482. constructor(name: string, position: Vector3, scene: Scene);
  105483. /**
  105484. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105485. */
  105486. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105487. private _dragFactor;
  105488. /**
  105489. * Enabled turning on the y axis when the orientation sensor is active
  105490. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105491. */
  105492. enableHorizontalDragging(dragFactor?: number): void;
  105493. /**
  105494. * Gets the current instance class name ("DeviceOrientationCamera").
  105495. * This helps avoiding instanceof at run time.
  105496. * @returns the class name
  105497. */
  105498. getClassName(): string;
  105499. /**
  105500. * @hidden
  105501. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105502. */
  105503. _checkInputs(): void;
  105504. /**
  105505. * Reset the camera to its default orientation on the specified axis only.
  105506. * @param axis The axis to reset
  105507. */
  105508. resetToCurrentRotation(axis?: Axis): void;
  105509. }
  105510. }
  105511. declare module BABYLON {
  105512. /**
  105513. * Defines supported buttons for XBox360 compatible gamepads
  105514. */
  105515. export enum Xbox360Button {
  105516. /** A */
  105517. A = 0,
  105518. /** B */
  105519. B = 1,
  105520. /** X */
  105521. X = 2,
  105522. /** Y */
  105523. Y = 3,
  105524. /** Start */
  105525. Start = 4,
  105526. /** Back */
  105527. Back = 5,
  105528. /** Left button */
  105529. LB = 6,
  105530. /** Right button */
  105531. RB = 7,
  105532. /** Left stick */
  105533. LeftStick = 8,
  105534. /** Right stick */
  105535. RightStick = 9
  105536. }
  105537. /** Defines values for XBox360 DPad */
  105538. export enum Xbox360Dpad {
  105539. /** Up */
  105540. Up = 0,
  105541. /** Down */
  105542. Down = 1,
  105543. /** Left */
  105544. Left = 2,
  105545. /** Right */
  105546. Right = 3
  105547. }
  105548. /**
  105549. * Defines a XBox360 gamepad
  105550. */
  105551. export class Xbox360Pad extends Gamepad {
  105552. private _leftTrigger;
  105553. private _rightTrigger;
  105554. private _onlefttriggerchanged;
  105555. private _onrighttriggerchanged;
  105556. private _onbuttondown;
  105557. private _onbuttonup;
  105558. private _ondpaddown;
  105559. private _ondpadup;
  105560. /** Observable raised when a button is pressed */
  105561. onButtonDownObservable: Observable<Xbox360Button>;
  105562. /** Observable raised when a button is released */
  105563. onButtonUpObservable: Observable<Xbox360Button>;
  105564. /** Observable raised when a pad is pressed */
  105565. onPadDownObservable: Observable<Xbox360Dpad>;
  105566. /** Observable raised when a pad is released */
  105567. onPadUpObservable: Observable<Xbox360Dpad>;
  105568. private _buttonA;
  105569. private _buttonB;
  105570. private _buttonX;
  105571. private _buttonY;
  105572. private _buttonBack;
  105573. private _buttonStart;
  105574. private _buttonLB;
  105575. private _buttonRB;
  105576. private _buttonLeftStick;
  105577. private _buttonRightStick;
  105578. private _dPadUp;
  105579. private _dPadDown;
  105580. private _dPadLeft;
  105581. private _dPadRight;
  105582. private _isXboxOnePad;
  105583. /**
  105584. * Creates a new XBox360 gamepad object
  105585. * @param id defines the id of this gamepad
  105586. * @param index defines its index
  105587. * @param gamepad defines the internal HTML gamepad object
  105588. * @param xboxOne defines if it is a XBox One gamepad
  105589. */
  105590. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105591. /**
  105592. * Defines the callback to call when left trigger is pressed
  105593. * @param callback defines the callback to use
  105594. */
  105595. onlefttriggerchanged(callback: (value: number) => void): void;
  105596. /**
  105597. * Defines the callback to call when right trigger is pressed
  105598. * @param callback defines the callback to use
  105599. */
  105600. onrighttriggerchanged(callback: (value: number) => void): void;
  105601. /**
  105602. * Gets the left trigger value
  105603. */
  105604. /**
  105605. * Sets the left trigger value
  105606. */
  105607. leftTrigger: number;
  105608. /**
  105609. * Gets the right trigger value
  105610. */
  105611. /**
  105612. * Sets the right trigger value
  105613. */
  105614. rightTrigger: number;
  105615. /**
  105616. * Defines the callback to call when a button is pressed
  105617. * @param callback defines the callback to use
  105618. */
  105619. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105620. /**
  105621. * Defines the callback to call when a button is released
  105622. * @param callback defines the callback to use
  105623. */
  105624. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105625. /**
  105626. * Defines the callback to call when a pad is pressed
  105627. * @param callback defines the callback to use
  105628. */
  105629. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105630. /**
  105631. * Defines the callback to call when a pad is released
  105632. * @param callback defines the callback to use
  105633. */
  105634. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105635. private _setButtonValue;
  105636. private _setDPadValue;
  105637. /**
  105638. * Gets the value of the `A` button
  105639. */
  105640. /**
  105641. * Sets the value of the `A` button
  105642. */
  105643. buttonA: number;
  105644. /**
  105645. * Gets the value of the `B` button
  105646. */
  105647. /**
  105648. * Sets the value of the `B` button
  105649. */
  105650. buttonB: number;
  105651. /**
  105652. * Gets the value of the `X` button
  105653. */
  105654. /**
  105655. * Sets the value of the `X` button
  105656. */
  105657. buttonX: number;
  105658. /**
  105659. * Gets the value of the `Y` button
  105660. */
  105661. /**
  105662. * Sets the value of the `Y` button
  105663. */
  105664. buttonY: number;
  105665. /**
  105666. * Gets the value of the `Start` button
  105667. */
  105668. /**
  105669. * Sets the value of the `Start` button
  105670. */
  105671. buttonStart: number;
  105672. /**
  105673. * Gets the value of the `Back` button
  105674. */
  105675. /**
  105676. * Sets the value of the `Back` button
  105677. */
  105678. buttonBack: number;
  105679. /**
  105680. * Gets the value of the `Left` button
  105681. */
  105682. /**
  105683. * Sets the value of the `Left` button
  105684. */
  105685. buttonLB: number;
  105686. /**
  105687. * Gets the value of the `Right` button
  105688. */
  105689. /**
  105690. * Sets the value of the `Right` button
  105691. */
  105692. buttonRB: number;
  105693. /**
  105694. * Gets the value of the Left joystick
  105695. */
  105696. /**
  105697. * Sets the value of the Left joystick
  105698. */
  105699. buttonLeftStick: number;
  105700. /**
  105701. * Gets the value of the Right joystick
  105702. */
  105703. /**
  105704. * Sets the value of the Right joystick
  105705. */
  105706. buttonRightStick: number;
  105707. /**
  105708. * Gets the value of D-pad up
  105709. */
  105710. /**
  105711. * Sets the value of D-pad up
  105712. */
  105713. dPadUp: number;
  105714. /**
  105715. * Gets the value of D-pad down
  105716. */
  105717. /**
  105718. * Sets the value of D-pad down
  105719. */
  105720. dPadDown: number;
  105721. /**
  105722. * Gets the value of D-pad left
  105723. */
  105724. /**
  105725. * Sets the value of D-pad left
  105726. */
  105727. dPadLeft: number;
  105728. /**
  105729. * Gets the value of D-pad right
  105730. */
  105731. /**
  105732. * Sets the value of D-pad right
  105733. */
  105734. dPadRight: number;
  105735. /**
  105736. * Force the gamepad to synchronize with device values
  105737. */
  105738. update(): void;
  105739. /**
  105740. * Disposes the gamepad
  105741. */
  105742. dispose(): void;
  105743. }
  105744. }
  105745. declare module BABYLON {
  105746. /**
  105747. * Defines supported buttons for DualShock compatible gamepads
  105748. */
  105749. export enum DualShockButton {
  105750. /** Cross */
  105751. Cross = 0,
  105752. /** Circle */
  105753. Circle = 1,
  105754. /** Square */
  105755. Square = 2,
  105756. /** Triangle */
  105757. Triangle = 3,
  105758. /** Options */
  105759. Options = 4,
  105760. /** Share */
  105761. Share = 5,
  105762. /** L1 */
  105763. L1 = 6,
  105764. /** R1 */
  105765. R1 = 7,
  105766. /** Left stick */
  105767. LeftStick = 8,
  105768. /** Right stick */
  105769. RightStick = 9
  105770. }
  105771. /** Defines values for DualShock DPad */
  105772. export enum DualShockDpad {
  105773. /** Up */
  105774. Up = 0,
  105775. /** Down */
  105776. Down = 1,
  105777. /** Left */
  105778. Left = 2,
  105779. /** Right */
  105780. Right = 3
  105781. }
  105782. /**
  105783. * Defines a DualShock gamepad
  105784. */
  105785. export class DualShockPad extends Gamepad {
  105786. private _leftTrigger;
  105787. private _rightTrigger;
  105788. private _onlefttriggerchanged;
  105789. private _onrighttriggerchanged;
  105790. private _onbuttondown;
  105791. private _onbuttonup;
  105792. private _ondpaddown;
  105793. private _ondpadup;
  105794. /** Observable raised when a button is pressed */
  105795. onButtonDownObservable: Observable<DualShockButton>;
  105796. /** Observable raised when a button is released */
  105797. onButtonUpObservable: Observable<DualShockButton>;
  105798. /** Observable raised when a pad is pressed */
  105799. onPadDownObservable: Observable<DualShockDpad>;
  105800. /** Observable raised when a pad is released */
  105801. onPadUpObservable: Observable<DualShockDpad>;
  105802. private _buttonCross;
  105803. private _buttonCircle;
  105804. private _buttonSquare;
  105805. private _buttonTriangle;
  105806. private _buttonShare;
  105807. private _buttonOptions;
  105808. private _buttonL1;
  105809. private _buttonR1;
  105810. private _buttonLeftStick;
  105811. private _buttonRightStick;
  105812. private _dPadUp;
  105813. private _dPadDown;
  105814. private _dPadLeft;
  105815. private _dPadRight;
  105816. /**
  105817. * Creates a new DualShock gamepad object
  105818. * @param id defines the id of this gamepad
  105819. * @param index defines its index
  105820. * @param gamepad defines the internal HTML gamepad object
  105821. */
  105822. constructor(id: string, index: number, gamepad: any);
  105823. /**
  105824. * Defines the callback to call when left trigger is pressed
  105825. * @param callback defines the callback to use
  105826. */
  105827. onlefttriggerchanged(callback: (value: number) => void): void;
  105828. /**
  105829. * Defines the callback to call when right trigger is pressed
  105830. * @param callback defines the callback to use
  105831. */
  105832. onrighttriggerchanged(callback: (value: number) => void): void;
  105833. /**
  105834. * Gets the left trigger value
  105835. */
  105836. /**
  105837. * Sets the left trigger value
  105838. */
  105839. leftTrigger: number;
  105840. /**
  105841. * Gets the right trigger value
  105842. */
  105843. /**
  105844. * Sets the right trigger value
  105845. */
  105846. rightTrigger: number;
  105847. /**
  105848. * Defines the callback to call when a button is pressed
  105849. * @param callback defines the callback to use
  105850. */
  105851. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105852. /**
  105853. * Defines the callback to call when a button is released
  105854. * @param callback defines the callback to use
  105855. */
  105856. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105857. /**
  105858. * Defines the callback to call when a pad is pressed
  105859. * @param callback defines the callback to use
  105860. */
  105861. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105862. /**
  105863. * Defines the callback to call when a pad is released
  105864. * @param callback defines the callback to use
  105865. */
  105866. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105867. private _setButtonValue;
  105868. private _setDPadValue;
  105869. /**
  105870. * Gets the value of the `Cross` button
  105871. */
  105872. /**
  105873. * Sets the value of the `Cross` button
  105874. */
  105875. buttonCross: number;
  105876. /**
  105877. * Gets the value of the `Circle` button
  105878. */
  105879. /**
  105880. * Sets the value of the `Circle` button
  105881. */
  105882. buttonCircle: number;
  105883. /**
  105884. * Gets the value of the `Square` button
  105885. */
  105886. /**
  105887. * Sets the value of the `Square` button
  105888. */
  105889. buttonSquare: number;
  105890. /**
  105891. * Gets the value of the `Triangle` button
  105892. */
  105893. /**
  105894. * Sets the value of the `Triangle` button
  105895. */
  105896. buttonTriangle: number;
  105897. /**
  105898. * Gets the value of the `Options` button
  105899. */
  105900. /**
  105901. * Sets the value of the `Options` button
  105902. */
  105903. buttonOptions: number;
  105904. /**
  105905. * Gets the value of the `Share` button
  105906. */
  105907. /**
  105908. * Sets the value of the `Share` button
  105909. */
  105910. buttonShare: number;
  105911. /**
  105912. * Gets the value of the `L1` button
  105913. */
  105914. /**
  105915. * Sets the value of the `L1` button
  105916. */
  105917. buttonL1: number;
  105918. /**
  105919. * Gets the value of the `R1` button
  105920. */
  105921. /**
  105922. * Sets the value of the `R1` button
  105923. */
  105924. buttonR1: number;
  105925. /**
  105926. * Gets the value of the Left joystick
  105927. */
  105928. /**
  105929. * Sets the value of the Left joystick
  105930. */
  105931. buttonLeftStick: number;
  105932. /**
  105933. * Gets the value of the Right joystick
  105934. */
  105935. /**
  105936. * Sets the value of the Right joystick
  105937. */
  105938. buttonRightStick: number;
  105939. /**
  105940. * Gets the value of D-pad up
  105941. */
  105942. /**
  105943. * Sets the value of D-pad up
  105944. */
  105945. dPadUp: number;
  105946. /**
  105947. * Gets the value of D-pad down
  105948. */
  105949. /**
  105950. * Sets the value of D-pad down
  105951. */
  105952. dPadDown: number;
  105953. /**
  105954. * Gets the value of D-pad left
  105955. */
  105956. /**
  105957. * Sets the value of D-pad left
  105958. */
  105959. dPadLeft: number;
  105960. /**
  105961. * Gets the value of D-pad right
  105962. */
  105963. /**
  105964. * Sets the value of D-pad right
  105965. */
  105966. dPadRight: number;
  105967. /**
  105968. * Force the gamepad to synchronize with device values
  105969. */
  105970. update(): void;
  105971. /**
  105972. * Disposes the gamepad
  105973. */
  105974. dispose(): void;
  105975. }
  105976. }
  105977. declare module BABYLON {
  105978. /**
  105979. * Manager for handling gamepads
  105980. */
  105981. export class GamepadManager {
  105982. private _scene?;
  105983. private _babylonGamepads;
  105984. private _oneGamepadConnected;
  105985. /** @hidden */
  105986. _isMonitoring: boolean;
  105987. private _gamepadEventSupported;
  105988. private _gamepadSupport;
  105989. /**
  105990. * observable to be triggered when the gamepad controller has been connected
  105991. */
  105992. onGamepadConnectedObservable: Observable<Gamepad>;
  105993. /**
  105994. * observable to be triggered when the gamepad controller has been disconnected
  105995. */
  105996. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105997. private _onGamepadConnectedEvent;
  105998. private _onGamepadDisconnectedEvent;
  105999. /**
  106000. * Initializes the gamepad manager
  106001. * @param _scene BabylonJS scene
  106002. */
  106003. constructor(_scene?: Scene | undefined);
  106004. /**
  106005. * The gamepads in the game pad manager
  106006. */
  106007. readonly gamepads: Gamepad[];
  106008. /**
  106009. * Get the gamepad controllers based on type
  106010. * @param type The type of gamepad controller
  106011. * @returns Nullable gamepad
  106012. */
  106013. getGamepadByType(type?: number): Nullable<Gamepad>;
  106014. /**
  106015. * Disposes the gamepad manager
  106016. */
  106017. dispose(): void;
  106018. private _addNewGamepad;
  106019. private _startMonitoringGamepads;
  106020. private _stopMonitoringGamepads;
  106021. /** @hidden */
  106022. _checkGamepadsStatus(): void;
  106023. private _updateGamepadObjects;
  106024. }
  106025. }
  106026. declare module BABYLON {
  106027. interface Scene {
  106028. /** @hidden */
  106029. _gamepadManager: Nullable<GamepadManager>;
  106030. /**
  106031. * Gets the gamepad manager associated with the scene
  106032. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106033. */
  106034. gamepadManager: GamepadManager;
  106035. }
  106036. /**
  106037. * Interface representing a free camera inputs manager
  106038. */
  106039. interface FreeCameraInputsManager {
  106040. /**
  106041. * Adds gamepad input support to the FreeCameraInputsManager.
  106042. * @returns the FreeCameraInputsManager
  106043. */
  106044. addGamepad(): FreeCameraInputsManager;
  106045. }
  106046. /**
  106047. * Interface representing an arc rotate camera inputs manager
  106048. */
  106049. interface ArcRotateCameraInputsManager {
  106050. /**
  106051. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106052. * @returns the camera inputs manager
  106053. */
  106054. addGamepad(): ArcRotateCameraInputsManager;
  106055. }
  106056. /**
  106057. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106058. */
  106059. export class GamepadSystemSceneComponent implements ISceneComponent {
  106060. /**
  106061. * The component name helpfull to identify the component in the list of scene components.
  106062. */
  106063. readonly name: string;
  106064. /**
  106065. * The scene the component belongs to.
  106066. */
  106067. scene: Scene;
  106068. /**
  106069. * Creates a new instance of the component for the given scene
  106070. * @param scene Defines the scene to register the component in
  106071. */
  106072. constructor(scene: Scene);
  106073. /**
  106074. * Registers the component in a given scene
  106075. */
  106076. register(): void;
  106077. /**
  106078. * Rebuilds the elements related to this component in case of
  106079. * context lost for instance.
  106080. */
  106081. rebuild(): void;
  106082. /**
  106083. * Disposes the component and the associated ressources
  106084. */
  106085. dispose(): void;
  106086. private _beforeCameraUpdate;
  106087. }
  106088. }
  106089. declare module BABYLON {
  106090. /**
  106091. * 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,
  106092. * which still works and will still be found in many Playgrounds.
  106093. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106094. */
  106095. export class UniversalCamera extends TouchCamera {
  106096. /**
  106097. * Defines the gamepad rotation sensiblity.
  106098. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106099. */
  106100. gamepadAngularSensibility: number;
  106101. /**
  106102. * Defines the gamepad move sensiblity.
  106103. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106104. */
  106105. gamepadMoveSensibility: number;
  106106. /**
  106107. * 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,
  106108. * which still works and will still be found in many Playgrounds.
  106109. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106110. * @param name Define the name of the camera in the scene
  106111. * @param position Define the start position of the camera in the scene
  106112. * @param scene Define the scene the camera belongs to
  106113. */
  106114. constructor(name: string, position: Vector3, scene: Scene);
  106115. /**
  106116. * Gets the current object class name.
  106117. * @return the class name
  106118. */
  106119. getClassName(): string;
  106120. }
  106121. }
  106122. declare module BABYLON {
  106123. /**
  106124. * This represents a FPS type of camera. This is only here for back compat purpose.
  106125. * Please use the UniversalCamera instead as both are identical.
  106126. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106127. */
  106128. export class GamepadCamera extends UniversalCamera {
  106129. /**
  106130. * Instantiates a new Gamepad Camera
  106131. * This represents a FPS type of camera. This is only here for back compat purpose.
  106132. * Please use the UniversalCamera instead as both are identical.
  106133. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106134. * @param name Define the name of the camera in the scene
  106135. * @param position Define the start position of the camera in the scene
  106136. * @param scene Define the scene the camera belongs to
  106137. */
  106138. constructor(name: string, position: Vector3, scene: Scene);
  106139. /**
  106140. * Gets the current object class name.
  106141. * @return the class name
  106142. */
  106143. getClassName(): string;
  106144. }
  106145. }
  106146. declare module BABYLON {
  106147. /** @hidden */
  106148. export var passPixelShader: {
  106149. name: string;
  106150. shader: string;
  106151. };
  106152. }
  106153. declare module BABYLON {
  106154. /** @hidden */
  106155. export var passCubePixelShader: {
  106156. name: string;
  106157. shader: string;
  106158. };
  106159. }
  106160. declare module BABYLON {
  106161. /**
  106162. * PassPostProcess which produces an output the same as it's input
  106163. */
  106164. export class PassPostProcess extends PostProcess {
  106165. /**
  106166. * Creates the PassPostProcess
  106167. * @param name The name of the effect.
  106168. * @param options The required width/height ratio to downsize to before computing the render pass.
  106169. * @param camera The camera to apply the render pass to.
  106170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106171. * @param engine The engine which the post process will be applied. (default: current engine)
  106172. * @param reusable If the post process can be reused on the same frame. (default: false)
  106173. * @param textureType The type of texture to be used when performing the post processing.
  106174. * @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)
  106175. */
  106176. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106177. }
  106178. /**
  106179. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106180. */
  106181. export class PassCubePostProcess extends PostProcess {
  106182. private _face;
  106183. /**
  106184. * Gets or sets the cube face to display.
  106185. * * 0 is +X
  106186. * * 1 is -X
  106187. * * 2 is +Y
  106188. * * 3 is -Y
  106189. * * 4 is +Z
  106190. * * 5 is -Z
  106191. */
  106192. face: number;
  106193. /**
  106194. * Creates the PassCubePostProcess
  106195. * @param name The name of the effect.
  106196. * @param options The required width/height ratio to downsize to before computing the render pass.
  106197. * @param camera The camera to apply the render pass to.
  106198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106199. * @param engine The engine which the post process will be applied. (default: current engine)
  106200. * @param reusable If the post process can be reused on the same frame. (default: false)
  106201. * @param textureType The type of texture to be used when performing the post processing.
  106202. * @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)
  106203. */
  106204. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106205. }
  106206. }
  106207. declare module BABYLON {
  106208. /** @hidden */
  106209. export var anaglyphPixelShader: {
  106210. name: string;
  106211. shader: string;
  106212. };
  106213. }
  106214. declare module BABYLON {
  106215. /**
  106216. * Postprocess used to generate anaglyphic rendering
  106217. */
  106218. export class AnaglyphPostProcess extends PostProcess {
  106219. private _passedProcess;
  106220. /**
  106221. * Creates a new AnaglyphPostProcess
  106222. * @param name defines postprocess name
  106223. * @param options defines creation options or target ratio scale
  106224. * @param rigCameras defines cameras using this postprocess
  106225. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106226. * @param engine defines hosting engine
  106227. * @param reusable defines if the postprocess will be reused multiple times per frame
  106228. */
  106229. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106230. }
  106231. }
  106232. declare module BABYLON {
  106233. /**
  106234. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106235. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106236. */
  106237. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106238. /**
  106239. * Creates a new AnaglyphArcRotateCamera
  106240. * @param name defines camera name
  106241. * @param alpha defines alpha angle (in radians)
  106242. * @param beta defines beta angle (in radians)
  106243. * @param radius defines radius
  106244. * @param target defines camera target
  106245. * @param interaxialDistance defines distance between each color axis
  106246. * @param scene defines the hosting scene
  106247. */
  106248. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106249. /**
  106250. * Gets camera class name
  106251. * @returns AnaglyphArcRotateCamera
  106252. */
  106253. getClassName(): string;
  106254. }
  106255. }
  106256. declare module BABYLON {
  106257. /**
  106258. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106259. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106260. */
  106261. export class AnaglyphFreeCamera extends FreeCamera {
  106262. /**
  106263. * Creates a new AnaglyphFreeCamera
  106264. * @param name defines camera name
  106265. * @param position defines initial position
  106266. * @param interaxialDistance defines distance between each color axis
  106267. * @param scene defines the hosting scene
  106268. */
  106269. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106270. /**
  106271. * Gets camera class name
  106272. * @returns AnaglyphFreeCamera
  106273. */
  106274. getClassName(): string;
  106275. }
  106276. }
  106277. declare module BABYLON {
  106278. /**
  106279. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106280. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106281. */
  106282. export class AnaglyphGamepadCamera extends GamepadCamera {
  106283. /**
  106284. * Creates a new AnaglyphGamepadCamera
  106285. * @param name defines camera name
  106286. * @param position defines initial position
  106287. * @param interaxialDistance defines distance between each color axis
  106288. * @param scene defines the hosting scene
  106289. */
  106290. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106291. /**
  106292. * Gets camera class name
  106293. * @returns AnaglyphGamepadCamera
  106294. */
  106295. getClassName(): string;
  106296. }
  106297. }
  106298. declare module BABYLON {
  106299. /**
  106300. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106301. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106302. */
  106303. export class AnaglyphUniversalCamera extends UniversalCamera {
  106304. /**
  106305. * Creates a new AnaglyphUniversalCamera
  106306. * @param name defines camera name
  106307. * @param position defines initial position
  106308. * @param interaxialDistance defines distance between each color axis
  106309. * @param scene defines the hosting scene
  106310. */
  106311. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106312. /**
  106313. * Gets camera class name
  106314. * @returns AnaglyphUniversalCamera
  106315. */
  106316. getClassName(): string;
  106317. }
  106318. }
  106319. declare module BABYLON {
  106320. /** @hidden */
  106321. export var stereoscopicInterlacePixelShader: {
  106322. name: string;
  106323. shader: string;
  106324. };
  106325. }
  106326. declare module BABYLON {
  106327. /**
  106328. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106329. */
  106330. export class StereoscopicInterlacePostProcess extends PostProcess {
  106331. private _stepSize;
  106332. private _passedProcess;
  106333. /**
  106334. * Initializes a StereoscopicInterlacePostProcess
  106335. * @param name The name of the effect.
  106336. * @param rigCameras The rig cameras to be appled to the post process
  106337. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106339. * @param engine The engine which the post process will be applied. (default: current engine)
  106340. * @param reusable If the post process can be reused on the same frame. (default: false)
  106341. */
  106342. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106343. }
  106344. }
  106345. declare module BABYLON {
  106346. /**
  106347. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106348. * @see http://doc.babylonjs.com/features/cameras
  106349. */
  106350. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106351. /**
  106352. * Creates a new StereoscopicArcRotateCamera
  106353. * @param name defines camera name
  106354. * @param alpha defines alpha angle (in radians)
  106355. * @param beta defines beta angle (in radians)
  106356. * @param radius defines radius
  106357. * @param target defines camera target
  106358. * @param interaxialDistance defines distance between each color axis
  106359. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106360. * @param scene defines the hosting scene
  106361. */
  106362. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106363. /**
  106364. * Gets camera class name
  106365. * @returns StereoscopicArcRotateCamera
  106366. */
  106367. getClassName(): string;
  106368. }
  106369. }
  106370. declare module BABYLON {
  106371. /**
  106372. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106373. * @see http://doc.babylonjs.com/features/cameras
  106374. */
  106375. export class StereoscopicFreeCamera extends FreeCamera {
  106376. /**
  106377. * Creates a new StereoscopicFreeCamera
  106378. * @param name defines camera name
  106379. * @param position defines initial position
  106380. * @param interaxialDistance defines distance between each color axis
  106381. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106382. * @param scene defines the hosting scene
  106383. */
  106384. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106385. /**
  106386. * Gets camera class name
  106387. * @returns StereoscopicFreeCamera
  106388. */
  106389. getClassName(): string;
  106390. }
  106391. }
  106392. declare module BABYLON {
  106393. /**
  106394. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106395. * @see http://doc.babylonjs.com/features/cameras
  106396. */
  106397. export class StereoscopicGamepadCamera extends GamepadCamera {
  106398. /**
  106399. * Creates a new StereoscopicGamepadCamera
  106400. * @param name defines camera name
  106401. * @param position defines initial position
  106402. * @param interaxialDistance defines distance between each color axis
  106403. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106404. * @param scene defines the hosting scene
  106405. */
  106406. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106407. /**
  106408. * Gets camera class name
  106409. * @returns StereoscopicGamepadCamera
  106410. */
  106411. getClassName(): string;
  106412. }
  106413. }
  106414. declare module BABYLON {
  106415. /**
  106416. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106417. * @see http://doc.babylonjs.com/features/cameras
  106418. */
  106419. export class StereoscopicUniversalCamera extends UniversalCamera {
  106420. /**
  106421. * Creates a new StereoscopicUniversalCamera
  106422. * @param name defines camera name
  106423. * @param position defines initial position
  106424. * @param interaxialDistance defines distance between each color axis
  106425. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106426. * @param scene defines the hosting scene
  106427. */
  106428. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106429. /**
  106430. * Gets camera class name
  106431. * @returns StereoscopicUniversalCamera
  106432. */
  106433. getClassName(): string;
  106434. }
  106435. }
  106436. declare module BABYLON {
  106437. /**
  106438. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106439. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106440. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106441. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106442. */
  106443. export class VirtualJoysticksCamera extends FreeCamera {
  106444. /**
  106445. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106446. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106447. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106448. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106449. * @param name Define the name of the camera in the scene
  106450. * @param position Define the start position of the camera in the scene
  106451. * @param scene Define the scene the camera belongs to
  106452. */
  106453. constructor(name: string, position: Vector3, scene: Scene);
  106454. /**
  106455. * Gets the current object class name.
  106456. * @return the class name
  106457. */
  106458. getClassName(): string;
  106459. }
  106460. }
  106461. declare module BABYLON {
  106462. /**
  106463. * This represents all the required metrics to create a VR camera.
  106464. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106465. */
  106466. export class VRCameraMetrics {
  106467. /**
  106468. * Define the horizontal resolution off the screen.
  106469. */
  106470. hResolution: number;
  106471. /**
  106472. * Define the vertical resolution off the screen.
  106473. */
  106474. vResolution: number;
  106475. /**
  106476. * Define the horizontal screen size.
  106477. */
  106478. hScreenSize: number;
  106479. /**
  106480. * Define the vertical screen size.
  106481. */
  106482. vScreenSize: number;
  106483. /**
  106484. * Define the vertical screen center position.
  106485. */
  106486. vScreenCenter: number;
  106487. /**
  106488. * Define the distance of the eyes to the screen.
  106489. */
  106490. eyeToScreenDistance: number;
  106491. /**
  106492. * Define the distance between both lenses
  106493. */
  106494. lensSeparationDistance: number;
  106495. /**
  106496. * Define the distance between both viewer's eyes.
  106497. */
  106498. interpupillaryDistance: number;
  106499. /**
  106500. * Define the distortion factor of the VR postprocess.
  106501. * Please, touch with care.
  106502. */
  106503. distortionK: number[];
  106504. /**
  106505. * Define the chromatic aberration correction factors for the VR post process.
  106506. */
  106507. chromaAbCorrection: number[];
  106508. /**
  106509. * Define the scale factor of the post process.
  106510. * The smaller the better but the slower.
  106511. */
  106512. postProcessScaleFactor: number;
  106513. /**
  106514. * Define an offset for the lens center.
  106515. */
  106516. lensCenterOffset: number;
  106517. /**
  106518. * Define if the current vr camera should compensate the distortion of the lense or not.
  106519. */
  106520. compensateDistortion: boolean;
  106521. /**
  106522. * Defines if multiview should be enabled when rendering (Default: false)
  106523. */
  106524. multiviewEnabled: boolean;
  106525. /**
  106526. * Gets the rendering aspect ratio based on the provided resolutions.
  106527. */
  106528. readonly aspectRatio: number;
  106529. /**
  106530. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106531. */
  106532. readonly aspectRatioFov: number;
  106533. /**
  106534. * @hidden
  106535. */
  106536. readonly leftHMatrix: Matrix;
  106537. /**
  106538. * @hidden
  106539. */
  106540. readonly rightHMatrix: Matrix;
  106541. /**
  106542. * @hidden
  106543. */
  106544. readonly leftPreViewMatrix: Matrix;
  106545. /**
  106546. * @hidden
  106547. */
  106548. readonly rightPreViewMatrix: Matrix;
  106549. /**
  106550. * Get the default VRMetrics based on the most generic setup.
  106551. * @returns the default vr metrics
  106552. */
  106553. static GetDefault(): VRCameraMetrics;
  106554. }
  106555. }
  106556. declare module BABYLON {
  106557. /** @hidden */
  106558. export var vrDistortionCorrectionPixelShader: {
  106559. name: string;
  106560. shader: string;
  106561. };
  106562. }
  106563. declare module BABYLON {
  106564. /**
  106565. * VRDistortionCorrectionPostProcess used for mobile VR
  106566. */
  106567. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106568. private _isRightEye;
  106569. private _distortionFactors;
  106570. private _postProcessScaleFactor;
  106571. private _lensCenterOffset;
  106572. private _scaleIn;
  106573. private _scaleFactor;
  106574. private _lensCenter;
  106575. /**
  106576. * Initializes the VRDistortionCorrectionPostProcess
  106577. * @param name The name of the effect.
  106578. * @param camera The camera to apply the render pass to.
  106579. * @param isRightEye If this is for the right eye distortion
  106580. * @param vrMetrics All the required metrics for the VR camera
  106581. */
  106582. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106583. }
  106584. }
  106585. declare module BABYLON {
  106586. /**
  106587. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106588. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106589. */
  106590. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106591. /**
  106592. * Creates a new VRDeviceOrientationArcRotateCamera
  106593. * @param name defines camera name
  106594. * @param alpha defines the camera rotation along the logitudinal axis
  106595. * @param beta defines the camera rotation along the latitudinal axis
  106596. * @param radius defines the camera distance from its target
  106597. * @param target defines the camera target
  106598. * @param scene defines the scene the camera belongs to
  106599. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106600. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106601. */
  106602. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106603. /**
  106604. * Gets camera class name
  106605. * @returns VRDeviceOrientationArcRotateCamera
  106606. */
  106607. getClassName(): string;
  106608. }
  106609. }
  106610. declare module BABYLON {
  106611. /**
  106612. * Camera used to simulate VR rendering (based on FreeCamera)
  106613. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106614. */
  106615. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106616. /**
  106617. * Creates a new VRDeviceOrientationFreeCamera
  106618. * @param name defines camera name
  106619. * @param position defines the start position of the camera
  106620. * @param scene defines the scene the camera belongs to
  106621. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106622. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106623. */
  106624. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106625. /**
  106626. * Gets camera class name
  106627. * @returns VRDeviceOrientationFreeCamera
  106628. */
  106629. getClassName(): string;
  106630. }
  106631. }
  106632. declare module BABYLON {
  106633. /**
  106634. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106635. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106636. */
  106637. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106638. /**
  106639. * Creates a new VRDeviceOrientationGamepadCamera
  106640. * @param name defines camera name
  106641. * @param position defines the start position of the camera
  106642. * @param scene defines the scene the camera belongs to
  106643. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106644. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106645. */
  106646. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106647. /**
  106648. * Gets camera class name
  106649. * @returns VRDeviceOrientationGamepadCamera
  106650. */
  106651. getClassName(): string;
  106652. }
  106653. }
  106654. declare module BABYLON {
  106655. /**
  106656. * Base class of materials working in push mode in babylon JS
  106657. * @hidden
  106658. */
  106659. export class PushMaterial extends Material {
  106660. protected _activeEffect: Effect;
  106661. protected _normalMatrix: Matrix;
  106662. /**
  106663. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106664. * This means that the material can keep using a previous shader while a new one is being compiled.
  106665. * This is mostly used when shader parallel compilation is supported (true by default)
  106666. */
  106667. allowShaderHotSwapping: boolean;
  106668. constructor(name: string, scene: Scene);
  106669. getEffect(): Effect;
  106670. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106671. /**
  106672. * Binds the given world matrix to the active effect
  106673. *
  106674. * @param world the matrix to bind
  106675. */
  106676. bindOnlyWorldMatrix(world: Matrix): void;
  106677. /**
  106678. * Binds the given normal matrix to the active effect
  106679. *
  106680. * @param normalMatrix the matrix to bind
  106681. */
  106682. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106683. bind(world: Matrix, mesh?: Mesh): void;
  106684. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106685. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106686. }
  106687. }
  106688. declare module BABYLON {
  106689. /**
  106690. * This groups all the flags used to control the materials channel.
  106691. */
  106692. export class MaterialFlags {
  106693. private static _DiffuseTextureEnabled;
  106694. /**
  106695. * Are diffuse textures enabled in the application.
  106696. */
  106697. static DiffuseTextureEnabled: boolean;
  106698. private static _AmbientTextureEnabled;
  106699. /**
  106700. * Are ambient textures enabled in the application.
  106701. */
  106702. static AmbientTextureEnabled: boolean;
  106703. private static _OpacityTextureEnabled;
  106704. /**
  106705. * Are opacity textures enabled in the application.
  106706. */
  106707. static OpacityTextureEnabled: boolean;
  106708. private static _ReflectionTextureEnabled;
  106709. /**
  106710. * Are reflection textures enabled in the application.
  106711. */
  106712. static ReflectionTextureEnabled: boolean;
  106713. private static _EmissiveTextureEnabled;
  106714. /**
  106715. * Are emissive textures enabled in the application.
  106716. */
  106717. static EmissiveTextureEnabled: boolean;
  106718. private static _SpecularTextureEnabled;
  106719. /**
  106720. * Are specular textures enabled in the application.
  106721. */
  106722. static SpecularTextureEnabled: boolean;
  106723. private static _BumpTextureEnabled;
  106724. /**
  106725. * Are bump textures enabled in the application.
  106726. */
  106727. static BumpTextureEnabled: boolean;
  106728. private static _LightmapTextureEnabled;
  106729. /**
  106730. * Are lightmap textures enabled in the application.
  106731. */
  106732. static LightmapTextureEnabled: boolean;
  106733. private static _RefractionTextureEnabled;
  106734. /**
  106735. * Are refraction textures enabled in the application.
  106736. */
  106737. static RefractionTextureEnabled: boolean;
  106738. private static _ColorGradingTextureEnabled;
  106739. /**
  106740. * Are color grading textures enabled in the application.
  106741. */
  106742. static ColorGradingTextureEnabled: boolean;
  106743. private static _FresnelEnabled;
  106744. /**
  106745. * Are fresnels enabled in the application.
  106746. */
  106747. static FresnelEnabled: boolean;
  106748. private static _ClearCoatTextureEnabled;
  106749. /**
  106750. * Are clear coat textures enabled in the application.
  106751. */
  106752. static ClearCoatTextureEnabled: boolean;
  106753. private static _ClearCoatBumpTextureEnabled;
  106754. /**
  106755. * Are clear coat bump textures enabled in the application.
  106756. */
  106757. static ClearCoatBumpTextureEnabled: boolean;
  106758. private static _ClearCoatTintTextureEnabled;
  106759. /**
  106760. * Are clear coat tint textures enabled in the application.
  106761. */
  106762. static ClearCoatTintTextureEnabled: boolean;
  106763. private static _SheenTextureEnabled;
  106764. /**
  106765. * Are sheen textures enabled in the application.
  106766. */
  106767. static SheenTextureEnabled: boolean;
  106768. private static _AnisotropicTextureEnabled;
  106769. /**
  106770. * Are anisotropic textures enabled in the application.
  106771. */
  106772. static AnisotropicTextureEnabled: boolean;
  106773. private static _ThicknessTextureEnabled;
  106774. /**
  106775. * Are thickness textures enabled in the application.
  106776. */
  106777. static ThicknessTextureEnabled: boolean;
  106778. }
  106779. }
  106780. declare module BABYLON {
  106781. /** @hidden */
  106782. export var defaultFragmentDeclaration: {
  106783. name: string;
  106784. shader: string;
  106785. };
  106786. }
  106787. declare module BABYLON {
  106788. /** @hidden */
  106789. export var defaultUboDeclaration: {
  106790. name: string;
  106791. shader: string;
  106792. };
  106793. }
  106794. declare module BABYLON {
  106795. /** @hidden */
  106796. export var lightFragmentDeclaration: {
  106797. name: string;
  106798. shader: string;
  106799. };
  106800. }
  106801. declare module BABYLON {
  106802. /** @hidden */
  106803. export var lightUboDeclaration: {
  106804. name: string;
  106805. shader: string;
  106806. };
  106807. }
  106808. declare module BABYLON {
  106809. /** @hidden */
  106810. export var lightsFragmentFunctions: {
  106811. name: string;
  106812. shader: string;
  106813. };
  106814. }
  106815. declare module BABYLON {
  106816. /** @hidden */
  106817. export var shadowsFragmentFunctions: {
  106818. name: string;
  106819. shader: string;
  106820. };
  106821. }
  106822. declare module BABYLON {
  106823. /** @hidden */
  106824. export var fresnelFunction: {
  106825. name: string;
  106826. shader: string;
  106827. };
  106828. }
  106829. declare module BABYLON {
  106830. /** @hidden */
  106831. export var reflectionFunction: {
  106832. name: string;
  106833. shader: string;
  106834. };
  106835. }
  106836. declare module BABYLON {
  106837. /** @hidden */
  106838. export var bumpFragmentFunctions: {
  106839. name: string;
  106840. shader: string;
  106841. };
  106842. }
  106843. declare module BABYLON {
  106844. /** @hidden */
  106845. export var logDepthDeclaration: {
  106846. name: string;
  106847. shader: string;
  106848. };
  106849. }
  106850. declare module BABYLON {
  106851. /** @hidden */
  106852. export var bumpFragment: {
  106853. name: string;
  106854. shader: string;
  106855. };
  106856. }
  106857. declare module BABYLON {
  106858. /** @hidden */
  106859. export var depthPrePass: {
  106860. name: string;
  106861. shader: string;
  106862. };
  106863. }
  106864. declare module BABYLON {
  106865. /** @hidden */
  106866. export var lightFragment: {
  106867. name: string;
  106868. shader: string;
  106869. };
  106870. }
  106871. declare module BABYLON {
  106872. /** @hidden */
  106873. export var logDepthFragment: {
  106874. name: string;
  106875. shader: string;
  106876. };
  106877. }
  106878. declare module BABYLON {
  106879. /** @hidden */
  106880. export var defaultPixelShader: {
  106881. name: string;
  106882. shader: string;
  106883. };
  106884. }
  106885. declare module BABYLON {
  106886. /** @hidden */
  106887. export var defaultVertexDeclaration: {
  106888. name: string;
  106889. shader: string;
  106890. };
  106891. }
  106892. declare module BABYLON {
  106893. /** @hidden */
  106894. export var bumpVertexDeclaration: {
  106895. name: string;
  106896. shader: string;
  106897. };
  106898. }
  106899. declare module BABYLON {
  106900. /** @hidden */
  106901. export var bumpVertex: {
  106902. name: string;
  106903. shader: string;
  106904. };
  106905. }
  106906. declare module BABYLON {
  106907. /** @hidden */
  106908. export var fogVertex: {
  106909. name: string;
  106910. shader: string;
  106911. };
  106912. }
  106913. declare module BABYLON {
  106914. /** @hidden */
  106915. export var shadowsVertex: {
  106916. name: string;
  106917. shader: string;
  106918. };
  106919. }
  106920. declare module BABYLON {
  106921. /** @hidden */
  106922. export var pointCloudVertex: {
  106923. name: string;
  106924. shader: string;
  106925. };
  106926. }
  106927. declare module BABYLON {
  106928. /** @hidden */
  106929. export var logDepthVertex: {
  106930. name: string;
  106931. shader: string;
  106932. };
  106933. }
  106934. declare module BABYLON {
  106935. /** @hidden */
  106936. export var defaultVertexShader: {
  106937. name: string;
  106938. shader: string;
  106939. };
  106940. }
  106941. declare module BABYLON {
  106942. /** @hidden */
  106943. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106944. MAINUV1: boolean;
  106945. MAINUV2: boolean;
  106946. DIFFUSE: boolean;
  106947. DIFFUSEDIRECTUV: number;
  106948. AMBIENT: boolean;
  106949. AMBIENTDIRECTUV: number;
  106950. OPACITY: boolean;
  106951. OPACITYDIRECTUV: number;
  106952. OPACITYRGB: boolean;
  106953. REFLECTION: boolean;
  106954. EMISSIVE: boolean;
  106955. EMISSIVEDIRECTUV: number;
  106956. SPECULAR: boolean;
  106957. SPECULARDIRECTUV: number;
  106958. BUMP: boolean;
  106959. BUMPDIRECTUV: number;
  106960. PARALLAX: boolean;
  106961. PARALLAXOCCLUSION: boolean;
  106962. SPECULAROVERALPHA: boolean;
  106963. CLIPPLANE: boolean;
  106964. CLIPPLANE2: boolean;
  106965. CLIPPLANE3: boolean;
  106966. CLIPPLANE4: boolean;
  106967. ALPHATEST: boolean;
  106968. DEPTHPREPASS: boolean;
  106969. ALPHAFROMDIFFUSE: boolean;
  106970. POINTSIZE: boolean;
  106971. FOG: boolean;
  106972. SPECULARTERM: boolean;
  106973. DIFFUSEFRESNEL: boolean;
  106974. OPACITYFRESNEL: boolean;
  106975. REFLECTIONFRESNEL: boolean;
  106976. REFRACTIONFRESNEL: boolean;
  106977. EMISSIVEFRESNEL: boolean;
  106978. FRESNEL: boolean;
  106979. NORMAL: boolean;
  106980. UV1: boolean;
  106981. UV2: boolean;
  106982. VERTEXCOLOR: boolean;
  106983. VERTEXALPHA: boolean;
  106984. NUM_BONE_INFLUENCERS: number;
  106985. BonesPerMesh: number;
  106986. BONETEXTURE: boolean;
  106987. INSTANCES: boolean;
  106988. GLOSSINESS: boolean;
  106989. ROUGHNESS: boolean;
  106990. EMISSIVEASILLUMINATION: boolean;
  106991. LINKEMISSIVEWITHDIFFUSE: boolean;
  106992. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106993. LIGHTMAP: boolean;
  106994. LIGHTMAPDIRECTUV: number;
  106995. OBJECTSPACE_NORMALMAP: boolean;
  106996. USELIGHTMAPASSHADOWMAP: boolean;
  106997. REFLECTIONMAP_3D: boolean;
  106998. REFLECTIONMAP_SPHERICAL: boolean;
  106999. REFLECTIONMAP_PLANAR: boolean;
  107000. REFLECTIONMAP_CUBIC: boolean;
  107001. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107002. REFLECTIONMAP_PROJECTION: boolean;
  107003. REFLECTIONMAP_SKYBOX: boolean;
  107004. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107005. REFLECTIONMAP_EXPLICIT: boolean;
  107006. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107007. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107008. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107009. INVERTCUBICMAP: boolean;
  107010. LOGARITHMICDEPTH: boolean;
  107011. REFRACTION: boolean;
  107012. REFRACTIONMAP_3D: boolean;
  107013. REFLECTIONOVERALPHA: boolean;
  107014. TWOSIDEDLIGHTING: boolean;
  107015. SHADOWFLOAT: boolean;
  107016. MORPHTARGETS: boolean;
  107017. MORPHTARGETS_NORMAL: boolean;
  107018. MORPHTARGETS_TANGENT: boolean;
  107019. MORPHTARGETS_UV: boolean;
  107020. NUM_MORPH_INFLUENCERS: number;
  107021. NONUNIFORMSCALING: boolean;
  107022. PREMULTIPLYALPHA: boolean;
  107023. IMAGEPROCESSING: boolean;
  107024. VIGNETTE: boolean;
  107025. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107026. VIGNETTEBLENDMODEOPAQUE: boolean;
  107027. TONEMAPPING: boolean;
  107028. TONEMAPPING_ACES: boolean;
  107029. CONTRAST: boolean;
  107030. COLORCURVES: boolean;
  107031. COLORGRADING: boolean;
  107032. COLORGRADING3D: boolean;
  107033. SAMPLER3DGREENDEPTH: boolean;
  107034. SAMPLER3DBGRMAP: boolean;
  107035. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107036. MULTIVIEW: boolean;
  107037. /**
  107038. * If the reflection texture on this material is in linear color space
  107039. * @hidden
  107040. */
  107041. IS_REFLECTION_LINEAR: boolean;
  107042. /**
  107043. * If the refraction texture on this material is in linear color space
  107044. * @hidden
  107045. */
  107046. IS_REFRACTION_LINEAR: boolean;
  107047. EXPOSURE: boolean;
  107048. constructor();
  107049. setReflectionMode(modeToEnable: string): void;
  107050. }
  107051. /**
  107052. * This is the default material used in Babylon. It is the best trade off between quality
  107053. * and performances.
  107054. * @see http://doc.babylonjs.com/babylon101/materials
  107055. */
  107056. export class StandardMaterial extends PushMaterial {
  107057. private _diffuseTexture;
  107058. /**
  107059. * The basic texture of the material as viewed under a light.
  107060. */
  107061. diffuseTexture: Nullable<BaseTexture>;
  107062. private _ambientTexture;
  107063. /**
  107064. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107065. */
  107066. ambientTexture: Nullable<BaseTexture>;
  107067. private _opacityTexture;
  107068. /**
  107069. * Define the transparency of the material from a texture.
  107070. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107071. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107072. */
  107073. opacityTexture: Nullable<BaseTexture>;
  107074. private _reflectionTexture;
  107075. /**
  107076. * Define the texture used to display the reflection.
  107077. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107078. */
  107079. reflectionTexture: Nullable<BaseTexture>;
  107080. private _emissiveTexture;
  107081. /**
  107082. * Define texture of the material as if self lit.
  107083. * This will be mixed in the final result even in the absence of light.
  107084. */
  107085. emissiveTexture: Nullable<BaseTexture>;
  107086. private _specularTexture;
  107087. /**
  107088. * Define how the color and intensity of the highlight given by the light in the material.
  107089. */
  107090. specularTexture: Nullable<BaseTexture>;
  107091. private _bumpTexture;
  107092. /**
  107093. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107094. * 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.
  107095. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107096. */
  107097. bumpTexture: Nullable<BaseTexture>;
  107098. private _lightmapTexture;
  107099. /**
  107100. * Complex lighting can be computationally expensive to compute at runtime.
  107101. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107102. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107103. */
  107104. lightmapTexture: Nullable<BaseTexture>;
  107105. private _refractionTexture;
  107106. /**
  107107. * Define the texture used to display the refraction.
  107108. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107109. */
  107110. refractionTexture: Nullable<BaseTexture>;
  107111. /**
  107112. * The color of the material lit by the environmental background lighting.
  107113. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107114. */
  107115. ambientColor: Color3;
  107116. /**
  107117. * The basic color of the material as viewed under a light.
  107118. */
  107119. diffuseColor: Color3;
  107120. /**
  107121. * Define how the color and intensity of the highlight given by the light in the material.
  107122. */
  107123. specularColor: Color3;
  107124. /**
  107125. * Define the color of the material as if self lit.
  107126. * This will be mixed in the final result even in the absence of light.
  107127. */
  107128. emissiveColor: Color3;
  107129. /**
  107130. * Defines how sharp are the highlights in the material.
  107131. * The bigger the value the sharper giving a more glossy feeling to the result.
  107132. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107133. */
  107134. specularPower: number;
  107135. private _useAlphaFromDiffuseTexture;
  107136. /**
  107137. * Does the transparency come from the diffuse texture alpha channel.
  107138. */
  107139. useAlphaFromDiffuseTexture: boolean;
  107140. private _useEmissiveAsIllumination;
  107141. /**
  107142. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107143. */
  107144. useEmissiveAsIllumination: boolean;
  107145. private _linkEmissiveWithDiffuse;
  107146. /**
  107147. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107148. * the emissive level when the final color is close to one.
  107149. */
  107150. linkEmissiveWithDiffuse: boolean;
  107151. private _useSpecularOverAlpha;
  107152. /**
  107153. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107154. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107155. */
  107156. useSpecularOverAlpha: boolean;
  107157. private _useReflectionOverAlpha;
  107158. /**
  107159. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107160. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107161. */
  107162. useReflectionOverAlpha: boolean;
  107163. private _disableLighting;
  107164. /**
  107165. * Does lights from the scene impacts this material.
  107166. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107167. */
  107168. disableLighting: boolean;
  107169. private _useObjectSpaceNormalMap;
  107170. /**
  107171. * Allows using an object space normal map (instead of tangent space).
  107172. */
  107173. useObjectSpaceNormalMap: boolean;
  107174. private _useParallax;
  107175. /**
  107176. * Is parallax enabled or not.
  107177. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107178. */
  107179. useParallax: boolean;
  107180. private _useParallaxOcclusion;
  107181. /**
  107182. * Is parallax occlusion enabled or not.
  107183. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107184. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107185. */
  107186. useParallaxOcclusion: boolean;
  107187. /**
  107188. * 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.
  107189. */
  107190. parallaxScaleBias: number;
  107191. private _roughness;
  107192. /**
  107193. * Helps to define how blurry the reflections should appears in the material.
  107194. */
  107195. roughness: number;
  107196. /**
  107197. * In case of refraction, define the value of the index of refraction.
  107198. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107199. */
  107200. indexOfRefraction: number;
  107201. /**
  107202. * Invert the refraction texture alongside the y axis.
  107203. * It can be useful with procedural textures or probe for instance.
  107204. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107205. */
  107206. invertRefractionY: boolean;
  107207. /**
  107208. * Defines the alpha limits in alpha test mode.
  107209. */
  107210. alphaCutOff: number;
  107211. private _useLightmapAsShadowmap;
  107212. /**
  107213. * In case of light mapping, define whether the map contains light or shadow informations.
  107214. */
  107215. useLightmapAsShadowmap: boolean;
  107216. private _diffuseFresnelParameters;
  107217. /**
  107218. * Define the diffuse fresnel parameters of the material.
  107219. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107220. */
  107221. diffuseFresnelParameters: FresnelParameters;
  107222. private _opacityFresnelParameters;
  107223. /**
  107224. * Define the opacity fresnel parameters of the material.
  107225. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107226. */
  107227. opacityFresnelParameters: FresnelParameters;
  107228. private _reflectionFresnelParameters;
  107229. /**
  107230. * Define the reflection fresnel parameters of the material.
  107231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107232. */
  107233. reflectionFresnelParameters: FresnelParameters;
  107234. private _refractionFresnelParameters;
  107235. /**
  107236. * Define the refraction fresnel parameters of the material.
  107237. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107238. */
  107239. refractionFresnelParameters: FresnelParameters;
  107240. private _emissiveFresnelParameters;
  107241. /**
  107242. * Define the emissive fresnel parameters of the material.
  107243. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107244. */
  107245. emissiveFresnelParameters: FresnelParameters;
  107246. private _useReflectionFresnelFromSpecular;
  107247. /**
  107248. * If true automatically deducts the fresnels values from the material specularity.
  107249. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107250. */
  107251. useReflectionFresnelFromSpecular: boolean;
  107252. private _useGlossinessFromSpecularMapAlpha;
  107253. /**
  107254. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107255. */
  107256. useGlossinessFromSpecularMapAlpha: boolean;
  107257. private _maxSimultaneousLights;
  107258. /**
  107259. * Defines the maximum number of lights that can be used in the material
  107260. */
  107261. maxSimultaneousLights: number;
  107262. private _invertNormalMapX;
  107263. /**
  107264. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107265. */
  107266. invertNormalMapX: boolean;
  107267. private _invertNormalMapY;
  107268. /**
  107269. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107270. */
  107271. invertNormalMapY: boolean;
  107272. private _twoSidedLighting;
  107273. /**
  107274. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107275. */
  107276. twoSidedLighting: boolean;
  107277. /**
  107278. * Default configuration related to image processing available in the standard Material.
  107279. */
  107280. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107281. /**
  107282. * Gets the image processing configuration used either in this material.
  107283. */
  107284. /**
  107285. * Sets the Default image processing configuration used either in the this material.
  107286. *
  107287. * If sets to null, the scene one is in use.
  107288. */
  107289. imageProcessingConfiguration: ImageProcessingConfiguration;
  107290. /**
  107291. * Keep track of the image processing observer to allow dispose and replace.
  107292. */
  107293. private _imageProcessingObserver;
  107294. /**
  107295. * Attaches a new image processing configuration to the Standard Material.
  107296. * @param configuration
  107297. */
  107298. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107299. /**
  107300. * Gets wether the color curves effect is enabled.
  107301. */
  107302. /**
  107303. * Sets wether the color curves effect is enabled.
  107304. */
  107305. cameraColorCurvesEnabled: boolean;
  107306. /**
  107307. * Gets wether the color grading effect is enabled.
  107308. */
  107309. /**
  107310. * Gets wether the color grading effect is enabled.
  107311. */
  107312. cameraColorGradingEnabled: boolean;
  107313. /**
  107314. * Gets wether tonemapping is enabled or not.
  107315. */
  107316. /**
  107317. * Sets wether tonemapping is enabled or not
  107318. */
  107319. cameraToneMappingEnabled: boolean;
  107320. /**
  107321. * The camera exposure used on this material.
  107322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107323. * This corresponds to a photographic exposure.
  107324. */
  107325. /**
  107326. * The camera exposure used on this material.
  107327. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107328. * This corresponds to a photographic exposure.
  107329. */
  107330. cameraExposure: number;
  107331. /**
  107332. * Gets The camera contrast used on this material.
  107333. */
  107334. /**
  107335. * Sets The camera contrast used on this material.
  107336. */
  107337. cameraContrast: number;
  107338. /**
  107339. * Gets the Color Grading 2D Lookup Texture.
  107340. */
  107341. /**
  107342. * Sets the Color Grading 2D Lookup Texture.
  107343. */
  107344. cameraColorGradingTexture: Nullable<BaseTexture>;
  107345. /**
  107346. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107347. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107348. * 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;
  107349. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107350. */
  107351. /**
  107352. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107353. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107354. * 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;
  107355. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107356. */
  107357. cameraColorCurves: Nullable<ColorCurves>;
  107358. /**
  107359. * Custom callback helping to override the default shader used in the material.
  107360. */
  107361. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107362. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107363. protected _worldViewProjectionMatrix: Matrix;
  107364. protected _globalAmbientColor: Color3;
  107365. protected _useLogarithmicDepth: boolean;
  107366. protected _rebuildInParallel: boolean;
  107367. /**
  107368. * Instantiates a new standard material.
  107369. * This is the default material used in Babylon. It is the best trade off between quality
  107370. * and performances.
  107371. * @see http://doc.babylonjs.com/babylon101/materials
  107372. * @param name Define the name of the material in the scene
  107373. * @param scene Define the scene the material belong to
  107374. */
  107375. constructor(name: string, scene: Scene);
  107376. /**
  107377. * Gets a boolean indicating that current material needs to register RTT
  107378. */
  107379. readonly hasRenderTargetTextures: boolean;
  107380. /**
  107381. * Gets the current class name of the material e.g. "StandardMaterial"
  107382. * Mainly use in serialization.
  107383. * @returns the class name
  107384. */
  107385. getClassName(): string;
  107386. /**
  107387. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107388. * You can try switching to logarithmic depth.
  107389. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107390. */
  107391. useLogarithmicDepth: boolean;
  107392. /**
  107393. * Specifies if the material will require alpha blending
  107394. * @returns a boolean specifying if alpha blending is needed
  107395. */
  107396. needAlphaBlending(): boolean;
  107397. /**
  107398. * Specifies if this material should be rendered in alpha test mode
  107399. * @returns a boolean specifying if an alpha test is needed.
  107400. */
  107401. needAlphaTesting(): boolean;
  107402. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107403. /**
  107404. * Get the texture used for alpha test purpose.
  107405. * @returns the diffuse texture in case of the standard material.
  107406. */
  107407. getAlphaTestTexture(): Nullable<BaseTexture>;
  107408. /**
  107409. * Get if the submesh is ready to be used and all its information available.
  107410. * Child classes can use it to update shaders
  107411. * @param mesh defines the mesh to check
  107412. * @param subMesh defines which submesh to check
  107413. * @param useInstances specifies that instances should be used
  107414. * @returns a boolean indicating that the submesh is ready or not
  107415. */
  107416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107417. /**
  107418. * Builds the material UBO layouts.
  107419. * Used internally during the effect preparation.
  107420. */
  107421. buildUniformLayout(): void;
  107422. /**
  107423. * Unbinds the material from the mesh
  107424. */
  107425. unbind(): void;
  107426. /**
  107427. * Binds the submesh to this material by preparing the effect and shader to draw
  107428. * @param world defines the world transformation matrix
  107429. * @param mesh defines the mesh containing the submesh
  107430. * @param subMesh defines the submesh to bind the material to
  107431. */
  107432. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107433. /**
  107434. * Get the list of animatables in the material.
  107435. * @returns the list of animatables object used in the material
  107436. */
  107437. getAnimatables(): IAnimatable[];
  107438. /**
  107439. * Gets the active textures from the material
  107440. * @returns an array of textures
  107441. */
  107442. getActiveTextures(): BaseTexture[];
  107443. /**
  107444. * Specifies if the material uses a texture
  107445. * @param texture defines the texture to check against the material
  107446. * @returns a boolean specifying if the material uses the texture
  107447. */
  107448. hasTexture(texture: BaseTexture): boolean;
  107449. /**
  107450. * Disposes the material
  107451. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107452. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107453. */
  107454. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107455. /**
  107456. * Makes a duplicate of the material, and gives it a new name
  107457. * @param name defines the new name for the duplicated material
  107458. * @returns the cloned material
  107459. */
  107460. clone(name: string): StandardMaterial;
  107461. /**
  107462. * Serializes this material in a JSON representation
  107463. * @returns the serialized material object
  107464. */
  107465. serialize(): any;
  107466. /**
  107467. * Creates a standard material from parsed material data
  107468. * @param source defines the JSON representation of the material
  107469. * @param scene defines the hosting scene
  107470. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107471. * @returns a new standard material
  107472. */
  107473. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107474. /**
  107475. * Are diffuse textures enabled in the application.
  107476. */
  107477. static DiffuseTextureEnabled: boolean;
  107478. /**
  107479. * Are ambient textures enabled in the application.
  107480. */
  107481. static AmbientTextureEnabled: boolean;
  107482. /**
  107483. * Are opacity textures enabled in the application.
  107484. */
  107485. static OpacityTextureEnabled: boolean;
  107486. /**
  107487. * Are reflection textures enabled in the application.
  107488. */
  107489. static ReflectionTextureEnabled: boolean;
  107490. /**
  107491. * Are emissive textures enabled in the application.
  107492. */
  107493. static EmissiveTextureEnabled: boolean;
  107494. /**
  107495. * Are specular textures enabled in the application.
  107496. */
  107497. static SpecularTextureEnabled: boolean;
  107498. /**
  107499. * Are bump textures enabled in the application.
  107500. */
  107501. static BumpTextureEnabled: boolean;
  107502. /**
  107503. * Are lightmap textures enabled in the application.
  107504. */
  107505. static LightmapTextureEnabled: boolean;
  107506. /**
  107507. * Are refraction textures enabled in the application.
  107508. */
  107509. static RefractionTextureEnabled: boolean;
  107510. /**
  107511. * Are color grading textures enabled in the application.
  107512. */
  107513. static ColorGradingTextureEnabled: boolean;
  107514. /**
  107515. * Are fresnels enabled in the application.
  107516. */
  107517. static FresnelEnabled: boolean;
  107518. }
  107519. }
  107520. declare module BABYLON {
  107521. /** @hidden */
  107522. export var imageProcessingPixelShader: {
  107523. name: string;
  107524. shader: string;
  107525. };
  107526. }
  107527. declare module BABYLON {
  107528. /**
  107529. * ImageProcessingPostProcess
  107530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107531. */
  107532. export class ImageProcessingPostProcess extends PostProcess {
  107533. /**
  107534. * Default configuration related to image processing available in the PBR Material.
  107535. */
  107536. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107537. /**
  107538. * Gets the image processing configuration used either in this material.
  107539. */
  107540. /**
  107541. * Sets the Default image processing configuration used either in the this material.
  107542. *
  107543. * If sets to null, the scene one is in use.
  107544. */
  107545. imageProcessingConfiguration: ImageProcessingConfiguration;
  107546. /**
  107547. * Keep track of the image processing observer to allow dispose and replace.
  107548. */
  107549. private _imageProcessingObserver;
  107550. /**
  107551. * Attaches a new image processing configuration to the PBR Material.
  107552. * @param configuration
  107553. */
  107554. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107555. /**
  107556. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107557. */
  107558. /**
  107559. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107560. */
  107561. colorCurves: Nullable<ColorCurves>;
  107562. /**
  107563. * Gets wether the color curves effect is enabled.
  107564. */
  107565. /**
  107566. * Sets wether the color curves effect is enabled.
  107567. */
  107568. colorCurvesEnabled: boolean;
  107569. /**
  107570. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107571. */
  107572. /**
  107573. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107574. */
  107575. colorGradingTexture: Nullable<BaseTexture>;
  107576. /**
  107577. * Gets wether the color grading effect is enabled.
  107578. */
  107579. /**
  107580. * Gets wether the color grading effect is enabled.
  107581. */
  107582. colorGradingEnabled: boolean;
  107583. /**
  107584. * Gets exposure used in the effect.
  107585. */
  107586. /**
  107587. * Sets exposure used in the effect.
  107588. */
  107589. exposure: number;
  107590. /**
  107591. * Gets wether tonemapping is enabled or not.
  107592. */
  107593. /**
  107594. * Sets wether tonemapping is enabled or not
  107595. */
  107596. toneMappingEnabled: boolean;
  107597. /**
  107598. * Gets the type of tone mapping effect.
  107599. */
  107600. /**
  107601. * Sets the type of tone mapping effect.
  107602. */
  107603. toneMappingType: number;
  107604. /**
  107605. * Gets contrast used in the effect.
  107606. */
  107607. /**
  107608. * Sets contrast used in the effect.
  107609. */
  107610. contrast: number;
  107611. /**
  107612. * Gets Vignette stretch size.
  107613. */
  107614. /**
  107615. * Sets Vignette stretch size.
  107616. */
  107617. vignetteStretch: number;
  107618. /**
  107619. * Gets Vignette centre X Offset.
  107620. */
  107621. /**
  107622. * Sets Vignette centre X Offset.
  107623. */
  107624. vignetteCentreX: number;
  107625. /**
  107626. * Gets Vignette centre Y Offset.
  107627. */
  107628. /**
  107629. * Sets Vignette centre Y Offset.
  107630. */
  107631. vignetteCentreY: number;
  107632. /**
  107633. * Gets Vignette weight or intensity of the vignette effect.
  107634. */
  107635. /**
  107636. * Sets Vignette weight or intensity of the vignette effect.
  107637. */
  107638. vignetteWeight: number;
  107639. /**
  107640. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107641. * if vignetteEnabled is set to true.
  107642. */
  107643. /**
  107644. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107645. * if vignetteEnabled is set to true.
  107646. */
  107647. vignetteColor: Color4;
  107648. /**
  107649. * Gets Camera field of view used by the Vignette effect.
  107650. */
  107651. /**
  107652. * Sets Camera field of view used by the Vignette effect.
  107653. */
  107654. vignetteCameraFov: number;
  107655. /**
  107656. * Gets the vignette blend mode allowing different kind of effect.
  107657. */
  107658. /**
  107659. * Sets the vignette blend mode allowing different kind of effect.
  107660. */
  107661. vignetteBlendMode: number;
  107662. /**
  107663. * Gets wether the vignette effect is enabled.
  107664. */
  107665. /**
  107666. * Sets wether the vignette effect is enabled.
  107667. */
  107668. vignetteEnabled: boolean;
  107669. private _fromLinearSpace;
  107670. /**
  107671. * Gets wether the input of the processing is in Gamma or Linear Space.
  107672. */
  107673. /**
  107674. * Sets wether the input of the processing is in Gamma or Linear Space.
  107675. */
  107676. fromLinearSpace: boolean;
  107677. /**
  107678. * Defines cache preventing GC.
  107679. */
  107680. private _defines;
  107681. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107682. /**
  107683. * "ImageProcessingPostProcess"
  107684. * @returns "ImageProcessingPostProcess"
  107685. */
  107686. getClassName(): string;
  107687. protected _updateParameters(): void;
  107688. dispose(camera?: Camera): void;
  107689. }
  107690. }
  107691. declare module BABYLON {
  107692. /**
  107693. * Class containing static functions to help procedurally build meshes
  107694. */
  107695. export class GroundBuilder {
  107696. /**
  107697. * Creates a ground mesh
  107698. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107699. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107701. * @param name defines the name of the mesh
  107702. * @param options defines the options used to create the mesh
  107703. * @param scene defines the hosting scene
  107704. * @returns the ground mesh
  107705. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107706. */
  107707. static CreateGround(name: string, options: {
  107708. width?: number;
  107709. height?: number;
  107710. subdivisions?: number;
  107711. subdivisionsX?: number;
  107712. subdivisionsY?: number;
  107713. updatable?: boolean;
  107714. }, scene: any): Mesh;
  107715. /**
  107716. * Creates a tiled ground mesh
  107717. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107718. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107719. * * 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
  107720. * * 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
  107721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107722. * @param name defines the name of the mesh
  107723. * @param options defines the options used to create the mesh
  107724. * @param scene defines the hosting scene
  107725. * @returns the tiled ground mesh
  107726. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107727. */
  107728. static CreateTiledGround(name: string, options: {
  107729. xmin: number;
  107730. zmin: number;
  107731. xmax: number;
  107732. zmax: number;
  107733. subdivisions?: {
  107734. w: number;
  107735. h: number;
  107736. };
  107737. precision?: {
  107738. w: number;
  107739. h: number;
  107740. };
  107741. updatable?: boolean;
  107742. }, scene?: Nullable<Scene>): Mesh;
  107743. /**
  107744. * Creates a ground mesh from a height map
  107745. * * The parameter `url` sets the URL of the height map image resource.
  107746. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107747. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107748. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107749. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107750. * * 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.
  107751. * * 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).
  107752. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107754. * @param name defines the name of the mesh
  107755. * @param url defines the url to the height map
  107756. * @param options defines the options used to create the mesh
  107757. * @param scene defines the hosting scene
  107758. * @returns the ground mesh
  107759. * @see https://doc.babylonjs.com/babylon101/height_map
  107760. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107761. */
  107762. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107763. width?: number;
  107764. height?: number;
  107765. subdivisions?: number;
  107766. minHeight?: number;
  107767. maxHeight?: number;
  107768. colorFilter?: Color3;
  107769. alphaFilter?: number;
  107770. updatable?: boolean;
  107771. onReady?: (mesh: GroundMesh) => void;
  107772. }, scene?: Nullable<Scene>): GroundMesh;
  107773. }
  107774. }
  107775. declare module BABYLON {
  107776. /**
  107777. * Class containing static functions to help procedurally build meshes
  107778. */
  107779. export class TorusBuilder {
  107780. /**
  107781. * Creates a torus mesh
  107782. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107783. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107784. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107788. * @param name defines the name of the mesh
  107789. * @param options defines the options used to create the mesh
  107790. * @param scene defines the hosting scene
  107791. * @returns the torus mesh
  107792. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107793. */
  107794. static CreateTorus(name: string, options: {
  107795. diameter?: number;
  107796. thickness?: number;
  107797. tessellation?: number;
  107798. updatable?: boolean;
  107799. sideOrientation?: number;
  107800. frontUVs?: Vector4;
  107801. backUVs?: Vector4;
  107802. }, scene: any): Mesh;
  107803. }
  107804. }
  107805. declare module BABYLON {
  107806. /**
  107807. * Class containing static functions to help procedurally build meshes
  107808. */
  107809. export class CylinderBuilder {
  107810. /**
  107811. * Creates a cylinder or a cone mesh
  107812. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107813. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107814. * * 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.
  107815. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107816. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107817. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107818. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107819. * * 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).
  107820. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107821. * * 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).
  107822. * * 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
  107823. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107824. * * 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
  107825. * * 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.
  107826. * * If `enclose` is false, a ring surface is one element.
  107827. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107828. * * 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
  107829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107832. * @param name defines the name of the mesh
  107833. * @param options defines the options used to create the mesh
  107834. * @param scene defines the hosting scene
  107835. * @returns the cylinder mesh
  107836. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107837. */
  107838. static CreateCylinder(name: string, options: {
  107839. height?: number;
  107840. diameterTop?: number;
  107841. diameterBottom?: number;
  107842. diameter?: number;
  107843. tessellation?: number;
  107844. subdivisions?: number;
  107845. arc?: number;
  107846. faceColors?: Color4[];
  107847. faceUV?: Vector4[];
  107848. updatable?: boolean;
  107849. hasRings?: boolean;
  107850. enclose?: boolean;
  107851. cap?: number;
  107852. sideOrientation?: number;
  107853. frontUVs?: Vector4;
  107854. backUVs?: Vector4;
  107855. }, scene: any): Mesh;
  107856. }
  107857. }
  107858. declare module BABYLON {
  107859. /**
  107860. * Options to modify the vr teleportation behavior.
  107861. */
  107862. export interface VRTeleportationOptions {
  107863. /**
  107864. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107865. */
  107866. floorMeshName?: string;
  107867. /**
  107868. * A list of meshes to be used as the teleportation floor. (default: empty)
  107869. */
  107870. floorMeshes?: Mesh[];
  107871. }
  107872. /**
  107873. * Options to modify the vr experience helper's behavior.
  107874. */
  107875. export interface VRExperienceHelperOptions extends WebVROptions {
  107876. /**
  107877. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107878. */
  107879. createDeviceOrientationCamera?: boolean;
  107880. /**
  107881. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107882. */
  107883. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107884. /**
  107885. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107886. */
  107887. laserToggle?: boolean;
  107888. /**
  107889. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107890. */
  107891. floorMeshes?: Mesh[];
  107892. /**
  107893. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107894. */
  107895. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107896. }
  107897. /**
  107898. * Event containing information after VR has been entered
  107899. */
  107900. export class OnAfterEnteringVRObservableEvent {
  107901. /**
  107902. * If entering vr was successful
  107903. */
  107904. success: boolean;
  107905. }
  107906. /**
  107907. * Helps to quickly add VR support to an existing scene.
  107908. * See http://doc.babylonjs.com/how_to/webvr_helper
  107909. */
  107910. export class VRExperienceHelper {
  107911. /** Options to modify the vr experience helper's behavior. */
  107912. webVROptions: VRExperienceHelperOptions;
  107913. private _scene;
  107914. private _position;
  107915. private _btnVR;
  107916. private _btnVRDisplayed;
  107917. private _webVRsupported;
  107918. private _webVRready;
  107919. private _webVRrequesting;
  107920. private _webVRpresenting;
  107921. private _hasEnteredVR;
  107922. private _fullscreenVRpresenting;
  107923. private _canvas;
  107924. private _webVRCamera;
  107925. private _vrDeviceOrientationCamera;
  107926. private _deviceOrientationCamera;
  107927. private _existingCamera;
  107928. private _onKeyDown;
  107929. private _onVrDisplayPresentChange;
  107930. private _onVRDisplayChanged;
  107931. private _onVRRequestPresentStart;
  107932. private _onVRRequestPresentComplete;
  107933. /**
  107934. * 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)
  107935. */
  107936. enableGazeEvenWhenNoPointerLock: boolean;
  107937. /**
  107938. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107939. */
  107940. exitVROnDoubleTap: boolean;
  107941. /**
  107942. * Observable raised right before entering VR.
  107943. */
  107944. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107945. /**
  107946. * Observable raised when entering VR has completed.
  107947. */
  107948. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107949. /**
  107950. * Observable raised when exiting VR.
  107951. */
  107952. onExitingVRObservable: Observable<VRExperienceHelper>;
  107953. /**
  107954. * Observable raised when controller mesh is loaded.
  107955. */
  107956. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107957. /** Return this.onEnteringVRObservable
  107958. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107959. */
  107960. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107961. /** Return this.onExitingVRObservable
  107962. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107963. */
  107964. readonly onExitingVR: Observable<VRExperienceHelper>;
  107965. /** Return this.onControllerMeshLoadedObservable
  107966. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107967. */
  107968. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107969. private _rayLength;
  107970. private _useCustomVRButton;
  107971. private _teleportationRequested;
  107972. private _teleportActive;
  107973. private _floorMeshName;
  107974. private _floorMeshesCollection;
  107975. private _rotationAllowed;
  107976. private _teleportBackwardsVector;
  107977. private _teleportationTarget;
  107978. private _isDefaultTeleportationTarget;
  107979. private _postProcessMove;
  107980. private _teleportationFillColor;
  107981. private _teleportationBorderColor;
  107982. private _rotationAngle;
  107983. private _haloCenter;
  107984. private _cameraGazer;
  107985. private _padSensibilityUp;
  107986. private _padSensibilityDown;
  107987. private _leftController;
  107988. private _rightController;
  107989. /**
  107990. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107991. */
  107992. onNewMeshSelected: Observable<AbstractMesh>;
  107993. /**
  107994. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107995. * This observable will provide the mesh and the controller used to select the mesh
  107996. */
  107997. onMeshSelectedWithController: Observable<{
  107998. mesh: AbstractMesh;
  107999. controller: WebVRController;
  108000. }>;
  108001. /**
  108002. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108003. */
  108004. onNewMeshPicked: Observable<PickingInfo>;
  108005. private _circleEase;
  108006. /**
  108007. * Observable raised before camera teleportation
  108008. */
  108009. onBeforeCameraTeleport: Observable<Vector3>;
  108010. /**
  108011. * Observable raised after camera teleportation
  108012. */
  108013. onAfterCameraTeleport: Observable<Vector3>;
  108014. /**
  108015. * Observable raised when current selected mesh gets unselected
  108016. */
  108017. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108018. private _raySelectionPredicate;
  108019. /**
  108020. * To be optionaly changed by user to define custom ray selection
  108021. */
  108022. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108023. /**
  108024. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108025. */
  108026. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108027. /**
  108028. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108029. */
  108030. teleportationEnabled: boolean;
  108031. private _defaultHeight;
  108032. private _teleportationInitialized;
  108033. private _interactionsEnabled;
  108034. private _interactionsRequested;
  108035. private _displayGaze;
  108036. private _displayLaserPointer;
  108037. /**
  108038. * The mesh used to display where the user is going to teleport.
  108039. */
  108040. /**
  108041. * Sets the mesh to be used to display where the user is going to teleport.
  108042. */
  108043. teleportationTarget: Mesh;
  108044. /**
  108045. * 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
  108046. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108047. * See http://doc.babylonjs.com/resources/baking_transformations
  108048. */
  108049. gazeTrackerMesh: Mesh;
  108050. /**
  108051. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108052. */
  108053. updateGazeTrackerScale: boolean;
  108054. /**
  108055. * If the gaze trackers color should be updated when selecting meshes
  108056. */
  108057. updateGazeTrackerColor: boolean;
  108058. /**
  108059. * If the controller laser color should be updated when selecting meshes
  108060. */
  108061. updateControllerLaserColor: boolean;
  108062. /**
  108063. * The gaze tracking mesh corresponding to the left controller
  108064. */
  108065. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108066. /**
  108067. * The gaze tracking mesh corresponding to the right controller
  108068. */
  108069. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108070. /**
  108071. * If the ray of the gaze should be displayed.
  108072. */
  108073. /**
  108074. * Sets if the ray of the gaze should be displayed.
  108075. */
  108076. displayGaze: boolean;
  108077. /**
  108078. * If the ray of the LaserPointer should be displayed.
  108079. */
  108080. /**
  108081. * Sets if the ray of the LaserPointer should be displayed.
  108082. */
  108083. displayLaserPointer: boolean;
  108084. /**
  108085. * The deviceOrientationCamera used as the camera when not in VR.
  108086. */
  108087. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108088. /**
  108089. * Based on the current WebVR support, returns the current VR camera used.
  108090. */
  108091. readonly currentVRCamera: Nullable<Camera>;
  108092. /**
  108093. * The webVRCamera which is used when in VR.
  108094. */
  108095. readonly webVRCamera: WebVRFreeCamera;
  108096. /**
  108097. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108098. */
  108099. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108100. /**
  108101. * The html button that is used to trigger entering into VR.
  108102. */
  108103. readonly vrButton: Nullable<HTMLButtonElement>;
  108104. private readonly _teleportationRequestInitiated;
  108105. /**
  108106. * Defines wether or not Pointer lock should be requested when switching to
  108107. * full screen.
  108108. */
  108109. requestPointerLockOnFullScreen: boolean;
  108110. /**
  108111. * Instantiates a VRExperienceHelper.
  108112. * Helps to quickly add VR support to an existing scene.
  108113. * @param scene The scene the VRExperienceHelper belongs to.
  108114. * @param webVROptions Options to modify the vr experience helper's behavior.
  108115. */
  108116. constructor(scene: Scene,
  108117. /** Options to modify the vr experience helper's behavior. */
  108118. webVROptions?: VRExperienceHelperOptions);
  108119. private _onDefaultMeshLoaded;
  108120. private _onResize;
  108121. private _onFullscreenChange;
  108122. /**
  108123. * Gets a value indicating if we are currently in VR mode.
  108124. */
  108125. readonly isInVRMode: boolean;
  108126. private onVrDisplayPresentChange;
  108127. private onVRDisplayChanged;
  108128. private moveButtonToBottomRight;
  108129. private displayVRButton;
  108130. private updateButtonVisibility;
  108131. private _cachedAngularSensibility;
  108132. /**
  108133. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108134. * Otherwise, will use the fullscreen API.
  108135. */
  108136. enterVR(): void;
  108137. /**
  108138. * Attempt to exit VR, or fullscreen.
  108139. */
  108140. exitVR(): void;
  108141. /**
  108142. * The position of the vr experience helper.
  108143. */
  108144. /**
  108145. * Sets the position of the vr experience helper.
  108146. */
  108147. position: Vector3;
  108148. /**
  108149. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108150. */
  108151. enableInteractions(): void;
  108152. private readonly _noControllerIsActive;
  108153. private beforeRender;
  108154. private _isTeleportationFloor;
  108155. /**
  108156. * Adds a floor mesh to be used for teleportation.
  108157. * @param floorMesh the mesh to be used for teleportation.
  108158. */
  108159. addFloorMesh(floorMesh: Mesh): void;
  108160. /**
  108161. * Removes a floor mesh from being used for teleportation.
  108162. * @param floorMesh the mesh to be removed.
  108163. */
  108164. removeFloorMesh(floorMesh: Mesh): void;
  108165. /**
  108166. * Enables interactions and teleportation using the VR controllers and gaze.
  108167. * @param vrTeleportationOptions options to modify teleportation behavior.
  108168. */
  108169. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108170. private _onNewGamepadConnected;
  108171. private _tryEnableInteractionOnController;
  108172. private _onNewGamepadDisconnected;
  108173. private _enableInteractionOnController;
  108174. private _checkTeleportWithRay;
  108175. private _checkRotate;
  108176. private _checkTeleportBackwards;
  108177. private _enableTeleportationOnController;
  108178. private _createTeleportationCircles;
  108179. private _displayTeleportationTarget;
  108180. private _hideTeleportationTarget;
  108181. private _rotateCamera;
  108182. private _moveTeleportationSelectorTo;
  108183. private _workingVector;
  108184. private _workingQuaternion;
  108185. private _workingMatrix;
  108186. /**
  108187. * Teleports the users feet to the desired location
  108188. * @param location The location where the user's feet should be placed
  108189. */
  108190. teleportCamera(location: Vector3): void;
  108191. private _convertNormalToDirectionOfRay;
  108192. private _castRayAndSelectObject;
  108193. private _notifySelectedMeshUnselected;
  108194. /**
  108195. * Sets the color of the laser ray from the vr controllers.
  108196. * @param color new color for the ray.
  108197. */
  108198. changeLaserColor(color: Color3): void;
  108199. /**
  108200. * Sets the color of the ray from the vr headsets gaze.
  108201. * @param color new color for the ray.
  108202. */
  108203. changeGazeColor(color: Color3): void;
  108204. /**
  108205. * Exits VR and disposes of the vr experience helper
  108206. */
  108207. dispose(): void;
  108208. /**
  108209. * Gets the name of the VRExperienceHelper class
  108210. * @returns "VRExperienceHelper"
  108211. */
  108212. getClassName(): string;
  108213. }
  108214. }
  108215. declare module BABYLON {
  108216. /**
  108217. * Manages an XRSession to work with Babylon's engine
  108218. * @see https://doc.babylonjs.com/how_to/webxr
  108219. */
  108220. export class WebXRSessionManager implements IDisposable {
  108221. private scene;
  108222. /**
  108223. * Fires every time a new xrFrame arrives which can be used to update the camera
  108224. */
  108225. onXRFrameObservable: Observable<any>;
  108226. /**
  108227. * Fires when the xr session is ended either by the device or manually done
  108228. */
  108229. onXRSessionEnded: Observable<any>;
  108230. /**
  108231. * Underlying xr session
  108232. */
  108233. session: XRSession;
  108234. /**
  108235. * Type of reference space used when creating the session
  108236. */
  108237. referenceSpace: XRReferenceSpace;
  108238. /** @hidden */
  108239. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108240. /**
  108241. * Current XR frame
  108242. */
  108243. currentFrame: Nullable<XRFrame>;
  108244. private _xrNavigator;
  108245. private baseLayer;
  108246. /**
  108247. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108248. * @param scene The scene which the session should be created for
  108249. */
  108250. constructor(scene: Scene);
  108251. /**
  108252. * Initializes the manager
  108253. * After initialization enterXR can be called to start an XR session
  108254. * @returns Promise which resolves after it is initialized
  108255. */
  108256. initializeAsync(): Promise<void>;
  108257. /**
  108258. * Initializes an xr session
  108259. * @param xrSessionMode mode to initialize
  108260. * @returns a promise which will resolve once the session has been initialized
  108261. */
  108262. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108263. /**
  108264. * Sets the reference space on the xr session
  108265. * @param referenceSpace space to set
  108266. * @returns a promise that will resolve once the reference space has been set
  108267. */
  108268. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108269. /**
  108270. * Updates the render state of the session
  108271. * @param state state to set
  108272. * @returns a promise that resolves once the render state has been updated
  108273. */
  108274. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108275. /**
  108276. * Starts rendering to the xr layer
  108277. * @returns a promise that will resolve once rendering has started
  108278. */
  108279. startRenderingToXRAsync(): Promise<void>;
  108280. /**
  108281. * Stops the xrSession and restores the renderloop
  108282. * @returns Promise which resolves after it exits XR
  108283. */
  108284. exitXRAsync(): Promise<unknown>;
  108285. /**
  108286. * Checks if a session would be supported for the creation options specified
  108287. * @param sessionMode session mode to check if supported eg. immersive-vr
  108288. * @returns true if supported
  108289. */
  108290. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108291. /**
  108292. * @hidden
  108293. * Converts the render layer of xrSession to a render target
  108294. * @param session session to create render target for
  108295. * @param scene scene the new render target should be created for
  108296. */
  108297. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108298. /**
  108299. * Disposes of the session manager
  108300. */
  108301. dispose(): void;
  108302. }
  108303. }
  108304. declare module BABYLON {
  108305. /**
  108306. * WebXR Camera which holds the views for the xrSession
  108307. * @see https://doc.babylonjs.com/how_to/webxr
  108308. */
  108309. export class WebXRCamera extends FreeCamera {
  108310. private static _TmpMatrix;
  108311. /**
  108312. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108313. * @param name the name of the camera
  108314. * @param scene the scene to add the camera to
  108315. */
  108316. constructor(name: string, scene: Scene);
  108317. private _updateNumberOfRigCameras;
  108318. /** @hidden */
  108319. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108320. /**
  108321. * Updates the cameras position from the current pose information of the XR session
  108322. * @param xrSessionManager the session containing pose information
  108323. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108324. */
  108325. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108326. }
  108327. }
  108328. declare module BABYLON {
  108329. /**
  108330. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108331. */
  108332. export class WebXRManagedOutputCanvas implements IDisposable {
  108333. private helper;
  108334. private _canvas;
  108335. /**
  108336. * xrpresent context of the canvas which can be used to display/mirror xr content
  108337. */
  108338. canvasContext: WebGLRenderingContext;
  108339. /**
  108340. * xr layer for the canvas
  108341. */
  108342. xrLayer: Nullable<XRWebGLLayer>;
  108343. /**
  108344. * Initializes the xr layer for the session
  108345. * @param xrSession xr session
  108346. * @returns a promise that will resolve once the XR Layer has been created
  108347. */
  108348. initializeXRLayerAsync(xrSession: any): any;
  108349. /**
  108350. * Initializes the canvas to be added/removed upon entering/exiting xr
  108351. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108352. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108353. */
  108354. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108355. /**
  108356. * Disposes of the object
  108357. */
  108358. dispose(): void;
  108359. private _setManagedOutputCanvas;
  108360. private _addCanvas;
  108361. private _removeCanvas;
  108362. }
  108363. }
  108364. declare module BABYLON {
  108365. /**
  108366. * States of the webXR experience
  108367. */
  108368. export enum WebXRState {
  108369. /**
  108370. * Transitioning to being in XR mode
  108371. */
  108372. ENTERING_XR = 0,
  108373. /**
  108374. * Transitioning to non XR mode
  108375. */
  108376. EXITING_XR = 1,
  108377. /**
  108378. * In XR mode and presenting
  108379. */
  108380. IN_XR = 2,
  108381. /**
  108382. * Not entered XR mode
  108383. */
  108384. NOT_IN_XR = 3
  108385. }
  108386. /**
  108387. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108388. * @see https://doc.babylonjs.com/how_to/webxr
  108389. */
  108390. export class WebXRExperienceHelper implements IDisposable {
  108391. private scene;
  108392. /**
  108393. * 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
  108394. */
  108395. container: AbstractMesh;
  108396. /**
  108397. * Camera used to render xr content
  108398. */
  108399. camera: WebXRCamera;
  108400. /**
  108401. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108402. */
  108403. state: WebXRState;
  108404. private _setState;
  108405. private static _TmpVector;
  108406. /**
  108407. * Fires when the state of the experience helper has changed
  108408. */
  108409. onStateChangedObservable: Observable<WebXRState>;
  108410. /** Session manager used to keep track of xr session */
  108411. sessionManager: WebXRSessionManager;
  108412. private _nonVRCamera;
  108413. private _originalSceneAutoClear;
  108414. private _supported;
  108415. /**
  108416. * Creates the experience helper
  108417. * @param scene the scene to attach the experience helper to
  108418. * @returns a promise for the experience helper
  108419. */
  108420. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108421. /**
  108422. * Creates a WebXRExperienceHelper
  108423. * @param scene The scene the helper should be created in
  108424. */
  108425. private constructor();
  108426. /**
  108427. * Exits XR mode and returns the scene to its original state
  108428. * @returns promise that resolves after xr mode has exited
  108429. */
  108430. exitXRAsync(): Promise<unknown>;
  108431. /**
  108432. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108433. * @param sessionCreationOptions options for the XR session
  108434. * @param referenceSpaceType frame of reference of the XR session
  108435. * @param outputCanvas the output canvas that will be used to enter XR mode
  108436. * @returns promise that resolves after xr mode has entered
  108437. */
  108438. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108439. /**
  108440. * Updates the global position of the camera by moving the camera's container
  108441. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108442. * @param position The desired global position of the camera
  108443. */
  108444. setPositionOfCameraUsingContainer(position: Vector3): void;
  108445. /**
  108446. * Rotates the xr camera by rotating the camera's container around the camera's position
  108447. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108448. * @param rotation the desired quaternion rotation to apply to the camera
  108449. */
  108450. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108451. /**
  108452. * Disposes of the experience helper
  108453. */
  108454. dispose(): void;
  108455. }
  108456. }
  108457. declare module BABYLON {
  108458. /**
  108459. * Button which can be used to enter a different mode of XR
  108460. */
  108461. export class WebXREnterExitUIButton {
  108462. /** button element */
  108463. element: HTMLElement;
  108464. /** XR initialization options for the button */
  108465. sessionMode: XRSessionMode;
  108466. /** Reference space type */
  108467. referenceSpaceType: XRReferenceSpaceType;
  108468. /**
  108469. * Creates a WebXREnterExitUIButton
  108470. * @param element button element
  108471. * @param sessionMode XR initialization session mode
  108472. * @param referenceSpaceType the type of reference space to be used
  108473. */
  108474. constructor(
  108475. /** button element */
  108476. element: HTMLElement,
  108477. /** XR initialization options for the button */
  108478. sessionMode: XRSessionMode,
  108479. /** Reference space type */
  108480. referenceSpaceType: XRReferenceSpaceType);
  108481. /**
  108482. * Overwritable function which can be used to update the button's visuals when the state changes
  108483. * @param activeButton the current active button in the UI
  108484. */
  108485. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108486. }
  108487. /**
  108488. * Options to create the webXR UI
  108489. */
  108490. export class WebXREnterExitUIOptions {
  108491. /**
  108492. * Context to enter xr with
  108493. */
  108494. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108495. /**
  108496. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108497. */
  108498. customButtons?: Array<WebXREnterExitUIButton>;
  108499. }
  108500. /**
  108501. * UI to allow the user to enter/exit XR mode
  108502. */
  108503. export class WebXREnterExitUI implements IDisposable {
  108504. private scene;
  108505. private _overlay;
  108506. private _buttons;
  108507. private _activeButton;
  108508. /**
  108509. * Fired every time the active button is changed.
  108510. *
  108511. * When xr is entered via a button that launches xr that button will be the callback parameter
  108512. *
  108513. * When exiting xr the callback parameter will be null)
  108514. */
  108515. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108516. /**
  108517. * Creates UI to allow the user to enter/exit XR mode
  108518. * @param scene the scene to add the ui to
  108519. * @param helper the xr experience helper to enter/exit xr with
  108520. * @param options options to configure the UI
  108521. * @returns the created ui
  108522. */
  108523. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108524. private constructor();
  108525. private _updateButtons;
  108526. /**
  108527. * Disposes of the object
  108528. */
  108529. dispose(): void;
  108530. }
  108531. }
  108532. declare module BABYLON {
  108533. /**
  108534. * Represents an XR input
  108535. */
  108536. export class WebXRController {
  108537. private scene;
  108538. /** The underlying input source for the controller */
  108539. inputSource: XRInputSource;
  108540. private parentContainer;
  108541. /**
  108542. * 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
  108543. */
  108544. grip?: AbstractMesh;
  108545. /**
  108546. * Pointer which can be used to select objects or attach a visible laser to
  108547. */
  108548. pointer: AbstractMesh;
  108549. /**
  108550. * Event that fires when the controller is removed/disposed
  108551. */
  108552. onDisposeObservable: Observable<{}>;
  108553. private _tmpMatrix;
  108554. private _tmpQuaternion;
  108555. private _tmpVector;
  108556. /**
  108557. * Creates the controller
  108558. * @see https://doc.babylonjs.com/how_to/webxr
  108559. * @param scene the scene which the controller should be associated to
  108560. * @param inputSource the underlying input source for the controller
  108561. * @param parentContainer parent that the controller meshes should be children of
  108562. */
  108563. constructor(scene: Scene,
  108564. /** The underlying input source for the controller */
  108565. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108566. /**
  108567. * Updates the controller pose based on the given XRFrame
  108568. * @param xrFrame xr frame to update the pose with
  108569. * @param referenceSpace reference space to use
  108570. */
  108571. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108572. /**
  108573. * Gets a world space ray coming from the controller
  108574. * @param result the resulting ray
  108575. */
  108576. getWorldPointerRayToRef(result: Ray): void;
  108577. /**
  108578. * Disposes of the object
  108579. */
  108580. dispose(): void;
  108581. }
  108582. }
  108583. declare module BABYLON {
  108584. /**
  108585. * XR input used to track XR inputs such as controllers/rays
  108586. */
  108587. export class WebXRInput implements IDisposable {
  108588. /**
  108589. * Base experience the input listens to
  108590. */
  108591. baseExperience: WebXRExperienceHelper;
  108592. /**
  108593. * XR controllers being tracked
  108594. */
  108595. controllers: Array<WebXRController>;
  108596. private _frameObserver;
  108597. private _stateObserver;
  108598. /**
  108599. * Event when a controller has been connected/added
  108600. */
  108601. onControllerAddedObservable: Observable<WebXRController>;
  108602. /**
  108603. * Event when a controller has been removed/disconnected
  108604. */
  108605. onControllerRemovedObservable: Observable<WebXRController>;
  108606. /**
  108607. * Initializes the WebXRInput
  108608. * @param baseExperience experience helper which the input should be created for
  108609. */
  108610. constructor(
  108611. /**
  108612. * Base experience the input listens to
  108613. */
  108614. baseExperience: WebXRExperienceHelper);
  108615. private _onInputSourcesChange;
  108616. private _addAndRemoveControllers;
  108617. /**
  108618. * Disposes of the object
  108619. */
  108620. dispose(): void;
  108621. }
  108622. }
  108623. declare module BABYLON {
  108624. /**
  108625. * Enables teleportation
  108626. */
  108627. export class WebXRControllerTeleportation {
  108628. private _teleportationFillColor;
  108629. private _teleportationBorderColor;
  108630. private _tmpRay;
  108631. private _tmpVector;
  108632. /**
  108633. * Creates a WebXRControllerTeleportation
  108634. * @param input input manager to add teleportation to
  108635. * @param floorMeshes floormeshes which can be teleported to
  108636. */
  108637. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108638. }
  108639. }
  108640. declare module BABYLON {
  108641. /**
  108642. * Handles pointer input automatically for the pointer of XR controllers
  108643. */
  108644. export class WebXRControllerPointerSelection {
  108645. private static _idCounter;
  108646. private _tmpRay;
  108647. /**
  108648. * Creates a WebXRControllerPointerSelection
  108649. * @param input input manager to setup pointer selection
  108650. */
  108651. constructor(input: WebXRInput);
  108652. private _convertNormalToDirectionOfRay;
  108653. private _updatePointerDistance;
  108654. }
  108655. }
  108656. declare module BABYLON {
  108657. /**
  108658. * Class used to represent data loading progression
  108659. */
  108660. export class SceneLoaderProgressEvent {
  108661. /** defines if data length to load can be evaluated */
  108662. readonly lengthComputable: boolean;
  108663. /** defines the loaded data length */
  108664. readonly loaded: number;
  108665. /** defines the data length to load */
  108666. readonly total: number;
  108667. /**
  108668. * Create a new progress event
  108669. * @param lengthComputable defines if data length to load can be evaluated
  108670. * @param loaded defines the loaded data length
  108671. * @param total defines the data length to load
  108672. */
  108673. constructor(
  108674. /** defines if data length to load can be evaluated */
  108675. lengthComputable: boolean,
  108676. /** defines the loaded data length */
  108677. loaded: number,
  108678. /** defines the data length to load */
  108679. total: number);
  108680. /**
  108681. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108682. * @param event defines the source event
  108683. * @returns a new SceneLoaderProgressEvent
  108684. */
  108685. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108686. }
  108687. /**
  108688. * Interface used by SceneLoader plugins to define supported file extensions
  108689. */
  108690. export interface ISceneLoaderPluginExtensions {
  108691. /**
  108692. * Defines the list of supported extensions
  108693. */
  108694. [extension: string]: {
  108695. isBinary: boolean;
  108696. };
  108697. }
  108698. /**
  108699. * Interface used by SceneLoader plugin factory
  108700. */
  108701. export interface ISceneLoaderPluginFactory {
  108702. /**
  108703. * Defines the name of the factory
  108704. */
  108705. name: string;
  108706. /**
  108707. * Function called to create a new plugin
  108708. * @return the new plugin
  108709. */
  108710. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108711. /**
  108712. * Boolean indicating if the plugin can direct load specific data
  108713. */
  108714. canDirectLoad?: (data: string) => boolean;
  108715. }
  108716. /**
  108717. * Interface used to define a SceneLoader plugin
  108718. */
  108719. export interface ISceneLoaderPlugin {
  108720. /**
  108721. * The friendly name of this plugin.
  108722. */
  108723. name: string;
  108724. /**
  108725. * The file extensions supported by this plugin.
  108726. */
  108727. extensions: string | ISceneLoaderPluginExtensions;
  108728. /**
  108729. * Import meshes into a scene.
  108730. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108731. * @param scene The scene to import into
  108732. * @param data The data to import
  108733. * @param rootUrl The root url for scene and resources
  108734. * @param meshes The meshes array to import into
  108735. * @param particleSystems The particle systems array to import into
  108736. * @param skeletons The skeletons array to import into
  108737. * @param onError The callback when import fails
  108738. * @returns True if successful or false otherwise
  108739. */
  108740. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108741. /**
  108742. * Load into a scene.
  108743. * @param scene The scene to load into
  108744. * @param data The data to import
  108745. * @param rootUrl The root url for scene and resources
  108746. * @param onError The callback when import fails
  108747. * @returns true if successful or false otherwise
  108748. */
  108749. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108750. /**
  108751. * The callback that returns true if the data can be directly loaded.
  108752. */
  108753. canDirectLoad?: (data: string) => boolean;
  108754. /**
  108755. * The callback that allows custom handling of the root url based on the response url.
  108756. */
  108757. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108758. /**
  108759. * Load into an asset container.
  108760. * @param scene The scene to load into
  108761. * @param data The data to import
  108762. * @param rootUrl The root url for scene and resources
  108763. * @param onError The callback when import fails
  108764. * @returns The loaded asset container
  108765. */
  108766. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108767. }
  108768. /**
  108769. * Interface used to define an async SceneLoader plugin
  108770. */
  108771. export interface ISceneLoaderPluginAsync {
  108772. /**
  108773. * The friendly name of this plugin.
  108774. */
  108775. name: string;
  108776. /**
  108777. * The file extensions supported by this plugin.
  108778. */
  108779. extensions: string | ISceneLoaderPluginExtensions;
  108780. /**
  108781. * Import meshes into a scene.
  108782. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108783. * @param scene The scene to import into
  108784. * @param data The data to import
  108785. * @param rootUrl The root url for scene and resources
  108786. * @param onProgress The callback when the load progresses
  108787. * @param fileName Defines the name of the file to load
  108788. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108789. */
  108790. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108791. meshes: AbstractMesh[];
  108792. particleSystems: IParticleSystem[];
  108793. skeletons: Skeleton[];
  108794. animationGroups: AnimationGroup[];
  108795. }>;
  108796. /**
  108797. * Load into a scene.
  108798. * @param scene The scene to load into
  108799. * @param data The data to import
  108800. * @param rootUrl The root url for scene and resources
  108801. * @param onProgress The callback when the load progresses
  108802. * @param fileName Defines the name of the file to load
  108803. * @returns Nothing
  108804. */
  108805. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108806. /**
  108807. * The callback that returns true if the data can be directly loaded.
  108808. */
  108809. canDirectLoad?: (data: string) => boolean;
  108810. /**
  108811. * The callback that allows custom handling of the root url based on the response url.
  108812. */
  108813. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108814. /**
  108815. * Load into an asset container.
  108816. * @param scene The scene to load into
  108817. * @param data The data to import
  108818. * @param rootUrl The root url for scene and resources
  108819. * @param onProgress The callback when the load progresses
  108820. * @param fileName Defines the name of the file to load
  108821. * @returns The loaded asset container
  108822. */
  108823. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108824. }
  108825. /**
  108826. * Class used to load scene from various file formats using registered plugins
  108827. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108828. */
  108829. export class SceneLoader {
  108830. /**
  108831. * No logging while loading
  108832. */
  108833. static readonly NO_LOGGING: number;
  108834. /**
  108835. * Minimal logging while loading
  108836. */
  108837. static readonly MINIMAL_LOGGING: number;
  108838. /**
  108839. * Summary logging while loading
  108840. */
  108841. static readonly SUMMARY_LOGGING: number;
  108842. /**
  108843. * Detailled logging while loading
  108844. */
  108845. static readonly DETAILED_LOGGING: number;
  108846. /**
  108847. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108848. */
  108849. static ForceFullSceneLoadingForIncremental: boolean;
  108850. /**
  108851. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108852. */
  108853. static ShowLoadingScreen: boolean;
  108854. /**
  108855. * Defines the current logging level (while loading the scene)
  108856. * @ignorenaming
  108857. */
  108858. static loggingLevel: number;
  108859. /**
  108860. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108861. */
  108862. static CleanBoneMatrixWeights: boolean;
  108863. /**
  108864. * Event raised when a plugin is used to load a scene
  108865. */
  108866. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108867. private static _registeredPlugins;
  108868. private static _getDefaultPlugin;
  108869. private static _getPluginForExtension;
  108870. private static _getPluginForDirectLoad;
  108871. private static _getPluginForFilename;
  108872. private static _getDirectLoad;
  108873. private static _loadData;
  108874. private static _getFileInfo;
  108875. /**
  108876. * Gets a plugin that can load the given extension
  108877. * @param extension defines the extension to load
  108878. * @returns a plugin or null if none works
  108879. */
  108880. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108881. /**
  108882. * Gets a boolean indicating that the given extension can be loaded
  108883. * @param extension defines the extension to load
  108884. * @returns true if the extension is supported
  108885. */
  108886. static IsPluginForExtensionAvailable(extension: string): boolean;
  108887. /**
  108888. * Adds a new plugin to the list of registered plugins
  108889. * @param plugin defines the plugin to add
  108890. */
  108891. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108892. /**
  108893. * Import meshes into a scene
  108894. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 the instance of BABYLON.Scene to append to
  108898. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108899. * @param onProgress a callback with a progress event for each file being loaded
  108900. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108901. * @param pluginExtension the extension used to determine the plugin
  108902. * @returns The loaded plugin
  108903. */
  108904. 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>;
  108905. /**
  108906. * Import meshes into a scene
  108907. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108908. * @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)
  108909. * @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)
  108910. * @param scene the instance of BABYLON.Scene to append to
  108911. * @param onProgress a callback with a progress event for each file being loaded
  108912. * @param pluginExtension the extension used to determine the plugin
  108913. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108914. */
  108915. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108916. meshes: AbstractMesh[];
  108917. particleSystems: IParticleSystem[];
  108918. skeletons: Skeleton[];
  108919. animationGroups: AnimationGroup[];
  108920. }>;
  108921. /**
  108922. * Load a scene
  108923. * @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)
  108924. * @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)
  108925. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108926. * @param onSuccess a callback with the scene when import succeeds
  108927. * @param onProgress a callback with a progress event for each file being loaded
  108928. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108929. * @param pluginExtension the extension used to determine the plugin
  108930. * @returns The loaded plugin
  108931. */
  108932. 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>;
  108933. /**
  108934. * Load a scene
  108935. * @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)
  108936. * @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)
  108937. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108938. * @param onProgress a callback with a progress event for each file being loaded
  108939. * @param pluginExtension the extension used to determine the plugin
  108940. * @returns The loaded scene
  108941. */
  108942. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108943. /**
  108944. * Append a scene
  108945. * @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)
  108946. * @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)
  108947. * @param scene is the instance of BABYLON.Scene to append to
  108948. * @param onSuccess a callback with the scene when import succeeds
  108949. * @param onProgress a callback with a progress event for each file being loaded
  108950. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108951. * @param pluginExtension the extension used to determine the plugin
  108952. * @returns The loaded plugin
  108953. */
  108954. 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>;
  108955. /**
  108956. * Append a scene
  108957. * @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)
  108958. * @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)
  108959. * @param scene is the instance of BABYLON.Scene to append to
  108960. * @param onProgress a callback with a progress event for each file being loaded
  108961. * @param pluginExtension the extension used to determine the plugin
  108962. * @returns The given scene
  108963. */
  108964. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108965. /**
  108966. * Load a scene into an asset container
  108967. * @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)
  108968. * @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)
  108969. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108970. * @param onSuccess a callback with the scene when import succeeds
  108971. * @param onProgress a callback with a progress event for each file being loaded
  108972. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108973. * @param pluginExtension the extension used to determine the plugin
  108974. * @returns The loaded plugin
  108975. */
  108976. 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>;
  108977. /**
  108978. * Load a scene into an asset container
  108979. * @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)
  108980. * @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)
  108981. * @param scene is the instance of Scene to append to
  108982. * @param onProgress a callback with a progress event for each file being loaded
  108983. * @param pluginExtension the extension used to determine the plugin
  108984. * @returns The loaded asset container
  108985. */
  108986. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108987. }
  108988. }
  108989. declare module BABYLON {
  108990. /**
  108991. * Generic Controller
  108992. */
  108993. export class GenericController extends WebVRController {
  108994. /**
  108995. * Base Url for the controller model.
  108996. */
  108997. static readonly MODEL_BASE_URL: string;
  108998. /**
  108999. * File name for the controller model.
  109000. */
  109001. static readonly MODEL_FILENAME: string;
  109002. /**
  109003. * Creates a new GenericController from a gamepad
  109004. * @param vrGamepad the gamepad that the controller should be created from
  109005. */
  109006. constructor(vrGamepad: any);
  109007. /**
  109008. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109009. * @param scene scene in which to add meshes
  109010. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109011. */
  109012. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109013. /**
  109014. * Called once for each button that changed state since the last frame
  109015. * @param buttonIdx Which button index changed
  109016. * @param state New state of the button
  109017. * @param changes Which properties on the state changed since last frame
  109018. */
  109019. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109020. }
  109021. }
  109022. declare module BABYLON {
  109023. /**
  109024. * Defines the WindowsMotionController object that the state of the windows motion controller
  109025. */
  109026. export class WindowsMotionController extends WebVRController {
  109027. /**
  109028. * The base url used to load the left and right controller models
  109029. */
  109030. static MODEL_BASE_URL: string;
  109031. /**
  109032. * The name of the left controller model file
  109033. */
  109034. static MODEL_LEFT_FILENAME: string;
  109035. /**
  109036. * The name of the right controller model file
  109037. */
  109038. static MODEL_RIGHT_FILENAME: string;
  109039. /**
  109040. * The controller name prefix for this controller type
  109041. */
  109042. static readonly GAMEPAD_ID_PREFIX: string;
  109043. /**
  109044. * The controller id pattern for this controller type
  109045. */
  109046. private static readonly GAMEPAD_ID_PATTERN;
  109047. private _loadedMeshInfo;
  109048. private readonly _mapping;
  109049. /**
  109050. * Fired when the trackpad on this controller is clicked
  109051. */
  109052. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109053. /**
  109054. * Fired when the trackpad on this controller is modified
  109055. */
  109056. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109057. /**
  109058. * The current x and y values of this controller's trackpad
  109059. */
  109060. trackpad: StickValues;
  109061. /**
  109062. * Creates a new WindowsMotionController from a gamepad
  109063. * @param vrGamepad the gamepad that the controller should be created from
  109064. */
  109065. constructor(vrGamepad: any);
  109066. /**
  109067. * Fired when the trigger on this controller is modified
  109068. */
  109069. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109070. /**
  109071. * Fired when the menu button on this controller is modified
  109072. */
  109073. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109074. /**
  109075. * Fired when the grip button on this controller is modified
  109076. */
  109077. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109078. /**
  109079. * Fired when the thumbstick button on this controller is modified
  109080. */
  109081. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109082. /**
  109083. * Fired when the touchpad button on this controller is modified
  109084. */
  109085. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109086. /**
  109087. * Fired when the touchpad values on this controller are modified
  109088. */
  109089. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109090. private _updateTrackpad;
  109091. /**
  109092. * Called once per frame by the engine.
  109093. */
  109094. update(): void;
  109095. /**
  109096. * Called once for each button that changed state since the last frame
  109097. * @param buttonIdx Which button index changed
  109098. * @param state New state of the button
  109099. * @param changes Which properties on the state changed since last frame
  109100. */
  109101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109102. /**
  109103. * Moves the buttons on the controller mesh based on their current state
  109104. * @param buttonName the name of the button to move
  109105. * @param buttonValue the value of the button which determines the buttons new position
  109106. */
  109107. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109108. /**
  109109. * Moves the axis on the controller mesh based on its current state
  109110. * @param axis the index of the axis
  109111. * @param axisValue the value of the axis which determines the meshes new position
  109112. * @hidden
  109113. */
  109114. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109115. /**
  109116. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109117. * @param scene scene in which to add meshes
  109118. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109119. */
  109120. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109121. /**
  109122. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109123. * can be transformed by button presses and axes values, based on this._mapping.
  109124. *
  109125. * @param scene scene in which the meshes exist
  109126. * @param meshes list of meshes that make up the controller model to process
  109127. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109128. */
  109129. private processModel;
  109130. private createMeshInfo;
  109131. /**
  109132. * Gets the ray of the controller in the direction the controller is pointing
  109133. * @param length the length the resulting ray should be
  109134. * @returns a ray in the direction the controller is pointing
  109135. */
  109136. getForwardRay(length?: number): Ray;
  109137. /**
  109138. * Disposes of the controller
  109139. */
  109140. dispose(): void;
  109141. }
  109142. }
  109143. declare module BABYLON {
  109144. /**
  109145. * Oculus Touch Controller
  109146. */
  109147. export class OculusTouchController extends WebVRController {
  109148. /**
  109149. * Base Url for the controller model.
  109150. */
  109151. static MODEL_BASE_URL: string;
  109152. /**
  109153. * File name for the left controller model.
  109154. */
  109155. static MODEL_LEFT_FILENAME: string;
  109156. /**
  109157. * File name for the right controller model.
  109158. */
  109159. static MODEL_RIGHT_FILENAME: string;
  109160. /**
  109161. * Base Url for the Quest controller model.
  109162. */
  109163. static QUEST_MODEL_BASE_URL: string;
  109164. /**
  109165. * @hidden
  109166. * If the controllers are running on a device that needs the updated Quest controller models
  109167. */
  109168. static _IsQuest: boolean;
  109169. /**
  109170. * Fired when the secondary trigger on this controller is modified
  109171. */
  109172. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109173. /**
  109174. * Fired when the thumb rest on this controller is modified
  109175. */
  109176. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109177. /**
  109178. * Creates a new OculusTouchController from a gamepad
  109179. * @param vrGamepad the gamepad that the controller should be created from
  109180. */
  109181. constructor(vrGamepad: any);
  109182. /**
  109183. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109184. * @param scene scene in which to add meshes
  109185. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109186. */
  109187. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109188. /**
  109189. * Fired when the A button on this controller is modified
  109190. */
  109191. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109192. /**
  109193. * Fired when the B button on this controller is modified
  109194. */
  109195. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109196. /**
  109197. * Fired when the X button on this controller is modified
  109198. */
  109199. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109200. /**
  109201. * Fired when the Y button on this controller is modified
  109202. */
  109203. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109204. /**
  109205. * Called once for each button that changed state since the last frame
  109206. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109207. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109208. * 2) secondary trigger (same)
  109209. * 3) A (right) X (left), touch, pressed = value
  109210. * 4) B / Y
  109211. * 5) thumb rest
  109212. * @param buttonIdx Which button index changed
  109213. * @param state New state of the button
  109214. * @param changes Which properties on the state changed since last frame
  109215. */
  109216. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109217. }
  109218. }
  109219. declare module BABYLON {
  109220. /**
  109221. * Vive Controller
  109222. */
  109223. export class ViveController extends WebVRController {
  109224. /**
  109225. * Base Url for the controller model.
  109226. */
  109227. static MODEL_BASE_URL: string;
  109228. /**
  109229. * File name for the controller model.
  109230. */
  109231. static MODEL_FILENAME: string;
  109232. /**
  109233. * Creates a new ViveController from a gamepad
  109234. * @param vrGamepad the gamepad that the controller should be created from
  109235. */
  109236. constructor(vrGamepad: any);
  109237. /**
  109238. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109239. * @param scene scene in which to add meshes
  109240. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109241. */
  109242. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109243. /**
  109244. * Fired when the left button on this controller is modified
  109245. */
  109246. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109247. /**
  109248. * Fired when the right button on this controller is modified
  109249. */
  109250. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109251. /**
  109252. * Fired when the menu button on this controller is modified
  109253. */
  109254. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109255. /**
  109256. * Called once for each button that changed state since the last frame
  109257. * Vive mapping:
  109258. * 0: touchpad
  109259. * 1: trigger
  109260. * 2: left AND right buttons
  109261. * 3: menu button
  109262. * @param buttonIdx Which button index changed
  109263. * @param state New state of the button
  109264. * @param changes Which properties on the state changed since last frame
  109265. */
  109266. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109267. }
  109268. }
  109269. declare module BABYLON {
  109270. /**
  109271. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109272. */
  109273. export class WebXRControllerModelLoader {
  109274. /**
  109275. * Creates the WebXRControllerModelLoader
  109276. * @param input xr input that creates the controllers
  109277. */
  109278. constructor(input: WebXRInput);
  109279. }
  109280. }
  109281. declare module BABYLON {
  109282. /**
  109283. * Contains an array of blocks representing the octree
  109284. */
  109285. export interface IOctreeContainer<T> {
  109286. /**
  109287. * Blocks within the octree
  109288. */
  109289. blocks: Array<OctreeBlock<T>>;
  109290. }
  109291. /**
  109292. * Class used to store a cell in an octree
  109293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109294. */
  109295. export class OctreeBlock<T> {
  109296. /**
  109297. * Gets the content of the current block
  109298. */
  109299. entries: T[];
  109300. /**
  109301. * Gets the list of block children
  109302. */
  109303. blocks: Array<OctreeBlock<T>>;
  109304. private _depth;
  109305. private _maxDepth;
  109306. private _capacity;
  109307. private _minPoint;
  109308. private _maxPoint;
  109309. private _boundingVectors;
  109310. private _creationFunc;
  109311. /**
  109312. * Creates a new block
  109313. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109314. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109315. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109316. * @param depth defines the current depth of this block in the octree
  109317. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109318. * @param creationFunc defines a callback to call when an element is added to the block
  109319. */
  109320. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109321. /**
  109322. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109323. */
  109324. readonly capacity: number;
  109325. /**
  109326. * Gets the minimum vector (in world space) of the block's bounding box
  109327. */
  109328. readonly minPoint: Vector3;
  109329. /**
  109330. * Gets the maximum vector (in world space) of the block's bounding box
  109331. */
  109332. readonly maxPoint: Vector3;
  109333. /**
  109334. * Add a new element to this block
  109335. * @param entry defines the element to add
  109336. */
  109337. addEntry(entry: T): void;
  109338. /**
  109339. * Remove an element from this block
  109340. * @param entry defines the element to remove
  109341. */
  109342. removeEntry(entry: T): void;
  109343. /**
  109344. * Add an array of elements to this block
  109345. * @param entries defines the array of elements to add
  109346. */
  109347. addEntries(entries: T[]): void;
  109348. /**
  109349. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109350. * @param frustumPlanes defines the frustum planes to test
  109351. * @param selection defines the array to store current content if selection is positive
  109352. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109353. */
  109354. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109355. /**
  109356. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109357. * @param sphereCenter defines the bounding sphere center
  109358. * @param sphereRadius defines the bounding sphere radius
  109359. * @param selection defines the array to store current content if selection is positive
  109360. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109361. */
  109362. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109363. /**
  109364. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109365. * @param ray defines the ray to test with
  109366. * @param selection defines the array to store current content if selection is positive
  109367. */
  109368. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109369. /**
  109370. * Subdivide the content into child blocks (this block will then be empty)
  109371. */
  109372. createInnerBlocks(): void;
  109373. /**
  109374. * @hidden
  109375. */
  109376. 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;
  109377. }
  109378. }
  109379. declare module BABYLON {
  109380. /**
  109381. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109382. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109383. */
  109384. export class Octree<T> {
  109385. /** 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.) */
  109386. maxDepth: number;
  109387. /**
  109388. * Blocks within the octree containing objects
  109389. */
  109390. blocks: Array<OctreeBlock<T>>;
  109391. /**
  109392. * Content stored in the octree
  109393. */
  109394. dynamicContent: T[];
  109395. private _maxBlockCapacity;
  109396. private _selectionContent;
  109397. private _creationFunc;
  109398. /**
  109399. * Creates a octree
  109400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109401. * @param creationFunc function to be used to instatiate the octree
  109402. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109403. * @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.)
  109404. */
  109405. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109406. /** 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.) */
  109407. maxDepth?: number);
  109408. /**
  109409. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109410. * @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);
  109411. * @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);
  109412. * @param entries meshes to be added to the octree blocks
  109413. */
  109414. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109415. /**
  109416. * Adds a mesh to the octree
  109417. * @param entry Mesh to add to the octree
  109418. */
  109419. addMesh(entry: T): void;
  109420. /**
  109421. * Remove an element from the octree
  109422. * @param entry defines the element to remove
  109423. */
  109424. removeMesh(entry: T): void;
  109425. /**
  109426. * Selects an array of meshes within the frustum
  109427. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109428. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109429. * @returns array of meshes within the frustum
  109430. */
  109431. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109432. /**
  109433. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109434. * @param sphereCenter defines the bounding sphere center
  109435. * @param sphereRadius defines the bounding sphere radius
  109436. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109437. * @returns an array of objects that intersect the sphere
  109438. */
  109439. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109440. /**
  109441. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109442. * @param ray defines the ray to test with
  109443. * @returns array of intersected objects
  109444. */
  109445. intersectsRay(ray: Ray): SmartArray<T>;
  109446. /**
  109447. * Adds a mesh into the octree block if it intersects the block
  109448. */
  109449. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109450. /**
  109451. * Adds a submesh into the octree block if it intersects the block
  109452. */
  109453. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109454. }
  109455. }
  109456. declare module BABYLON {
  109457. interface Scene {
  109458. /**
  109459. * @hidden
  109460. * Backing Filed
  109461. */
  109462. _selectionOctree: Octree<AbstractMesh>;
  109463. /**
  109464. * Gets the octree used to boost mesh selection (picking)
  109465. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109466. */
  109467. selectionOctree: Octree<AbstractMesh>;
  109468. /**
  109469. * Creates or updates the octree used to boost selection (picking)
  109470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109471. * @param maxCapacity defines the maximum capacity per leaf
  109472. * @param maxDepth defines the maximum depth of the octree
  109473. * @returns an octree of AbstractMesh
  109474. */
  109475. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109476. }
  109477. interface AbstractMesh {
  109478. /**
  109479. * @hidden
  109480. * Backing Field
  109481. */
  109482. _submeshesOctree: Octree<SubMesh>;
  109483. /**
  109484. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109485. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109486. * @param maxCapacity defines the maximum size of each block (64 by default)
  109487. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109488. * @returns the new octree
  109489. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109491. */
  109492. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109493. }
  109494. /**
  109495. * Defines the octree scene component responsible to manage any octrees
  109496. * in a given scene.
  109497. */
  109498. export class OctreeSceneComponent {
  109499. /**
  109500. * The component name help to identify the component in the list of scene components.
  109501. */
  109502. readonly name: string;
  109503. /**
  109504. * The scene the component belongs to.
  109505. */
  109506. scene: Scene;
  109507. /**
  109508. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109509. */
  109510. readonly checksIsEnabled: boolean;
  109511. /**
  109512. * Creates a new instance of the component for the given scene
  109513. * @param scene Defines the scene to register the component in
  109514. */
  109515. constructor(scene: Scene);
  109516. /**
  109517. * Registers the component in a given scene
  109518. */
  109519. register(): void;
  109520. /**
  109521. * Return the list of active meshes
  109522. * @returns the list of active meshes
  109523. */
  109524. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109525. /**
  109526. * Return the list of active sub meshes
  109527. * @param mesh The mesh to get the candidates sub meshes from
  109528. * @returns the list of active sub meshes
  109529. */
  109530. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109531. private _tempRay;
  109532. /**
  109533. * Return the list of sub meshes intersecting with a given local ray
  109534. * @param mesh defines the mesh to find the submesh for
  109535. * @param localRay defines the ray in local space
  109536. * @returns the list of intersecting sub meshes
  109537. */
  109538. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109539. /**
  109540. * Return the list of sub meshes colliding with a collider
  109541. * @param mesh defines the mesh to find the submesh for
  109542. * @param collider defines the collider to evaluate the collision against
  109543. * @returns the list of colliding sub meshes
  109544. */
  109545. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109546. /**
  109547. * Rebuilds the elements related to this component in case of
  109548. * context lost for instance.
  109549. */
  109550. rebuild(): void;
  109551. /**
  109552. * Disposes the component and the associated ressources.
  109553. */
  109554. dispose(): void;
  109555. }
  109556. }
  109557. declare module BABYLON {
  109558. /**
  109559. * Renders a layer on top of an existing scene
  109560. */
  109561. export class UtilityLayerRenderer implements IDisposable {
  109562. /** the original scene that will be rendered on top of */
  109563. originalScene: Scene;
  109564. private _pointerCaptures;
  109565. private _lastPointerEvents;
  109566. private static _DefaultUtilityLayer;
  109567. private static _DefaultKeepDepthUtilityLayer;
  109568. private _sharedGizmoLight;
  109569. private _renderCamera;
  109570. /**
  109571. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109572. * @returns the camera that is used when rendering the utility layer
  109573. */
  109574. getRenderCamera(): Nullable<Camera>;
  109575. /**
  109576. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109577. * @param cam the camera that should be used when rendering the utility layer
  109578. */
  109579. setRenderCamera(cam: Nullable<Camera>): void;
  109580. /**
  109581. * @hidden
  109582. * Light which used by gizmos to get light shading
  109583. */
  109584. _getSharedGizmoLight(): HemisphericLight;
  109585. /**
  109586. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109587. */
  109588. pickUtilitySceneFirst: boolean;
  109589. /**
  109590. * 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)
  109591. */
  109592. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109593. /**
  109594. * 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)
  109595. */
  109596. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109597. /**
  109598. * The scene that is rendered on top of the original scene
  109599. */
  109600. utilityLayerScene: Scene;
  109601. /**
  109602. * If the utility layer should automatically be rendered on top of existing scene
  109603. */
  109604. shouldRender: boolean;
  109605. /**
  109606. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109607. */
  109608. onlyCheckPointerDownEvents: boolean;
  109609. /**
  109610. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109611. */
  109612. processAllEvents: boolean;
  109613. /**
  109614. * Observable raised when the pointer move from the utility layer scene to the main scene
  109615. */
  109616. onPointerOutObservable: Observable<number>;
  109617. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109618. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109619. private _afterRenderObserver;
  109620. private _sceneDisposeObserver;
  109621. private _originalPointerObserver;
  109622. /**
  109623. * Instantiates a UtilityLayerRenderer
  109624. * @param originalScene the original scene that will be rendered on top of
  109625. * @param handleEvents boolean indicating if the utility layer should handle events
  109626. */
  109627. constructor(
  109628. /** the original scene that will be rendered on top of */
  109629. originalScene: Scene, handleEvents?: boolean);
  109630. private _notifyObservers;
  109631. /**
  109632. * Renders the utility layers scene on top of the original scene
  109633. */
  109634. render(): void;
  109635. /**
  109636. * Disposes of the renderer
  109637. */
  109638. dispose(): void;
  109639. private _updateCamera;
  109640. }
  109641. }
  109642. declare module BABYLON {
  109643. /**
  109644. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109645. */
  109646. export class Gizmo implements IDisposable {
  109647. /** The utility layer the gizmo will be added to */
  109648. gizmoLayer: UtilityLayerRenderer;
  109649. /**
  109650. * The root mesh of the gizmo
  109651. */
  109652. _rootMesh: Mesh;
  109653. private _attachedMesh;
  109654. /**
  109655. * Ratio for the scale of the gizmo (Default: 1)
  109656. */
  109657. scaleRatio: number;
  109658. /**
  109659. * If a custom mesh has been set (Default: false)
  109660. */
  109661. protected _customMeshSet: boolean;
  109662. /**
  109663. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109664. * * When set, interactions will be enabled
  109665. */
  109666. attachedMesh: Nullable<AbstractMesh>;
  109667. /**
  109668. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109669. * @param mesh The mesh to replace the default mesh of the gizmo
  109670. */
  109671. setCustomMesh(mesh: Mesh): void;
  109672. /**
  109673. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109674. */
  109675. updateGizmoRotationToMatchAttachedMesh: boolean;
  109676. /**
  109677. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109678. */
  109679. updateGizmoPositionToMatchAttachedMesh: boolean;
  109680. /**
  109681. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109682. */
  109683. updateScale: boolean;
  109684. protected _interactionsEnabled: boolean;
  109685. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109686. private _beforeRenderObserver;
  109687. private _tempVector;
  109688. /**
  109689. * Creates a gizmo
  109690. * @param gizmoLayer The utility layer the gizmo will be added to
  109691. */
  109692. constructor(
  109693. /** The utility layer the gizmo will be added to */
  109694. gizmoLayer?: UtilityLayerRenderer);
  109695. /**
  109696. * Updates the gizmo to match the attached mesh's position/rotation
  109697. */
  109698. protected _update(): void;
  109699. /**
  109700. * Disposes of the gizmo
  109701. */
  109702. dispose(): void;
  109703. }
  109704. }
  109705. declare module BABYLON {
  109706. /**
  109707. * Single plane drag gizmo
  109708. */
  109709. export class PlaneDragGizmo extends Gizmo {
  109710. /**
  109711. * Drag behavior responsible for the gizmos dragging interactions
  109712. */
  109713. dragBehavior: PointerDragBehavior;
  109714. private _pointerObserver;
  109715. /**
  109716. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109717. */
  109718. snapDistance: number;
  109719. /**
  109720. * Event that fires each time the gizmo snaps to a new location.
  109721. * * snapDistance is the the change in distance
  109722. */
  109723. onSnapObservable: Observable<{
  109724. snapDistance: number;
  109725. }>;
  109726. private _plane;
  109727. private _coloredMaterial;
  109728. private _hoverMaterial;
  109729. private _isEnabled;
  109730. private _parent;
  109731. /** @hidden */
  109732. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109733. /** @hidden */
  109734. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109735. /**
  109736. * Creates a PlaneDragGizmo
  109737. * @param gizmoLayer The utility layer the gizmo will be added to
  109738. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109739. * @param color The color of the gizmo
  109740. */
  109741. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109742. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109743. /**
  109744. * If the gizmo is enabled
  109745. */
  109746. isEnabled: boolean;
  109747. /**
  109748. * Disposes of the gizmo
  109749. */
  109750. dispose(): void;
  109751. }
  109752. }
  109753. declare module BABYLON {
  109754. /**
  109755. * Gizmo that enables dragging a mesh along 3 axis
  109756. */
  109757. export class PositionGizmo extends Gizmo {
  109758. /**
  109759. * Internal gizmo used for interactions on the x axis
  109760. */
  109761. xGizmo: AxisDragGizmo;
  109762. /**
  109763. * Internal gizmo used for interactions on the y axis
  109764. */
  109765. yGizmo: AxisDragGizmo;
  109766. /**
  109767. * Internal gizmo used for interactions on the z axis
  109768. */
  109769. zGizmo: AxisDragGizmo;
  109770. /**
  109771. * Internal gizmo used for interactions on the yz plane
  109772. */
  109773. xPlaneGizmo: PlaneDragGizmo;
  109774. /**
  109775. * Internal gizmo used for interactions on the xz plane
  109776. */
  109777. yPlaneGizmo: PlaneDragGizmo;
  109778. /**
  109779. * Internal gizmo used for interactions on the xy plane
  109780. */
  109781. zPlaneGizmo: PlaneDragGizmo;
  109782. /**
  109783. * private variables
  109784. */
  109785. private _meshAttached;
  109786. private _updateGizmoRotationToMatchAttachedMesh;
  109787. private _snapDistance;
  109788. private _scaleRatio;
  109789. /** Fires an event when any of it's sub gizmos are dragged */
  109790. onDragStartObservable: Observable<unknown>;
  109791. /** Fires an event when any of it's sub gizmos are released from dragging */
  109792. onDragEndObservable: Observable<unknown>;
  109793. /**
  109794. * If set to true, planar drag is enabled
  109795. */
  109796. private _planarGizmoEnabled;
  109797. attachedMesh: Nullable<AbstractMesh>;
  109798. /**
  109799. * Creates a PositionGizmo
  109800. * @param gizmoLayer The utility layer the gizmo will be added to
  109801. */
  109802. constructor(gizmoLayer?: UtilityLayerRenderer);
  109803. /**
  109804. * If the planar drag gizmo is enabled
  109805. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109806. */
  109807. planarGizmoEnabled: boolean;
  109808. updateGizmoRotationToMatchAttachedMesh: boolean;
  109809. /**
  109810. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109811. */
  109812. snapDistance: number;
  109813. /**
  109814. * Ratio for the scale of the gizmo (Default: 1)
  109815. */
  109816. scaleRatio: number;
  109817. /**
  109818. * Disposes of the gizmo
  109819. */
  109820. dispose(): void;
  109821. /**
  109822. * CustomMeshes are not supported by this gizmo
  109823. * @param mesh The mesh to replace the default mesh of the gizmo
  109824. */
  109825. setCustomMesh(mesh: Mesh): void;
  109826. }
  109827. }
  109828. declare module BABYLON {
  109829. /**
  109830. * Single axis drag gizmo
  109831. */
  109832. export class AxisDragGizmo extends Gizmo {
  109833. /**
  109834. * Drag behavior responsible for the gizmos dragging interactions
  109835. */
  109836. dragBehavior: PointerDragBehavior;
  109837. private _pointerObserver;
  109838. /**
  109839. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109840. */
  109841. snapDistance: number;
  109842. /**
  109843. * Event that fires each time the gizmo snaps to a new location.
  109844. * * snapDistance is the the change in distance
  109845. */
  109846. onSnapObservable: Observable<{
  109847. snapDistance: number;
  109848. }>;
  109849. private _isEnabled;
  109850. private _parent;
  109851. private _arrow;
  109852. private _coloredMaterial;
  109853. private _hoverMaterial;
  109854. /** @hidden */
  109855. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109856. /** @hidden */
  109857. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109858. /**
  109859. * Creates an AxisDragGizmo
  109860. * @param gizmoLayer The utility layer the gizmo will be added to
  109861. * @param dragAxis The axis which the gizmo will be able to drag on
  109862. * @param color The color of the gizmo
  109863. */
  109864. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109865. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109866. /**
  109867. * If the gizmo is enabled
  109868. */
  109869. isEnabled: boolean;
  109870. /**
  109871. * Disposes of the gizmo
  109872. */
  109873. dispose(): void;
  109874. }
  109875. }
  109876. declare module BABYLON.Debug {
  109877. /**
  109878. * The Axes viewer will show 3 axes in a specific point in space
  109879. */
  109880. export class AxesViewer {
  109881. private _xAxis;
  109882. private _yAxis;
  109883. private _zAxis;
  109884. private _scaleLinesFactor;
  109885. private _instanced;
  109886. /**
  109887. * Gets the hosting scene
  109888. */
  109889. scene: Scene;
  109890. /**
  109891. * Gets or sets a number used to scale line length
  109892. */
  109893. scaleLines: number;
  109894. /** Gets the node hierarchy used to render x-axis */
  109895. readonly xAxis: TransformNode;
  109896. /** Gets the node hierarchy used to render y-axis */
  109897. readonly yAxis: TransformNode;
  109898. /** Gets the node hierarchy used to render z-axis */
  109899. readonly zAxis: TransformNode;
  109900. /**
  109901. * Creates a new AxesViewer
  109902. * @param scene defines the hosting scene
  109903. * @param scaleLines defines a number used to scale line length (1 by default)
  109904. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109905. * @param xAxis defines the node hierarchy used to render the x-axis
  109906. * @param yAxis defines the node hierarchy used to render the y-axis
  109907. * @param zAxis defines the node hierarchy used to render the z-axis
  109908. */
  109909. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109910. /**
  109911. * Force the viewer to update
  109912. * @param position defines the position of the viewer
  109913. * @param xaxis defines the x axis of the viewer
  109914. * @param yaxis defines the y axis of the viewer
  109915. * @param zaxis defines the z axis of the viewer
  109916. */
  109917. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109918. /**
  109919. * Creates an instance of this axes viewer.
  109920. * @returns a new axes viewer with instanced meshes
  109921. */
  109922. createInstance(): AxesViewer;
  109923. /** Releases resources */
  109924. dispose(): void;
  109925. private static _SetRenderingGroupId;
  109926. }
  109927. }
  109928. declare module BABYLON.Debug {
  109929. /**
  109930. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109931. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109932. */
  109933. export class BoneAxesViewer extends AxesViewer {
  109934. /**
  109935. * Gets or sets the target mesh where to display the axes viewer
  109936. */
  109937. mesh: Nullable<Mesh>;
  109938. /**
  109939. * Gets or sets the target bone where to display the axes viewer
  109940. */
  109941. bone: Nullable<Bone>;
  109942. /** Gets current position */
  109943. pos: Vector3;
  109944. /** Gets direction of X axis */
  109945. xaxis: Vector3;
  109946. /** Gets direction of Y axis */
  109947. yaxis: Vector3;
  109948. /** Gets direction of Z axis */
  109949. zaxis: Vector3;
  109950. /**
  109951. * Creates a new BoneAxesViewer
  109952. * @param scene defines the hosting scene
  109953. * @param bone defines the target bone
  109954. * @param mesh defines the target mesh
  109955. * @param scaleLines defines a scaling factor for line length (1 by default)
  109956. */
  109957. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109958. /**
  109959. * Force the viewer to update
  109960. */
  109961. update(): void;
  109962. /** Releases resources */
  109963. dispose(): void;
  109964. }
  109965. }
  109966. declare module BABYLON {
  109967. /**
  109968. * Interface used to define scene explorer extensibility option
  109969. */
  109970. export interface IExplorerExtensibilityOption {
  109971. /**
  109972. * Define the option label
  109973. */
  109974. label: string;
  109975. /**
  109976. * Defines the action to execute on click
  109977. */
  109978. action: (entity: any) => void;
  109979. }
  109980. /**
  109981. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109982. */
  109983. export interface IExplorerExtensibilityGroup {
  109984. /**
  109985. * Defines a predicate to test if a given type mut be extended
  109986. */
  109987. predicate: (entity: any) => boolean;
  109988. /**
  109989. * Gets the list of options added to a type
  109990. */
  109991. entries: IExplorerExtensibilityOption[];
  109992. }
  109993. /**
  109994. * Interface used to define the options to use to create the Inspector
  109995. */
  109996. export interface IInspectorOptions {
  109997. /**
  109998. * Display in overlay mode (default: false)
  109999. */
  110000. overlay?: boolean;
  110001. /**
  110002. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  110003. */
  110004. globalRoot?: HTMLElement;
  110005. /**
  110006. * Display the Scene explorer
  110007. */
  110008. showExplorer?: boolean;
  110009. /**
  110010. * Display the property inspector
  110011. */
  110012. showInspector?: boolean;
  110013. /**
  110014. * Display in embed mode (both panes on the right)
  110015. */
  110016. embedMode?: boolean;
  110017. /**
  110018. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110019. */
  110020. handleResize?: boolean;
  110021. /**
  110022. * Allow the panes to popup (default: true)
  110023. */
  110024. enablePopup?: boolean;
  110025. /**
  110026. * Allow the panes to be closed by users (default: true)
  110027. */
  110028. enableClose?: boolean;
  110029. /**
  110030. * Optional list of extensibility entries
  110031. */
  110032. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110033. /**
  110034. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110035. */
  110036. inspectorURL?: string;
  110037. }
  110038. interface Scene {
  110039. /**
  110040. * @hidden
  110041. * Backing field
  110042. */
  110043. _debugLayer: DebugLayer;
  110044. /**
  110045. * Gets the debug layer (aka Inspector) associated with the scene
  110046. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110047. */
  110048. debugLayer: DebugLayer;
  110049. }
  110050. /**
  110051. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110052. * what is happening in your scene
  110053. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110054. */
  110055. export class DebugLayer {
  110056. /**
  110057. * Define the url to get the inspector script from.
  110058. * By default it uses the babylonjs CDN.
  110059. * @ignoreNaming
  110060. */
  110061. static InspectorURL: string;
  110062. private _scene;
  110063. private BJSINSPECTOR;
  110064. private _onPropertyChangedObservable?;
  110065. /**
  110066. * Observable triggered when a property is changed through the inspector.
  110067. */
  110068. readonly onPropertyChangedObservable: any;
  110069. /**
  110070. * Instantiates a new debug layer.
  110071. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110072. * what is happening in your scene
  110073. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110074. * @param scene Defines the scene to inspect
  110075. */
  110076. constructor(scene: Scene);
  110077. /** Creates the inspector window. */
  110078. private _createInspector;
  110079. /**
  110080. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110081. * @param entity defines the entity to select
  110082. * @param lineContainerTitle defines the specific block to highlight
  110083. */
  110084. select(entity: any, lineContainerTitle?: string): void;
  110085. /** Get the inspector from bundle or global */
  110086. private _getGlobalInspector;
  110087. /**
  110088. * Get if the inspector is visible or not.
  110089. * @returns true if visible otherwise, false
  110090. */
  110091. isVisible(): boolean;
  110092. /**
  110093. * Hide the inspector and close its window.
  110094. */
  110095. hide(): void;
  110096. /**
  110097. * Launch the debugLayer.
  110098. * @param config Define the configuration of the inspector
  110099. * @return a promise fulfilled when the debug layer is visible
  110100. */
  110101. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110102. }
  110103. }
  110104. declare module BABYLON {
  110105. /**
  110106. * Class containing static functions to help procedurally build meshes
  110107. */
  110108. export class BoxBuilder {
  110109. /**
  110110. * Creates a box mesh
  110111. * * The parameter `size` sets the size (float) of each box side (default 1)
  110112. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110113. * * 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)
  110114. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110118. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110119. * @param name defines the name of the mesh
  110120. * @param options defines the options used to create the mesh
  110121. * @param scene defines the hosting scene
  110122. * @returns the box mesh
  110123. */
  110124. static CreateBox(name: string, options: {
  110125. size?: number;
  110126. width?: number;
  110127. height?: number;
  110128. depth?: number;
  110129. faceUV?: Vector4[];
  110130. faceColors?: Color4[];
  110131. sideOrientation?: number;
  110132. frontUVs?: Vector4;
  110133. backUVs?: Vector4;
  110134. wrap?: boolean;
  110135. topBaseAt?: number;
  110136. bottomBaseAt?: number;
  110137. updatable?: boolean;
  110138. }, scene?: Nullable<Scene>): Mesh;
  110139. }
  110140. }
  110141. declare module BABYLON {
  110142. /**
  110143. * Class containing static functions to help procedurally build meshes
  110144. */
  110145. export class SphereBuilder {
  110146. /**
  110147. * Creates a sphere mesh
  110148. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110149. * * 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`)
  110150. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110151. * * 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
  110152. * * 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)
  110153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110156. * @param name defines the name of the mesh
  110157. * @param options defines the options used to create the mesh
  110158. * @param scene defines the hosting scene
  110159. * @returns the sphere mesh
  110160. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110161. */
  110162. static CreateSphere(name: string, options: {
  110163. segments?: number;
  110164. diameter?: number;
  110165. diameterX?: number;
  110166. diameterY?: number;
  110167. diameterZ?: number;
  110168. arc?: number;
  110169. slice?: number;
  110170. sideOrientation?: number;
  110171. frontUVs?: Vector4;
  110172. backUVs?: Vector4;
  110173. updatable?: boolean;
  110174. }, scene?: Nullable<Scene>): Mesh;
  110175. }
  110176. }
  110177. declare module BABYLON.Debug {
  110178. /**
  110179. * Used to show the physics impostor around the specific mesh
  110180. */
  110181. export class PhysicsViewer {
  110182. /** @hidden */
  110183. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110184. /** @hidden */
  110185. protected _meshes: Array<Nullable<AbstractMesh>>;
  110186. /** @hidden */
  110187. protected _scene: Nullable<Scene>;
  110188. /** @hidden */
  110189. protected _numMeshes: number;
  110190. /** @hidden */
  110191. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110192. private _renderFunction;
  110193. private _utilityLayer;
  110194. private _debugBoxMesh;
  110195. private _debugSphereMesh;
  110196. private _debugCylinderMesh;
  110197. private _debugMaterial;
  110198. private _debugMeshMeshes;
  110199. /**
  110200. * Creates a new PhysicsViewer
  110201. * @param scene defines the hosting scene
  110202. */
  110203. constructor(scene: Scene);
  110204. /** @hidden */
  110205. protected _updateDebugMeshes(): void;
  110206. /**
  110207. * Renders a specified physic impostor
  110208. * @param impostor defines the impostor to render
  110209. * @param targetMesh defines the mesh represented by the impostor
  110210. * @returns the new debug mesh used to render the impostor
  110211. */
  110212. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110213. /**
  110214. * Hides a specified physic impostor
  110215. * @param impostor defines the impostor to hide
  110216. */
  110217. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110218. private _getDebugMaterial;
  110219. private _getDebugBoxMesh;
  110220. private _getDebugSphereMesh;
  110221. private _getDebugCylinderMesh;
  110222. private _getDebugMeshMesh;
  110223. private _getDebugMesh;
  110224. /** Releases all resources */
  110225. dispose(): void;
  110226. }
  110227. }
  110228. declare module BABYLON {
  110229. /**
  110230. * Class containing static functions to help procedurally build meshes
  110231. */
  110232. export class LinesBuilder {
  110233. /**
  110234. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110235. * * 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
  110236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110237. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110238. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110239. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110241. * * 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
  110242. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110245. * @param name defines the name of the new line system
  110246. * @param options defines the options used to create the line system
  110247. * @param scene defines the hosting scene
  110248. * @returns a new line system mesh
  110249. */
  110250. static CreateLineSystem(name: string, options: {
  110251. lines: Vector3[][];
  110252. updatable?: boolean;
  110253. instance?: Nullable<LinesMesh>;
  110254. colors?: Nullable<Color4[][]>;
  110255. useVertexAlpha?: boolean;
  110256. }, scene: Nullable<Scene>): LinesMesh;
  110257. /**
  110258. * Creates a line mesh
  110259. * 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
  110260. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110261. * * The parameter `points` is an array successive Vector3
  110262. * * 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
  110263. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110264. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110265. * * When updating an instance, remember that only point positions can change, not the number of points
  110266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110268. * @param name defines the name of the new line system
  110269. * @param options defines the options used to create the line system
  110270. * @param scene defines the hosting scene
  110271. * @returns a new line mesh
  110272. */
  110273. static CreateLines(name: string, options: {
  110274. points: Vector3[];
  110275. updatable?: boolean;
  110276. instance?: Nullable<LinesMesh>;
  110277. colors?: Color4[];
  110278. useVertexAlpha?: boolean;
  110279. }, scene?: Nullable<Scene>): LinesMesh;
  110280. /**
  110281. * Creates a dashed line mesh
  110282. * * 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
  110283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110284. * * The parameter `points` is an array successive Vector3
  110285. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110286. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110287. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110288. * * 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
  110289. * * When updating an instance, remember that only point positions can change, not the number of points
  110290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110291. * @param name defines the name of the mesh
  110292. * @param options defines the options used to create the mesh
  110293. * @param scene defines the hosting scene
  110294. * @returns the dashed line mesh
  110295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110296. */
  110297. static CreateDashedLines(name: string, options: {
  110298. points: Vector3[];
  110299. dashSize?: number;
  110300. gapSize?: number;
  110301. dashNb?: number;
  110302. updatable?: boolean;
  110303. instance?: LinesMesh;
  110304. }, scene?: Nullable<Scene>): LinesMesh;
  110305. }
  110306. }
  110307. declare module BABYLON {
  110308. /**
  110309. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110310. * in order to better appreciate the issue one might have.
  110311. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110312. */
  110313. export class RayHelper {
  110314. /**
  110315. * Defines the ray we are currently tryin to visualize.
  110316. */
  110317. ray: Nullable<Ray>;
  110318. private _renderPoints;
  110319. private _renderLine;
  110320. private _renderFunction;
  110321. private _scene;
  110322. private _updateToMeshFunction;
  110323. private _attachedToMesh;
  110324. private _meshSpaceDirection;
  110325. private _meshSpaceOrigin;
  110326. /**
  110327. * Helper function to create a colored helper in a scene in one line.
  110328. * @param ray Defines the ray we are currently tryin to visualize
  110329. * @param scene Defines the scene the ray is used in
  110330. * @param color Defines the color we want to see the ray in
  110331. * @returns The newly created ray helper.
  110332. */
  110333. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110334. /**
  110335. * Instantiate a new ray helper.
  110336. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110337. * in order to better appreciate the issue one might have.
  110338. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110339. * @param ray Defines the ray we are currently tryin to visualize
  110340. */
  110341. constructor(ray: Ray);
  110342. /**
  110343. * Shows the ray we are willing to debug.
  110344. * @param scene Defines the scene the ray needs to be rendered in
  110345. * @param color Defines the color the ray needs to be rendered in
  110346. */
  110347. show(scene: Scene, color?: Color3): void;
  110348. /**
  110349. * Hides the ray we are debugging.
  110350. */
  110351. hide(): void;
  110352. private _render;
  110353. /**
  110354. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110355. * @param mesh Defines the mesh we want the helper attached to
  110356. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110357. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110358. * @param length Defines the length of the ray
  110359. */
  110360. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110361. /**
  110362. * Detach the ray helper from the mesh it has previously been attached to.
  110363. */
  110364. detachFromMesh(): void;
  110365. private _updateToMesh;
  110366. /**
  110367. * Dispose the helper and release its associated resources.
  110368. */
  110369. dispose(): void;
  110370. }
  110371. }
  110372. declare module BABYLON.Debug {
  110373. /**
  110374. * Class used to render a debug view of a given skeleton
  110375. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110376. */
  110377. export class SkeletonViewer {
  110378. /** defines the skeleton to render */
  110379. skeleton: Skeleton;
  110380. /** defines the mesh attached to the skeleton */
  110381. mesh: AbstractMesh;
  110382. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110383. autoUpdateBonesMatrices: boolean;
  110384. /** defines the rendering group id to use with the viewer */
  110385. renderingGroupId: number;
  110386. /** Gets or sets the color used to render the skeleton */
  110387. color: Color3;
  110388. private _scene;
  110389. private _debugLines;
  110390. private _debugMesh;
  110391. private _isEnabled;
  110392. private _renderFunction;
  110393. private _utilityLayer;
  110394. /**
  110395. * Returns the mesh used to render the bones
  110396. */
  110397. readonly debugMesh: Nullable<LinesMesh>;
  110398. /**
  110399. * Creates a new SkeletonViewer
  110400. * @param skeleton defines the skeleton to render
  110401. * @param mesh defines the mesh attached to the skeleton
  110402. * @param scene defines the hosting scene
  110403. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110404. * @param renderingGroupId defines the rendering group id to use with the viewer
  110405. */
  110406. constructor(
  110407. /** defines the skeleton to render */
  110408. skeleton: Skeleton,
  110409. /** defines the mesh attached to the skeleton */
  110410. mesh: AbstractMesh, scene: Scene,
  110411. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110412. autoUpdateBonesMatrices?: boolean,
  110413. /** defines the rendering group id to use with the viewer */
  110414. renderingGroupId?: number);
  110415. /** Gets or sets a boolean indicating if the viewer is enabled */
  110416. isEnabled: boolean;
  110417. private _getBonePosition;
  110418. private _getLinesForBonesWithLength;
  110419. private _getLinesForBonesNoLength;
  110420. /** Update the viewer to sync with current skeleton state */
  110421. update(): void;
  110422. /** Release associated resources */
  110423. dispose(): void;
  110424. }
  110425. }
  110426. declare module BABYLON {
  110427. /**
  110428. * Options to create the null engine
  110429. */
  110430. export class NullEngineOptions {
  110431. /**
  110432. * Render width (Default: 512)
  110433. */
  110434. renderWidth: number;
  110435. /**
  110436. * Render height (Default: 256)
  110437. */
  110438. renderHeight: number;
  110439. /**
  110440. * Texture size (Default: 512)
  110441. */
  110442. textureSize: number;
  110443. /**
  110444. * If delta time between frames should be constant
  110445. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110446. */
  110447. deterministicLockstep: boolean;
  110448. /**
  110449. * Maximum about of steps between frames (Default: 4)
  110450. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110451. */
  110452. lockstepMaxSteps: number;
  110453. }
  110454. /**
  110455. * The null engine class provides support for headless version of babylon.js.
  110456. * This can be used in server side scenario or for testing purposes
  110457. */
  110458. export class NullEngine extends Engine {
  110459. private _options;
  110460. /**
  110461. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110463. * @returns true if engine is in deterministic lock step mode
  110464. */
  110465. isDeterministicLockStep(): boolean;
  110466. /**
  110467. * Gets the max steps when engine is running in deterministic lock step
  110468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110469. * @returns the max steps
  110470. */
  110471. getLockstepMaxSteps(): number;
  110472. /**
  110473. * Gets the current hardware scaling level.
  110474. * By default the hardware scaling level is computed from the window device ratio.
  110475. * 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.
  110476. * @returns a number indicating the current hardware scaling level
  110477. */
  110478. getHardwareScalingLevel(): number;
  110479. constructor(options?: NullEngineOptions);
  110480. /**
  110481. * Creates a vertex buffer
  110482. * @param vertices the data for the vertex buffer
  110483. * @returns the new WebGL static buffer
  110484. */
  110485. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110486. /**
  110487. * Creates a new index buffer
  110488. * @param indices defines the content of the index buffer
  110489. * @param updatable defines if the index buffer must be updatable
  110490. * @returns a new webGL buffer
  110491. */
  110492. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110493. /**
  110494. * Clear the current render buffer or the current render target (if any is set up)
  110495. * @param color defines the color to use
  110496. * @param backBuffer defines if the back buffer must be cleared
  110497. * @param depth defines if the depth buffer must be cleared
  110498. * @param stencil defines if the stencil buffer must be cleared
  110499. */
  110500. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110501. /**
  110502. * Gets the current render width
  110503. * @param useScreen defines if screen size must be used (or the current render target if any)
  110504. * @returns a number defining the current render width
  110505. */
  110506. getRenderWidth(useScreen?: boolean): number;
  110507. /**
  110508. * Gets the current render height
  110509. * @param useScreen defines if screen size must be used (or the current render target if any)
  110510. * @returns a number defining the current render height
  110511. */
  110512. getRenderHeight(useScreen?: boolean): number;
  110513. /**
  110514. * Set the WebGL's viewport
  110515. * @param viewport defines the viewport element to be used
  110516. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110517. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110518. */
  110519. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110520. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110521. /**
  110522. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110523. * @param pipelineContext defines the pipeline context to use
  110524. * @param uniformsNames defines the list of uniform names
  110525. * @returns an array of webGL uniform locations
  110526. */
  110527. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110528. /**
  110529. * Gets the lsit of active attributes for a given webGL program
  110530. * @param pipelineContext defines the pipeline context to use
  110531. * @param attributesNames defines the list of attribute names to get
  110532. * @returns an array of indices indicating the offset of each attribute
  110533. */
  110534. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110535. /**
  110536. * Binds an effect to the webGL context
  110537. * @param effect defines the effect to bind
  110538. */
  110539. bindSamplers(effect: Effect): void;
  110540. /**
  110541. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110542. * @param effect defines the effect to activate
  110543. */
  110544. enableEffect(effect: Effect): void;
  110545. /**
  110546. * Set various states to the webGL context
  110547. * @param culling defines backface culling state
  110548. * @param zOffset defines the value to apply to zOffset (0 by default)
  110549. * @param force defines if states must be applied even if cache is up to date
  110550. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110551. */
  110552. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110553. /**
  110554. * Set the value of an uniform to an array of int32
  110555. * @param uniform defines the webGL uniform location where to store the value
  110556. * @param array defines the array of int32 to store
  110557. */
  110558. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110559. /**
  110560. * Set the value of an uniform to an array of int32 (stored as vec2)
  110561. * @param uniform defines the webGL uniform location where to store the value
  110562. * @param array defines the array of int32 to store
  110563. */
  110564. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110565. /**
  110566. * Set the value of an uniform to an array of int32 (stored as vec3)
  110567. * @param uniform defines the webGL uniform location where to store the value
  110568. * @param array defines the array of int32 to store
  110569. */
  110570. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110571. /**
  110572. * Set the value of an uniform to an array of int32 (stored as vec4)
  110573. * @param uniform defines the webGL uniform location where to store the value
  110574. * @param array defines the array of int32 to store
  110575. */
  110576. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110577. /**
  110578. * Set the value of an uniform to an array of float32
  110579. * @param uniform defines the webGL uniform location where to store the value
  110580. * @param array defines the array of float32 to store
  110581. */
  110582. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110583. /**
  110584. * Set the value of an uniform to an array of float32 (stored as vec2)
  110585. * @param uniform defines the webGL uniform location where to store the value
  110586. * @param array defines the array of float32 to store
  110587. */
  110588. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110589. /**
  110590. * Set the value of an uniform to an array of float32 (stored as vec3)
  110591. * @param uniform defines the webGL uniform location where to store the value
  110592. * @param array defines the array of float32 to store
  110593. */
  110594. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110595. /**
  110596. * Set the value of an uniform to an array of float32 (stored as vec4)
  110597. * @param uniform defines the webGL uniform location where to store the value
  110598. * @param array defines the array of float32 to store
  110599. */
  110600. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110601. /**
  110602. * Set the value of an uniform to an array of number
  110603. * @param uniform defines the webGL uniform location where to store the value
  110604. * @param array defines the array of number to store
  110605. */
  110606. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110607. /**
  110608. * Set the value of an uniform to an array of number (stored as vec2)
  110609. * @param uniform defines the webGL uniform location where to store the value
  110610. * @param array defines the array of number to store
  110611. */
  110612. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110613. /**
  110614. * Set the value of an uniform to an array of number (stored as vec3)
  110615. * @param uniform defines the webGL uniform location where to store the value
  110616. * @param array defines the array of number to store
  110617. */
  110618. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110619. /**
  110620. * Set the value of an uniform to an array of number (stored as vec4)
  110621. * @param uniform defines the webGL uniform location where to store the value
  110622. * @param array defines the array of number to store
  110623. */
  110624. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110625. /**
  110626. * Set the value of an uniform to an array of float32 (stored as matrices)
  110627. * @param uniform defines the webGL uniform location where to store the value
  110628. * @param matrices defines the array of float32 to store
  110629. */
  110630. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110631. /**
  110632. * Set the value of an uniform to a matrix (3x3)
  110633. * @param uniform defines the webGL uniform location where to store the value
  110634. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110635. */
  110636. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110637. /**
  110638. * Set the value of an uniform to a matrix (2x2)
  110639. * @param uniform defines the webGL uniform location where to store the value
  110640. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110641. */
  110642. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110643. /**
  110644. * Set the value of an uniform to a number (float)
  110645. * @param uniform defines the webGL uniform location where to store the value
  110646. * @param value defines the float number to store
  110647. */
  110648. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110649. /**
  110650. * Set the value of an uniform to a vec2
  110651. * @param uniform defines the webGL uniform location where to store the value
  110652. * @param x defines the 1st component of the value
  110653. * @param y defines the 2nd component of the value
  110654. */
  110655. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110656. /**
  110657. * Set the value of an uniform to a vec3
  110658. * @param uniform defines the webGL uniform location where to store the value
  110659. * @param x defines the 1st component of the value
  110660. * @param y defines the 2nd component of the value
  110661. * @param z defines the 3rd component of the value
  110662. */
  110663. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110664. /**
  110665. * Set the value of an uniform to a boolean
  110666. * @param uniform defines the webGL uniform location where to store the value
  110667. * @param bool defines the boolean to store
  110668. */
  110669. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110670. /**
  110671. * Set the value of an uniform to a vec4
  110672. * @param uniform defines the webGL uniform location where to store the value
  110673. * @param x defines the 1st component of the value
  110674. * @param y defines the 2nd component of the value
  110675. * @param z defines the 3rd component of the value
  110676. * @param w defines the 4th component of the value
  110677. */
  110678. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110679. /**
  110680. * Sets the current alpha mode
  110681. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110682. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110683. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110684. */
  110685. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110686. /**
  110687. * Bind webGl buffers directly to the webGL context
  110688. * @param vertexBuffers defines the vertex buffer to bind
  110689. * @param indexBuffer defines the index buffer to bind
  110690. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110691. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110692. * @param effect defines the effect associated with the vertex buffer
  110693. */
  110694. bindBuffers(vertexBuffers: {
  110695. [key: string]: VertexBuffer;
  110696. }, indexBuffer: DataBuffer, effect: Effect): void;
  110697. /**
  110698. * Force the entire cache to be cleared
  110699. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110700. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110701. */
  110702. wipeCaches(bruteForce?: boolean): void;
  110703. /**
  110704. * Send a draw order
  110705. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110706. * @param indexStart defines the starting index
  110707. * @param indexCount defines the number of index to draw
  110708. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110709. */
  110710. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110711. /**
  110712. * Draw a list of indexed primitives
  110713. * @param fillMode defines the primitive to use
  110714. * @param indexStart defines the starting index
  110715. * @param indexCount defines the number of index to draw
  110716. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110717. */
  110718. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110719. /**
  110720. * Draw a list of unindexed primitives
  110721. * @param fillMode defines the primitive to use
  110722. * @param verticesStart defines the index of first vertex to draw
  110723. * @param verticesCount defines the count of vertices to draw
  110724. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110725. */
  110726. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110727. /** @hidden */
  110728. _createTexture(): WebGLTexture;
  110729. /** @hidden */
  110730. _releaseTexture(texture: InternalTexture): void;
  110731. /**
  110732. * Usually called from Texture.ts.
  110733. * Passed information to create a WebGLTexture
  110734. * @param urlArg defines a value which contains one of the following:
  110735. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110736. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110737. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110738. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110739. * @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)
  110740. * @param scene needed for loading to the correct scene
  110741. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110742. * @param onLoad optional callback to be called upon successful completion
  110743. * @param onError optional callback to be called upon failure
  110744. * @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
  110745. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110746. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110747. * @param forcedExtension defines the extension to use to pick the right loader
  110748. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110749. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110750. */
  110751. 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;
  110752. /**
  110753. * Creates a new render target texture
  110754. * @param size defines the size of the texture
  110755. * @param options defines the options used to create the texture
  110756. * @returns a new render target texture stored in an InternalTexture
  110757. */
  110758. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110759. /**
  110760. * Update the sampling mode of a given texture
  110761. * @param samplingMode defines the required sampling mode
  110762. * @param texture defines the texture to update
  110763. */
  110764. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110765. /**
  110766. * Binds the frame buffer to the specified texture.
  110767. * @param texture The texture to render to or null for the default canvas
  110768. * @param faceIndex The face of the texture to render to in case of cube texture
  110769. * @param requiredWidth The width of the target to render to
  110770. * @param requiredHeight The height of the target to render to
  110771. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110772. * @param depthStencilTexture The depth stencil texture to use to render
  110773. * @param lodLevel defines le lod level to bind to the frame buffer
  110774. */
  110775. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110776. /**
  110777. * Unbind the current render target texture from the webGL context
  110778. * @param texture defines the render target texture to unbind
  110779. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110780. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110781. */
  110782. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110783. /**
  110784. * Creates a dynamic vertex buffer
  110785. * @param vertices the data for the dynamic vertex buffer
  110786. * @returns the new WebGL dynamic buffer
  110787. */
  110788. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110789. /**
  110790. * Update the content of a dynamic texture
  110791. * @param texture defines the texture to update
  110792. * @param canvas defines the canvas containing the source
  110793. * @param invertY defines if data must be stored with Y axis inverted
  110794. * @param premulAlpha defines if alpha is stored as premultiplied
  110795. * @param format defines the format of the data
  110796. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110797. */
  110798. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110799. /**
  110800. * Gets a boolean indicating if all created effects are ready
  110801. * @returns true if all effects are ready
  110802. */
  110803. areAllEffectsReady(): boolean;
  110804. /**
  110805. * @hidden
  110806. * Get the current error code of the webGL context
  110807. * @returns the error code
  110808. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110809. */
  110810. getError(): number;
  110811. /** @hidden */
  110812. _getUnpackAlignement(): number;
  110813. /** @hidden */
  110814. _unpackFlipY(value: boolean): void;
  110815. /**
  110816. * Update a dynamic index buffer
  110817. * @param indexBuffer defines the target index buffer
  110818. * @param indices defines the data to update
  110819. * @param offset defines the offset in the target index buffer where update should start
  110820. */
  110821. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110822. /**
  110823. * Updates a dynamic vertex buffer.
  110824. * @param vertexBuffer the vertex buffer to update
  110825. * @param vertices the data used to update the vertex buffer
  110826. * @param byteOffset the byte offset of the data (optional)
  110827. * @param byteLength the byte length of the data (optional)
  110828. */
  110829. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110830. /** @hidden */
  110831. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110832. /** @hidden */
  110833. _bindTexture(channel: number, texture: InternalTexture): void;
  110834. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110835. /**
  110836. * 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
  110837. */
  110838. releaseEffects(): void;
  110839. displayLoadingUI(): void;
  110840. hideLoadingUI(): void;
  110841. /** @hidden */
  110842. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110843. /** @hidden */
  110844. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110845. /** @hidden */
  110846. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110847. /** @hidden */
  110848. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110849. }
  110850. }
  110851. declare module BABYLON {
  110852. /** @hidden */
  110853. export class _OcclusionDataStorage {
  110854. /** @hidden */
  110855. occlusionInternalRetryCounter: number;
  110856. /** @hidden */
  110857. isOcclusionQueryInProgress: boolean;
  110858. /** @hidden */
  110859. isOccluded: boolean;
  110860. /** @hidden */
  110861. occlusionRetryCount: number;
  110862. /** @hidden */
  110863. occlusionType: number;
  110864. /** @hidden */
  110865. occlusionQueryAlgorithmType: number;
  110866. }
  110867. interface Engine {
  110868. /**
  110869. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110870. * @return the new query
  110871. */
  110872. createQuery(): WebGLQuery;
  110873. /**
  110874. * Delete and release a webGL query
  110875. * @param query defines the query to delete
  110876. * @return the current engine
  110877. */
  110878. deleteQuery(query: WebGLQuery): Engine;
  110879. /**
  110880. * Check if a given query has resolved and got its value
  110881. * @param query defines the query to check
  110882. * @returns true if the query got its value
  110883. */
  110884. isQueryResultAvailable(query: WebGLQuery): boolean;
  110885. /**
  110886. * Gets the value of a given query
  110887. * @param query defines the query to check
  110888. * @returns the value of the query
  110889. */
  110890. getQueryResult(query: WebGLQuery): number;
  110891. /**
  110892. * Initiates an occlusion query
  110893. * @param algorithmType defines the algorithm to use
  110894. * @param query defines the query to use
  110895. * @returns the current engine
  110896. * @see http://doc.babylonjs.com/features/occlusionquery
  110897. */
  110898. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110899. /**
  110900. * Ends an occlusion query
  110901. * @see http://doc.babylonjs.com/features/occlusionquery
  110902. * @param algorithmType defines the algorithm to use
  110903. * @returns the current engine
  110904. */
  110905. endOcclusionQuery(algorithmType: number): Engine;
  110906. /**
  110907. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110908. * Please note that only one query can be issued at a time
  110909. * @returns a time token used to track the time span
  110910. */
  110911. startTimeQuery(): Nullable<_TimeToken>;
  110912. /**
  110913. * Ends a time query
  110914. * @param token defines the token used to measure the time span
  110915. * @returns the time spent (in ns)
  110916. */
  110917. endTimeQuery(token: _TimeToken): int;
  110918. /** @hidden */
  110919. _currentNonTimestampToken: Nullable<_TimeToken>;
  110920. /** @hidden */
  110921. _createTimeQuery(): WebGLQuery;
  110922. /** @hidden */
  110923. _deleteTimeQuery(query: WebGLQuery): void;
  110924. /** @hidden */
  110925. _getGlAlgorithmType(algorithmType: number): number;
  110926. /** @hidden */
  110927. _getTimeQueryResult(query: WebGLQuery): any;
  110928. /** @hidden */
  110929. _getTimeQueryAvailability(query: WebGLQuery): any;
  110930. }
  110931. interface AbstractMesh {
  110932. /**
  110933. * Backing filed
  110934. * @hidden
  110935. */
  110936. __occlusionDataStorage: _OcclusionDataStorage;
  110937. /**
  110938. * Access property
  110939. * @hidden
  110940. */
  110941. _occlusionDataStorage: _OcclusionDataStorage;
  110942. /**
  110943. * 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.
  110944. * The default value is -1 which means don't break the query and wait till the result
  110945. * @see http://doc.babylonjs.com/features/occlusionquery
  110946. */
  110947. occlusionRetryCount: number;
  110948. /**
  110949. * 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:
  110950. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110951. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110952. * * 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.
  110953. * @see http://doc.babylonjs.com/features/occlusionquery
  110954. */
  110955. occlusionType: number;
  110956. /**
  110957. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110958. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110959. * * 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.
  110960. * @see http://doc.babylonjs.com/features/occlusionquery
  110961. */
  110962. occlusionQueryAlgorithmType: number;
  110963. /**
  110964. * 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
  110965. * @see http://doc.babylonjs.com/features/occlusionquery
  110966. */
  110967. isOccluded: boolean;
  110968. /**
  110969. * Flag to check the progress status of the query
  110970. * @see http://doc.babylonjs.com/features/occlusionquery
  110971. */
  110972. isOcclusionQueryInProgress: boolean;
  110973. }
  110974. }
  110975. declare module BABYLON {
  110976. /** @hidden */
  110977. export var _forceTransformFeedbackToBundle: boolean;
  110978. interface Engine {
  110979. /**
  110980. * Creates a webGL transform feedback object
  110981. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110982. * @returns the webGL transform feedback object
  110983. */
  110984. createTransformFeedback(): WebGLTransformFeedback;
  110985. /**
  110986. * Delete a webGL transform feedback object
  110987. * @param value defines the webGL transform feedback object to delete
  110988. */
  110989. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110990. /**
  110991. * Bind a webGL transform feedback object to the webgl context
  110992. * @param value defines the webGL transform feedback object to bind
  110993. */
  110994. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110995. /**
  110996. * Begins a transform feedback operation
  110997. * @param usePoints defines if points or triangles must be used
  110998. */
  110999. beginTransformFeedback(usePoints: boolean): void;
  111000. /**
  111001. * Ends a transform feedback operation
  111002. */
  111003. endTransformFeedback(): void;
  111004. /**
  111005. * Specify the varyings to use with transform feedback
  111006. * @param program defines the associated webGL program
  111007. * @param value defines the list of strings representing the varying names
  111008. */
  111009. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  111010. /**
  111011. * Bind a webGL buffer for a transform feedback operation
  111012. * @param value defines the webGL buffer to bind
  111013. */
  111014. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  111015. }
  111016. }
  111017. declare module BABYLON {
  111018. /**
  111019. * Creation options of the multi render target texture.
  111020. */
  111021. export interface IMultiRenderTargetOptions {
  111022. /**
  111023. * Define if the texture needs to create mip maps after render.
  111024. */
  111025. generateMipMaps?: boolean;
  111026. /**
  111027. * Define the types of all the draw buffers we want to create
  111028. */
  111029. types?: number[];
  111030. /**
  111031. * Define the sampling modes of all the draw buffers we want to create
  111032. */
  111033. samplingModes?: number[];
  111034. /**
  111035. * Define if a depth buffer is required
  111036. */
  111037. generateDepthBuffer?: boolean;
  111038. /**
  111039. * Define if a stencil buffer is required
  111040. */
  111041. generateStencilBuffer?: boolean;
  111042. /**
  111043. * Define if a depth texture is required instead of a depth buffer
  111044. */
  111045. generateDepthTexture?: boolean;
  111046. /**
  111047. * Define the number of desired draw buffers
  111048. */
  111049. textureCount?: number;
  111050. /**
  111051. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111052. */
  111053. doNotChangeAspectRatio?: boolean;
  111054. /**
  111055. * Define the default type of the buffers we are creating
  111056. */
  111057. defaultType?: number;
  111058. }
  111059. /**
  111060. * A multi render target, like a render target provides the ability to render to a texture.
  111061. * Unlike the render target, it can render to several draw buffers in one draw.
  111062. * This is specially interesting in deferred rendering or for any effects requiring more than
  111063. * just one color from a single pass.
  111064. */
  111065. export class MultiRenderTarget extends RenderTargetTexture {
  111066. private _internalTextures;
  111067. private _textures;
  111068. private _multiRenderTargetOptions;
  111069. /**
  111070. * Get if draw buffers are currently supported by the used hardware and browser.
  111071. */
  111072. readonly isSupported: boolean;
  111073. /**
  111074. * Get the list of textures generated by the multi render target.
  111075. */
  111076. readonly textures: Texture[];
  111077. /**
  111078. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111079. */
  111080. readonly depthTexture: Texture;
  111081. /**
  111082. * Set the wrapping mode on U of all the textures we are rendering to.
  111083. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111084. */
  111085. wrapU: number;
  111086. /**
  111087. * Set the wrapping mode on V of all the textures we are rendering to.
  111088. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111089. */
  111090. wrapV: number;
  111091. /**
  111092. * Instantiate a new multi render target texture.
  111093. * A multi render target, like a render target provides the ability to render to a texture.
  111094. * Unlike the render target, it can render to several draw buffers in one draw.
  111095. * This is specially interesting in deferred rendering or for any effects requiring more than
  111096. * just one color from a single pass.
  111097. * @param name Define the name of the texture
  111098. * @param size Define the size of the buffers to render to
  111099. * @param count Define the number of target we are rendering into
  111100. * @param scene Define the scene the texture belongs to
  111101. * @param options Define the options used to create the multi render target
  111102. */
  111103. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111104. /** @hidden */
  111105. _rebuild(): void;
  111106. private _createInternalTextures;
  111107. private _createTextures;
  111108. /**
  111109. * Define the number of samples used if MSAA is enabled.
  111110. */
  111111. samples: number;
  111112. /**
  111113. * Resize all the textures in the multi render target.
  111114. * Be carrefull as it will recreate all the data in the new texture.
  111115. * @param size Define the new size
  111116. */
  111117. resize(size: any): void;
  111118. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111119. /**
  111120. * Dispose the render targets and their associated resources
  111121. */
  111122. dispose(): void;
  111123. /**
  111124. * Release all the underlying texture used as draw buffers.
  111125. */
  111126. releaseInternalTextures(): void;
  111127. }
  111128. }
  111129. declare module BABYLON {
  111130. interface ThinEngine {
  111131. /**
  111132. * Unbind a list of render target textures from the webGL context
  111133. * This is used only when drawBuffer extension or webGL2 are active
  111134. * @param textures defines the render target textures to unbind
  111135. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111136. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111137. */
  111138. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111139. /**
  111140. * Create a multi render target texture
  111141. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111142. * @param size defines the size of the texture
  111143. * @param options defines the creation options
  111144. * @returns the cube texture as an InternalTexture
  111145. */
  111146. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111147. /**
  111148. * Update the sample count for a given multiple render target texture
  111149. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111150. * @param textures defines the textures to update
  111151. * @param samples defines the sample count to set
  111152. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111153. */
  111154. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111155. }
  111156. }
  111157. declare module BABYLON {
  111158. /** @hidden */
  111159. export var rgbdEncodePixelShader: {
  111160. name: string;
  111161. shader: string;
  111162. };
  111163. }
  111164. declare module BABYLON {
  111165. /** @hidden */
  111166. export var rgbdDecodePixelShader: {
  111167. name: string;
  111168. shader: string;
  111169. };
  111170. }
  111171. declare module BABYLON {
  111172. /**
  111173. * Raw texture data and descriptor sufficient for WebGL texture upload
  111174. */
  111175. export interface EnvironmentTextureInfo {
  111176. /**
  111177. * Version of the environment map
  111178. */
  111179. version: number;
  111180. /**
  111181. * Width of image
  111182. */
  111183. width: number;
  111184. /**
  111185. * Irradiance information stored in the file.
  111186. */
  111187. irradiance: any;
  111188. /**
  111189. * Specular information stored in the file.
  111190. */
  111191. specular: any;
  111192. }
  111193. /**
  111194. * Defines One Image in the file. It requires only the position in the file
  111195. * as well as the length.
  111196. */
  111197. interface BufferImageData {
  111198. /**
  111199. * Length of the image data.
  111200. */
  111201. length: number;
  111202. /**
  111203. * Position of the data from the null terminator delimiting the end of the JSON.
  111204. */
  111205. position: number;
  111206. }
  111207. /**
  111208. * Defines the specular data enclosed in the file.
  111209. * This corresponds to the version 1 of the data.
  111210. */
  111211. export interface EnvironmentTextureSpecularInfoV1 {
  111212. /**
  111213. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111214. */
  111215. specularDataPosition?: number;
  111216. /**
  111217. * This contains all the images data needed to reconstruct the cubemap.
  111218. */
  111219. mipmaps: Array<BufferImageData>;
  111220. /**
  111221. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111222. */
  111223. lodGenerationScale: number;
  111224. }
  111225. /**
  111226. * Sets of helpers addressing the serialization and deserialization of environment texture
  111227. * stored in a BabylonJS env file.
  111228. * Those files are usually stored as .env files.
  111229. */
  111230. export class EnvironmentTextureTools {
  111231. /**
  111232. * Magic number identifying the env file.
  111233. */
  111234. private static _MagicBytes;
  111235. /**
  111236. * Gets the environment info from an env file.
  111237. * @param data The array buffer containing the .env bytes.
  111238. * @returns the environment file info (the json header) if successfully parsed.
  111239. */
  111240. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111241. /**
  111242. * Creates an environment texture from a loaded cube texture.
  111243. * @param texture defines the cube texture to convert in env file
  111244. * @return a promise containing the environment data if succesfull.
  111245. */
  111246. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111247. /**
  111248. * Creates a JSON representation of the spherical data.
  111249. * @param texture defines the texture containing the polynomials
  111250. * @return the JSON representation of the spherical info
  111251. */
  111252. private static _CreateEnvTextureIrradiance;
  111253. /**
  111254. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111255. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111256. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111257. * @return the views described by info providing access to the underlying buffer
  111258. */
  111259. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111260. /**
  111261. * Uploads the texture info contained in the env file to the GPU.
  111262. * @param texture defines the internal texture to upload to
  111263. * @param arrayBuffer defines the buffer cotaining the data to load
  111264. * @param info defines the texture info retrieved through the GetEnvInfo method
  111265. * @returns a promise
  111266. */
  111267. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111268. /**
  111269. * Uploads the levels of image data to the GPU.
  111270. * @param texture defines the internal texture to upload to
  111271. * @param imageData defines the array buffer views of image data [mipmap][face]
  111272. * @returns a promise
  111273. */
  111274. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111275. /**
  111276. * Uploads spherical polynomials information to the texture.
  111277. * @param texture defines the texture we are trying to upload the information to
  111278. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111279. */
  111280. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111281. /** @hidden */
  111282. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111283. }
  111284. }
  111285. declare module BABYLON {
  111286. /**
  111287. * Contains position and normal vectors for a vertex
  111288. */
  111289. export class PositionNormalVertex {
  111290. /** the position of the vertex (defaut: 0,0,0) */
  111291. position: Vector3;
  111292. /** the normal of the vertex (defaut: 0,1,0) */
  111293. normal: Vector3;
  111294. /**
  111295. * Creates a PositionNormalVertex
  111296. * @param position the position of the vertex (defaut: 0,0,0)
  111297. * @param normal the normal of the vertex (defaut: 0,1,0)
  111298. */
  111299. constructor(
  111300. /** the position of the vertex (defaut: 0,0,0) */
  111301. position?: Vector3,
  111302. /** the normal of the vertex (defaut: 0,1,0) */
  111303. normal?: Vector3);
  111304. /**
  111305. * Clones the PositionNormalVertex
  111306. * @returns the cloned PositionNormalVertex
  111307. */
  111308. clone(): PositionNormalVertex;
  111309. }
  111310. /**
  111311. * Contains position, normal and uv vectors for a vertex
  111312. */
  111313. export class PositionNormalTextureVertex {
  111314. /** the position of the vertex (defaut: 0,0,0) */
  111315. position: Vector3;
  111316. /** the normal of the vertex (defaut: 0,1,0) */
  111317. normal: Vector3;
  111318. /** the uv of the vertex (default: 0,0) */
  111319. uv: Vector2;
  111320. /**
  111321. * Creates a PositionNormalTextureVertex
  111322. * @param position the position of the vertex (defaut: 0,0,0)
  111323. * @param normal the normal of the vertex (defaut: 0,1,0)
  111324. * @param uv the uv of the vertex (default: 0,0)
  111325. */
  111326. constructor(
  111327. /** the position of the vertex (defaut: 0,0,0) */
  111328. position?: Vector3,
  111329. /** the normal of the vertex (defaut: 0,1,0) */
  111330. normal?: Vector3,
  111331. /** the uv of the vertex (default: 0,0) */
  111332. uv?: Vector2);
  111333. /**
  111334. * Clones the PositionNormalTextureVertex
  111335. * @returns the cloned PositionNormalTextureVertex
  111336. */
  111337. clone(): PositionNormalTextureVertex;
  111338. }
  111339. }
  111340. declare module BABYLON {
  111341. /** @hidden */
  111342. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111343. private _genericAttributeLocation;
  111344. private _varyingLocationCount;
  111345. private _varyingLocationMap;
  111346. private _replacements;
  111347. private _textureCount;
  111348. private _uniforms;
  111349. lineProcessor(line: string): string;
  111350. attributeProcessor(attribute: string): string;
  111351. varyingProcessor(varying: string, isFragment: boolean): string;
  111352. uniformProcessor(uniform: string): string;
  111353. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111354. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111355. }
  111356. }
  111357. declare module BABYLON {
  111358. /**
  111359. * Container for accessors for natively-stored mesh data buffers.
  111360. */
  111361. class NativeDataBuffer extends DataBuffer {
  111362. /**
  111363. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111364. */
  111365. nativeIndexBuffer?: any;
  111366. /**
  111367. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111368. */
  111369. nativeVertexBuffer?: any;
  111370. }
  111371. /** @hidden */
  111372. export class NativeEngine extends Engine {
  111373. private readonly _native;
  111374. getHardwareScalingLevel(): number;
  111375. constructor();
  111376. /**
  111377. * Can be used to override the current requestAnimationFrame requester.
  111378. * @hidden
  111379. */
  111380. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111381. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111382. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111383. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111384. recordVertexArrayObject(vertexBuffers: {
  111385. [key: string]: VertexBuffer;
  111386. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111387. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111388. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111389. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111390. /**
  111391. * Draw a list of indexed primitives
  111392. * @param fillMode defines the primitive to use
  111393. * @param indexStart defines the starting index
  111394. * @param indexCount defines the number of index to draw
  111395. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111396. */
  111397. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111398. /**
  111399. * Draw a list of unindexed primitives
  111400. * @param fillMode defines the primitive to use
  111401. * @param verticesStart defines the index of first vertex to draw
  111402. * @param verticesCount defines the count of vertices to draw
  111403. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111404. */
  111405. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111406. createPipelineContext(): IPipelineContext;
  111407. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111408. /** @hidden */
  111409. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111410. /** @hidden */
  111411. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111412. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111413. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111414. protected _setProgram(program: WebGLProgram): void;
  111415. _releaseEffect(effect: Effect): void;
  111416. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111417. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111418. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111419. bindSamplers(effect: Effect): void;
  111420. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111421. getRenderWidth(useScreen?: boolean): number;
  111422. getRenderHeight(useScreen?: boolean): number;
  111423. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111424. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111425. /**
  111426. * Set the z offset to apply to current rendering
  111427. * @param value defines the offset to apply
  111428. */
  111429. setZOffset(value: number): void;
  111430. /**
  111431. * Gets the current value of the zOffset
  111432. * @returns the current zOffset state
  111433. */
  111434. getZOffset(): number;
  111435. /**
  111436. * Enable or disable depth buffering
  111437. * @param enable defines the state to set
  111438. */
  111439. setDepthBuffer(enable: boolean): void;
  111440. /**
  111441. * Gets a boolean indicating if depth writing is enabled
  111442. * @returns the current depth writing state
  111443. */
  111444. getDepthWrite(): boolean;
  111445. /**
  111446. * Enable or disable depth writing
  111447. * @param enable defines the state to set
  111448. */
  111449. setDepthWrite(enable: boolean): void;
  111450. /**
  111451. * Enable or disable color writing
  111452. * @param enable defines the state to set
  111453. */
  111454. setColorWrite(enable: boolean): void;
  111455. /**
  111456. * Gets a boolean indicating if color writing is enabled
  111457. * @returns the current color writing state
  111458. */
  111459. getColorWrite(): boolean;
  111460. /**
  111461. * Sets alpha constants used by some alpha blending modes
  111462. * @param r defines the red component
  111463. * @param g defines the green component
  111464. * @param b defines the blue component
  111465. * @param a defines the alpha component
  111466. */
  111467. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111468. /**
  111469. * Sets the current alpha mode
  111470. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111471. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111472. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111473. */
  111474. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111475. /**
  111476. * Gets the current alpha mode
  111477. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111478. * @returns the current alpha mode
  111479. */
  111480. getAlphaMode(): number;
  111481. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111482. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111483. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111484. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111485. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111486. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111487. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111488. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111489. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111490. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111491. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111492. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111493. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111494. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111495. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111496. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111497. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111498. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111499. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111500. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111501. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111502. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111503. wipeCaches(bruteForce?: boolean): void;
  111504. _createTexture(): WebGLTexture;
  111505. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111506. /**
  111507. * Usually called from BABYLON.Texture.ts.
  111508. * Passed information to create a WebGLTexture
  111509. * @param urlArg defines a value which contains one of the following:
  111510. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111511. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111512. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111514. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111515. * @param scene needed for loading to the correct scene
  111516. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111517. * @param onLoad optional callback to be called upon successful completion
  111518. * @param onError optional callback to be called upon failure
  111519. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111520. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111521. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111522. * @param forcedExtension defines the extension to use to pick the right loader
  111523. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111524. */
  111525. 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;
  111526. /**
  111527. * Creates a cube texture
  111528. * @param rootUrl defines the url where the files to load is located
  111529. * @param scene defines the current scene
  111530. * @param files defines the list of files to load (1 per face)
  111531. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111532. * @param onLoad defines an optional callback raised when the texture is loaded
  111533. * @param onError defines an optional callback raised if there is an issue to load the texture
  111534. * @param format defines the format of the data
  111535. * @param forcedExtension defines the extension to use to pick the right loader
  111536. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111537. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111538. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111539. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111540. * @returns the cube texture as an InternalTexture
  111541. */
  111542. 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;
  111543. private _getSamplingFilter;
  111544. private static _GetNativeTextureFormat;
  111545. createRenderTargetTexture(size: number | {
  111546. width: number;
  111547. height: number;
  111548. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111549. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111550. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111551. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111552. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111553. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111554. /**
  111555. * Updates a dynamic vertex buffer.
  111556. * @param vertexBuffer the vertex buffer to update
  111557. * @param data the data used to update the vertex buffer
  111558. * @param byteOffset the byte offset of the data (optional)
  111559. * @param byteLength the byte length of the data (optional)
  111560. */
  111561. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111562. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111563. private _updateAnisotropicLevel;
  111564. private _getAddressMode;
  111565. /** @hidden */
  111566. _bindTexture(channel: number, texture: InternalTexture): void;
  111567. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111568. releaseEffects(): void;
  111569. /** @hidden */
  111570. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111571. /** @hidden */
  111572. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111573. /** @hidden */
  111574. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111575. /** @hidden */
  111576. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111577. }
  111578. }
  111579. declare module BABYLON {
  111580. /**
  111581. * Gather the list of clipboard event types as constants.
  111582. */
  111583. export class ClipboardEventTypes {
  111584. /**
  111585. * The clipboard event is fired when a copy command is active (pressed).
  111586. */
  111587. static readonly COPY: number;
  111588. /**
  111589. * The clipboard event is fired when a cut command is active (pressed).
  111590. */
  111591. static readonly CUT: number;
  111592. /**
  111593. * The clipboard event is fired when a paste command is active (pressed).
  111594. */
  111595. static readonly PASTE: number;
  111596. }
  111597. /**
  111598. * This class is used to store clipboard related info for the onClipboardObservable event.
  111599. */
  111600. export class ClipboardInfo {
  111601. /**
  111602. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111603. */
  111604. type: number;
  111605. /**
  111606. * Defines the related dom event
  111607. */
  111608. event: ClipboardEvent;
  111609. /**
  111610. *Creates an instance of ClipboardInfo.
  111611. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111612. * @param event Defines the related dom event
  111613. */
  111614. constructor(
  111615. /**
  111616. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111617. */
  111618. type: number,
  111619. /**
  111620. * Defines the related dom event
  111621. */
  111622. event: ClipboardEvent);
  111623. /**
  111624. * Get the clipboard event's type from the keycode.
  111625. * @param keyCode Defines the keyCode for the current keyboard event.
  111626. * @return {number}
  111627. */
  111628. static GetTypeFromCharacter(keyCode: number): number;
  111629. }
  111630. }
  111631. declare module BABYLON {
  111632. /**
  111633. * Google Daydream controller
  111634. */
  111635. export class DaydreamController extends WebVRController {
  111636. /**
  111637. * Base Url for the controller model.
  111638. */
  111639. static MODEL_BASE_URL: string;
  111640. /**
  111641. * File name for the controller model.
  111642. */
  111643. static MODEL_FILENAME: string;
  111644. /**
  111645. * Gamepad Id prefix used to identify Daydream Controller.
  111646. */
  111647. static readonly GAMEPAD_ID_PREFIX: string;
  111648. /**
  111649. * Creates a new DaydreamController from a gamepad
  111650. * @param vrGamepad the gamepad that the controller should be created from
  111651. */
  111652. constructor(vrGamepad: any);
  111653. /**
  111654. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111655. * @param scene scene in which to add meshes
  111656. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111657. */
  111658. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111659. /**
  111660. * Called once for each button that changed state since the last frame
  111661. * @param buttonIdx Which button index changed
  111662. * @param state New state of the button
  111663. * @param changes Which properties on the state changed since last frame
  111664. */
  111665. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111666. }
  111667. }
  111668. declare module BABYLON {
  111669. /**
  111670. * Gear VR Controller
  111671. */
  111672. export class GearVRController extends WebVRController {
  111673. /**
  111674. * Base Url for the controller model.
  111675. */
  111676. static MODEL_BASE_URL: string;
  111677. /**
  111678. * File name for the controller model.
  111679. */
  111680. static MODEL_FILENAME: string;
  111681. /**
  111682. * Gamepad Id prefix used to identify this controller.
  111683. */
  111684. static readonly GAMEPAD_ID_PREFIX: string;
  111685. private readonly _buttonIndexToObservableNameMap;
  111686. /**
  111687. * Creates a new GearVRController from a gamepad
  111688. * @param vrGamepad the gamepad that the controller should be created from
  111689. */
  111690. constructor(vrGamepad: any);
  111691. /**
  111692. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111693. * @param scene scene in which to add meshes
  111694. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111695. */
  111696. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111697. /**
  111698. * Called once for each button that changed state since the last frame
  111699. * @param buttonIdx Which button index changed
  111700. * @param state New state of the button
  111701. * @param changes Which properties on the state changed since last frame
  111702. */
  111703. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111704. }
  111705. }
  111706. declare module BABYLON {
  111707. /**
  111708. * Class containing static functions to help procedurally build meshes
  111709. */
  111710. export class PolyhedronBuilder {
  111711. /**
  111712. * Creates a polyhedron mesh
  111713. * * 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
  111714. * * The parameter `size` (positive float, default 1) sets the polygon size
  111715. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111716. * * 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`
  111717. * * 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
  111718. * * 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)`)
  111719. * * 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
  111720. * * 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
  111721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111724. * @param name defines the name of the mesh
  111725. * @param options defines the options used to create the mesh
  111726. * @param scene defines the hosting scene
  111727. * @returns the polyhedron mesh
  111728. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111729. */
  111730. static CreatePolyhedron(name: string, options: {
  111731. type?: number;
  111732. size?: number;
  111733. sizeX?: number;
  111734. sizeY?: number;
  111735. sizeZ?: number;
  111736. custom?: any;
  111737. faceUV?: Vector4[];
  111738. faceColors?: Color4[];
  111739. flat?: boolean;
  111740. updatable?: boolean;
  111741. sideOrientation?: number;
  111742. frontUVs?: Vector4;
  111743. backUVs?: Vector4;
  111744. }, scene?: Nullable<Scene>): Mesh;
  111745. }
  111746. }
  111747. declare module BABYLON {
  111748. /**
  111749. * Gizmo that enables scaling a mesh along 3 axis
  111750. */
  111751. export class ScaleGizmo extends Gizmo {
  111752. /**
  111753. * Internal gizmo used for interactions on the x axis
  111754. */
  111755. xGizmo: AxisScaleGizmo;
  111756. /**
  111757. * Internal gizmo used for interactions on the y axis
  111758. */
  111759. yGizmo: AxisScaleGizmo;
  111760. /**
  111761. * Internal gizmo used for interactions on the z axis
  111762. */
  111763. zGizmo: AxisScaleGizmo;
  111764. /**
  111765. * Internal gizmo used to scale all axis equally
  111766. */
  111767. uniformScaleGizmo: AxisScaleGizmo;
  111768. private _meshAttached;
  111769. private _updateGizmoRotationToMatchAttachedMesh;
  111770. private _snapDistance;
  111771. private _scaleRatio;
  111772. private _uniformScalingMesh;
  111773. private _octahedron;
  111774. /** Fires an event when any of it's sub gizmos are dragged */
  111775. onDragStartObservable: Observable<unknown>;
  111776. /** Fires an event when any of it's sub gizmos are released from dragging */
  111777. onDragEndObservable: Observable<unknown>;
  111778. attachedMesh: Nullable<AbstractMesh>;
  111779. /**
  111780. * Creates a ScaleGizmo
  111781. * @param gizmoLayer The utility layer the gizmo will be added to
  111782. */
  111783. constructor(gizmoLayer?: UtilityLayerRenderer);
  111784. updateGizmoRotationToMatchAttachedMesh: boolean;
  111785. /**
  111786. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111787. */
  111788. snapDistance: number;
  111789. /**
  111790. * Ratio for the scale of the gizmo (Default: 1)
  111791. */
  111792. scaleRatio: number;
  111793. /**
  111794. * Disposes of the gizmo
  111795. */
  111796. dispose(): void;
  111797. }
  111798. }
  111799. declare module BABYLON {
  111800. /**
  111801. * Single axis scale gizmo
  111802. */
  111803. export class AxisScaleGizmo extends Gizmo {
  111804. /**
  111805. * Drag behavior responsible for the gizmos dragging interactions
  111806. */
  111807. dragBehavior: PointerDragBehavior;
  111808. private _pointerObserver;
  111809. /**
  111810. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111811. */
  111812. snapDistance: number;
  111813. /**
  111814. * Event that fires each time the gizmo snaps to a new location.
  111815. * * snapDistance is the the change in distance
  111816. */
  111817. onSnapObservable: Observable<{
  111818. snapDistance: number;
  111819. }>;
  111820. /**
  111821. * If the scaling operation should be done on all axis (default: false)
  111822. */
  111823. uniformScaling: boolean;
  111824. private _isEnabled;
  111825. private _parent;
  111826. private _arrow;
  111827. private _coloredMaterial;
  111828. private _hoverMaterial;
  111829. /**
  111830. * Creates an AxisScaleGizmo
  111831. * @param gizmoLayer The utility layer the gizmo will be added to
  111832. * @param dragAxis The axis which the gizmo will be able to scale on
  111833. * @param color The color of the gizmo
  111834. */
  111835. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111836. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111837. /**
  111838. * If the gizmo is enabled
  111839. */
  111840. isEnabled: boolean;
  111841. /**
  111842. * Disposes of the gizmo
  111843. */
  111844. dispose(): void;
  111845. /**
  111846. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111847. * @param mesh The mesh to replace the default mesh of the gizmo
  111848. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111849. */
  111850. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111851. }
  111852. }
  111853. declare module BABYLON {
  111854. /**
  111855. * Bounding box gizmo
  111856. */
  111857. export class BoundingBoxGizmo extends Gizmo {
  111858. private _lineBoundingBox;
  111859. private _rotateSpheresParent;
  111860. private _scaleBoxesParent;
  111861. private _boundingDimensions;
  111862. private _renderObserver;
  111863. private _pointerObserver;
  111864. private _scaleDragSpeed;
  111865. private _tmpQuaternion;
  111866. private _tmpVector;
  111867. private _tmpRotationMatrix;
  111868. /**
  111869. * 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)
  111870. */
  111871. ignoreChildren: boolean;
  111872. /**
  111873. * 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)
  111874. */
  111875. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111876. /**
  111877. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111878. */
  111879. rotationSphereSize: number;
  111880. /**
  111881. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111882. */
  111883. scaleBoxSize: number;
  111884. /**
  111885. * 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)
  111886. */
  111887. fixedDragMeshScreenSize: boolean;
  111888. /**
  111889. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111890. */
  111891. fixedDragMeshScreenSizeDistanceFactor: number;
  111892. /**
  111893. * Fired when a rotation sphere or scale box is dragged
  111894. */
  111895. onDragStartObservable: Observable<{}>;
  111896. /**
  111897. * Fired when a scale box is dragged
  111898. */
  111899. onScaleBoxDragObservable: Observable<{}>;
  111900. /**
  111901. * Fired when a scale box drag is ended
  111902. */
  111903. onScaleBoxDragEndObservable: Observable<{}>;
  111904. /**
  111905. * Fired when a rotation sphere is dragged
  111906. */
  111907. onRotationSphereDragObservable: Observable<{}>;
  111908. /**
  111909. * Fired when a rotation sphere drag is ended
  111910. */
  111911. onRotationSphereDragEndObservable: Observable<{}>;
  111912. /**
  111913. * 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)
  111914. */
  111915. scalePivot: Nullable<Vector3>;
  111916. /**
  111917. * Mesh used as a pivot to rotate the attached mesh
  111918. */
  111919. private _anchorMesh;
  111920. private _existingMeshScale;
  111921. private _dragMesh;
  111922. private pointerDragBehavior;
  111923. private coloredMaterial;
  111924. private hoverColoredMaterial;
  111925. /**
  111926. * Sets the color of the bounding box gizmo
  111927. * @param color the color to set
  111928. */
  111929. setColor(color: Color3): void;
  111930. /**
  111931. * Creates an BoundingBoxGizmo
  111932. * @param gizmoLayer The utility layer the gizmo will be added to
  111933. * @param color The color of the gizmo
  111934. */
  111935. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111936. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111937. private _selectNode;
  111938. /**
  111939. * Updates the bounding box information for the Gizmo
  111940. */
  111941. updateBoundingBox(): void;
  111942. private _updateRotationSpheres;
  111943. private _updateScaleBoxes;
  111944. /**
  111945. * Enables rotation on the specified axis and disables rotation on the others
  111946. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111947. */
  111948. setEnabledRotationAxis(axis: string): void;
  111949. /**
  111950. * Enables/disables scaling
  111951. * @param enable if scaling should be enabled
  111952. */
  111953. setEnabledScaling(enable: boolean): void;
  111954. private _updateDummy;
  111955. /**
  111956. * Enables a pointer drag behavior on the bounding box of the gizmo
  111957. */
  111958. enableDragBehavior(): void;
  111959. /**
  111960. * Disposes of the gizmo
  111961. */
  111962. dispose(): void;
  111963. /**
  111964. * 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)
  111965. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111966. * @returns the bounding box mesh with the passed in mesh as a child
  111967. */
  111968. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111969. /**
  111970. * CustomMeshes are not supported by this gizmo
  111971. * @param mesh The mesh to replace the default mesh of the gizmo
  111972. */
  111973. setCustomMesh(mesh: Mesh): void;
  111974. }
  111975. }
  111976. declare module BABYLON {
  111977. /**
  111978. * Single plane rotation gizmo
  111979. */
  111980. export class PlaneRotationGizmo extends Gizmo {
  111981. /**
  111982. * Drag behavior responsible for the gizmos dragging interactions
  111983. */
  111984. dragBehavior: PointerDragBehavior;
  111985. private _pointerObserver;
  111986. /**
  111987. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111988. */
  111989. snapDistance: number;
  111990. /**
  111991. * Event that fires each time the gizmo snaps to a new location.
  111992. * * snapDistance is the the change in distance
  111993. */
  111994. onSnapObservable: Observable<{
  111995. snapDistance: number;
  111996. }>;
  111997. private _isEnabled;
  111998. private _parent;
  111999. /**
  112000. * Creates a PlaneRotationGizmo
  112001. * @param gizmoLayer The utility layer the gizmo will be added to
  112002. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112003. * @param color The color of the gizmo
  112004. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112005. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112006. */
  112007. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112008. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112009. /**
  112010. * If the gizmo is enabled
  112011. */
  112012. isEnabled: boolean;
  112013. /**
  112014. * Disposes of the gizmo
  112015. */
  112016. dispose(): void;
  112017. }
  112018. }
  112019. declare module BABYLON {
  112020. /**
  112021. * Gizmo that enables rotating a mesh along 3 axis
  112022. */
  112023. export class RotationGizmo extends Gizmo {
  112024. /**
  112025. * Internal gizmo used for interactions on the x axis
  112026. */
  112027. xGizmo: PlaneRotationGizmo;
  112028. /**
  112029. * Internal gizmo used for interactions on the y axis
  112030. */
  112031. yGizmo: PlaneRotationGizmo;
  112032. /**
  112033. * Internal gizmo used for interactions on the z axis
  112034. */
  112035. zGizmo: PlaneRotationGizmo;
  112036. /** Fires an event when any of it's sub gizmos are dragged */
  112037. onDragStartObservable: Observable<unknown>;
  112038. /** Fires an event when any of it's sub gizmos are released from dragging */
  112039. onDragEndObservable: Observable<unknown>;
  112040. private _meshAttached;
  112041. attachedMesh: Nullable<AbstractMesh>;
  112042. /**
  112043. * Creates a RotationGizmo
  112044. * @param gizmoLayer The utility layer the gizmo will be added to
  112045. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112046. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112047. */
  112048. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112049. updateGizmoRotationToMatchAttachedMesh: boolean;
  112050. /**
  112051. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112052. */
  112053. snapDistance: number;
  112054. /**
  112055. * Ratio for the scale of the gizmo (Default: 1)
  112056. */
  112057. scaleRatio: number;
  112058. /**
  112059. * Disposes of the gizmo
  112060. */
  112061. dispose(): void;
  112062. /**
  112063. * CustomMeshes are not supported by this gizmo
  112064. * @param mesh The mesh to replace the default mesh of the gizmo
  112065. */
  112066. setCustomMesh(mesh: Mesh): void;
  112067. }
  112068. }
  112069. declare module BABYLON {
  112070. /**
  112071. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112072. */
  112073. export class GizmoManager implements IDisposable {
  112074. private scene;
  112075. /**
  112076. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112077. */
  112078. gizmos: {
  112079. positionGizmo: Nullable<PositionGizmo>;
  112080. rotationGizmo: Nullable<RotationGizmo>;
  112081. scaleGizmo: Nullable<ScaleGizmo>;
  112082. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112083. };
  112084. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112085. clearGizmoOnEmptyPointerEvent: boolean;
  112086. /** Fires an event when the manager is attached to a mesh */
  112087. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112088. private _gizmosEnabled;
  112089. private _pointerObserver;
  112090. private _attachedMesh;
  112091. private _boundingBoxColor;
  112092. private _defaultUtilityLayer;
  112093. private _defaultKeepDepthUtilityLayer;
  112094. /**
  112095. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112096. */
  112097. boundingBoxDragBehavior: SixDofDragBehavior;
  112098. /**
  112099. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112100. */
  112101. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112102. /**
  112103. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112104. */
  112105. usePointerToAttachGizmos: boolean;
  112106. /**
  112107. * Utility layer that the bounding box gizmo belongs to
  112108. */
  112109. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112110. /**
  112111. * Utility layer that all gizmos besides bounding box belong to
  112112. */
  112113. readonly utilityLayer: UtilityLayerRenderer;
  112114. /**
  112115. * Instatiates a gizmo manager
  112116. * @param scene the scene to overlay the gizmos on top of
  112117. */
  112118. constructor(scene: Scene);
  112119. /**
  112120. * Attaches a set of gizmos to the specified mesh
  112121. * @param mesh The mesh the gizmo's should be attached to
  112122. */
  112123. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112124. /**
  112125. * If the position gizmo is enabled
  112126. */
  112127. positionGizmoEnabled: boolean;
  112128. /**
  112129. * If the rotation gizmo is enabled
  112130. */
  112131. rotationGizmoEnabled: boolean;
  112132. /**
  112133. * If the scale gizmo is enabled
  112134. */
  112135. scaleGizmoEnabled: boolean;
  112136. /**
  112137. * If the boundingBox gizmo is enabled
  112138. */
  112139. boundingBoxGizmoEnabled: boolean;
  112140. /**
  112141. * Disposes of the gizmo manager
  112142. */
  112143. dispose(): void;
  112144. }
  112145. }
  112146. declare module BABYLON {
  112147. /**
  112148. * A directional light is defined by a direction (what a surprise!).
  112149. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112150. * 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.
  112151. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112152. */
  112153. export class DirectionalLight extends ShadowLight {
  112154. private _shadowFrustumSize;
  112155. /**
  112156. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112157. */
  112158. /**
  112159. * Specifies a fix frustum size for the shadow generation.
  112160. */
  112161. shadowFrustumSize: number;
  112162. private _shadowOrthoScale;
  112163. /**
  112164. * Gets the shadow projection scale against the optimal computed one.
  112165. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112166. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112167. */
  112168. /**
  112169. * Sets the shadow projection scale against the optimal computed one.
  112170. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112171. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112172. */
  112173. shadowOrthoScale: number;
  112174. /**
  112175. * Automatically compute the projection matrix to best fit (including all the casters)
  112176. * on each frame.
  112177. */
  112178. autoUpdateExtends: boolean;
  112179. private _orthoLeft;
  112180. private _orthoRight;
  112181. private _orthoTop;
  112182. private _orthoBottom;
  112183. /**
  112184. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112185. * The directional light is emitted from everywhere in the given direction.
  112186. * It can cast shadows.
  112187. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112188. * @param name The friendly name of the light
  112189. * @param direction The direction of the light
  112190. * @param scene The scene the light belongs to
  112191. */
  112192. constructor(name: string, direction: Vector3, scene: Scene);
  112193. /**
  112194. * Returns the string "DirectionalLight".
  112195. * @return The class name
  112196. */
  112197. getClassName(): string;
  112198. /**
  112199. * Returns the integer 1.
  112200. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112201. */
  112202. getTypeID(): number;
  112203. /**
  112204. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112205. * Returns the DirectionalLight Shadow projection matrix.
  112206. */
  112207. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112208. /**
  112209. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112210. * Returns the DirectionalLight Shadow projection matrix.
  112211. */
  112212. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112213. /**
  112214. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112215. * Returns the DirectionalLight Shadow projection matrix.
  112216. */
  112217. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112218. protected _buildUniformLayout(): void;
  112219. /**
  112220. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112221. * @param effect The effect to update
  112222. * @param lightIndex The index of the light in the effect to update
  112223. * @returns The directional light
  112224. */
  112225. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112226. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112227. /**
  112228. * Gets the minZ used for shadow according to both the scene and the light.
  112229. *
  112230. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112231. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112232. * @param activeCamera The camera we are returning the min for
  112233. * @returns the depth min z
  112234. */
  112235. getDepthMinZ(activeCamera: Camera): number;
  112236. /**
  112237. * Gets the maxZ used for shadow according to both the scene and the light.
  112238. *
  112239. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112240. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112241. * @param activeCamera The camera we are returning the max for
  112242. * @returns the depth max z
  112243. */
  112244. getDepthMaxZ(activeCamera: Camera): number;
  112245. /**
  112246. * Prepares the list of defines specific to the light type.
  112247. * @param defines the list of defines
  112248. * @param lightIndex defines the index of the light for the effect
  112249. */
  112250. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112251. }
  112252. }
  112253. declare module BABYLON {
  112254. /**
  112255. * Class containing static functions to help procedurally build meshes
  112256. */
  112257. export class HemisphereBuilder {
  112258. /**
  112259. * Creates a hemisphere mesh
  112260. * @param name defines the name of the mesh
  112261. * @param options defines the options used to create the mesh
  112262. * @param scene defines the hosting scene
  112263. * @returns the hemisphere mesh
  112264. */
  112265. static CreateHemisphere(name: string, options: {
  112266. segments?: number;
  112267. diameter?: number;
  112268. sideOrientation?: number;
  112269. }, scene: any): Mesh;
  112270. }
  112271. }
  112272. declare module BABYLON {
  112273. /**
  112274. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112275. * These values define a cone of light starting from the position, emitting toward the direction.
  112276. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112277. * and the exponent defines the speed of the decay of the light with distance (reach).
  112278. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112279. */
  112280. export class SpotLight extends ShadowLight {
  112281. private _angle;
  112282. private _innerAngle;
  112283. private _cosHalfAngle;
  112284. private _lightAngleScale;
  112285. private _lightAngleOffset;
  112286. /**
  112287. * Gets the cone angle of the spot light in Radians.
  112288. */
  112289. /**
  112290. * Sets the cone angle of the spot light in Radians.
  112291. */
  112292. angle: number;
  112293. /**
  112294. * Only used in gltf falloff mode, this defines the angle where
  112295. * the directional falloff will start before cutting at angle which could be seen
  112296. * as outer angle.
  112297. */
  112298. /**
  112299. * Only used in gltf falloff mode, this defines the angle where
  112300. * the directional falloff will start before cutting at angle which could be seen
  112301. * as outer angle.
  112302. */
  112303. innerAngle: number;
  112304. private _shadowAngleScale;
  112305. /**
  112306. * Allows scaling the angle of the light for shadow generation only.
  112307. */
  112308. /**
  112309. * Allows scaling the angle of the light for shadow generation only.
  112310. */
  112311. shadowAngleScale: number;
  112312. /**
  112313. * The light decay speed with the distance from the emission spot.
  112314. */
  112315. exponent: number;
  112316. private _projectionTextureMatrix;
  112317. /**
  112318. * Allows reading the projecton texture
  112319. */
  112320. readonly projectionTextureMatrix: Matrix;
  112321. protected _projectionTextureLightNear: number;
  112322. /**
  112323. * Gets the near clip of the Spotlight for texture projection.
  112324. */
  112325. /**
  112326. * Sets the near clip of the Spotlight for texture projection.
  112327. */
  112328. projectionTextureLightNear: number;
  112329. protected _projectionTextureLightFar: number;
  112330. /**
  112331. * Gets the far clip of the Spotlight for texture projection.
  112332. */
  112333. /**
  112334. * Sets the far clip of the Spotlight for texture projection.
  112335. */
  112336. projectionTextureLightFar: number;
  112337. protected _projectionTextureUpDirection: Vector3;
  112338. /**
  112339. * Gets the Up vector of the Spotlight for texture projection.
  112340. */
  112341. /**
  112342. * Sets the Up vector of the Spotlight for texture projection.
  112343. */
  112344. projectionTextureUpDirection: Vector3;
  112345. private _projectionTexture;
  112346. /**
  112347. * Gets the projection texture of the light.
  112348. */
  112349. /**
  112350. * Sets the projection texture of the light.
  112351. */
  112352. projectionTexture: Nullable<BaseTexture>;
  112353. private _projectionTextureViewLightDirty;
  112354. private _projectionTextureProjectionLightDirty;
  112355. private _projectionTextureDirty;
  112356. private _projectionTextureViewTargetVector;
  112357. private _projectionTextureViewLightMatrix;
  112358. private _projectionTextureProjectionLightMatrix;
  112359. private _projectionTextureScalingMatrix;
  112360. /**
  112361. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112362. * It can cast shadows.
  112363. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112364. * @param name The light friendly name
  112365. * @param position The position of the spot light in the scene
  112366. * @param direction The direction of the light in the scene
  112367. * @param angle The cone angle of the light in Radians
  112368. * @param exponent The light decay speed with the distance from the emission spot
  112369. * @param scene The scene the lights belongs to
  112370. */
  112371. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112372. /**
  112373. * Returns the string "SpotLight".
  112374. * @returns the class name
  112375. */
  112376. getClassName(): string;
  112377. /**
  112378. * Returns the integer 2.
  112379. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112380. */
  112381. getTypeID(): number;
  112382. /**
  112383. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112384. */
  112385. protected _setDirection(value: Vector3): void;
  112386. /**
  112387. * Overrides the position setter to recompute the projection texture view light Matrix.
  112388. */
  112389. protected _setPosition(value: Vector3): void;
  112390. /**
  112391. * 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.
  112392. * Returns the SpotLight.
  112393. */
  112394. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112395. protected _computeProjectionTextureViewLightMatrix(): void;
  112396. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112397. /**
  112398. * Main function for light texture projection matrix computing.
  112399. */
  112400. protected _computeProjectionTextureMatrix(): void;
  112401. protected _buildUniformLayout(): void;
  112402. private _computeAngleValues;
  112403. /**
  112404. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112405. * @param effect The effect to update
  112406. * @param lightIndex The index of the light in the effect to update
  112407. * @returns The spot light
  112408. */
  112409. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112410. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112411. /**
  112412. * Disposes the light and the associated resources.
  112413. */
  112414. dispose(): void;
  112415. /**
  112416. * Prepares the list of defines specific to the light type.
  112417. * @param defines the list of defines
  112418. * @param lightIndex defines the index of the light for the effect
  112419. */
  112420. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112421. }
  112422. }
  112423. declare module BABYLON {
  112424. /**
  112425. * Gizmo that enables viewing a light
  112426. */
  112427. export class LightGizmo extends Gizmo {
  112428. private _lightMesh;
  112429. private _material;
  112430. private cachedPosition;
  112431. private cachedForward;
  112432. /**
  112433. * Creates a LightGizmo
  112434. * @param gizmoLayer The utility layer the gizmo will be added to
  112435. */
  112436. constructor(gizmoLayer?: UtilityLayerRenderer);
  112437. private _light;
  112438. /**
  112439. * The light that the gizmo is attached to
  112440. */
  112441. light: Nullable<Light>;
  112442. /**
  112443. * Gets the material used to render the light gizmo
  112444. */
  112445. readonly material: StandardMaterial;
  112446. /**
  112447. * @hidden
  112448. * Updates the gizmo to match the attached mesh's position/rotation
  112449. */
  112450. protected _update(): void;
  112451. private static _Scale;
  112452. /**
  112453. * Creates the lines for a light mesh
  112454. */
  112455. private static _createLightLines;
  112456. /**
  112457. * Disposes of the light gizmo
  112458. */
  112459. dispose(): void;
  112460. private static _CreateHemisphericLightMesh;
  112461. private static _CreatePointLightMesh;
  112462. private static _CreateSpotLightMesh;
  112463. private static _CreateDirectionalLightMesh;
  112464. }
  112465. }
  112466. declare module BABYLON {
  112467. /** @hidden */
  112468. export var backgroundFragmentDeclaration: {
  112469. name: string;
  112470. shader: string;
  112471. };
  112472. }
  112473. declare module BABYLON {
  112474. /** @hidden */
  112475. export var backgroundUboDeclaration: {
  112476. name: string;
  112477. shader: string;
  112478. };
  112479. }
  112480. declare module BABYLON {
  112481. /** @hidden */
  112482. export var backgroundPixelShader: {
  112483. name: string;
  112484. shader: string;
  112485. };
  112486. }
  112487. declare module BABYLON {
  112488. /** @hidden */
  112489. export var backgroundVertexDeclaration: {
  112490. name: string;
  112491. shader: string;
  112492. };
  112493. }
  112494. declare module BABYLON {
  112495. /** @hidden */
  112496. export var backgroundVertexShader: {
  112497. name: string;
  112498. shader: string;
  112499. };
  112500. }
  112501. declare module BABYLON {
  112502. /**
  112503. * Background material used to create an efficient environement around your scene.
  112504. */
  112505. export class BackgroundMaterial extends PushMaterial {
  112506. /**
  112507. * Standard reflectance value at parallel view angle.
  112508. */
  112509. static StandardReflectance0: number;
  112510. /**
  112511. * Standard reflectance value at grazing angle.
  112512. */
  112513. static StandardReflectance90: number;
  112514. protected _primaryColor: Color3;
  112515. /**
  112516. * Key light Color (multiply against the environement texture)
  112517. */
  112518. primaryColor: Color3;
  112519. protected __perceptualColor: Nullable<Color3>;
  112520. /**
  112521. * Experimental Internal Use Only.
  112522. *
  112523. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112524. * This acts as a helper to set the primary color to a more "human friendly" value.
  112525. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112526. * output color as close as possible from the chosen value.
  112527. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112528. * part of lighting setup.)
  112529. */
  112530. _perceptualColor: Nullable<Color3>;
  112531. protected _primaryColorShadowLevel: float;
  112532. /**
  112533. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112534. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112535. */
  112536. primaryColorShadowLevel: float;
  112537. protected _primaryColorHighlightLevel: float;
  112538. /**
  112539. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112540. * The primary color is used at the level chosen to define what the white area would look.
  112541. */
  112542. primaryColorHighlightLevel: float;
  112543. protected _reflectionTexture: Nullable<BaseTexture>;
  112544. /**
  112545. * Reflection Texture used in the material.
  112546. * Should be author in a specific way for the best result (refer to the documentation).
  112547. */
  112548. reflectionTexture: Nullable<BaseTexture>;
  112549. protected _reflectionBlur: float;
  112550. /**
  112551. * Reflection Texture level of blur.
  112552. *
  112553. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112554. * texture twice.
  112555. */
  112556. reflectionBlur: float;
  112557. protected _diffuseTexture: Nullable<BaseTexture>;
  112558. /**
  112559. * Diffuse Texture used in the material.
  112560. * Should be author in a specific way for the best result (refer to the documentation).
  112561. */
  112562. diffuseTexture: Nullable<BaseTexture>;
  112563. protected _shadowLights: Nullable<IShadowLight[]>;
  112564. /**
  112565. * Specify the list of lights casting shadow on the material.
  112566. * All scene shadow lights will be included if null.
  112567. */
  112568. shadowLights: Nullable<IShadowLight[]>;
  112569. protected _shadowLevel: float;
  112570. /**
  112571. * Helps adjusting the shadow to a softer level if required.
  112572. * 0 means black shadows and 1 means no shadows.
  112573. */
  112574. shadowLevel: float;
  112575. protected _sceneCenter: Vector3;
  112576. /**
  112577. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112578. * It is usually zero but might be interesting to modify according to your setup.
  112579. */
  112580. sceneCenter: Vector3;
  112581. protected _opacityFresnel: boolean;
  112582. /**
  112583. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112584. * This helps ensuring a nice transition when the camera goes under the ground.
  112585. */
  112586. opacityFresnel: boolean;
  112587. protected _reflectionFresnel: boolean;
  112588. /**
  112589. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112590. * This helps adding a mirror texture on the ground.
  112591. */
  112592. reflectionFresnel: boolean;
  112593. protected _reflectionFalloffDistance: number;
  112594. /**
  112595. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112596. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112597. */
  112598. reflectionFalloffDistance: number;
  112599. protected _reflectionAmount: number;
  112600. /**
  112601. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112602. */
  112603. reflectionAmount: number;
  112604. protected _reflectionReflectance0: number;
  112605. /**
  112606. * This specifies the weight of the reflection at grazing angle.
  112607. */
  112608. reflectionReflectance0: number;
  112609. protected _reflectionReflectance90: number;
  112610. /**
  112611. * This specifies the weight of the reflection at a perpendicular point of view.
  112612. */
  112613. reflectionReflectance90: number;
  112614. /**
  112615. * Sets the reflection reflectance fresnel values according to the default standard
  112616. * empirically know to work well :-)
  112617. */
  112618. reflectionStandardFresnelWeight: number;
  112619. protected _useRGBColor: boolean;
  112620. /**
  112621. * Helps to directly use the maps channels instead of their level.
  112622. */
  112623. useRGBColor: boolean;
  112624. protected _enableNoise: boolean;
  112625. /**
  112626. * This helps reducing the banding effect that could occur on the background.
  112627. */
  112628. enableNoise: boolean;
  112629. /**
  112630. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112631. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112632. * Recommended to be keep at 1.0 except for special cases.
  112633. */
  112634. fovMultiplier: number;
  112635. private _fovMultiplier;
  112636. /**
  112637. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112638. */
  112639. useEquirectangularFOV: boolean;
  112640. private _maxSimultaneousLights;
  112641. /**
  112642. * Number of Simultaneous lights allowed on the material.
  112643. */
  112644. maxSimultaneousLights: int;
  112645. /**
  112646. * Default configuration related to image processing available in the Background Material.
  112647. */
  112648. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112649. /**
  112650. * Keep track of the image processing observer to allow dispose and replace.
  112651. */
  112652. private _imageProcessingObserver;
  112653. /**
  112654. * Attaches a new image processing configuration to the PBR Material.
  112655. * @param configuration (if null the scene configuration will be use)
  112656. */
  112657. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112658. /**
  112659. * Gets the image processing configuration used either in this material.
  112660. */
  112661. /**
  112662. * Sets the Default image processing configuration used either in the this material.
  112663. *
  112664. * If sets to null, the scene one is in use.
  112665. */
  112666. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112667. /**
  112668. * Gets wether the color curves effect is enabled.
  112669. */
  112670. /**
  112671. * Sets wether the color curves effect is enabled.
  112672. */
  112673. cameraColorCurvesEnabled: boolean;
  112674. /**
  112675. * Gets wether the color grading effect is enabled.
  112676. */
  112677. /**
  112678. * Gets wether the color grading effect is enabled.
  112679. */
  112680. cameraColorGradingEnabled: boolean;
  112681. /**
  112682. * Gets wether tonemapping is enabled or not.
  112683. */
  112684. /**
  112685. * Sets wether tonemapping is enabled or not
  112686. */
  112687. cameraToneMappingEnabled: boolean;
  112688. /**
  112689. * The camera exposure used on this material.
  112690. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112691. * This corresponds to a photographic exposure.
  112692. */
  112693. /**
  112694. * The camera exposure used on this material.
  112695. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112696. * This corresponds to a photographic exposure.
  112697. */
  112698. cameraExposure: float;
  112699. /**
  112700. * Gets The camera contrast used on this material.
  112701. */
  112702. /**
  112703. * Sets The camera contrast used on this material.
  112704. */
  112705. cameraContrast: float;
  112706. /**
  112707. * Gets the Color Grading 2D Lookup Texture.
  112708. */
  112709. /**
  112710. * Sets the Color Grading 2D Lookup Texture.
  112711. */
  112712. cameraColorGradingTexture: Nullable<BaseTexture>;
  112713. /**
  112714. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112715. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112716. * 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;
  112717. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112718. */
  112719. /**
  112720. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112721. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112722. * 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;
  112723. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112724. */
  112725. cameraColorCurves: Nullable<ColorCurves>;
  112726. /**
  112727. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112728. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112729. */
  112730. switchToBGR: boolean;
  112731. private _renderTargets;
  112732. private _reflectionControls;
  112733. private _white;
  112734. private _primaryShadowColor;
  112735. private _primaryHighlightColor;
  112736. /**
  112737. * Instantiates a Background Material in the given scene
  112738. * @param name The friendly name of the material
  112739. * @param scene The scene to add the material to
  112740. */
  112741. constructor(name: string, scene: Scene);
  112742. /**
  112743. * Gets a boolean indicating that current material needs to register RTT
  112744. */
  112745. readonly hasRenderTargetTextures: boolean;
  112746. /**
  112747. * The entire material has been created in order to prevent overdraw.
  112748. * @returns false
  112749. */
  112750. needAlphaTesting(): boolean;
  112751. /**
  112752. * The entire material has been created in order to prevent overdraw.
  112753. * @returns true if blending is enable
  112754. */
  112755. needAlphaBlending(): boolean;
  112756. /**
  112757. * Checks wether the material is ready to be rendered for a given mesh.
  112758. * @param mesh The mesh to render
  112759. * @param subMesh The submesh to check against
  112760. * @param useInstances Specify wether or not the material is used with instances
  112761. * @returns true if all the dependencies are ready (Textures, Effects...)
  112762. */
  112763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112764. /**
  112765. * Compute the primary color according to the chosen perceptual color.
  112766. */
  112767. private _computePrimaryColorFromPerceptualColor;
  112768. /**
  112769. * Compute the highlights and shadow colors according to their chosen levels.
  112770. */
  112771. private _computePrimaryColors;
  112772. /**
  112773. * Build the uniform buffer used in the material.
  112774. */
  112775. buildUniformLayout(): void;
  112776. /**
  112777. * Unbind the material.
  112778. */
  112779. unbind(): void;
  112780. /**
  112781. * Bind only the world matrix to the material.
  112782. * @param world The world matrix to bind.
  112783. */
  112784. bindOnlyWorldMatrix(world: Matrix): void;
  112785. /**
  112786. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112787. * @param world The world matrix to bind.
  112788. * @param subMesh The submesh to bind for.
  112789. */
  112790. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112791. /**
  112792. * Checks to see if a texture is used in the material.
  112793. * @param texture - Base texture to use.
  112794. * @returns - Boolean specifying if a texture is used in the material.
  112795. */
  112796. hasTexture(texture: BaseTexture): boolean;
  112797. /**
  112798. * Dispose the material.
  112799. * @param forceDisposeEffect Force disposal of the associated effect.
  112800. * @param forceDisposeTextures Force disposal of the associated textures.
  112801. */
  112802. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112803. /**
  112804. * Clones the material.
  112805. * @param name The cloned name.
  112806. * @returns The cloned material.
  112807. */
  112808. clone(name: string): BackgroundMaterial;
  112809. /**
  112810. * Serializes the current material to its JSON representation.
  112811. * @returns The JSON representation.
  112812. */
  112813. serialize(): any;
  112814. /**
  112815. * Gets the class name of the material
  112816. * @returns "BackgroundMaterial"
  112817. */
  112818. getClassName(): string;
  112819. /**
  112820. * Parse a JSON input to create back a background material.
  112821. * @param source The JSON data to parse
  112822. * @param scene The scene to create the parsed material in
  112823. * @param rootUrl The root url of the assets the material depends upon
  112824. * @returns the instantiated BackgroundMaterial.
  112825. */
  112826. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112827. }
  112828. }
  112829. declare module BABYLON {
  112830. /**
  112831. * Represents the different options available during the creation of
  112832. * a Environment helper.
  112833. *
  112834. * This can control the default ground, skybox and image processing setup of your scene.
  112835. */
  112836. export interface IEnvironmentHelperOptions {
  112837. /**
  112838. * Specifies wether or not to create a ground.
  112839. * True by default.
  112840. */
  112841. createGround: boolean;
  112842. /**
  112843. * Specifies the ground size.
  112844. * 15 by default.
  112845. */
  112846. groundSize: number;
  112847. /**
  112848. * The texture used on the ground for the main color.
  112849. * Comes from the BabylonJS CDN by default.
  112850. *
  112851. * Remarks: Can be either a texture or a url.
  112852. */
  112853. groundTexture: string | BaseTexture;
  112854. /**
  112855. * The color mixed in the ground texture by default.
  112856. * BabylonJS clearColor by default.
  112857. */
  112858. groundColor: Color3;
  112859. /**
  112860. * Specifies the ground opacity.
  112861. * 1 by default.
  112862. */
  112863. groundOpacity: number;
  112864. /**
  112865. * Enables the ground to receive shadows.
  112866. * True by default.
  112867. */
  112868. enableGroundShadow: boolean;
  112869. /**
  112870. * Helps preventing the shadow to be fully black on the ground.
  112871. * 0.5 by default.
  112872. */
  112873. groundShadowLevel: number;
  112874. /**
  112875. * Creates a mirror texture attach to the ground.
  112876. * false by default.
  112877. */
  112878. enableGroundMirror: boolean;
  112879. /**
  112880. * Specifies the ground mirror size ratio.
  112881. * 0.3 by default as the default kernel is 64.
  112882. */
  112883. groundMirrorSizeRatio: number;
  112884. /**
  112885. * Specifies the ground mirror blur kernel size.
  112886. * 64 by default.
  112887. */
  112888. groundMirrorBlurKernel: number;
  112889. /**
  112890. * Specifies the ground mirror visibility amount.
  112891. * 1 by default
  112892. */
  112893. groundMirrorAmount: number;
  112894. /**
  112895. * Specifies the ground mirror reflectance weight.
  112896. * This uses the standard weight of the background material to setup the fresnel effect
  112897. * of the mirror.
  112898. * 1 by default.
  112899. */
  112900. groundMirrorFresnelWeight: number;
  112901. /**
  112902. * Specifies the ground mirror Falloff distance.
  112903. * This can helps reducing the size of the reflection.
  112904. * 0 by Default.
  112905. */
  112906. groundMirrorFallOffDistance: number;
  112907. /**
  112908. * Specifies the ground mirror texture type.
  112909. * Unsigned Int by Default.
  112910. */
  112911. groundMirrorTextureType: number;
  112912. /**
  112913. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112914. * the shown objects.
  112915. */
  112916. groundYBias: number;
  112917. /**
  112918. * Specifies wether or not to create a skybox.
  112919. * True by default.
  112920. */
  112921. createSkybox: boolean;
  112922. /**
  112923. * Specifies the skybox size.
  112924. * 20 by default.
  112925. */
  112926. skyboxSize: number;
  112927. /**
  112928. * The texture used on the skybox for the main color.
  112929. * Comes from the BabylonJS CDN by default.
  112930. *
  112931. * Remarks: Can be either a texture or a url.
  112932. */
  112933. skyboxTexture: string | BaseTexture;
  112934. /**
  112935. * The color mixed in the skybox texture by default.
  112936. * BabylonJS clearColor by default.
  112937. */
  112938. skyboxColor: Color3;
  112939. /**
  112940. * The background rotation around the Y axis of the scene.
  112941. * This helps aligning the key lights of your scene with the background.
  112942. * 0 by default.
  112943. */
  112944. backgroundYRotation: number;
  112945. /**
  112946. * Compute automatically the size of the elements to best fit with the scene.
  112947. */
  112948. sizeAuto: boolean;
  112949. /**
  112950. * Default position of the rootMesh if autoSize is not true.
  112951. */
  112952. rootPosition: Vector3;
  112953. /**
  112954. * Sets up the image processing in the scene.
  112955. * true by default.
  112956. */
  112957. setupImageProcessing: boolean;
  112958. /**
  112959. * The texture used as your environment texture in the scene.
  112960. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112961. *
  112962. * Remarks: Can be either a texture or a url.
  112963. */
  112964. environmentTexture: string | BaseTexture;
  112965. /**
  112966. * The value of the exposure to apply to the scene.
  112967. * 0.6 by default if setupImageProcessing is true.
  112968. */
  112969. cameraExposure: number;
  112970. /**
  112971. * The value of the contrast to apply to the scene.
  112972. * 1.6 by default if setupImageProcessing is true.
  112973. */
  112974. cameraContrast: number;
  112975. /**
  112976. * Specifies wether or not tonemapping should be enabled in the scene.
  112977. * true by default if setupImageProcessing is true.
  112978. */
  112979. toneMappingEnabled: boolean;
  112980. }
  112981. /**
  112982. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112983. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112984. * It also helps with the default setup of your imageProcessing configuration.
  112985. */
  112986. export class EnvironmentHelper {
  112987. /**
  112988. * Default ground texture URL.
  112989. */
  112990. private static _groundTextureCDNUrl;
  112991. /**
  112992. * Default skybox texture URL.
  112993. */
  112994. private static _skyboxTextureCDNUrl;
  112995. /**
  112996. * Default environment texture URL.
  112997. */
  112998. private static _environmentTextureCDNUrl;
  112999. /**
  113000. * Creates the default options for the helper.
  113001. */
  113002. private static _getDefaultOptions;
  113003. private _rootMesh;
  113004. /**
  113005. * Gets the root mesh created by the helper.
  113006. */
  113007. readonly rootMesh: Mesh;
  113008. private _skybox;
  113009. /**
  113010. * Gets the skybox created by the helper.
  113011. */
  113012. readonly skybox: Nullable<Mesh>;
  113013. private _skyboxTexture;
  113014. /**
  113015. * Gets the skybox texture created by the helper.
  113016. */
  113017. readonly skyboxTexture: Nullable<BaseTexture>;
  113018. private _skyboxMaterial;
  113019. /**
  113020. * Gets the skybox material created by the helper.
  113021. */
  113022. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113023. private _ground;
  113024. /**
  113025. * Gets the ground mesh created by the helper.
  113026. */
  113027. readonly ground: Nullable<Mesh>;
  113028. private _groundTexture;
  113029. /**
  113030. * Gets the ground texture created by the helper.
  113031. */
  113032. readonly groundTexture: Nullable<BaseTexture>;
  113033. private _groundMirror;
  113034. /**
  113035. * Gets the ground mirror created by the helper.
  113036. */
  113037. readonly groundMirror: Nullable<MirrorTexture>;
  113038. /**
  113039. * Gets the ground mirror render list to helps pushing the meshes
  113040. * you wish in the ground reflection.
  113041. */
  113042. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113043. private _groundMaterial;
  113044. /**
  113045. * Gets the ground material created by the helper.
  113046. */
  113047. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113048. /**
  113049. * Stores the creation options.
  113050. */
  113051. private readonly _scene;
  113052. private _options;
  113053. /**
  113054. * This observable will be notified with any error during the creation of the environment,
  113055. * mainly texture creation errors.
  113056. */
  113057. onErrorObservable: Observable<{
  113058. message?: string;
  113059. exception?: any;
  113060. }>;
  113061. /**
  113062. * constructor
  113063. * @param options Defines the options we want to customize the helper
  113064. * @param scene The scene to add the material to
  113065. */
  113066. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113067. /**
  113068. * Updates the background according to the new options
  113069. * @param options
  113070. */
  113071. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113072. /**
  113073. * Sets the primary color of all the available elements.
  113074. * @param color the main color to affect to the ground and the background
  113075. */
  113076. setMainColor(color: Color3): void;
  113077. /**
  113078. * Setup the image processing according to the specified options.
  113079. */
  113080. private _setupImageProcessing;
  113081. /**
  113082. * Setup the environment texture according to the specified options.
  113083. */
  113084. private _setupEnvironmentTexture;
  113085. /**
  113086. * Setup the background according to the specified options.
  113087. */
  113088. private _setupBackground;
  113089. /**
  113090. * Get the scene sizes according to the setup.
  113091. */
  113092. private _getSceneSize;
  113093. /**
  113094. * Setup the ground according to the specified options.
  113095. */
  113096. private _setupGround;
  113097. /**
  113098. * Setup the ground material according to the specified options.
  113099. */
  113100. private _setupGroundMaterial;
  113101. /**
  113102. * Setup the ground diffuse texture according to the specified options.
  113103. */
  113104. private _setupGroundDiffuseTexture;
  113105. /**
  113106. * Setup the ground mirror texture according to the specified options.
  113107. */
  113108. private _setupGroundMirrorTexture;
  113109. /**
  113110. * Setup the ground to receive the mirror texture.
  113111. */
  113112. private _setupMirrorInGroundMaterial;
  113113. /**
  113114. * Setup the skybox according to the specified options.
  113115. */
  113116. private _setupSkybox;
  113117. /**
  113118. * Setup the skybox material according to the specified options.
  113119. */
  113120. private _setupSkyboxMaterial;
  113121. /**
  113122. * Setup the skybox reflection texture according to the specified options.
  113123. */
  113124. private _setupSkyboxReflectionTexture;
  113125. private _errorHandler;
  113126. /**
  113127. * Dispose all the elements created by the Helper.
  113128. */
  113129. dispose(): void;
  113130. }
  113131. }
  113132. declare module BABYLON {
  113133. /**
  113134. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113135. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113136. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113137. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113138. */
  113139. export class PhotoDome extends TransformNode {
  113140. /**
  113141. * Define the image as a Monoscopic panoramic 360 image.
  113142. */
  113143. static readonly MODE_MONOSCOPIC: number;
  113144. /**
  113145. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113146. */
  113147. static readonly MODE_TOPBOTTOM: number;
  113148. /**
  113149. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113150. */
  113151. static readonly MODE_SIDEBYSIDE: number;
  113152. private _useDirectMapping;
  113153. /**
  113154. * The texture being displayed on the sphere
  113155. */
  113156. protected _photoTexture: Texture;
  113157. /**
  113158. * Gets or sets the texture being displayed on the sphere
  113159. */
  113160. photoTexture: Texture;
  113161. /**
  113162. * Observable raised when an error occured while loading the 360 image
  113163. */
  113164. onLoadErrorObservable: Observable<string>;
  113165. /**
  113166. * The skybox material
  113167. */
  113168. protected _material: BackgroundMaterial;
  113169. /**
  113170. * The surface used for the skybox
  113171. */
  113172. protected _mesh: Mesh;
  113173. /**
  113174. * Gets the mesh used for the skybox.
  113175. */
  113176. readonly mesh: Mesh;
  113177. /**
  113178. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113179. * Also see the options.resolution property.
  113180. */
  113181. fovMultiplier: number;
  113182. private _imageMode;
  113183. /**
  113184. * Gets or set the current video mode for the video. It can be:
  113185. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113186. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113187. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113188. */
  113189. imageMode: number;
  113190. /**
  113191. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113192. * @param name Element's name, child elements will append suffixes for their own names.
  113193. * @param urlsOfPhoto defines the url of the photo to display
  113194. * @param options defines an object containing optional or exposed sub element properties
  113195. * @param onError defines a callback called when an error occured while loading the texture
  113196. */
  113197. constructor(name: string, urlOfPhoto: string, options: {
  113198. resolution?: number;
  113199. size?: number;
  113200. useDirectMapping?: boolean;
  113201. faceForward?: boolean;
  113202. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113203. private _onBeforeCameraRenderObserver;
  113204. private _changeImageMode;
  113205. /**
  113206. * Releases resources associated with this node.
  113207. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113208. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113209. */
  113210. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113211. }
  113212. }
  113213. declare module BABYLON {
  113214. /**
  113215. * Class used to host RGBD texture specific utilities
  113216. */
  113217. export class RGBDTextureTools {
  113218. /**
  113219. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113220. * @param texture the texture to expand.
  113221. */
  113222. static ExpandRGBDTexture(texture: Texture): void;
  113223. }
  113224. }
  113225. declare module BABYLON {
  113226. /**
  113227. * Class used to host texture specific utilities
  113228. */
  113229. export class BRDFTextureTools {
  113230. /**
  113231. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113232. * @param scene defines the hosting scene
  113233. * @returns the environment BRDF texture
  113234. */
  113235. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113236. private static _environmentBRDFBase64Texture;
  113237. }
  113238. }
  113239. declare module BABYLON {
  113240. /**
  113241. * @hidden
  113242. */
  113243. export interface IMaterialClearCoatDefines {
  113244. CLEARCOAT: boolean;
  113245. CLEARCOAT_DEFAULTIOR: boolean;
  113246. CLEARCOAT_TEXTURE: boolean;
  113247. CLEARCOAT_TEXTUREDIRECTUV: number;
  113248. CLEARCOAT_BUMP: boolean;
  113249. CLEARCOAT_BUMPDIRECTUV: number;
  113250. CLEARCOAT_TINT: boolean;
  113251. CLEARCOAT_TINT_TEXTURE: boolean;
  113252. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113253. /** @hidden */
  113254. _areTexturesDirty: boolean;
  113255. }
  113256. /**
  113257. * Define the code related to the clear coat parameters of the pbr material.
  113258. */
  113259. export class PBRClearCoatConfiguration {
  113260. /**
  113261. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113262. * The default fits with a polyurethane material.
  113263. */
  113264. private static readonly _DefaultIndexOfRefraction;
  113265. private _isEnabled;
  113266. /**
  113267. * Defines if the clear coat is enabled in the material.
  113268. */
  113269. isEnabled: boolean;
  113270. /**
  113271. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113272. */
  113273. intensity: number;
  113274. /**
  113275. * Defines the clear coat layer roughness.
  113276. */
  113277. roughness: number;
  113278. private _indexOfRefraction;
  113279. /**
  113280. * Defines the index of refraction of the clear coat.
  113281. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113282. * The default fits with a polyurethane material.
  113283. * Changing the default value is more performance intensive.
  113284. */
  113285. indexOfRefraction: number;
  113286. private _texture;
  113287. /**
  113288. * Stores the clear coat values in a texture.
  113289. */
  113290. texture: Nullable<BaseTexture>;
  113291. private _bumpTexture;
  113292. /**
  113293. * Define the clear coat specific bump texture.
  113294. */
  113295. bumpTexture: Nullable<BaseTexture>;
  113296. private _isTintEnabled;
  113297. /**
  113298. * Defines if the clear coat tint is enabled in the material.
  113299. */
  113300. isTintEnabled: boolean;
  113301. /**
  113302. * Defines the clear coat tint of the material.
  113303. * This is only use if tint is enabled
  113304. */
  113305. tintColor: Color3;
  113306. /**
  113307. * Defines the distance at which the tint color should be found in the
  113308. * clear coat media.
  113309. * This is only use if tint is enabled
  113310. */
  113311. tintColorAtDistance: number;
  113312. /**
  113313. * Defines the clear coat layer thickness.
  113314. * This is only use if tint is enabled
  113315. */
  113316. tintThickness: number;
  113317. private _tintTexture;
  113318. /**
  113319. * Stores the clear tint values in a texture.
  113320. * rgb is tint
  113321. * a is a thickness factor
  113322. */
  113323. tintTexture: Nullable<BaseTexture>;
  113324. /** @hidden */
  113325. private _internalMarkAllSubMeshesAsTexturesDirty;
  113326. /** @hidden */
  113327. _markAllSubMeshesAsTexturesDirty(): void;
  113328. /**
  113329. * Instantiate a new istance of clear coat configuration.
  113330. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113331. */
  113332. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113333. /**
  113334. * Gets wehter the submesh is ready to be used or not.
  113335. * @param defines the list of "defines" to update.
  113336. * @param scene defines the scene the material belongs to.
  113337. * @param engine defines the engine the material belongs to.
  113338. * @param disableBumpMap defines wether the material disables bump or not.
  113339. * @returns - boolean indicating that the submesh is ready or not.
  113340. */
  113341. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113342. /**
  113343. * Checks to see if a texture is used in the material.
  113344. * @param defines the list of "defines" to update.
  113345. * @param scene defines the scene to the material belongs to.
  113346. */
  113347. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113348. /**
  113349. * Binds the material data.
  113350. * @param uniformBuffer defines the Uniform buffer to fill in.
  113351. * @param scene defines the scene the material belongs to.
  113352. * @param engine defines the engine the material belongs to.
  113353. * @param disableBumpMap defines wether the material disables bump or not.
  113354. * @param isFrozen defines wether the material is frozen or not.
  113355. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113356. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113357. */
  113358. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113359. /**
  113360. * Checks to see if a texture is used in the material.
  113361. * @param texture - Base texture to use.
  113362. * @returns - Boolean specifying if a texture is used in the material.
  113363. */
  113364. hasTexture(texture: BaseTexture): boolean;
  113365. /**
  113366. * Returns an array of the actively used textures.
  113367. * @param activeTextures Array of BaseTextures
  113368. */
  113369. getActiveTextures(activeTextures: BaseTexture[]): void;
  113370. /**
  113371. * Returns the animatable textures.
  113372. * @param animatables Array of animatable textures.
  113373. */
  113374. getAnimatables(animatables: IAnimatable[]): void;
  113375. /**
  113376. * Disposes the resources of the material.
  113377. * @param forceDisposeTextures - Forces the disposal of all textures.
  113378. */
  113379. dispose(forceDisposeTextures?: boolean): void;
  113380. /**
  113381. * Get the current class name of the texture useful for serialization or dynamic coding.
  113382. * @returns "PBRClearCoatConfiguration"
  113383. */
  113384. getClassName(): string;
  113385. /**
  113386. * Add fallbacks to the effect fallbacks list.
  113387. * @param defines defines the Base texture to use.
  113388. * @param fallbacks defines the current fallback list.
  113389. * @param currentRank defines the current fallback rank.
  113390. * @returns the new fallback rank.
  113391. */
  113392. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113393. /**
  113394. * Add the required uniforms to the current list.
  113395. * @param uniforms defines the current uniform list.
  113396. */
  113397. static AddUniforms(uniforms: string[]): void;
  113398. /**
  113399. * Add the required samplers to the current list.
  113400. * @param samplers defines the current sampler list.
  113401. */
  113402. static AddSamplers(samplers: string[]): void;
  113403. /**
  113404. * Add the required uniforms to the current buffer.
  113405. * @param uniformBuffer defines the current uniform buffer.
  113406. */
  113407. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113408. /**
  113409. * Makes a duplicate of the current configuration into another one.
  113410. * @param clearCoatConfiguration define the config where to copy the info
  113411. */
  113412. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113413. /**
  113414. * Serializes this clear coat configuration.
  113415. * @returns - An object with the serialized config.
  113416. */
  113417. serialize(): any;
  113418. /**
  113419. * Parses a anisotropy Configuration from a serialized object.
  113420. * @param source - Serialized object.
  113421. * @param scene Defines the scene we are parsing for
  113422. * @param rootUrl Defines the rootUrl to load from
  113423. */
  113424. parse(source: any, scene: Scene, rootUrl: string): void;
  113425. }
  113426. }
  113427. declare module BABYLON {
  113428. /**
  113429. * @hidden
  113430. */
  113431. export interface IMaterialAnisotropicDefines {
  113432. ANISOTROPIC: boolean;
  113433. ANISOTROPIC_TEXTURE: boolean;
  113434. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113435. MAINUV1: boolean;
  113436. _areTexturesDirty: boolean;
  113437. _needUVs: boolean;
  113438. }
  113439. /**
  113440. * Define the code related to the anisotropic parameters of the pbr material.
  113441. */
  113442. export class PBRAnisotropicConfiguration {
  113443. private _isEnabled;
  113444. /**
  113445. * Defines if the anisotropy is enabled in the material.
  113446. */
  113447. isEnabled: boolean;
  113448. /**
  113449. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113450. */
  113451. intensity: number;
  113452. /**
  113453. * Defines if the effect is along the tangents, bitangents or in between.
  113454. * By default, the effect is "strectching" the highlights along the tangents.
  113455. */
  113456. direction: Vector2;
  113457. private _texture;
  113458. /**
  113459. * Stores the anisotropy values in a texture.
  113460. * rg is direction (like normal from -1 to 1)
  113461. * b is a intensity
  113462. */
  113463. texture: Nullable<BaseTexture>;
  113464. /** @hidden */
  113465. private _internalMarkAllSubMeshesAsTexturesDirty;
  113466. /** @hidden */
  113467. _markAllSubMeshesAsTexturesDirty(): void;
  113468. /**
  113469. * Instantiate a new istance of anisotropy configuration.
  113470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113471. */
  113472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113473. /**
  113474. * Specifies that the submesh is ready to be used.
  113475. * @param defines the list of "defines" to update.
  113476. * @param scene defines the scene the material belongs to.
  113477. * @returns - boolean indicating that the submesh is ready or not.
  113478. */
  113479. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113480. /**
  113481. * Checks to see if a texture is used in the material.
  113482. * @param defines the list of "defines" to update.
  113483. * @param mesh the mesh we are preparing the defines for.
  113484. * @param scene defines the scene the material belongs to.
  113485. */
  113486. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113487. /**
  113488. * Binds the material data.
  113489. * @param uniformBuffer defines the Uniform buffer to fill in.
  113490. * @param scene defines the scene the material belongs to.
  113491. * @param isFrozen defines wether the material is frozen or not.
  113492. */
  113493. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113494. /**
  113495. * Checks to see if a texture is used in the material.
  113496. * @param texture - Base texture to use.
  113497. * @returns - Boolean specifying if a texture is used in the material.
  113498. */
  113499. hasTexture(texture: BaseTexture): boolean;
  113500. /**
  113501. * Returns an array of the actively used textures.
  113502. * @param activeTextures Array of BaseTextures
  113503. */
  113504. getActiveTextures(activeTextures: BaseTexture[]): void;
  113505. /**
  113506. * Returns the animatable textures.
  113507. * @param animatables Array of animatable textures.
  113508. */
  113509. getAnimatables(animatables: IAnimatable[]): void;
  113510. /**
  113511. * Disposes the resources of the material.
  113512. * @param forceDisposeTextures - Forces the disposal of all textures.
  113513. */
  113514. dispose(forceDisposeTextures?: boolean): void;
  113515. /**
  113516. * Get the current class name of the texture useful for serialization or dynamic coding.
  113517. * @returns "PBRAnisotropicConfiguration"
  113518. */
  113519. getClassName(): string;
  113520. /**
  113521. * Add fallbacks to the effect fallbacks list.
  113522. * @param defines defines the Base texture to use.
  113523. * @param fallbacks defines the current fallback list.
  113524. * @param currentRank defines the current fallback rank.
  113525. * @returns the new fallback rank.
  113526. */
  113527. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113528. /**
  113529. * Add the required uniforms to the current list.
  113530. * @param uniforms defines the current uniform list.
  113531. */
  113532. static AddUniforms(uniforms: string[]): void;
  113533. /**
  113534. * Add the required uniforms to the current buffer.
  113535. * @param uniformBuffer defines the current uniform buffer.
  113536. */
  113537. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113538. /**
  113539. * Add the required samplers to the current list.
  113540. * @param samplers defines the current sampler list.
  113541. */
  113542. static AddSamplers(samplers: string[]): void;
  113543. /**
  113544. * Makes a duplicate of the current configuration into another one.
  113545. * @param anisotropicConfiguration define the config where to copy the info
  113546. */
  113547. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113548. /**
  113549. * Serializes this anisotropy configuration.
  113550. * @returns - An object with the serialized config.
  113551. */
  113552. serialize(): any;
  113553. /**
  113554. * Parses a anisotropy Configuration from a serialized object.
  113555. * @param source - Serialized object.
  113556. * @param scene Defines the scene we are parsing for
  113557. * @param rootUrl Defines the rootUrl to load from
  113558. */
  113559. parse(source: any, scene: Scene, rootUrl: string): void;
  113560. }
  113561. }
  113562. declare module BABYLON {
  113563. /**
  113564. * @hidden
  113565. */
  113566. export interface IMaterialBRDFDefines {
  113567. BRDF_V_HEIGHT_CORRELATED: boolean;
  113568. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113569. SPHERICAL_HARMONICS: boolean;
  113570. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113571. /** @hidden */
  113572. _areMiscDirty: boolean;
  113573. }
  113574. /**
  113575. * Define the code related to the BRDF parameters of the pbr material.
  113576. */
  113577. export class PBRBRDFConfiguration {
  113578. /**
  113579. * Default value used for the energy conservation.
  113580. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113581. */
  113582. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113583. /**
  113584. * Default value used for the Smith Visibility Height Correlated mode.
  113585. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113586. */
  113587. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113588. /**
  113589. * Default value used for the IBL diffuse part.
  113590. * This can help switching back to the polynomials mode globally which is a tiny bit
  113591. * less GPU intensive at the drawback of a lower quality.
  113592. */
  113593. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113594. /**
  113595. * Default value used for activating energy conservation for the specular workflow.
  113596. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113597. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113598. */
  113599. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113600. private _useEnergyConservation;
  113601. /**
  113602. * Defines if the material uses energy conservation.
  113603. */
  113604. useEnergyConservation: boolean;
  113605. private _useSmithVisibilityHeightCorrelated;
  113606. /**
  113607. * LEGACY Mode set to false
  113608. * Defines if the material uses height smith correlated visibility term.
  113609. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113610. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113611. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113612. * Not relying on height correlated will also disable energy conservation.
  113613. */
  113614. useSmithVisibilityHeightCorrelated: boolean;
  113615. private _useSphericalHarmonics;
  113616. /**
  113617. * LEGACY Mode set to false
  113618. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113619. * diffuse part of the IBL.
  113620. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113621. * to the ground truth.
  113622. */
  113623. useSphericalHarmonics: boolean;
  113624. private _useSpecularGlossinessInputEnergyConservation;
  113625. /**
  113626. * Defines if the material uses energy conservation, when the specular workflow is active.
  113627. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113628. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113629. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113630. */
  113631. useSpecularGlossinessInputEnergyConservation: boolean;
  113632. /** @hidden */
  113633. private _internalMarkAllSubMeshesAsMiscDirty;
  113634. /** @hidden */
  113635. _markAllSubMeshesAsMiscDirty(): void;
  113636. /**
  113637. * Instantiate a new istance of clear coat configuration.
  113638. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113639. */
  113640. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113641. /**
  113642. * Checks to see if a texture is used in the material.
  113643. * @param defines the list of "defines" to update.
  113644. */
  113645. prepareDefines(defines: IMaterialBRDFDefines): void;
  113646. /**
  113647. * Get the current class name of the texture useful for serialization or dynamic coding.
  113648. * @returns "PBRClearCoatConfiguration"
  113649. */
  113650. getClassName(): string;
  113651. /**
  113652. * Makes a duplicate of the current configuration into another one.
  113653. * @param brdfConfiguration define the config where to copy the info
  113654. */
  113655. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113656. /**
  113657. * Serializes this BRDF configuration.
  113658. * @returns - An object with the serialized config.
  113659. */
  113660. serialize(): any;
  113661. /**
  113662. * Parses a anisotropy Configuration from a serialized object.
  113663. * @param source - Serialized object.
  113664. * @param scene Defines the scene we are parsing for
  113665. * @param rootUrl Defines the rootUrl to load from
  113666. */
  113667. parse(source: any, scene: Scene, rootUrl: string): void;
  113668. }
  113669. }
  113670. declare module BABYLON {
  113671. /**
  113672. * @hidden
  113673. */
  113674. export interface IMaterialSheenDefines {
  113675. SHEEN: boolean;
  113676. SHEEN_TEXTURE: boolean;
  113677. SHEEN_TEXTUREDIRECTUV: number;
  113678. SHEEN_LINKWITHALBEDO: boolean;
  113679. /** @hidden */
  113680. _areTexturesDirty: boolean;
  113681. }
  113682. /**
  113683. * Define the code related to the Sheen parameters of the pbr material.
  113684. */
  113685. export class PBRSheenConfiguration {
  113686. private _isEnabled;
  113687. /**
  113688. * Defines if the material uses sheen.
  113689. */
  113690. isEnabled: boolean;
  113691. private _linkSheenWithAlbedo;
  113692. /**
  113693. * Defines if the sheen is linked to the sheen color.
  113694. */
  113695. linkSheenWithAlbedo: boolean;
  113696. /**
  113697. * Defines the sheen intensity.
  113698. */
  113699. intensity: number;
  113700. /**
  113701. * Defines the sheen color.
  113702. */
  113703. color: Color3;
  113704. private _texture;
  113705. /**
  113706. * Stores the sheen tint values in a texture.
  113707. * rgb is tint
  113708. * a is a intensity
  113709. */
  113710. texture: Nullable<BaseTexture>;
  113711. /** @hidden */
  113712. private _internalMarkAllSubMeshesAsTexturesDirty;
  113713. /** @hidden */
  113714. _markAllSubMeshesAsTexturesDirty(): void;
  113715. /**
  113716. * Instantiate a new istance of clear coat configuration.
  113717. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113718. */
  113719. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113720. /**
  113721. * Specifies that the submesh is ready to be used.
  113722. * @param defines the list of "defines" to update.
  113723. * @param scene defines the scene the material belongs to.
  113724. * @returns - boolean indicating that the submesh is ready or not.
  113725. */
  113726. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113727. /**
  113728. * Checks to see if a texture is used in the material.
  113729. * @param defines the list of "defines" to update.
  113730. * @param scene defines the scene the material belongs to.
  113731. */
  113732. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113733. /**
  113734. * Binds the material data.
  113735. * @param uniformBuffer defines the Uniform buffer to fill in.
  113736. * @param scene defines the scene the material belongs to.
  113737. * @param isFrozen defines wether the material is frozen or not.
  113738. */
  113739. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113740. /**
  113741. * Checks to see if a texture is used in the material.
  113742. * @param texture - Base texture to use.
  113743. * @returns - Boolean specifying if a texture is used in the material.
  113744. */
  113745. hasTexture(texture: BaseTexture): boolean;
  113746. /**
  113747. * Returns an array of the actively used textures.
  113748. * @param activeTextures Array of BaseTextures
  113749. */
  113750. getActiveTextures(activeTextures: BaseTexture[]): void;
  113751. /**
  113752. * Returns the animatable textures.
  113753. * @param animatables Array of animatable textures.
  113754. */
  113755. getAnimatables(animatables: IAnimatable[]): void;
  113756. /**
  113757. * Disposes the resources of the material.
  113758. * @param forceDisposeTextures - Forces the disposal of all textures.
  113759. */
  113760. dispose(forceDisposeTextures?: boolean): void;
  113761. /**
  113762. * Get the current class name of the texture useful for serialization or dynamic coding.
  113763. * @returns "PBRSheenConfiguration"
  113764. */
  113765. getClassName(): string;
  113766. /**
  113767. * Add fallbacks to the effect fallbacks list.
  113768. * @param defines defines the Base texture to use.
  113769. * @param fallbacks defines the current fallback list.
  113770. * @param currentRank defines the current fallback rank.
  113771. * @returns the new fallback rank.
  113772. */
  113773. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113774. /**
  113775. * Add the required uniforms to the current list.
  113776. * @param uniforms defines the current uniform list.
  113777. */
  113778. static AddUniforms(uniforms: string[]): void;
  113779. /**
  113780. * Add the required uniforms to the current buffer.
  113781. * @param uniformBuffer defines the current uniform buffer.
  113782. */
  113783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113784. /**
  113785. * Add the required samplers to the current list.
  113786. * @param samplers defines the current sampler list.
  113787. */
  113788. static AddSamplers(samplers: string[]): void;
  113789. /**
  113790. * Makes a duplicate of the current configuration into another one.
  113791. * @param sheenConfiguration define the config where to copy the info
  113792. */
  113793. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113794. /**
  113795. * Serializes this BRDF configuration.
  113796. * @returns - An object with the serialized config.
  113797. */
  113798. serialize(): any;
  113799. /**
  113800. * Parses a anisotropy Configuration from a serialized object.
  113801. * @param source - Serialized object.
  113802. * @param scene Defines the scene we are parsing for
  113803. * @param rootUrl Defines the rootUrl to load from
  113804. */
  113805. parse(source: any, scene: Scene, rootUrl: string): void;
  113806. }
  113807. }
  113808. declare module BABYLON {
  113809. /**
  113810. * @hidden
  113811. */
  113812. export interface IMaterialSubSurfaceDefines {
  113813. SUBSURFACE: boolean;
  113814. SS_REFRACTION: boolean;
  113815. SS_TRANSLUCENCY: boolean;
  113816. SS_SCATERRING: boolean;
  113817. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113818. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113819. SS_REFRACTIONMAP_3D: boolean;
  113820. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113821. SS_LODINREFRACTIONALPHA: boolean;
  113822. SS_GAMMAREFRACTION: boolean;
  113823. SS_RGBDREFRACTION: boolean;
  113824. SS_LINEARSPECULARREFRACTION: boolean;
  113825. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113826. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113827. /** @hidden */
  113828. _areTexturesDirty: boolean;
  113829. }
  113830. /**
  113831. * Define the code related to the sub surface parameters of the pbr material.
  113832. */
  113833. export class PBRSubSurfaceConfiguration {
  113834. private _isRefractionEnabled;
  113835. /**
  113836. * Defines if the refraction is enabled in the material.
  113837. */
  113838. isRefractionEnabled: boolean;
  113839. private _isTranslucencyEnabled;
  113840. /**
  113841. * Defines if the translucency is enabled in the material.
  113842. */
  113843. isTranslucencyEnabled: boolean;
  113844. private _isScatteringEnabled;
  113845. /**
  113846. * Defines the refraction intensity of the material.
  113847. * The refraction when enabled replaces the Diffuse part of the material.
  113848. * The intensity helps transitionning between diffuse and refraction.
  113849. */
  113850. refractionIntensity: number;
  113851. /**
  113852. * Defines the translucency intensity of the material.
  113853. * When translucency has been enabled, this defines how much of the "translucency"
  113854. * is addded to the diffuse part of the material.
  113855. */
  113856. translucencyIntensity: number;
  113857. /**
  113858. * Defines the scattering intensity of the material.
  113859. * When scattering has been enabled, this defines how much of the "scattered light"
  113860. * is addded to the diffuse part of the material.
  113861. */
  113862. scatteringIntensity: number;
  113863. private _thicknessTexture;
  113864. /**
  113865. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113866. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113867. * 0 would mean minimumThickness
  113868. * 1 would mean maximumThickness
  113869. * The other channels might be use as a mask to vary the different effects intensity.
  113870. */
  113871. thicknessTexture: Nullable<BaseTexture>;
  113872. private _refractionTexture;
  113873. /**
  113874. * Defines the texture to use for refraction.
  113875. */
  113876. refractionTexture: Nullable<BaseTexture>;
  113877. private _indexOfRefraction;
  113878. /**
  113879. * Defines the index of refraction used in the material.
  113880. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113881. */
  113882. indexOfRefraction: number;
  113883. private _invertRefractionY;
  113884. /**
  113885. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113886. */
  113887. invertRefractionY: boolean;
  113888. private _linkRefractionWithTransparency;
  113889. /**
  113890. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113891. * Materials half opaque for instance using refraction could benefit from this control.
  113892. */
  113893. linkRefractionWithTransparency: boolean;
  113894. /**
  113895. * Defines the minimum thickness stored in the thickness map.
  113896. * If no thickness map is defined, this value will be used to simulate thickness.
  113897. */
  113898. minimumThickness: number;
  113899. /**
  113900. * Defines the maximum thickness stored in the thickness map.
  113901. */
  113902. maximumThickness: number;
  113903. /**
  113904. * Defines the volume tint of the material.
  113905. * This is used for both translucency and scattering.
  113906. */
  113907. tintColor: Color3;
  113908. /**
  113909. * Defines the distance at which the tint color should be found in the media.
  113910. * This is used for refraction only.
  113911. */
  113912. tintColorAtDistance: number;
  113913. /**
  113914. * Defines how far each channel transmit through the media.
  113915. * It is defined as a color to simplify it selection.
  113916. */
  113917. diffusionDistance: Color3;
  113918. private _useMaskFromThicknessTexture;
  113919. /**
  113920. * Stores the intensity of the different subsurface effects in the thickness texture.
  113921. * * the green channel is the translucency intensity.
  113922. * * the blue channel is the scattering intensity.
  113923. * * the alpha channel is the refraction intensity.
  113924. */
  113925. useMaskFromThicknessTexture: boolean;
  113926. /** @hidden */
  113927. private _internalMarkAllSubMeshesAsTexturesDirty;
  113928. /** @hidden */
  113929. _markAllSubMeshesAsTexturesDirty(): void;
  113930. /**
  113931. * Instantiate a new istance of sub surface configuration.
  113932. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113933. */
  113934. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113935. /**
  113936. * Gets wehter the submesh is ready to be used or not.
  113937. * @param defines the list of "defines" to update.
  113938. * @param scene defines the scene the material belongs to.
  113939. * @returns - boolean indicating that the submesh is ready or not.
  113940. */
  113941. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113942. /**
  113943. * Checks to see if a texture is used in the material.
  113944. * @param defines the list of "defines" to update.
  113945. * @param scene defines the scene to the material belongs to.
  113946. */
  113947. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113948. /**
  113949. * Binds the material data.
  113950. * @param uniformBuffer defines the Uniform buffer to fill in.
  113951. * @param scene defines the scene the material belongs to.
  113952. * @param engine defines the engine the material belongs to.
  113953. * @param isFrozen defines wether the material is frozen or not.
  113954. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113955. */
  113956. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113957. /**
  113958. * Unbinds the material from the mesh.
  113959. * @param activeEffect defines the effect that should be unbound from.
  113960. * @returns true if unbound, otherwise false
  113961. */
  113962. unbind(activeEffect: Effect): boolean;
  113963. /**
  113964. * Returns the texture used for refraction or null if none is used.
  113965. * @param scene defines the scene the material belongs to.
  113966. * @returns - Refraction texture if present. If no refraction texture and refraction
  113967. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113968. */
  113969. private _getRefractionTexture;
  113970. /**
  113971. * Returns true if alpha blending should be disabled.
  113972. */
  113973. readonly disableAlphaBlending: boolean;
  113974. /**
  113975. * Fills the list of render target textures.
  113976. * @param renderTargets the list of render targets to update
  113977. */
  113978. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113979. /**
  113980. * Checks to see if a texture is used in the material.
  113981. * @param texture - Base texture to use.
  113982. * @returns - Boolean specifying if a texture is used in the material.
  113983. */
  113984. hasTexture(texture: BaseTexture): boolean;
  113985. /**
  113986. * Gets a boolean indicating that current material needs to register RTT
  113987. * @returns true if this uses a render target otherwise false.
  113988. */
  113989. hasRenderTargetTextures(): boolean;
  113990. /**
  113991. * Returns an array of the actively used textures.
  113992. * @param activeTextures Array of BaseTextures
  113993. */
  113994. getActiveTextures(activeTextures: BaseTexture[]): void;
  113995. /**
  113996. * Returns the animatable textures.
  113997. * @param animatables Array of animatable textures.
  113998. */
  113999. getAnimatables(animatables: IAnimatable[]): void;
  114000. /**
  114001. * Disposes the resources of the material.
  114002. * @param forceDisposeTextures - Forces the disposal of all textures.
  114003. */
  114004. dispose(forceDisposeTextures?: boolean): void;
  114005. /**
  114006. * Get the current class name of the texture useful for serialization or dynamic coding.
  114007. * @returns "PBRSubSurfaceConfiguration"
  114008. */
  114009. getClassName(): string;
  114010. /**
  114011. * Add fallbacks to the effect fallbacks list.
  114012. * @param defines defines the Base texture to use.
  114013. * @param fallbacks defines the current fallback list.
  114014. * @param currentRank defines the current fallback rank.
  114015. * @returns the new fallback rank.
  114016. */
  114017. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114018. /**
  114019. * Add the required uniforms to the current list.
  114020. * @param uniforms defines the current uniform list.
  114021. */
  114022. static AddUniforms(uniforms: string[]): void;
  114023. /**
  114024. * Add the required samplers to the current list.
  114025. * @param samplers defines the current sampler list.
  114026. */
  114027. static AddSamplers(samplers: string[]): void;
  114028. /**
  114029. * Add the required uniforms to the current buffer.
  114030. * @param uniformBuffer defines the current uniform buffer.
  114031. */
  114032. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114033. /**
  114034. * Makes a duplicate of the current configuration into another one.
  114035. * @param configuration define the config where to copy the info
  114036. */
  114037. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114038. /**
  114039. * Serializes this Sub Surface configuration.
  114040. * @returns - An object with the serialized config.
  114041. */
  114042. serialize(): any;
  114043. /**
  114044. * Parses a anisotropy Configuration from a serialized object.
  114045. * @param source - Serialized object.
  114046. * @param scene Defines the scene we are parsing for
  114047. * @param rootUrl Defines the rootUrl to load from
  114048. */
  114049. parse(source: any, scene: Scene, rootUrl: string): void;
  114050. }
  114051. }
  114052. declare module BABYLON {
  114053. /** @hidden */
  114054. export var pbrFragmentDeclaration: {
  114055. name: string;
  114056. shader: string;
  114057. };
  114058. }
  114059. declare module BABYLON {
  114060. /** @hidden */
  114061. export var pbrUboDeclaration: {
  114062. name: string;
  114063. shader: string;
  114064. };
  114065. }
  114066. declare module BABYLON {
  114067. /** @hidden */
  114068. export var pbrFragmentExtraDeclaration: {
  114069. name: string;
  114070. shader: string;
  114071. };
  114072. }
  114073. declare module BABYLON {
  114074. /** @hidden */
  114075. export var pbrFragmentSamplersDeclaration: {
  114076. name: string;
  114077. shader: string;
  114078. };
  114079. }
  114080. declare module BABYLON {
  114081. /** @hidden */
  114082. export var pbrHelperFunctions: {
  114083. name: string;
  114084. shader: string;
  114085. };
  114086. }
  114087. declare module BABYLON {
  114088. /** @hidden */
  114089. export var harmonicsFunctions: {
  114090. name: string;
  114091. shader: string;
  114092. };
  114093. }
  114094. declare module BABYLON {
  114095. /** @hidden */
  114096. export var pbrDirectLightingSetupFunctions: {
  114097. name: string;
  114098. shader: string;
  114099. };
  114100. }
  114101. declare module BABYLON {
  114102. /** @hidden */
  114103. export var pbrDirectLightingFalloffFunctions: {
  114104. name: string;
  114105. shader: string;
  114106. };
  114107. }
  114108. declare module BABYLON {
  114109. /** @hidden */
  114110. export var pbrBRDFFunctions: {
  114111. name: string;
  114112. shader: string;
  114113. };
  114114. }
  114115. declare module BABYLON {
  114116. /** @hidden */
  114117. export var pbrDirectLightingFunctions: {
  114118. name: string;
  114119. shader: string;
  114120. };
  114121. }
  114122. declare module BABYLON {
  114123. /** @hidden */
  114124. export var pbrIBLFunctions: {
  114125. name: string;
  114126. shader: string;
  114127. };
  114128. }
  114129. declare module BABYLON {
  114130. /** @hidden */
  114131. export var pbrDebug: {
  114132. name: string;
  114133. shader: string;
  114134. };
  114135. }
  114136. declare module BABYLON {
  114137. /** @hidden */
  114138. export var pbrPixelShader: {
  114139. name: string;
  114140. shader: string;
  114141. };
  114142. }
  114143. declare module BABYLON {
  114144. /** @hidden */
  114145. export var pbrVertexDeclaration: {
  114146. name: string;
  114147. shader: string;
  114148. };
  114149. }
  114150. declare module BABYLON {
  114151. /** @hidden */
  114152. export var pbrVertexShader: {
  114153. name: string;
  114154. shader: string;
  114155. };
  114156. }
  114157. declare module BABYLON {
  114158. /**
  114159. * Manages the defines for the PBR Material.
  114160. * @hidden
  114161. */
  114162. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114163. PBR: boolean;
  114164. MAINUV1: boolean;
  114165. MAINUV2: boolean;
  114166. UV1: boolean;
  114167. UV2: boolean;
  114168. ALBEDO: boolean;
  114169. ALBEDODIRECTUV: number;
  114170. VERTEXCOLOR: boolean;
  114171. AMBIENT: boolean;
  114172. AMBIENTDIRECTUV: number;
  114173. AMBIENTINGRAYSCALE: boolean;
  114174. OPACITY: boolean;
  114175. VERTEXALPHA: boolean;
  114176. OPACITYDIRECTUV: number;
  114177. OPACITYRGB: boolean;
  114178. ALPHATEST: boolean;
  114179. DEPTHPREPASS: boolean;
  114180. ALPHABLEND: boolean;
  114181. ALPHAFROMALBEDO: boolean;
  114182. ALPHATESTVALUE: string;
  114183. SPECULAROVERALPHA: boolean;
  114184. RADIANCEOVERALPHA: boolean;
  114185. ALPHAFRESNEL: boolean;
  114186. LINEARALPHAFRESNEL: boolean;
  114187. PREMULTIPLYALPHA: boolean;
  114188. EMISSIVE: boolean;
  114189. EMISSIVEDIRECTUV: number;
  114190. REFLECTIVITY: boolean;
  114191. REFLECTIVITYDIRECTUV: number;
  114192. SPECULARTERM: boolean;
  114193. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114194. MICROSURFACEAUTOMATIC: boolean;
  114195. LODBASEDMICROSFURACE: boolean;
  114196. MICROSURFACEMAP: boolean;
  114197. MICROSURFACEMAPDIRECTUV: number;
  114198. METALLICWORKFLOW: boolean;
  114199. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114200. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114201. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114202. AOSTOREINMETALMAPRED: boolean;
  114203. ENVIRONMENTBRDF: boolean;
  114204. ENVIRONMENTBRDF_RGBD: boolean;
  114205. NORMAL: boolean;
  114206. TANGENT: boolean;
  114207. BUMP: boolean;
  114208. BUMPDIRECTUV: number;
  114209. OBJECTSPACE_NORMALMAP: boolean;
  114210. PARALLAX: boolean;
  114211. PARALLAXOCCLUSION: boolean;
  114212. NORMALXYSCALE: boolean;
  114213. LIGHTMAP: boolean;
  114214. LIGHTMAPDIRECTUV: number;
  114215. USELIGHTMAPASSHADOWMAP: boolean;
  114216. GAMMALIGHTMAP: boolean;
  114217. RGBDLIGHTMAP: boolean;
  114218. REFLECTION: boolean;
  114219. REFLECTIONMAP_3D: boolean;
  114220. REFLECTIONMAP_SPHERICAL: boolean;
  114221. REFLECTIONMAP_PLANAR: boolean;
  114222. REFLECTIONMAP_CUBIC: boolean;
  114223. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114224. REFLECTIONMAP_PROJECTION: boolean;
  114225. REFLECTIONMAP_SKYBOX: boolean;
  114226. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114227. REFLECTIONMAP_EXPLICIT: boolean;
  114228. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114229. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114230. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114231. INVERTCUBICMAP: boolean;
  114232. USESPHERICALFROMREFLECTIONMAP: boolean;
  114233. USEIRRADIANCEMAP: boolean;
  114234. SPHERICAL_HARMONICS: boolean;
  114235. USESPHERICALINVERTEX: boolean;
  114236. REFLECTIONMAP_OPPOSITEZ: boolean;
  114237. LODINREFLECTIONALPHA: boolean;
  114238. GAMMAREFLECTION: boolean;
  114239. RGBDREFLECTION: boolean;
  114240. LINEARSPECULARREFLECTION: boolean;
  114241. RADIANCEOCCLUSION: boolean;
  114242. HORIZONOCCLUSION: boolean;
  114243. INSTANCES: boolean;
  114244. NUM_BONE_INFLUENCERS: number;
  114245. BonesPerMesh: number;
  114246. BONETEXTURE: boolean;
  114247. NONUNIFORMSCALING: boolean;
  114248. MORPHTARGETS: boolean;
  114249. MORPHTARGETS_NORMAL: boolean;
  114250. MORPHTARGETS_TANGENT: boolean;
  114251. MORPHTARGETS_UV: boolean;
  114252. NUM_MORPH_INFLUENCERS: number;
  114253. IMAGEPROCESSING: boolean;
  114254. VIGNETTE: boolean;
  114255. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114256. VIGNETTEBLENDMODEOPAQUE: boolean;
  114257. TONEMAPPING: boolean;
  114258. TONEMAPPING_ACES: boolean;
  114259. CONTRAST: boolean;
  114260. COLORCURVES: boolean;
  114261. COLORGRADING: boolean;
  114262. COLORGRADING3D: boolean;
  114263. SAMPLER3DGREENDEPTH: boolean;
  114264. SAMPLER3DBGRMAP: boolean;
  114265. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114266. EXPOSURE: boolean;
  114267. MULTIVIEW: boolean;
  114268. USEPHYSICALLIGHTFALLOFF: boolean;
  114269. USEGLTFLIGHTFALLOFF: boolean;
  114270. TWOSIDEDLIGHTING: boolean;
  114271. SHADOWFLOAT: boolean;
  114272. CLIPPLANE: boolean;
  114273. CLIPPLANE2: boolean;
  114274. CLIPPLANE3: boolean;
  114275. CLIPPLANE4: boolean;
  114276. POINTSIZE: boolean;
  114277. FOG: boolean;
  114278. LOGARITHMICDEPTH: boolean;
  114279. FORCENORMALFORWARD: boolean;
  114280. SPECULARAA: boolean;
  114281. CLEARCOAT: boolean;
  114282. CLEARCOAT_DEFAULTIOR: boolean;
  114283. CLEARCOAT_TEXTURE: boolean;
  114284. CLEARCOAT_TEXTUREDIRECTUV: number;
  114285. CLEARCOAT_BUMP: boolean;
  114286. CLEARCOAT_BUMPDIRECTUV: number;
  114287. CLEARCOAT_TINT: boolean;
  114288. CLEARCOAT_TINT_TEXTURE: boolean;
  114289. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114290. ANISOTROPIC: boolean;
  114291. ANISOTROPIC_TEXTURE: boolean;
  114292. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114293. BRDF_V_HEIGHT_CORRELATED: boolean;
  114294. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114295. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114296. SHEEN: boolean;
  114297. SHEEN_TEXTURE: boolean;
  114298. SHEEN_TEXTUREDIRECTUV: number;
  114299. SHEEN_LINKWITHALBEDO: boolean;
  114300. SUBSURFACE: boolean;
  114301. SS_REFRACTION: boolean;
  114302. SS_TRANSLUCENCY: boolean;
  114303. SS_SCATERRING: boolean;
  114304. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114305. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114306. SS_REFRACTIONMAP_3D: boolean;
  114307. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114308. SS_LODINREFRACTIONALPHA: boolean;
  114309. SS_GAMMAREFRACTION: boolean;
  114310. SS_RGBDREFRACTION: boolean;
  114311. SS_LINEARSPECULARREFRACTION: boolean;
  114312. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114313. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114314. UNLIT: boolean;
  114315. DEBUGMODE: number;
  114316. /**
  114317. * Initializes the PBR Material defines.
  114318. */
  114319. constructor();
  114320. /**
  114321. * Resets the PBR Material defines.
  114322. */
  114323. reset(): void;
  114324. }
  114325. /**
  114326. * The Physically based material base class of BJS.
  114327. *
  114328. * This offers the main features of a standard PBR material.
  114329. * For more information, please refer to the documentation :
  114330. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114331. */
  114332. export abstract class PBRBaseMaterial extends PushMaterial {
  114333. /**
  114334. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114335. */
  114336. static readonly PBRMATERIAL_OPAQUE: number;
  114337. /**
  114338. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114339. */
  114340. static readonly PBRMATERIAL_ALPHATEST: number;
  114341. /**
  114342. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114343. */
  114344. static readonly PBRMATERIAL_ALPHABLEND: number;
  114345. /**
  114346. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114347. * They are also discarded below the alpha cutoff threshold to improve performances.
  114348. */
  114349. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114350. /**
  114351. * Defines the default value of how much AO map is occluding the analytical lights
  114352. * (point spot...).
  114353. */
  114354. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114355. /**
  114356. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114357. */
  114358. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114359. /**
  114360. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114361. * to enhance interoperability with other engines.
  114362. */
  114363. static readonly LIGHTFALLOFF_GLTF: number;
  114364. /**
  114365. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114366. * to enhance interoperability with other materials.
  114367. */
  114368. static readonly LIGHTFALLOFF_STANDARD: number;
  114369. /**
  114370. * Intensity of the direct lights e.g. the four lights available in your scene.
  114371. * This impacts both the direct diffuse and specular highlights.
  114372. */
  114373. protected _directIntensity: number;
  114374. /**
  114375. * Intensity of the emissive part of the material.
  114376. * This helps controlling the emissive effect without modifying the emissive color.
  114377. */
  114378. protected _emissiveIntensity: number;
  114379. /**
  114380. * Intensity of the environment e.g. how much the environment will light the object
  114381. * either through harmonics for rough material or through the refelction for shiny ones.
  114382. */
  114383. protected _environmentIntensity: number;
  114384. /**
  114385. * This is a special control allowing the reduction of the specular highlights coming from the
  114386. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114387. */
  114388. protected _specularIntensity: number;
  114389. /**
  114390. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114391. */
  114392. private _lightingInfos;
  114393. /**
  114394. * Debug Control allowing disabling the bump map on this material.
  114395. */
  114396. protected _disableBumpMap: boolean;
  114397. /**
  114398. * AKA Diffuse Texture in standard nomenclature.
  114399. */
  114400. protected _albedoTexture: Nullable<BaseTexture>;
  114401. /**
  114402. * AKA Occlusion Texture in other nomenclature.
  114403. */
  114404. protected _ambientTexture: Nullable<BaseTexture>;
  114405. /**
  114406. * AKA Occlusion Texture Intensity in other nomenclature.
  114407. */
  114408. protected _ambientTextureStrength: number;
  114409. /**
  114410. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114411. * 1 means it completely occludes it
  114412. * 0 mean it has no impact
  114413. */
  114414. protected _ambientTextureImpactOnAnalyticalLights: number;
  114415. /**
  114416. * Stores the alpha values in a texture.
  114417. */
  114418. protected _opacityTexture: Nullable<BaseTexture>;
  114419. /**
  114420. * Stores the reflection values in a texture.
  114421. */
  114422. protected _reflectionTexture: Nullable<BaseTexture>;
  114423. /**
  114424. * Stores the emissive values in a texture.
  114425. */
  114426. protected _emissiveTexture: Nullable<BaseTexture>;
  114427. /**
  114428. * AKA Specular texture in other nomenclature.
  114429. */
  114430. protected _reflectivityTexture: Nullable<BaseTexture>;
  114431. /**
  114432. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114433. */
  114434. protected _metallicTexture: Nullable<BaseTexture>;
  114435. /**
  114436. * Specifies the metallic scalar of the metallic/roughness workflow.
  114437. * Can also be used to scale the metalness values of the metallic texture.
  114438. */
  114439. protected _metallic: Nullable<number>;
  114440. /**
  114441. * Specifies the roughness scalar of the metallic/roughness workflow.
  114442. * Can also be used to scale the roughness values of the metallic texture.
  114443. */
  114444. protected _roughness: Nullable<number>;
  114445. /**
  114446. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114447. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114448. */
  114449. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114450. /**
  114451. * Stores surface normal data used to displace a mesh in a texture.
  114452. */
  114453. protected _bumpTexture: Nullable<BaseTexture>;
  114454. /**
  114455. * Stores the pre-calculated light information of a mesh in a texture.
  114456. */
  114457. protected _lightmapTexture: Nullable<BaseTexture>;
  114458. /**
  114459. * The color of a material in ambient lighting.
  114460. */
  114461. protected _ambientColor: Color3;
  114462. /**
  114463. * AKA Diffuse Color in other nomenclature.
  114464. */
  114465. protected _albedoColor: Color3;
  114466. /**
  114467. * AKA Specular Color in other nomenclature.
  114468. */
  114469. protected _reflectivityColor: Color3;
  114470. /**
  114471. * The color applied when light is reflected from a material.
  114472. */
  114473. protected _reflectionColor: Color3;
  114474. /**
  114475. * The color applied when light is emitted from a material.
  114476. */
  114477. protected _emissiveColor: Color3;
  114478. /**
  114479. * AKA Glossiness in other nomenclature.
  114480. */
  114481. protected _microSurface: number;
  114482. /**
  114483. * Specifies that the material will use the light map as a show map.
  114484. */
  114485. protected _useLightmapAsShadowmap: boolean;
  114486. /**
  114487. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114488. * makes the reflect vector face the model (under horizon).
  114489. */
  114490. protected _useHorizonOcclusion: boolean;
  114491. /**
  114492. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114493. * too much the area relying on ambient texture to define their ambient occlusion.
  114494. */
  114495. protected _useRadianceOcclusion: boolean;
  114496. /**
  114497. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114498. */
  114499. protected _useAlphaFromAlbedoTexture: boolean;
  114500. /**
  114501. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114502. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114503. */
  114504. protected _useSpecularOverAlpha: boolean;
  114505. /**
  114506. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114507. */
  114508. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114509. /**
  114510. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114511. */
  114512. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114513. /**
  114514. * Specifies if the metallic texture contains the roughness information in its green channel.
  114515. */
  114516. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114517. /**
  114518. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114519. */
  114520. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114521. /**
  114522. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114523. */
  114524. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114525. /**
  114526. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114527. */
  114528. protected _useAmbientInGrayScale: boolean;
  114529. /**
  114530. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114531. * The material will try to infer what glossiness each pixel should be.
  114532. */
  114533. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114534. /**
  114535. * Defines the falloff type used in this material.
  114536. * It by default is Physical.
  114537. */
  114538. protected _lightFalloff: number;
  114539. /**
  114540. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114541. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114542. */
  114543. protected _useRadianceOverAlpha: boolean;
  114544. /**
  114545. * Allows using an object space normal map (instead of tangent space).
  114546. */
  114547. protected _useObjectSpaceNormalMap: boolean;
  114548. /**
  114549. * Allows using the bump map in parallax mode.
  114550. */
  114551. protected _useParallax: boolean;
  114552. /**
  114553. * Allows using the bump map in parallax occlusion mode.
  114554. */
  114555. protected _useParallaxOcclusion: boolean;
  114556. /**
  114557. * Controls the scale bias of the parallax mode.
  114558. */
  114559. protected _parallaxScaleBias: number;
  114560. /**
  114561. * If sets to true, disables all the lights affecting the material.
  114562. */
  114563. protected _disableLighting: boolean;
  114564. /**
  114565. * Number of Simultaneous lights allowed on the material.
  114566. */
  114567. protected _maxSimultaneousLights: number;
  114568. /**
  114569. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114570. */
  114571. protected _invertNormalMapX: boolean;
  114572. /**
  114573. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114574. */
  114575. protected _invertNormalMapY: boolean;
  114576. /**
  114577. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114578. */
  114579. protected _twoSidedLighting: boolean;
  114580. /**
  114581. * Defines the alpha limits in alpha test mode.
  114582. */
  114583. protected _alphaCutOff: number;
  114584. /**
  114585. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114586. */
  114587. protected _forceAlphaTest: boolean;
  114588. /**
  114589. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114590. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114591. */
  114592. protected _useAlphaFresnel: boolean;
  114593. /**
  114594. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114595. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114596. */
  114597. protected _useLinearAlphaFresnel: boolean;
  114598. /**
  114599. * The transparency mode of the material.
  114600. */
  114601. protected _transparencyMode: Nullable<number>;
  114602. /**
  114603. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114604. * from cos thetav and roughness:
  114605. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114606. */
  114607. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114608. /**
  114609. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114610. */
  114611. protected _forceIrradianceInFragment: boolean;
  114612. /**
  114613. * Force normal to face away from face.
  114614. */
  114615. protected _forceNormalForward: boolean;
  114616. /**
  114617. * Enables specular anti aliasing in the PBR shader.
  114618. * It will both interacts on the Geometry for analytical and IBL lighting.
  114619. * It also prefilter the roughness map based on the bump values.
  114620. */
  114621. protected _enableSpecularAntiAliasing: boolean;
  114622. /**
  114623. * Default configuration related to image processing available in the PBR Material.
  114624. */
  114625. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114626. /**
  114627. * Keep track of the image processing observer to allow dispose and replace.
  114628. */
  114629. private _imageProcessingObserver;
  114630. /**
  114631. * Attaches a new image processing configuration to the PBR Material.
  114632. * @param configuration
  114633. */
  114634. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114635. /**
  114636. * Stores the available render targets.
  114637. */
  114638. private _renderTargets;
  114639. /**
  114640. * Sets the global ambient color for the material used in lighting calculations.
  114641. */
  114642. private _globalAmbientColor;
  114643. /**
  114644. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114645. */
  114646. private _useLogarithmicDepth;
  114647. /**
  114648. * If set to true, no lighting calculations will be applied.
  114649. */
  114650. private _unlit;
  114651. private _debugMode;
  114652. /**
  114653. * @hidden
  114654. * This is reserved for the inspector.
  114655. * Defines the material debug mode.
  114656. * It helps seeing only some components of the material while troubleshooting.
  114657. */
  114658. debugMode: number;
  114659. /**
  114660. * @hidden
  114661. * This is reserved for the inspector.
  114662. * Specify from where on screen the debug mode should start.
  114663. * The value goes from -1 (full screen) to 1 (not visible)
  114664. * It helps with side by side comparison against the final render
  114665. * This defaults to -1
  114666. */
  114667. private debugLimit;
  114668. /**
  114669. * @hidden
  114670. * This is reserved for the inspector.
  114671. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114672. * You can use the factor to better multiply the final value.
  114673. */
  114674. private debugFactor;
  114675. /**
  114676. * Defines the clear coat layer parameters for the material.
  114677. */
  114678. readonly clearCoat: PBRClearCoatConfiguration;
  114679. /**
  114680. * Defines the anisotropic parameters for the material.
  114681. */
  114682. readonly anisotropy: PBRAnisotropicConfiguration;
  114683. /**
  114684. * Defines the BRDF parameters for the material.
  114685. */
  114686. readonly brdf: PBRBRDFConfiguration;
  114687. /**
  114688. * Defines the Sheen parameters for the material.
  114689. */
  114690. readonly sheen: PBRSheenConfiguration;
  114691. /**
  114692. * Defines the SubSurface parameters for the material.
  114693. */
  114694. readonly subSurface: PBRSubSurfaceConfiguration;
  114695. /**
  114696. * Custom callback helping to override the default shader used in the material.
  114697. */
  114698. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114699. protected _rebuildInParallel: boolean;
  114700. /**
  114701. * Instantiates a new PBRMaterial instance.
  114702. *
  114703. * @param name The material name
  114704. * @param scene The scene the material will be use in.
  114705. */
  114706. constructor(name: string, scene: Scene);
  114707. /**
  114708. * Gets a boolean indicating that current material needs to register RTT
  114709. */
  114710. readonly hasRenderTargetTextures: boolean;
  114711. /**
  114712. * Gets the name of the material class.
  114713. */
  114714. getClassName(): string;
  114715. /**
  114716. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114717. */
  114718. /**
  114719. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114720. */
  114721. useLogarithmicDepth: boolean;
  114722. /**
  114723. * Gets the current transparency mode.
  114724. */
  114725. /**
  114726. * Sets the transparency mode of the material.
  114727. *
  114728. * | Value | Type | Description |
  114729. * | ----- | ----------------------------------- | ----------- |
  114730. * | 0 | OPAQUE | |
  114731. * | 1 | ALPHATEST | |
  114732. * | 2 | ALPHABLEND | |
  114733. * | 3 | ALPHATESTANDBLEND | |
  114734. *
  114735. */
  114736. transparencyMode: Nullable<number>;
  114737. /**
  114738. * Returns true if alpha blending should be disabled.
  114739. */
  114740. private readonly _disableAlphaBlending;
  114741. /**
  114742. * Specifies whether or not this material should be rendered in alpha blend mode.
  114743. */
  114744. needAlphaBlending(): boolean;
  114745. /**
  114746. * Specifies if the mesh will require alpha blending.
  114747. * @param mesh - BJS mesh.
  114748. */
  114749. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114750. /**
  114751. * Specifies whether or not this material should be rendered in alpha test mode.
  114752. */
  114753. needAlphaTesting(): boolean;
  114754. /**
  114755. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114756. */
  114757. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114758. /**
  114759. * Gets the texture used for the alpha test.
  114760. */
  114761. getAlphaTestTexture(): Nullable<BaseTexture>;
  114762. /**
  114763. * Specifies that the submesh is ready to be used.
  114764. * @param mesh - BJS mesh.
  114765. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114766. * @param useInstances - Specifies that instances should be used.
  114767. * @returns - boolean indicating that the submesh is ready or not.
  114768. */
  114769. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114770. /**
  114771. * Specifies if the material uses metallic roughness workflow.
  114772. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114773. */
  114774. isMetallicWorkflow(): boolean;
  114775. private _prepareEffect;
  114776. private _prepareDefines;
  114777. /**
  114778. * Force shader compilation
  114779. */
  114780. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114781. clipPlane: boolean;
  114782. }>): void;
  114783. /**
  114784. * Initializes the uniform buffer layout for the shader.
  114785. */
  114786. buildUniformLayout(): void;
  114787. /**
  114788. * Unbinds the material from the mesh
  114789. */
  114790. unbind(): void;
  114791. /**
  114792. * Binds the submesh data.
  114793. * @param world - The world matrix.
  114794. * @param mesh - The BJS mesh.
  114795. * @param subMesh - A submesh of the BJS mesh.
  114796. */
  114797. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114798. /**
  114799. * Returns the animatable textures.
  114800. * @returns - Array of animatable textures.
  114801. */
  114802. getAnimatables(): IAnimatable[];
  114803. /**
  114804. * Returns the texture used for reflections.
  114805. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114806. */
  114807. private _getReflectionTexture;
  114808. /**
  114809. * Returns an array of the actively used textures.
  114810. * @returns - Array of BaseTextures
  114811. */
  114812. getActiveTextures(): BaseTexture[];
  114813. /**
  114814. * Checks to see if a texture is used in the material.
  114815. * @param texture - Base texture to use.
  114816. * @returns - Boolean specifying if a texture is used in the material.
  114817. */
  114818. hasTexture(texture: BaseTexture): boolean;
  114819. /**
  114820. * Disposes the resources of the material.
  114821. * @param forceDisposeEffect - Forces the disposal of effects.
  114822. * @param forceDisposeTextures - Forces the disposal of all textures.
  114823. */
  114824. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114825. }
  114826. }
  114827. declare module BABYLON {
  114828. /**
  114829. * The Physically based material of BJS.
  114830. *
  114831. * This offers the main features of a standard PBR material.
  114832. * For more information, please refer to the documentation :
  114833. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114834. */
  114835. export class PBRMaterial extends PBRBaseMaterial {
  114836. /**
  114837. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114838. */
  114839. static readonly PBRMATERIAL_OPAQUE: number;
  114840. /**
  114841. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114842. */
  114843. static readonly PBRMATERIAL_ALPHATEST: number;
  114844. /**
  114845. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114846. */
  114847. static readonly PBRMATERIAL_ALPHABLEND: number;
  114848. /**
  114849. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114850. * They are also discarded below the alpha cutoff threshold to improve performances.
  114851. */
  114852. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114853. /**
  114854. * Defines the default value of how much AO map is occluding the analytical lights
  114855. * (point spot...).
  114856. */
  114857. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114858. /**
  114859. * Intensity of the direct lights e.g. the four lights available in your scene.
  114860. * This impacts both the direct diffuse and specular highlights.
  114861. */
  114862. directIntensity: number;
  114863. /**
  114864. * Intensity of the emissive part of the material.
  114865. * This helps controlling the emissive effect without modifying the emissive color.
  114866. */
  114867. emissiveIntensity: number;
  114868. /**
  114869. * Intensity of the environment e.g. how much the environment will light the object
  114870. * either through harmonics for rough material or through the refelction for shiny ones.
  114871. */
  114872. environmentIntensity: number;
  114873. /**
  114874. * This is a special control allowing the reduction of the specular highlights coming from the
  114875. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114876. */
  114877. specularIntensity: number;
  114878. /**
  114879. * Debug Control allowing disabling the bump map on this material.
  114880. */
  114881. disableBumpMap: boolean;
  114882. /**
  114883. * AKA Diffuse Texture in standard nomenclature.
  114884. */
  114885. albedoTexture: BaseTexture;
  114886. /**
  114887. * AKA Occlusion Texture in other nomenclature.
  114888. */
  114889. ambientTexture: BaseTexture;
  114890. /**
  114891. * AKA Occlusion Texture Intensity in other nomenclature.
  114892. */
  114893. ambientTextureStrength: number;
  114894. /**
  114895. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114896. * 1 means it completely occludes it
  114897. * 0 mean it has no impact
  114898. */
  114899. ambientTextureImpactOnAnalyticalLights: number;
  114900. /**
  114901. * Stores the alpha values in a texture.
  114902. */
  114903. opacityTexture: BaseTexture;
  114904. /**
  114905. * Stores the reflection values in a texture.
  114906. */
  114907. reflectionTexture: Nullable<BaseTexture>;
  114908. /**
  114909. * Stores the emissive values in a texture.
  114910. */
  114911. emissiveTexture: BaseTexture;
  114912. /**
  114913. * AKA Specular texture in other nomenclature.
  114914. */
  114915. reflectivityTexture: BaseTexture;
  114916. /**
  114917. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114918. */
  114919. metallicTexture: BaseTexture;
  114920. /**
  114921. * Specifies the metallic scalar of the metallic/roughness workflow.
  114922. * Can also be used to scale the metalness values of the metallic texture.
  114923. */
  114924. metallic: Nullable<number>;
  114925. /**
  114926. * Specifies the roughness scalar of the metallic/roughness workflow.
  114927. * Can also be used to scale the roughness values of the metallic texture.
  114928. */
  114929. roughness: Nullable<number>;
  114930. /**
  114931. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114932. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114933. */
  114934. microSurfaceTexture: BaseTexture;
  114935. /**
  114936. * Stores surface normal data used to displace a mesh in a texture.
  114937. */
  114938. bumpTexture: BaseTexture;
  114939. /**
  114940. * Stores the pre-calculated light information of a mesh in a texture.
  114941. */
  114942. lightmapTexture: BaseTexture;
  114943. /**
  114944. * Stores the refracted light information in a texture.
  114945. */
  114946. refractionTexture: Nullable<BaseTexture>;
  114947. /**
  114948. * The color of a material in ambient lighting.
  114949. */
  114950. ambientColor: Color3;
  114951. /**
  114952. * AKA Diffuse Color in other nomenclature.
  114953. */
  114954. albedoColor: Color3;
  114955. /**
  114956. * AKA Specular Color in other nomenclature.
  114957. */
  114958. reflectivityColor: Color3;
  114959. /**
  114960. * The color reflected from the material.
  114961. */
  114962. reflectionColor: Color3;
  114963. /**
  114964. * The color emitted from the material.
  114965. */
  114966. emissiveColor: Color3;
  114967. /**
  114968. * AKA Glossiness in other nomenclature.
  114969. */
  114970. microSurface: number;
  114971. /**
  114972. * source material index of refraction (IOR)' / 'destination material IOR.
  114973. */
  114974. indexOfRefraction: number;
  114975. /**
  114976. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114977. */
  114978. invertRefractionY: boolean;
  114979. /**
  114980. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114981. * Materials half opaque for instance using refraction could benefit from this control.
  114982. */
  114983. linkRefractionWithTransparency: boolean;
  114984. /**
  114985. * If true, the light map contains occlusion information instead of lighting info.
  114986. */
  114987. useLightmapAsShadowmap: boolean;
  114988. /**
  114989. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114990. */
  114991. useAlphaFromAlbedoTexture: boolean;
  114992. /**
  114993. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114994. */
  114995. forceAlphaTest: boolean;
  114996. /**
  114997. * Defines the alpha limits in alpha test mode.
  114998. */
  114999. alphaCutOff: number;
  115000. /**
  115001. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115002. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115003. */
  115004. useSpecularOverAlpha: boolean;
  115005. /**
  115006. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115007. */
  115008. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115009. /**
  115010. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115011. */
  115012. useRoughnessFromMetallicTextureAlpha: boolean;
  115013. /**
  115014. * Specifies if the metallic texture contains the roughness information in its green channel.
  115015. */
  115016. useRoughnessFromMetallicTextureGreen: boolean;
  115017. /**
  115018. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115019. */
  115020. useMetallnessFromMetallicTextureBlue: boolean;
  115021. /**
  115022. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115023. */
  115024. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115025. /**
  115026. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115027. */
  115028. useAmbientInGrayScale: boolean;
  115029. /**
  115030. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115031. * The material will try to infer what glossiness each pixel should be.
  115032. */
  115033. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115034. /**
  115035. * BJS is using an harcoded light falloff based on a manually sets up range.
  115036. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115037. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115038. */
  115039. /**
  115040. * BJS is using an harcoded light falloff based on a manually sets up range.
  115041. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115042. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115043. */
  115044. usePhysicalLightFalloff: boolean;
  115045. /**
  115046. * In order to support the falloff compatibility with gltf, a special mode has been added
  115047. * to reproduce the gltf light falloff.
  115048. */
  115049. /**
  115050. * In order to support the falloff compatibility with gltf, a special mode has been added
  115051. * to reproduce the gltf light falloff.
  115052. */
  115053. useGLTFLightFalloff: boolean;
  115054. /**
  115055. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115056. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115057. */
  115058. useRadianceOverAlpha: boolean;
  115059. /**
  115060. * Allows using an object space normal map (instead of tangent space).
  115061. */
  115062. useObjectSpaceNormalMap: boolean;
  115063. /**
  115064. * Allows using the bump map in parallax mode.
  115065. */
  115066. useParallax: boolean;
  115067. /**
  115068. * Allows using the bump map in parallax occlusion mode.
  115069. */
  115070. useParallaxOcclusion: boolean;
  115071. /**
  115072. * Controls the scale bias of the parallax mode.
  115073. */
  115074. parallaxScaleBias: number;
  115075. /**
  115076. * If sets to true, disables all the lights affecting the material.
  115077. */
  115078. disableLighting: boolean;
  115079. /**
  115080. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115081. */
  115082. forceIrradianceInFragment: boolean;
  115083. /**
  115084. * Number of Simultaneous lights allowed on the material.
  115085. */
  115086. maxSimultaneousLights: number;
  115087. /**
  115088. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115089. */
  115090. invertNormalMapX: boolean;
  115091. /**
  115092. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115093. */
  115094. invertNormalMapY: boolean;
  115095. /**
  115096. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115097. */
  115098. twoSidedLighting: boolean;
  115099. /**
  115100. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115101. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115102. */
  115103. useAlphaFresnel: boolean;
  115104. /**
  115105. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115106. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115107. */
  115108. useLinearAlphaFresnel: boolean;
  115109. /**
  115110. * Let user defines the brdf lookup texture used for IBL.
  115111. * A default 8bit version is embedded but you could point at :
  115112. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115113. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115114. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115115. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115116. */
  115117. environmentBRDFTexture: Nullable<BaseTexture>;
  115118. /**
  115119. * Force normal to face away from face.
  115120. */
  115121. forceNormalForward: boolean;
  115122. /**
  115123. * Enables specular anti aliasing in the PBR shader.
  115124. * It will both interacts on the Geometry for analytical and IBL lighting.
  115125. * It also prefilter the roughness map based on the bump values.
  115126. */
  115127. enableSpecularAntiAliasing: boolean;
  115128. /**
  115129. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115130. * makes the reflect vector face the model (under horizon).
  115131. */
  115132. useHorizonOcclusion: boolean;
  115133. /**
  115134. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115135. * too much the area relying on ambient texture to define their ambient occlusion.
  115136. */
  115137. useRadianceOcclusion: boolean;
  115138. /**
  115139. * If set to true, no lighting calculations will be applied.
  115140. */
  115141. unlit: boolean;
  115142. /**
  115143. * Gets the image processing configuration used either in this material.
  115144. */
  115145. /**
  115146. * Sets the Default image processing configuration used either in the this material.
  115147. *
  115148. * If sets to null, the scene one is in use.
  115149. */
  115150. imageProcessingConfiguration: ImageProcessingConfiguration;
  115151. /**
  115152. * Gets wether the color curves effect is enabled.
  115153. */
  115154. /**
  115155. * Sets wether the color curves effect is enabled.
  115156. */
  115157. cameraColorCurvesEnabled: boolean;
  115158. /**
  115159. * Gets wether the color grading effect is enabled.
  115160. */
  115161. /**
  115162. * Gets wether the color grading effect is enabled.
  115163. */
  115164. cameraColorGradingEnabled: boolean;
  115165. /**
  115166. * Gets wether tonemapping is enabled or not.
  115167. */
  115168. /**
  115169. * Sets wether tonemapping is enabled or not
  115170. */
  115171. cameraToneMappingEnabled: boolean;
  115172. /**
  115173. * The camera exposure used on this material.
  115174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115175. * This corresponds to a photographic exposure.
  115176. */
  115177. /**
  115178. * The camera exposure used on this material.
  115179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115180. * This corresponds to a photographic exposure.
  115181. */
  115182. cameraExposure: number;
  115183. /**
  115184. * Gets The camera contrast used on this material.
  115185. */
  115186. /**
  115187. * Sets The camera contrast used on this material.
  115188. */
  115189. cameraContrast: number;
  115190. /**
  115191. * Gets the Color Grading 2D Lookup Texture.
  115192. */
  115193. /**
  115194. * Sets the Color Grading 2D Lookup Texture.
  115195. */
  115196. cameraColorGradingTexture: Nullable<BaseTexture>;
  115197. /**
  115198. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115199. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115200. * 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;
  115201. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115202. */
  115203. /**
  115204. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115205. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115206. * 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;
  115207. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115208. */
  115209. cameraColorCurves: Nullable<ColorCurves>;
  115210. /**
  115211. * Instantiates a new PBRMaterial instance.
  115212. *
  115213. * @param name The material name
  115214. * @param scene The scene the material will be use in.
  115215. */
  115216. constructor(name: string, scene: Scene);
  115217. /**
  115218. * Returns the name of this material class.
  115219. */
  115220. getClassName(): string;
  115221. /**
  115222. * Makes a duplicate of the current material.
  115223. * @param name - name to use for the new material.
  115224. */
  115225. clone(name: string): PBRMaterial;
  115226. /**
  115227. * Serializes this PBR Material.
  115228. * @returns - An object with the serialized material.
  115229. */
  115230. serialize(): any;
  115231. /**
  115232. * Parses a PBR Material from a serialized object.
  115233. * @param source - Serialized object.
  115234. * @param scene - BJS scene instance.
  115235. * @param rootUrl - url for the scene object
  115236. * @returns - PBRMaterial
  115237. */
  115238. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115239. }
  115240. }
  115241. declare module BABYLON {
  115242. /**
  115243. * Direct draw surface info
  115244. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115245. */
  115246. export interface DDSInfo {
  115247. /**
  115248. * Width of the texture
  115249. */
  115250. width: number;
  115251. /**
  115252. * Width of the texture
  115253. */
  115254. height: number;
  115255. /**
  115256. * Number of Mipmaps for the texture
  115257. * @see https://en.wikipedia.org/wiki/Mipmap
  115258. */
  115259. mipmapCount: number;
  115260. /**
  115261. * If the textures format is a known fourCC format
  115262. * @see https://www.fourcc.org/
  115263. */
  115264. isFourCC: boolean;
  115265. /**
  115266. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115267. */
  115268. isRGB: boolean;
  115269. /**
  115270. * If the texture is a lumincance format
  115271. */
  115272. isLuminance: boolean;
  115273. /**
  115274. * If this is a cube texture
  115275. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115276. */
  115277. isCube: boolean;
  115278. /**
  115279. * If the texture is a compressed format eg. FOURCC_DXT1
  115280. */
  115281. isCompressed: boolean;
  115282. /**
  115283. * The dxgiFormat of the texture
  115284. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115285. */
  115286. dxgiFormat: number;
  115287. /**
  115288. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115289. */
  115290. textureType: number;
  115291. /**
  115292. * Sphericle polynomial created for the dds texture
  115293. */
  115294. sphericalPolynomial?: SphericalPolynomial;
  115295. }
  115296. /**
  115297. * Class used to provide DDS decompression tools
  115298. */
  115299. export class DDSTools {
  115300. /**
  115301. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115302. */
  115303. static StoreLODInAlphaChannel: boolean;
  115304. /**
  115305. * Gets DDS information from an array buffer
  115306. * @param arrayBuffer defines the array buffer to read data from
  115307. * @returns the DDS information
  115308. */
  115309. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115310. private static _FloatView;
  115311. private static _Int32View;
  115312. private static _ToHalfFloat;
  115313. private static _FromHalfFloat;
  115314. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115315. private static _GetHalfFloatRGBAArrayBuffer;
  115316. private static _GetFloatRGBAArrayBuffer;
  115317. private static _GetFloatAsUIntRGBAArrayBuffer;
  115318. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115319. private static _GetRGBAArrayBuffer;
  115320. private static _ExtractLongWordOrder;
  115321. private static _GetRGBArrayBuffer;
  115322. private static _GetLuminanceArrayBuffer;
  115323. /**
  115324. * Uploads DDS Levels to a Babylon Texture
  115325. * @hidden
  115326. */
  115327. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115328. }
  115329. interface ThinEngine {
  115330. /**
  115331. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115332. * @param rootUrl defines the url where the file to load is located
  115333. * @param scene defines the current scene
  115334. * @param lodScale defines scale to apply to the mip map selection
  115335. * @param lodOffset defines offset to apply to the mip map selection
  115336. * @param onLoad defines an optional callback raised when the texture is loaded
  115337. * @param onError defines an optional callback raised if there is an issue to load the texture
  115338. * @param format defines the format of the data
  115339. * @param forcedExtension defines the extension to use to pick the right loader
  115340. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115341. * @returns the cube texture as an InternalTexture
  115342. */
  115343. 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;
  115344. }
  115345. }
  115346. declare module BABYLON {
  115347. /**
  115348. * Implementation of the DDS Texture Loader.
  115349. * @hidden
  115350. */
  115351. export class _DDSTextureLoader implements IInternalTextureLoader {
  115352. /**
  115353. * Defines wether the loader supports cascade loading the different faces.
  115354. */
  115355. readonly supportCascades: boolean;
  115356. /**
  115357. * This returns if the loader support the current file information.
  115358. * @param extension defines the file extension of the file being loaded
  115359. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115360. * @param fallback defines the fallback internal texture if any
  115361. * @param isBase64 defines whether the texture is encoded as a base64
  115362. * @param isBuffer defines whether the texture data are stored as a buffer
  115363. * @returns true if the loader can load the specified file
  115364. */
  115365. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115366. /**
  115367. * Transform the url before loading if required.
  115368. * @param rootUrl the url of the texture
  115369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115370. * @returns the transformed texture
  115371. */
  115372. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115373. /**
  115374. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115375. * @param rootUrl the url of the texture
  115376. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115377. * @returns the fallback texture
  115378. */
  115379. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115380. /**
  115381. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115382. * @param data contains the texture data
  115383. * @param texture defines the BabylonJS internal texture
  115384. * @param createPolynomials will be true if polynomials have been requested
  115385. * @param onLoad defines the callback to trigger once the texture is ready
  115386. * @param onError defines the callback to trigger in case of error
  115387. */
  115388. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115389. /**
  115390. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115391. * @param data contains the texture data
  115392. * @param texture defines the BabylonJS internal texture
  115393. * @param callback defines the method to call once ready to upload
  115394. */
  115395. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115396. }
  115397. }
  115398. declare module BABYLON {
  115399. /**
  115400. * Implementation of the ENV Texture Loader.
  115401. * @hidden
  115402. */
  115403. export class _ENVTextureLoader implements IInternalTextureLoader {
  115404. /**
  115405. * Defines wether the loader supports cascade loading the different faces.
  115406. */
  115407. readonly supportCascades: boolean;
  115408. /**
  115409. * This returns if the loader support the current file information.
  115410. * @param extension defines the file extension of the file being loaded
  115411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115412. * @param fallback defines the fallback internal texture if any
  115413. * @param isBase64 defines whether the texture is encoded as a base64
  115414. * @param isBuffer defines whether the texture data are stored as a buffer
  115415. * @returns true if the loader can load the specified file
  115416. */
  115417. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115418. /**
  115419. * Transform the url before loading if required.
  115420. * @param rootUrl the url of the texture
  115421. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115422. * @returns the transformed texture
  115423. */
  115424. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115425. /**
  115426. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115427. * @param rootUrl the url of the texture
  115428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115429. * @returns the fallback texture
  115430. */
  115431. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115432. /**
  115433. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115434. * @param data contains the texture data
  115435. * @param texture defines the BabylonJS internal texture
  115436. * @param createPolynomials will be true if polynomials have been requested
  115437. * @param onLoad defines the callback to trigger once the texture is ready
  115438. * @param onError defines the callback to trigger in case of error
  115439. */
  115440. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115441. /**
  115442. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115443. * @param data contains the texture data
  115444. * @param texture defines the BabylonJS internal texture
  115445. * @param callback defines the method to call once ready to upload
  115446. */
  115447. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115448. }
  115449. }
  115450. declare module BABYLON {
  115451. /**
  115452. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115453. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115454. */
  115455. export class KhronosTextureContainer {
  115456. /** contents of the KTX container file */
  115457. arrayBuffer: any;
  115458. private static HEADER_LEN;
  115459. private static COMPRESSED_2D;
  115460. private static COMPRESSED_3D;
  115461. private static TEX_2D;
  115462. private static TEX_3D;
  115463. /**
  115464. * Gets the openGL type
  115465. */
  115466. glType: number;
  115467. /**
  115468. * Gets the openGL type size
  115469. */
  115470. glTypeSize: number;
  115471. /**
  115472. * Gets the openGL format
  115473. */
  115474. glFormat: number;
  115475. /**
  115476. * Gets the openGL internal format
  115477. */
  115478. glInternalFormat: number;
  115479. /**
  115480. * Gets the base internal format
  115481. */
  115482. glBaseInternalFormat: number;
  115483. /**
  115484. * Gets image width in pixel
  115485. */
  115486. pixelWidth: number;
  115487. /**
  115488. * Gets image height in pixel
  115489. */
  115490. pixelHeight: number;
  115491. /**
  115492. * Gets image depth in pixels
  115493. */
  115494. pixelDepth: number;
  115495. /**
  115496. * Gets the number of array elements
  115497. */
  115498. numberOfArrayElements: number;
  115499. /**
  115500. * Gets the number of faces
  115501. */
  115502. numberOfFaces: number;
  115503. /**
  115504. * Gets the number of mipmap levels
  115505. */
  115506. numberOfMipmapLevels: number;
  115507. /**
  115508. * Gets the bytes of key value data
  115509. */
  115510. bytesOfKeyValueData: number;
  115511. /**
  115512. * Gets the load type
  115513. */
  115514. loadType: number;
  115515. /**
  115516. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115517. */
  115518. isInvalid: boolean;
  115519. /**
  115520. * Creates a new KhronosTextureContainer
  115521. * @param arrayBuffer contents of the KTX container file
  115522. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115523. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115524. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115525. */
  115526. constructor(
  115527. /** contents of the KTX container file */
  115528. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115529. /**
  115530. * Uploads KTX content to a Babylon Texture.
  115531. * It is assumed that the texture has already been created & is currently bound
  115532. * @hidden
  115533. */
  115534. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115535. private _upload2DCompressedLevels;
  115536. }
  115537. }
  115538. declare module BABYLON {
  115539. /**
  115540. * Implementation of the KTX Texture Loader.
  115541. * @hidden
  115542. */
  115543. export class _KTXTextureLoader implements IInternalTextureLoader {
  115544. /**
  115545. * Defines wether the loader supports cascade loading the different faces.
  115546. */
  115547. readonly supportCascades: boolean;
  115548. /**
  115549. * This returns if the loader support the current file information.
  115550. * @param extension defines the file extension of the file being loaded
  115551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115552. * @param fallback defines the fallback internal texture if any
  115553. * @param isBase64 defines whether the texture is encoded as a base64
  115554. * @param isBuffer defines whether the texture data are stored as a buffer
  115555. * @returns true if the loader can load the specified file
  115556. */
  115557. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115558. /**
  115559. * Transform the url before loading if required.
  115560. * @param rootUrl the url of the texture
  115561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115562. * @returns the transformed texture
  115563. */
  115564. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115565. /**
  115566. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115567. * @param rootUrl the url of the texture
  115568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115569. * @returns the fallback texture
  115570. */
  115571. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115572. /**
  115573. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115574. * @param data contains the texture data
  115575. * @param texture defines the BabylonJS internal texture
  115576. * @param createPolynomials will be true if polynomials have been requested
  115577. * @param onLoad defines the callback to trigger once the texture is ready
  115578. * @param onError defines the callback to trigger in case of error
  115579. */
  115580. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115581. /**
  115582. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115583. * @param data contains the texture data
  115584. * @param texture defines the BabylonJS internal texture
  115585. * @param callback defines the method to call once ready to upload
  115586. */
  115587. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115588. }
  115589. }
  115590. declare module BABYLON {
  115591. /**
  115592. * Options for the default xr helper
  115593. */
  115594. export class WebXRDefaultExperienceOptions {
  115595. /**
  115596. * Floor meshes that should be used for teleporting
  115597. */
  115598. floorMeshes: Array<AbstractMesh>;
  115599. }
  115600. /**
  115601. * Default experience which provides a similar setup to the previous webVRExperience
  115602. */
  115603. export class WebXRDefaultExperience {
  115604. /**
  115605. * Base experience
  115606. */
  115607. baseExperience: WebXRExperienceHelper;
  115608. /**
  115609. * Input experience extension
  115610. */
  115611. input: WebXRInput;
  115612. /**
  115613. * Loads the controller models
  115614. */
  115615. controllerModelLoader: WebXRControllerModelLoader;
  115616. /**
  115617. * Enables laser pointer and selection
  115618. */
  115619. pointerSelection: WebXRControllerPointerSelection;
  115620. /**
  115621. * Enables teleportation
  115622. */
  115623. teleportation: WebXRControllerTeleportation;
  115624. /**
  115625. * Enables ui for enetering/exiting xr
  115626. */
  115627. enterExitUI: WebXREnterExitUI;
  115628. /**
  115629. * Default output canvas xr should render to
  115630. */
  115631. outputCanvas: WebXRManagedOutputCanvas;
  115632. /**
  115633. * Creates the default xr experience
  115634. * @param scene scene
  115635. * @param options options for basic configuration
  115636. * @returns resulting WebXRDefaultExperience
  115637. */
  115638. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115639. private constructor();
  115640. /**
  115641. * DIsposes of the experience helper
  115642. */
  115643. dispose(): void;
  115644. }
  115645. }
  115646. declare module BABYLON {
  115647. /** @hidden */
  115648. export var _forceSceneHelpersToBundle: boolean;
  115649. interface Scene {
  115650. /**
  115651. * Creates a default light for the scene.
  115652. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115653. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115654. */
  115655. createDefaultLight(replace?: boolean): void;
  115656. /**
  115657. * Creates a default camera for the scene.
  115658. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115659. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115660. * @param replace has default false, when true replaces the active camera in the scene
  115661. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115662. */
  115663. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115664. /**
  115665. * Creates a default camera and a default light.
  115666. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115667. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115668. * @param replace has the default false, when true replaces the active camera/light in the scene
  115669. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115670. */
  115671. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115672. /**
  115673. * Creates a new sky box
  115674. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115675. * @param environmentTexture defines the texture to use as environment texture
  115676. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115677. * @param scale defines the overall scale of the skybox
  115678. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115679. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115680. * @returns a new mesh holding the sky box
  115681. */
  115682. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115683. /**
  115684. * Creates a new environment
  115685. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115686. * @param options defines the options you can use to configure the environment
  115687. * @returns the new EnvironmentHelper
  115688. */
  115689. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115690. /**
  115691. * Creates a new VREXperienceHelper
  115692. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115693. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115694. * @returns a new VREXperienceHelper
  115695. */
  115696. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115697. /**
  115698. * Creates a new WebXRDefaultExperience
  115699. * @see http://doc.babylonjs.com/how_to/webxr
  115700. * @param options experience options
  115701. * @returns a promise for a new WebXRDefaultExperience
  115702. */
  115703. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115704. }
  115705. }
  115706. declare module BABYLON {
  115707. /**
  115708. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115709. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115710. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115711. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115712. */
  115713. export class VideoDome extends TransformNode {
  115714. /**
  115715. * Define the video source as a Monoscopic panoramic 360 video.
  115716. */
  115717. static readonly MODE_MONOSCOPIC: number;
  115718. /**
  115719. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115720. */
  115721. static readonly MODE_TOPBOTTOM: number;
  115722. /**
  115723. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115724. */
  115725. static readonly MODE_SIDEBYSIDE: number;
  115726. private _halfDome;
  115727. private _useDirectMapping;
  115728. /**
  115729. * The video texture being displayed on the sphere
  115730. */
  115731. protected _videoTexture: VideoTexture;
  115732. /**
  115733. * Gets the video texture being displayed on the sphere
  115734. */
  115735. readonly videoTexture: VideoTexture;
  115736. /**
  115737. * The skybox material
  115738. */
  115739. protected _material: BackgroundMaterial;
  115740. /**
  115741. * The surface used for the skybox
  115742. */
  115743. protected _mesh: Mesh;
  115744. /**
  115745. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115746. */
  115747. private _halfDomeMask;
  115748. /**
  115749. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115750. * Also see the options.resolution property.
  115751. */
  115752. fovMultiplier: number;
  115753. private _videoMode;
  115754. /**
  115755. * Gets or set the current video mode for the video. It can be:
  115756. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115757. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115758. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115759. */
  115760. videoMode: number;
  115761. /**
  115762. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115763. *
  115764. */
  115765. /**
  115766. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115767. */
  115768. halfDome: boolean;
  115769. /**
  115770. * Oberserver used in Stereoscopic VR Mode.
  115771. */
  115772. private _onBeforeCameraRenderObserver;
  115773. /**
  115774. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115775. * @param name Element's name, child elements will append suffixes for their own names.
  115776. * @param urlsOrVideo defines the url(s) or the video element to use
  115777. * @param options An object containing optional or exposed sub element properties
  115778. */
  115779. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115780. resolution?: number;
  115781. clickToPlay?: boolean;
  115782. autoPlay?: boolean;
  115783. loop?: boolean;
  115784. size?: number;
  115785. poster?: string;
  115786. faceForward?: boolean;
  115787. useDirectMapping?: boolean;
  115788. halfDomeMode?: boolean;
  115789. }, scene: Scene);
  115790. private _changeVideoMode;
  115791. /**
  115792. * Releases resources associated with this node.
  115793. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115794. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115795. */
  115796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115797. }
  115798. }
  115799. declare module BABYLON {
  115800. /**
  115801. * This class can be used to get instrumentation data from a Babylon engine
  115802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115803. */
  115804. export class EngineInstrumentation implements IDisposable {
  115805. /**
  115806. * Define the instrumented engine.
  115807. */
  115808. engine: Engine;
  115809. private _captureGPUFrameTime;
  115810. private _gpuFrameTimeToken;
  115811. private _gpuFrameTime;
  115812. private _captureShaderCompilationTime;
  115813. private _shaderCompilationTime;
  115814. private _onBeginFrameObserver;
  115815. private _onEndFrameObserver;
  115816. private _onBeforeShaderCompilationObserver;
  115817. private _onAfterShaderCompilationObserver;
  115818. /**
  115819. * Gets the perf counter used for GPU frame time
  115820. */
  115821. readonly gpuFrameTimeCounter: PerfCounter;
  115822. /**
  115823. * Gets the GPU frame time capture status
  115824. */
  115825. /**
  115826. * Enable or disable the GPU frame time capture
  115827. */
  115828. captureGPUFrameTime: boolean;
  115829. /**
  115830. * Gets the perf counter used for shader compilation time
  115831. */
  115832. readonly shaderCompilationTimeCounter: PerfCounter;
  115833. /**
  115834. * Gets the shader compilation time capture status
  115835. */
  115836. /**
  115837. * Enable or disable the shader compilation time capture
  115838. */
  115839. captureShaderCompilationTime: boolean;
  115840. /**
  115841. * Instantiates a new engine instrumentation.
  115842. * This class can be used to get instrumentation data from a Babylon engine
  115843. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115844. * @param engine Defines the engine to instrument
  115845. */
  115846. constructor(
  115847. /**
  115848. * Define the instrumented engine.
  115849. */
  115850. engine: Engine);
  115851. /**
  115852. * Dispose and release associated resources.
  115853. */
  115854. dispose(): void;
  115855. }
  115856. }
  115857. declare module BABYLON {
  115858. /**
  115859. * This class can be used to get instrumentation data from a Babylon engine
  115860. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115861. */
  115862. export class SceneInstrumentation implements IDisposable {
  115863. /**
  115864. * Defines the scene to instrument
  115865. */
  115866. scene: Scene;
  115867. private _captureActiveMeshesEvaluationTime;
  115868. private _activeMeshesEvaluationTime;
  115869. private _captureRenderTargetsRenderTime;
  115870. private _renderTargetsRenderTime;
  115871. private _captureFrameTime;
  115872. private _frameTime;
  115873. private _captureRenderTime;
  115874. private _renderTime;
  115875. private _captureInterFrameTime;
  115876. private _interFrameTime;
  115877. private _captureParticlesRenderTime;
  115878. private _particlesRenderTime;
  115879. private _captureSpritesRenderTime;
  115880. private _spritesRenderTime;
  115881. private _capturePhysicsTime;
  115882. private _physicsTime;
  115883. private _captureAnimationsTime;
  115884. private _animationsTime;
  115885. private _captureCameraRenderTime;
  115886. private _cameraRenderTime;
  115887. private _onBeforeActiveMeshesEvaluationObserver;
  115888. private _onAfterActiveMeshesEvaluationObserver;
  115889. private _onBeforeRenderTargetsRenderObserver;
  115890. private _onAfterRenderTargetsRenderObserver;
  115891. private _onAfterRenderObserver;
  115892. private _onBeforeDrawPhaseObserver;
  115893. private _onAfterDrawPhaseObserver;
  115894. private _onBeforeAnimationsObserver;
  115895. private _onBeforeParticlesRenderingObserver;
  115896. private _onAfterParticlesRenderingObserver;
  115897. private _onBeforeSpritesRenderingObserver;
  115898. private _onAfterSpritesRenderingObserver;
  115899. private _onBeforePhysicsObserver;
  115900. private _onAfterPhysicsObserver;
  115901. private _onAfterAnimationsObserver;
  115902. private _onBeforeCameraRenderObserver;
  115903. private _onAfterCameraRenderObserver;
  115904. /**
  115905. * Gets the perf counter used for active meshes evaluation time
  115906. */
  115907. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115908. /**
  115909. * Gets the active meshes evaluation time capture status
  115910. */
  115911. /**
  115912. * Enable or disable the active meshes evaluation time capture
  115913. */
  115914. captureActiveMeshesEvaluationTime: boolean;
  115915. /**
  115916. * Gets the perf counter used for render targets render time
  115917. */
  115918. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115919. /**
  115920. * Gets the render targets render time capture status
  115921. */
  115922. /**
  115923. * Enable or disable the render targets render time capture
  115924. */
  115925. captureRenderTargetsRenderTime: boolean;
  115926. /**
  115927. * Gets the perf counter used for particles render time
  115928. */
  115929. readonly particlesRenderTimeCounter: PerfCounter;
  115930. /**
  115931. * Gets the particles render time capture status
  115932. */
  115933. /**
  115934. * Enable or disable the particles render time capture
  115935. */
  115936. captureParticlesRenderTime: boolean;
  115937. /**
  115938. * Gets the perf counter used for sprites render time
  115939. */
  115940. readonly spritesRenderTimeCounter: PerfCounter;
  115941. /**
  115942. * Gets the sprites render time capture status
  115943. */
  115944. /**
  115945. * Enable or disable the sprites render time capture
  115946. */
  115947. captureSpritesRenderTime: boolean;
  115948. /**
  115949. * Gets the perf counter used for physics time
  115950. */
  115951. readonly physicsTimeCounter: PerfCounter;
  115952. /**
  115953. * Gets the physics time capture status
  115954. */
  115955. /**
  115956. * Enable or disable the physics time capture
  115957. */
  115958. capturePhysicsTime: boolean;
  115959. /**
  115960. * Gets the perf counter used for animations time
  115961. */
  115962. readonly animationsTimeCounter: PerfCounter;
  115963. /**
  115964. * Gets the animations time capture status
  115965. */
  115966. /**
  115967. * Enable or disable the animations time capture
  115968. */
  115969. captureAnimationsTime: boolean;
  115970. /**
  115971. * Gets the perf counter used for frame time capture
  115972. */
  115973. readonly frameTimeCounter: PerfCounter;
  115974. /**
  115975. * Gets the frame time capture status
  115976. */
  115977. /**
  115978. * Enable or disable the frame time capture
  115979. */
  115980. captureFrameTime: boolean;
  115981. /**
  115982. * Gets the perf counter used for inter-frames time capture
  115983. */
  115984. readonly interFrameTimeCounter: PerfCounter;
  115985. /**
  115986. * Gets the inter-frames time capture status
  115987. */
  115988. /**
  115989. * Enable or disable the inter-frames time capture
  115990. */
  115991. captureInterFrameTime: boolean;
  115992. /**
  115993. * Gets the perf counter used for render time capture
  115994. */
  115995. readonly renderTimeCounter: PerfCounter;
  115996. /**
  115997. * Gets the render time capture status
  115998. */
  115999. /**
  116000. * Enable or disable the render time capture
  116001. */
  116002. captureRenderTime: boolean;
  116003. /**
  116004. * Gets the perf counter used for camera render time capture
  116005. */
  116006. readonly cameraRenderTimeCounter: PerfCounter;
  116007. /**
  116008. * Gets the camera render time capture status
  116009. */
  116010. /**
  116011. * Enable or disable the camera render time capture
  116012. */
  116013. captureCameraRenderTime: boolean;
  116014. /**
  116015. * Gets the perf counter used for draw calls
  116016. */
  116017. readonly drawCallsCounter: PerfCounter;
  116018. /**
  116019. * Instantiates a new scene instrumentation.
  116020. * This class can be used to get instrumentation data from a Babylon engine
  116021. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116022. * @param scene Defines the scene to instrument
  116023. */
  116024. constructor(
  116025. /**
  116026. * Defines the scene to instrument
  116027. */
  116028. scene: Scene);
  116029. /**
  116030. * Dispose and release associated resources.
  116031. */
  116032. dispose(): void;
  116033. }
  116034. }
  116035. declare module BABYLON {
  116036. /** @hidden */
  116037. export var glowMapGenerationPixelShader: {
  116038. name: string;
  116039. shader: string;
  116040. };
  116041. }
  116042. declare module BABYLON {
  116043. /** @hidden */
  116044. export var glowMapGenerationVertexShader: {
  116045. name: string;
  116046. shader: string;
  116047. };
  116048. }
  116049. declare module BABYLON {
  116050. /**
  116051. * Effect layer options. This helps customizing the behaviour
  116052. * of the effect layer.
  116053. */
  116054. export interface IEffectLayerOptions {
  116055. /**
  116056. * Multiplication factor apply to the canvas size to compute the render target size
  116057. * used to generated the objects (the smaller the faster).
  116058. */
  116059. mainTextureRatio: number;
  116060. /**
  116061. * Enforces a fixed size texture to ensure effect stability across devices.
  116062. */
  116063. mainTextureFixedSize?: number;
  116064. /**
  116065. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116066. */
  116067. alphaBlendingMode: number;
  116068. /**
  116069. * The camera attached to the layer.
  116070. */
  116071. camera: Nullable<Camera>;
  116072. /**
  116073. * The rendering group to draw the layer in.
  116074. */
  116075. renderingGroupId: number;
  116076. }
  116077. /**
  116078. * The effect layer Helps adding post process effect blended with the main pass.
  116079. *
  116080. * This can be for instance use to generate glow or higlight effects on the scene.
  116081. *
  116082. * The effect layer class can not be used directly and is intented to inherited from to be
  116083. * customized per effects.
  116084. */
  116085. export abstract class EffectLayer {
  116086. private _vertexBuffers;
  116087. private _indexBuffer;
  116088. private _cachedDefines;
  116089. private _effectLayerMapGenerationEffect;
  116090. private _effectLayerOptions;
  116091. private _mergeEffect;
  116092. protected _scene: Scene;
  116093. protected _engine: Engine;
  116094. protected _maxSize: number;
  116095. protected _mainTextureDesiredSize: ISize;
  116096. protected _mainTexture: RenderTargetTexture;
  116097. protected _shouldRender: boolean;
  116098. protected _postProcesses: PostProcess[];
  116099. protected _textures: BaseTexture[];
  116100. protected _emissiveTextureAndColor: {
  116101. texture: Nullable<BaseTexture>;
  116102. color: Color4;
  116103. };
  116104. /**
  116105. * The name of the layer
  116106. */
  116107. name: string;
  116108. /**
  116109. * The clear color of the texture used to generate the glow map.
  116110. */
  116111. neutralColor: Color4;
  116112. /**
  116113. * Specifies wether the highlight layer is enabled or not.
  116114. */
  116115. isEnabled: boolean;
  116116. /**
  116117. * Gets the camera attached to the layer.
  116118. */
  116119. readonly camera: Nullable<Camera>;
  116120. /**
  116121. * Gets the rendering group id the layer should render in.
  116122. */
  116123. renderingGroupId: number;
  116124. /**
  116125. * An event triggered when the effect layer has been disposed.
  116126. */
  116127. onDisposeObservable: Observable<EffectLayer>;
  116128. /**
  116129. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116130. */
  116131. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116132. /**
  116133. * An event triggered when the generated texture is being merged in the scene.
  116134. */
  116135. onBeforeComposeObservable: Observable<EffectLayer>;
  116136. /**
  116137. * An event triggered when the generated texture has been merged in the scene.
  116138. */
  116139. onAfterComposeObservable: Observable<EffectLayer>;
  116140. /**
  116141. * An event triggered when the efffect layer changes its size.
  116142. */
  116143. onSizeChangedObservable: Observable<EffectLayer>;
  116144. /** @hidden */
  116145. static _SceneComponentInitialization: (scene: Scene) => void;
  116146. /**
  116147. * Instantiates a new effect Layer and references it in the scene.
  116148. * @param name The name of the layer
  116149. * @param scene The scene to use the layer in
  116150. */
  116151. constructor(
  116152. /** The Friendly of the effect in the scene */
  116153. name: string, scene: Scene);
  116154. /**
  116155. * Get the effect name of the layer.
  116156. * @return The effect name
  116157. */
  116158. abstract getEffectName(): string;
  116159. /**
  116160. * Checks for the readiness of the element composing the layer.
  116161. * @param subMesh the mesh to check for
  116162. * @param useInstances specify wether or not to use instances to render the mesh
  116163. * @return true if ready otherwise, false
  116164. */
  116165. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116166. /**
  116167. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116168. * @returns true if the effect requires stencil during the main canvas render pass.
  116169. */
  116170. abstract needStencil(): boolean;
  116171. /**
  116172. * Create the merge effect. This is the shader use to blit the information back
  116173. * to the main canvas at the end of the scene rendering.
  116174. * @returns The effect containing the shader used to merge the effect on the main canvas
  116175. */
  116176. protected abstract _createMergeEffect(): Effect;
  116177. /**
  116178. * Creates the render target textures and post processes used in the effect layer.
  116179. */
  116180. protected abstract _createTextureAndPostProcesses(): void;
  116181. /**
  116182. * Implementation specific of rendering the generating effect on the main canvas.
  116183. * @param effect The effect used to render through
  116184. */
  116185. protected abstract _internalRender(effect: Effect): void;
  116186. /**
  116187. * Sets the required values for both the emissive texture and and the main color.
  116188. */
  116189. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116190. /**
  116191. * Free any resources and references associated to a mesh.
  116192. * Internal use
  116193. * @param mesh The mesh to free.
  116194. */
  116195. abstract _disposeMesh(mesh: Mesh): void;
  116196. /**
  116197. * Serializes this layer (Glow or Highlight for example)
  116198. * @returns a serialized layer object
  116199. */
  116200. abstract serialize?(): any;
  116201. /**
  116202. * Initializes the effect layer with the required options.
  116203. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116204. */
  116205. protected _init(options: Partial<IEffectLayerOptions>): void;
  116206. /**
  116207. * Generates the index buffer of the full screen quad blending to the main canvas.
  116208. */
  116209. private _generateIndexBuffer;
  116210. /**
  116211. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116212. */
  116213. private _generateVertexBuffer;
  116214. /**
  116215. * Sets the main texture desired size which is the closest power of two
  116216. * of the engine canvas size.
  116217. */
  116218. private _setMainTextureSize;
  116219. /**
  116220. * Creates the main texture for the effect layer.
  116221. */
  116222. protected _createMainTexture(): void;
  116223. /**
  116224. * Adds specific effects defines.
  116225. * @param defines The defines to add specifics to.
  116226. */
  116227. protected _addCustomEffectDefines(defines: string[]): void;
  116228. /**
  116229. * Checks for the readiness of the element composing the layer.
  116230. * @param subMesh the mesh to check for
  116231. * @param useInstances specify wether or not to use instances to render the mesh
  116232. * @param emissiveTexture the associated emissive texture used to generate the glow
  116233. * @return true if ready otherwise, false
  116234. */
  116235. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116236. /**
  116237. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116238. */
  116239. render(): void;
  116240. /**
  116241. * Determine if a given mesh will be used in the current effect.
  116242. * @param mesh mesh to test
  116243. * @returns true if the mesh will be used
  116244. */
  116245. hasMesh(mesh: AbstractMesh): boolean;
  116246. /**
  116247. * Returns true if the layer contains information to display, otherwise false.
  116248. * @returns true if the glow layer should be rendered
  116249. */
  116250. shouldRender(): boolean;
  116251. /**
  116252. * Returns true if the mesh should render, otherwise false.
  116253. * @param mesh The mesh to render
  116254. * @returns true if it should render otherwise false
  116255. */
  116256. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116257. /**
  116258. * Returns true if the mesh can be rendered, otherwise false.
  116259. * @param mesh The mesh to render
  116260. * @param material The material used on the mesh
  116261. * @returns true if it can be rendered otherwise false
  116262. */
  116263. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116264. /**
  116265. * Returns true if the mesh should render, otherwise false.
  116266. * @param mesh The mesh to render
  116267. * @returns true if it should render otherwise false
  116268. */
  116269. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116270. /**
  116271. * Renders the submesh passed in parameter to the generation map.
  116272. */
  116273. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116274. /**
  116275. * Rebuild the required buffers.
  116276. * @hidden Internal use only.
  116277. */
  116278. _rebuild(): void;
  116279. /**
  116280. * Dispose only the render target textures and post process.
  116281. */
  116282. private _disposeTextureAndPostProcesses;
  116283. /**
  116284. * Dispose the highlight layer and free resources.
  116285. */
  116286. dispose(): void;
  116287. /**
  116288. * Gets the class name of the effect layer
  116289. * @returns the string with the class name of the effect layer
  116290. */
  116291. getClassName(): string;
  116292. /**
  116293. * Creates an effect layer from parsed effect layer data
  116294. * @param parsedEffectLayer defines effect layer data
  116295. * @param scene defines the current scene
  116296. * @param rootUrl defines the root URL containing the effect layer information
  116297. * @returns a parsed effect Layer
  116298. */
  116299. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116300. }
  116301. }
  116302. declare module BABYLON {
  116303. interface AbstractScene {
  116304. /**
  116305. * The list of effect layers (highlights/glow) added to the scene
  116306. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116307. * @see http://doc.babylonjs.com/how_to/glow_layer
  116308. */
  116309. effectLayers: Array<EffectLayer>;
  116310. /**
  116311. * Removes the given effect layer from this scene.
  116312. * @param toRemove defines the effect layer to remove
  116313. * @returns the index of the removed effect layer
  116314. */
  116315. removeEffectLayer(toRemove: EffectLayer): number;
  116316. /**
  116317. * Adds the given effect layer to this scene
  116318. * @param newEffectLayer defines the effect layer to add
  116319. */
  116320. addEffectLayer(newEffectLayer: EffectLayer): void;
  116321. }
  116322. /**
  116323. * Defines the layer scene component responsible to manage any effect layers
  116324. * in a given scene.
  116325. */
  116326. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116327. /**
  116328. * The component name helpfull to identify the component in the list of scene components.
  116329. */
  116330. readonly name: string;
  116331. /**
  116332. * The scene the component belongs to.
  116333. */
  116334. scene: Scene;
  116335. private _engine;
  116336. private _renderEffects;
  116337. private _needStencil;
  116338. private _previousStencilState;
  116339. /**
  116340. * Creates a new instance of the component for the given scene
  116341. * @param scene Defines the scene to register the component in
  116342. */
  116343. constructor(scene: Scene);
  116344. /**
  116345. * Registers the component in a given scene
  116346. */
  116347. register(): void;
  116348. /**
  116349. * Rebuilds the elements related to this component in case of
  116350. * context lost for instance.
  116351. */
  116352. rebuild(): void;
  116353. /**
  116354. * Serializes the component data to the specified json object
  116355. * @param serializationObject The object to serialize to
  116356. */
  116357. serialize(serializationObject: any): void;
  116358. /**
  116359. * Adds all the elements from the container to the scene
  116360. * @param container the container holding the elements
  116361. */
  116362. addFromContainer(container: AbstractScene): void;
  116363. /**
  116364. * Removes all the elements in the container from the scene
  116365. * @param container contains the elements to remove
  116366. * @param dispose if the removed element should be disposed (default: false)
  116367. */
  116368. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116369. /**
  116370. * Disposes the component and the associated ressources.
  116371. */
  116372. dispose(): void;
  116373. private _isReadyForMesh;
  116374. private _renderMainTexture;
  116375. private _setStencil;
  116376. private _setStencilBack;
  116377. private _draw;
  116378. private _drawCamera;
  116379. private _drawRenderingGroup;
  116380. }
  116381. }
  116382. declare module BABYLON {
  116383. /** @hidden */
  116384. export var glowMapMergePixelShader: {
  116385. name: string;
  116386. shader: string;
  116387. };
  116388. }
  116389. declare module BABYLON {
  116390. /** @hidden */
  116391. export var glowMapMergeVertexShader: {
  116392. name: string;
  116393. shader: string;
  116394. };
  116395. }
  116396. declare module BABYLON {
  116397. interface AbstractScene {
  116398. /**
  116399. * Return a the first highlight layer of the scene with a given name.
  116400. * @param name The name of the highlight layer to look for.
  116401. * @return The highlight layer if found otherwise null.
  116402. */
  116403. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116404. }
  116405. /**
  116406. * Glow layer options. This helps customizing the behaviour
  116407. * of the glow layer.
  116408. */
  116409. export interface IGlowLayerOptions {
  116410. /**
  116411. * Multiplication factor apply to the canvas size to compute the render target size
  116412. * used to generated the glowing objects (the smaller the faster).
  116413. */
  116414. mainTextureRatio: number;
  116415. /**
  116416. * Enforces a fixed size texture to ensure resize independant blur.
  116417. */
  116418. mainTextureFixedSize?: number;
  116419. /**
  116420. * How big is the kernel of the blur texture.
  116421. */
  116422. blurKernelSize: number;
  116423. /**
  116424. * The camera attached to the layer.
  116425. */
  116426. camera: Nullable<Camera>;
  116427. /**
  116428. * Enable MSAA by chosing the number of samples.
  116429. */
  116430. mainTextureSamples?: number;
  116431. /**
  116432. * The rendering group to draw the layer in.
  116433. */
  116434. renderingGroupId: number;
  116435. }
  116436. /**
  116437. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116438. *
  116439. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116440. * glowy meshes to your scene.
  116441. *
  116442. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116443. */
  116444. export class GlowLayer extends EffectLayer {
  116445. /**
  116446. * Effect Name of the layer.
  116447. */
  116448. static readonly EffectName: string;
  116449. /**
  116450. * The default blur kernel size used for the glow.
  116451. */
  116452. static DefaultBlurKernelSize: number;
  116453. /**
  116454. * The default texture size ratio used for the glow.
  116455. */
  116456. static DefaultTextureRatio: number;
  116457. /**
  116458. * Sets the kernel size of the blur.
  116459. */
  116460. /**
  116461. * Gets the kernel size of the blur.
  116462. */
  116463. blurKernelSize: number;
  116464. /**
  116465. * Sets the glow intensity.
  116466. */
  116467. /**
  116468. * Gets the glow intensity.
  116469. */
  116470. intensity: number;
  116471. private _options;
  116472. private _intensity;
  116473. private _horizontalBlurPostprocess1;
  116474. private _verticalBlurPostprocess1;
  116475. private _horizontalBlurPostprocess2;
  116476. private _verticalBlurPostprocess2;
  116477. private _blurTexture1;
  116478. private _blurTexture2;
  116479. private _postProcesses1;
  116480. private _postProcesses2;
  116481. private _includedOnlyMeshes;
  116482. private _excludedMeshes;
  116483. /**
  116484. * Callback used to let the user override the color selection on a per mesh basis
  116485. */
  116486. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116487. /**
  116488. * Callback used to let the user override the texture selection on a per mesh basis
  116489. */
  116490. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116491. /**
  116492. * Instantiates a new glow Layer and references it to the scene.
  116493. * @param name The name of the layer
  116494. * @param scene The scene to use the layer in
  116495. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116496. */
  116497. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116498. /**
  116499. * Get the effect name of the layer.
  116500. * @return The effect name
  116501. */
  116502. getEffectName(): string;
  116503. /**
  116504. * Create the merge effect. This is the shader use to blit the information back
  116505. * to the main canvas at the end of the scene rendering.
  116506. */
  116507. protected _createMergeEffect(): Effect;
  116508. /**
  116509. * Creates the render target textures and post processes used in the glow layer.
  116510. */
  116511. protected _createTextureAndPostProcesses(): void;
  116512. /**
  116513. * Checks for the readiness of the element composing the layer.
  116514. * @param subMesh the mesh to check for
  116515. * @param useInstances specify wether or not to use instances to render the mesh
  116516. * @param emissiveTexture the associated emissive texture used to generate the glow
  116517. * @return true if ready otherwise, false
  116518. */
  116519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116520. /**
  116521. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116522. */
  116523. needStencil(): boolean;
  116524. /**
  116525. * Returns true if the mesh can be rendered, otherwise false.
  116526. * @param mesh The mesh to render
  116527. * @param material The material used on the mesh
  116528. * @returns true if it can be rendered otherwise false
  116529. */
  116530. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116531. /**
  116532. * Implementation specific of rendering the generating effect on the main canvas.
  116533. * @param effect The effect used to render through
  116534. */
  116535. protected _internalRender(effect: Effect): void;
  116536. /**
  116537. * Sets the required values for both the emissive texture and and the main color.
  116538. */
  116539. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116540. /**
  116541. * Returns true if the mesh should render, otherwise false.
  116542. * @param mesh The mesh to render
  116543. * @returns true if it should render otherwise false
  116544. */
  116545. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116546. /**
  116547. * Adds specific effects defines.
  116548. * @param defines The defines to add specifics to.
  116549. */
  116550. protected _addCustomEffectDefines(defines: string[]): void;
  116551. /**
  116552. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116553. * @param mesh The mesh to exclude from the glow layer
  116554. */
  116555. addExcludedMesh(mesh: Mesh): void;
  116556. /**
  116557. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116558. * @param mesh The mesh to remove
  116559. */
  116560. removeExcludedMesh(mesh: Mesh): void;
  116561. /**
  116562. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116563. * @param mesh The mesh to include in the glow layer
  116564. */
  116565. addIncludedOnlyMesh(mesh: Mesh): void;
  116566. /**
  116567. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116568. * @param mesh The mesh to remove
  116569. */
  116570. removeIncludedOnlyMesh(mesh: Mesh): void;
  116571. /**
  116572. * Determine if a given mesh will be used in the glow layer
  116573. * @param mesh The mesh to test
  116574. * @returns true if the mesh will be highlighted by the current glow layer
  116575. */
  116576. hasMesh(mesh: AbstractMesh): boolean;
  116577. /**
  116578. * Free any resources and references associated to a mesh.
  116579. * Internal use
  116580. * @param mesh The mesh to free.
  116581. * @hidden
  116582. */
  116583. _disposeMesh(mesh: Mesh): void;
  116584. /**
  116585. * Gets the class name of the effect layer
  116586. * @returns the string with the class name of the effect layer
  116587. */
  116588. getClassName(): string;
  116589. /**
  116590. * Serializes this glow layer
  116591. * @returns a serialized glow layer object
  116592. */
  116593. serialize(): any;
  116594. /**
  116595. * Creates a Glow Layer from parsed glow layer data
  116596. * @param parsedGlowLayer defines glow layer data
  116597. * @param scene defines the current scene
  116598. * @param rootUrl defines the root URL containing the glow layer information
  116599. * @returns a parsed Glow Layer
  116600. */
  116601. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116602. }
  116603. }
  116604. declare module BABYLON {
  116605. /** @hidden */
  116606. export var glowBlurPostProcessPixelShader: {
  116607. name: string;
  116608. shader: string;
  116609. };
  116610. }
  116611. declare module BABYLON {
  116612. interface AbstractScene {
  116613. /**
  116614. * Return a the first highlight layer of the scene with a given name.
  116615. * @param name The name of the highlight layer to look for.
  116616. * @return The highlight layer if found otherwise null.
  116617. */
  116618. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116619. }
  116620. /**
  116621. * Highlight layer options. This helps customizing the behaviour
  116622. * of the highlight layer.
  116623. */
  116624. export interface IHighlightLayerOptions {
  116625. /**
  116626. * Multiplication factor apply to the canvas size to compute the render target size
  116627. * used to generated the glowing objects (the smaller the faster).
  116628. */
  116629. mainTextureRatio: number;
  116630. /**
  116631. * Enforces a fixed size texture to ensure resize independant blur.
  116632. */
  116633. mainTextureFixedSize?: number;
  116634. /**
  116635. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116636. * of the picture to blur (the smaller the faster).
  116637. */
  116638. blurTextureSizeRatio: number;
  116639. /**
  116640. * How big in texel of the blur texture is the vertical blur.
  116641. */
  116642. blurVerticalSize: number;
  116643. /**
  116644. * How big in texel of the blur texture is the horizontal blur.
  116645. */
  116646. blurHorizontalSize: number;
  116647. /**
  116648. * Alpha blending mode used to apply the blur. Default is combine.
  116649. */
  116650. alphaBlendingMode: number;
  116651. /**
  116652. * The camera attached to the layer.
  116653. */
  116654. camera: Nullable<Camera>;
  116655. /**
  116656. * Should we display highlight as a solid stroke?
  116657. */
  116658. isStroke?: boolean;
  116659. /**
  116660. * The rendering group to draw the layer in.
  116661. */
  116662. renderingGroupId: number;
  116663. }
  116664. /**
  116665. * The highlight layer Helps adding a glow effect around a mesh.
  116666. *
  116667. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116668. * glowy meshes to your scene.
  116669. *
  116670. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116671. */
  116672. export class HighlightLayer extends EffectLayer {
  116673. name: string;
  116674. /**
  116675. * Effect Name of the highlight layer.
  116676. */
  116677. static readonly EffectName: string;
  116678. /**
  116679. * The neutral color used during the preparation of the glow effect.
  116680. * This is black by default as the blend operation is a blend operation.
  116681. */
  116682. static NeutralColor: Color4;
  116683. /**
  116684. * Stencil value used for glowing meshes.
  116685. */
  116686. static GlowingMeshStencilReference: number;
  116687. /**
  116688. * Stencil value used for the other meshes in the scene.
  116689. */
  116690. static NormalMeshStencilReference: number;
  116691. /**
  116692. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116693. */
  116694. innerGlow: boolean;
  116695. /**
  116696. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116697. */
  116698. outerGlow: boolean;
  116699. /**
  116700. * Specifies the horizontal size of the blur.
  116701. */
  116702. /**
  116703. * Gets the horizontal size of the blur.
  116704. */
  116705. blurHorizontalSize: number;
  116706. /**
  116707. * Specifies the vertical size of the blur.
  116708. */
  116709. /**
  116710. * Gets the vertical size of the blur.
  116711. */
  116712. blurVerticalSize: number;
  116713. /**
  116714. * An event triggered when the highlight layer is being blurred.
  116715. */
  116716. onBeforeBlurObservable: Observable<HighlightLayer>;
  116717. /**
  116718. * An event triggered when the highlight layer has been blurred.
  116719. */
  116720. onAfterBlurObservable: Observable<HighlightLayer>;
  116721. private _instanceGlowingMeshStencilReference;
  116722. private _options;
  116723. private _downSamplePostprocess;
  116724. private _horizontalBlurPostprocess;
  116725. private _verticalBlurPostprocess;
  116726. private _blurTexture;
  116727. private _meshes;
  116728. private _excludedMeshes;
  116729. /**
  116730. * Instantiates a new highlight Layer and references it to the scene..
  116731. * @param name The name of the layer
  116732. * @param scene The scene to use the layer in
  116733. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116734. */
  116735. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116736. /**
  116737. * Get the effect name of the layer.
  116738. * @return The effect name
  116739. */
  116740. getEffectName(): string;
  116741. /**
  116742. * Create the merge effect. This is the shader use to blit the information back
  116743. * to the main canvas at the end of the scene rendering.
  116744. */
  116745. protected _createMergeEffect(): Effect;
  116746. /**
  116747. * Creates the render target textures and post processes used in the highlight layer.
  116748. */
  116749. protected _createTextureAndPostProcesses(): void;
  116750. /**
  116751. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116752. */
  116753. needStencil(): boolean;
  116754. /**
  116755. * Checks for the readiness of the element composing the layer.
  116756. * @param subMesh the mesh to check for
  116757. * @param useInstances specify wether or not to use instances to render the mesh
  116758. * @param emissiveTexture the associated emissive texture used to generate the glow
  116759. * @return true if ready otherwise, false
  116760. */
  116761. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116762. /**
  116763. * Implementation specific of rendering the generating effect on the main canvas.
  116764. * @param effect The effect used to render through
  116765. */
  116766. protected _internalRender(effect: Effect): void;
  116767. /**
  116768. * Returns true if the layer contains information to display, otherwise false.
  116769. */
  116770. shouldRender(): boolean;
  116771. /**
  116772. * Returns true if the mesh should render, otherwise false.
  116773. * @param mesh The mesh to render
  116774. * @returns true if it should render otherwise false
  116775. */
  116776. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116777. /**
  116778. * Sets the required values for both the emissive texture and and the main color.
  116779. */
  116780. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116781. /**
  116782. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116783. * @param mesh The mesh to exclude from the highlight layer
  116784. */
  116785. addExcludedMesh(mesh: Mesh): void;
  116786. /**
  116787. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116788. * @param mesh The mesh to highlight
  116789. */
  116790. removeExcludedMesh(mesh: Mesh): void;
  116791. /**
  116792. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116793. * @param mesh mesh to test
  116794. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116795. */
  116796. hasMesh(mesh: AbstractMesh): boolean;
  116797. /**
  116798. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116799. * @param mesh The mesh to highlight
  116800. * @param color The color of the highlight
  116801. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116802. */
  116803. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116804. /**
  116805. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116806. * @param mesh The mesh to highlight
  116807. */
  116808. removeMesh(mesh: Mesh): void;
  116809. /**
  116810. * Force the stencil to the normal expected value for none glowing parts
  116811. */
  116812. private _defaultStencilReference;
  116813. /**
  116814. * Free any resources and references associated to a mesh.
  116815. * Internal use
  116816. * @param mesh The mesh to free.
  116817. * @hidden
  116818. */
  116819. _disposeMesh(mesh: Mesh): void;
  116820. /**
  116821. * Dispose the highlight layer and free resources.
  116822. */
  116823. dispose(): void;
  116824. /**
  116825. * Gets the class name of the effect layer
  116826. * @returns the string with the class name of the effect layer
  116827. */
  116828. getClassName(): string;
  116829. /**
  116830. * Serializes this Highlight layer
  116831. * @returns a serialized Highlight layer object
  116832. */
  116833. serialize(): any;
  116834. /**
  116835. * Creates a Highlight layer from parsed Highlight layer data
  116836. * @param parsedHightlightLayer defines the Highlight layer data
  116837. * @param scene defines the current scene
  116838. * @param rootUrl defines the root URL containing the Highlight layer information
  116839. * @returns a parsed Highlight layer
  116840. */
  116841. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116842. }
  116843. }
  116844. declare module BABYLON {
  116845. interface AbstractScene {
  116846. /**
  116847. * The list of layers (background and foreground) of the scene
  116848. */
  116849. layers: Array<Layer>;
  116850. }
  116851. /**
  116852. * Defines the layer scene component responsible to manage any layers
  116853. * in a given scene.
  116854. */
  116855. export class LayerSceneComponent implements ISceneComponent {
  116856. /**
  116857. * The component name helpfull to identify the component in the list of scene components.
  116858. */
  116859. readonly name: string;
  116860. /**
  116861. * The scene the component belongs to.
  116862. */
  116863. scene: Scene;
  116864. private _engine;
  116865. /**
  116866. * Creates a new instance of the component for the given scene
  116867. * @param scene Defines the scene to register the component in
  116868. */
  116869. constructor(scene: Scene);
  116870. /**
  116871. * Registers the component in a given scene
  116872. */
  116873. register(): void;
  116874. /**
  116875. * Rebuilds the elements related to this component in case of
  116876. * context lost for instance.
  116877. */
  116878. rebuild(): void;
  116879. /**
  116880. * Disposes the component and the associated ressources.
  116881. */
  116882. dispose(): void;
  116883. private _draw;
  116884. private _drawCameraPredicate;
  116885. private _drawCameraBackground;
  116886. private _drawCameraForeground;
  116887. private _drawRenderTargetPredicate;
  116888. private _drawRenderTargetBackground;
  116889. private _drawRenderTargetForeground;
  116890. /**
  116891. * Adds all the elements from the container to the scene
  116892. * @param container the container holding the elements
  116893. */
  116894. addFromContainer(container: AbstractScene): void;
  116895. /**
  116896. * Removes all the elements in the container from the scene
  116897. * @param container contains the elements to remove
  116898. * @param dispose if the removed element should be disposed (default: false)
  116899. */
  116900. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116901. }
  116902. }
  116903. declare module BABYLON {
  116904. /** @hidden */
  116905. export var layerPixelShader: {
  116906. name: string;
  116907. shader: string;
  116908. };
  116909. }
  116910. declare module BABYLON {
  116911. /** @hidden */
  116912. export var layerVertexShader: {
  116913. name: string;
  116914. shader: string;
  116915. };
  116916. }
  116917. declare module BABYLON {
  116918. /**
  116919. * This represents a full screen 2d layer.
  116920. * This can be useful to display a picture in the background of your scene for instance.
  116921. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116922. */
  116923. export class Layer {
  116924. /**
  116925. * Define the name of the layer.
  116926. */
  116927. name: string;
  116928. /**
  116929. * Define the texture the layer should display.
  116930. */
  116931. texture: Nullable<Texture>;
  116932. /**
  116933. * Is the layer in background or foreground.
  116934. */
  116935. isBackground: boolean;
  116936. /**
  116937. * Define the color of the layer (instead of texture).
  116938. */
  116939. color: Color4;
  116940. /**
  116941. * Define the scale of the layer in order to zoom in out of the texture.
  116942. */
  116943. scale: Vector2;
  116944. /**
  116945. * Define an offset for the layer in order to shift the texture.
  116946. */
  116947. offset: Vector2;
  116948. /**
  116949. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116950. */
  116951. alphaBlendingMode: number;
  116952. /**
  116953. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116954. * Alpha test will not mix with the background color in case of transparency.
  116955. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116956. */
  116957. alphaTest: boolean;
  116958. /**
  116959. * Define a mask to restrict the layer to only some of the scene cameras.
  116960. */
  116961. layerMask: number;
  116962. /**
  116963. * Define the list of render target the layer is visible into.
  116964. */
  116965. renderTargetTextures: RenderTargetTexture[];
  116966. /**
  116967. * Define if the layer is only used in renderTarget or if it also
  116968. * renders in the main frame buffer of the canvas.
  116969. */
  116970. renderOnlyInRenderTargetTextures: boolean;
  116971. private _scene;
  116972. private _vertexBuffers;
  116973. private _indexBuffer;
  116974. private _effect;
  116975. private _alphaTestEffect;
  116976. /**
  116977. * An event triggered when the layer is disposed.
  116978. */
  116979. onDisposeObservable: Observable<Layer>;
  116980. private _onDisposeObserver;
  116981. /**
  116982. * Back compatibility with callback before the onDisposeObservable existed.
  116983. * The set callback will be triggered when the layer has been disposed.
  116984. */
  116985. onDispose: () => void;
  116986. /**
  116987. * An event triggered before rendering the scene
  116988. */
  116989. onBeforeRenderObservable: Observable<Layer>;
  116990. private _onBeforeRenderObserver;
  116991. /**
  116992. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116993. * The set callback will be triggered just before rendering the layer.
  116994. */
  116995. onBeforeRender: () => void;
  116996. /**
  116997. * An event triggered after rendering the scene
  116998. */
  116999. onAfterRenderObservable: Observable<Layer>;
  117000. private _onAfterRenderObserver;
  117001. /**
  117002. * Back compatibility with callback before the onAfterRenderObservable existed.
  117003. * The set callback will be triggered just after rendering the layer.
  117004. */
  117005. onAfterRender: () => void;
  117006. /**
  117007. * Instantiates a new layer.
  117008. * This represents a full screen 2d layer.
  117009. * This can be useful to display a picture in the background of your scene for instance.
  117010. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117011. * @param name Define the name of the layer in the scene
  117012. * @param imgUrl Define the url of the texture to display in the layer
  117013. * @param scene Define the scene the layer belongs to
  117014. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117015. * @param color Defines a color for the layer
  117016. */
  117017. constructor(
  117018. /**
  117019. * Define the name of the layer.
  117020. */
  117021. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117022. private _createIndexBuffer;
  117023. /** @hidden */
  117024. _rebuild(): void;
  117025. /**
  117026. * Renders the layer in the scene.
  117027. */
  117028. render(): void;
  117029. /**
  117030. * Disposes and releases the associated ressources.
  117031. */
  117032. dispose(): void;
  117033. }
  117034. }
  117035. declare module BABYLON {
  117036. /** @hidden */
  117037. export var lensFlarePixelShader: {
  117038. name: string;
  117039. shader: string;
  117040. };
  117041. }
  117042. declare module BABYLON {
  117043. /** @hidden */
  117044. export var lensFlareVertexShader: {
  117045. name: string;
  117046. shader: string;
  117047. };
  117048. }
  117049. declare module BABYLON {
  117050. /**
  117051. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117052. * It is usually composed of several `lensFlare`.
  117053. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117054. */
  117055. export class LensFlareSystem {
  117056. /**
  117057. * Define the name of the lens flare system
  117058. */
  117059. name: string;
  117060. /**
  117061. * List of lens flares used in this system.
  117062. */
  117063. lensFlares: LensFlare[];
  117064. /**
  117065. * Define a limit from the border the lens flare can be visible.
  117066. */
  117067. borderLimit: number;
  117068. /**
  117069. * Define a viewport border we do not want to see the lens flare in.
  117070. */
  117071. viewportBorder: number;
  117072. /**
  117073. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117074. */
  117075. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117076. /**
  117077. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117078. */
  117079. layerMask: number;
  117080. /**
  117081. * Define the id of the lens flare system in the scene.
  117082. * (equal to name by default)
  117083. */
  117084. id: string;
  117085. private _scene;
  117086. private _emitter;
  117087. private _vertexBuffers;
  117088. private _indexBuffer;
  117089. private _effect;
  117090. private _positionX;
  117091. private _positionY;
  117092. private _isEnabled;
  117093. /** @hidden */
  117094. static _SceneComponentInitialization: (scene: Scene) => void;
  117095. /**
  117096. * Instantiates a lens flare system.
  117097. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117098. * It is usually composed of several `lensFlare`.
  117099. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117100. * @param name Define the name of the lens flare system in the scene
  117101. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117102. * @param scene Define the scene the lens flare system belongs to
  117103. */
  117104. constructor(
  117105. /**
  117106. * Define the name of the lens flare system
  117107. */
  117108. name: string, emitter: any, scene: Scene);
  117109. /**
  117110. * Define if the lens flare system is enabled.
  117111. */
  117112. isEnabled: boolean;
  117113. /**
  117114. * Get the scene the effects belongs to.
  117115. * @returns the scene holding the lens flare system
  117116. */
  117117. getScene(): Scene;
  117118. /**
  117119. * Get the emitter of the lens flare system.
  117120. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117121. * @returns the emitter of the lens flare system
  117122. */
  117123. getEmitter(): any;
  117124. /**
  117125. * Set the emitter of the lens flare system.
  117126. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117127. * @param newEmitter Define the new emitter of the system
  117128. */
  117129. setEmitter(newEmitter: any): void;
  117130. /**
  117131. * Get the lens flare system emitter position.
  117132. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117133. * @returns the position
  117134. */
  117135. getEmitterPosition(): Vector3;
  117136. /**
  117137. * @hidden
  117138. */
  117139. computeEffectivePosition(globalViewport: Viewport): boolean;
  117140. /** @hidden */
  117141. _isVisible(): boolean;
  117142. /**
  117143. * @hidden
  117144. */
  117145. render(): boolean;
  117146. /**
  117147. * Dispose and release the lens flare with its associated resources.
  117148. */
  117149. dispose(): void;
  117150. /**
  117151. * Parse a lens flare system from a JSON repressentation
  117152. * @param parsedLensFlareSystem Define the JSON to parse
  117153. * @param scene Define the scene the parsed system should be instantiated in
  117154. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117155. * @returns the parsed system
  117156. */
  117157. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117158. /**
  117159. * Serialize the current Lens Flare System into a JSON representation.
  117160. * @returns the serialized JSON
  117161. */
  117162. serialize(): any;
  117163. }
  117164. }
  117165. declare module BABYLON {
  117166. /**
  117167. * This represents one of the lens effect in a `lensFlareSystem`.
  117168. * It controls one of the indiviual texture used in the effect.
  117169. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117170. */
  117171. export class LensFlare {
  117172. /**
  117173. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117174. */
  117175. size: number;
  117176. /**
  117177. * 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.
  117178. */
  117179. position: number;
  117180. /**
  117181. * Define the lens color.
  117182. */
  117183. color: Color3;
  117184. /**
  117185. * Define the lens texture.
  117186. */
  117187. texture: Nullable<Texture>;
  117188. /**
  117189. * Define the alpha mode to render this particular lens.
  117190. */
  117191. alphaMode: number;
  117192. private _system;
  117193. /**
  117194. * Creates a new Lens Flare.
  117195. * This represents one of the lens effect in a `lensFlareSystem`.
  117196. * It controls one of the indiviual texture used in the effect.
  117197. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117198. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117199. * @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.
  117200. * @param color Define the lens color
  117201. * @param imgUrl Define the lens texture url
  117202. * @param system Define the `lensFlareSystem` this flare is part of
  117203. * @returns The newly created Lens Flare
  117204. */
  117205. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117206. /**
  117207. * Instantiates a new Lens Flare.
  117208. * This represents one of the lens effect in a `lensFlareSystem`.
  117209. * It controls one of the indiviual texture used in the effect.
  117210. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117211. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117212. * @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.
  117213. * @param color Define the lens color
  117214. * @param imgUrl Define the lens texture url
  117215. * @param system Define the `lensFlareSystem` this flare is part of
  117216. */
  117217. constructor(
  117218. /**
  117219. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117220. */
  117221. size: number,
  117222. /**
  117223. * 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.
  117224. */
  117225. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117226. /**
  117227. * Dispose and release the lens flare with its associated resources.
  117228. */
  117229. dispose(): void;
  117230. }
  117231. }
  117232. declare module BABYLON {
  117233. interface AbstractScene {
  117234. /**
  117235. * The list of lens flare system added to the scene
  117236. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117237. */
  117238. lensFlareSystems: Array<LensFlareSystem>;
  117239. /**
  117240. * Removes the given lens flare system from this scene.
  117241. * @param toRemove The lens flare system to remove
  117242. * @returns The index of the removed lens flare system
  117243. */
  117244. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117245. /**
  117246. * Adds the given lens flare system to this scene
  117247. * @param newLensFlareSystem The lens flare system to add
  117248. */
  117249. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117250. /**
  117251. * Gets a lens flare system using its name
  117252. * @param name defines the name to look for
  117253. * @returns the lens flare system or null if not found
  117254. */
  117255. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117256. /**
  117257. * Gets a lens flare system using its id
  117258. * @param id defines the id to look for
  117259. * @returns the lens flare system or null if not found
  117260. */
  117261. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117262. }
  117263. /**
  117264. * Defines the lens flare scene component responsible to manage any lens flares
  117265. * in a given scene.
  117266. */
  117267. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117268. /**
  117269. * The component name helpfull to identify the component in the list of scene components.
  117270. */
  117271. readonly name: string;
  117272. /**
  117273. * The scene the component belongs to.
  117274. */
  117275. scene: Scene;
  117276. /**
  117277. * Creates a new instance of the component for the given scene
  117278. * @param scene Defines the scene to register the component in
  117279. */
  117280. constructor(scene: Scene);
  117281. /**
  117282. * Registers the component in a given scene
  117283. */
  117284. register(): void;
  117285. /**
  117286. * Rebuilds the elements related to this component in case of
  117287. * context lost for instance.
  117288. */
  117289. rebuild(): void;
  117290. /**
  117291. * Adds all the elements from the container to the scene
  117292. * @param container the container holding the elements
  117293. */
  117294. addFromContainer(container: AbstractScene): void;
  117295. /**
  117296. * Removes all the elements in the container from the scene
  117297. * @param container contains the elements to remove
  117298. * @param dispose if the removed element should be disposed (default: false)
  117299. */
  117300. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117301. /**
  117302. * Serializes the component data to the specified json object
  117303. * @param serializationObject The object to serialize to
  117304. */
  117305. serialize(serializationObject: any): void;
  117306. /**
  117307. * Disposes the component and the associated ressources.
  117308. */
  117309. dispose(): void;
  117310. private _draw;
  117311. }
  117312. }
  117313. declare module BABYLON {
  117314. /**
  117315. * Defines the shadow generator component responsible to manage any shadow generators
  117316. * in a given scene.
  117317. */
  117318. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117319. /**
  117320. * The component name helpfull to identify the component in the list of scene components.
  117321. */
  117322. readonly name: string;
  117323. /**
  117324. * The scene the component belongs to.
  117325. */
  117326. scene: Scene;
  117327. /**
  117328. * Creates a new instance of the component for the given scene
  117329. * @param scene Defines the scene to register the component in
  117330. */
  117331. constructor(scene: Scene);
  117332. /**
  117333. * Registers the component in a given scene
  117334. */
  117335. register(): void;
  117336. /**
  117337. * Rebuilds the elements related to this component in case of
  117338. * context lost for instance.
  117339. */
  117340. rebuild(): void;
  117341. /**
  117342. * Serializes the component data to the specified json object
  117343. * @param serializationObject The object to serialize to
  117344. */
  117345. serialize(serializationObject: any): void;
  117346. /**
  117347. * Adds all the elements from the container to the scene
  117348. * @param container the container holding the elements
  117349. */
  117350. addFromContainer(container: AbstractScene): void;
  117351. /**
  117352. * Removes all the elements in the container from the scene
  117353. * @param container contains the elements to remove
  117354. * @param dispose if the removed element should be disposed (default: false)
  117355. */
  117356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117357. /**
  117358. * Rebuilds the elements related to this component in case of
  117359. * context lost for instance.
  117360. */
  117361. dispose(): void;
  117362. private _gatherRenderTargets;
  117363. }
  117364. }
  117365. declare module BABYLON {
  117366. /**
  117367. * A point light is a light defined by an unique point in world space.
  117368. * The light is emitted in every direction from this point.
  117369. * A good example of a point light is a standard light bulb.
  117370. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117371. */
  117372. export class PointLight extends ShadowLight {
  117373. private _shadowAngle;
  117374. /**
  117375. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117376. * This specifies what angle the shadow will use to be created.
  117377. *
  117378. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117379. */
  117380. /**
  117381. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117382. * This specifies what angle the shadow will use to be created.
  117383. *
  117384. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117385. */
  117386. shadowAngle: number;
  117387. /**
  117388. * Gets the direction if it has been set.
  117389. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117390. */
  117391. /**
  117392. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117393. */
  117394. direction: Vector3;
  117395. /**
  117396. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117397. * A PointLight emits the light in every direction.
  117398. * It can cast shadows.
  117399. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117400. * ```javascript
  117401. * var pointLight = new PointLight("pl", camera.position, scene);
  117402. * ```
  117403. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117404. * @param name The light friendly name
  117405. * @param position The position of the point light in the scene
  117406. * @param scene The scene the lights belongs to
  117407. */
  117408. constructor(name: string, position: Vector3, scene: Scene);
  117409. /**
  117410. * Returns the string "PointLight"
  117411. * @returns the class name
  117412. */
  117413. getClassName(): string;
  117414. /**
  117415. * Returns the integer 0.
  117416. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117417. */
  117418. getTypeID(): number;
  117419. /**
  117420. * Specifies wether or not the shadowmap should be a cube texture.
  117421. * @returns true if the shadowmap needs to be a cube texture.
  117422. */
  117423. needCube(): boolean;
  117424. /**
  117425. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117426. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117427. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117428. */
  117429. getShadowDirection(faceIndex?: number): Vector3;
  117430. /**
  117431. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117432. * - fov = PI / 2
  117433. * - aspect ratio : 1.0
  117434. * - z-near and far equal to the active camera minZ and maxZ.
  117435. * Returns the PointLight.
  117436. */
  117437. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117438. protected _buildUniformLayout(): void;
  117439. /**
  117440. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117441. * @param effect The effect to update
  117442. * @param lightIndex The index of the light in the effect to update
  117443. * @returns The point light
  117444. */
  117445. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117446. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117447. /**
  117448. * Prepares the list of defines specific to the light type.
  117449. * @param defines the list of defines
  117450. * @param lightIndex defines the index of the light for the effect
  117451. */
  117452. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117453. }
  117454. }
  117455. declare module BABYLON {
  117456. /**
  117457. * Header information of HDR texture files.
  117458. */
  117459. export interface HDRInfo {
  117460. /**
  117461. * The height of the texture in pixels.
  117462. */
  117463. height: number;
  117464. /**
  117465. * The width of the texture in pixels.
  117466. */
  117467. width: number;
  117468. /**
  117469. * The index of the beginning of the data in the binary file.
  117470. */
  117471. dataPosition: number;
  117472. }
  117473. /**
  117474. * This groups tools to convert HDR texture to native colors array.
  117475. */
  117476. export class HDRTools {
  117477. private static Ldexp;
  117478. private static Rgbe2float;
  117479. private static readStringLine;
  117480. /**
  117481. * Reads header information from an RGBE texture stored in a native array.
  117482. * More information on this format are available here:
  117483. * https://en.wikipedia.org/wiki/RGBE_image_format
  117484. *
  117485. * @param uint8array The binary file stored in native array.
  117486. * @return The header information.
  117487. */
  117488. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117489. /**
  117490. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117491. * This RGBE texture needs to store the information as a panorama.
  117492. *
  117493. * More information on this format are available here:
  117494. * https://en.wikipedia.org/wiki/RGBE_image_format
  117495. *
  117496. * @param buffer The binary file stored in an array buffer.
  117497. * @param size The expected size of the extracted cubemap.
  117498. * @return The Cube Map information.
  117499. */
  117500. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117501. /**
  117502. * Returns the pixels data extracted from an RGBE texture.
  117503. * This pixels will be stored left to right up to down in the R G B order in one array.
  117504. *
  117505. * More information on this format are available here:
  117506. * https://en.wikipedia.org/wiki/RGBE_image_format
  117507. *
  117508. * @param uint8array The binary file stored in an array buffer.
  117509. * @param hdrInfo The header information of the file.
  117510. * @return The pixels data in RGB right to left up to down order.
  117511. */
  117512. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117513. private static RGBE_ReadPixels_RLE;
  117514. }
  117515. }
  117516. declare module BABYLON {
  117517. /**
  117518. * This represents a texture coming from an HDR input.
  117519. *
  117520. * The only supported format is currently panorama picture stored in RGBE format.
  117521. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117522. */
  117523. export class HDRCubeTexture extends BaseTexture {
  117524. private static _facesMapping;
  117525. private _generateHarmonics;
  117526. private _noMipmap;
  117527. private _textureMatrix;
  117528. private _size;
  117529. private _onLoad;
  117530. private _onError;
  117531. /**
  117532. * The texture URL.
  117533. */
  117534. url: string;
  117535. /**
  117536. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117537. */
  117538. coordinatesMode: number;
  117539. protected _isBlocking: boolean;
  117540. /**
  117541. * Sets wether or not the texture is blocking during loading.
  117542. */
  117543. /**
  117544. * Gets wether or not the texture is blocking during loading.
  117545. */
  117546. isBlocking: boolean;
  117547. protected _rotationY: number;
  117548. /**
  117549. * Sets texture matrix rotation angle around Y axis in radians.
  117550. */
  117551. /**
  117552. * Gets texture matrix rotation angle around Y axis radians.
  117553. */
  117554. rotationY: number;
  117555. /**
  117556. * Gets or sets the center of the bounding box associated with the cube texture
  117557. * It must define where the camera used to render the texture was set
  117558. */
  117559. boundingBoxPosition: Vector3;
  117560. private _boundingBoxSize;
  117561. /**
  117562. * Gets or sets the size of the bounding box associated with the cube texture
  117563. * When defined, the cubemap will switch to local mode
  117564. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117565. * @example https://www.babylonjs-playground.com/#RNASML
  117566. */
  117567. boundingBoxSize: Vector3;
  117568. /**
  117569. * Instantiates an HDRTexture from the following parameters.
  117570. *
  117571. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117572. * @param scene The scene the texture will be used in
  117573. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117574. * @param noMipmap Forces to not generate the mipmap if true
  117575. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117576. * @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)
  117577. * @param reserved Reserved flag for internal use.
  117578. */
  117579. 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>);
  117580. /**
  117581. * Get the current class name of the texture useful for serialization or dynamic coding.
  117582. * @returns "HDRCubeTexture"
  117583. */
  117584. getClassName(): string;
  117585. /**
  117586. * Occurs when the file is raw .hdr file.
  117587. */
  117588. private loadTexture;
  117589. clone(): HDRCubeTexture;
  117590. delayLoad(): void;
  117591. /**
  117592. * Get the texture reflection matrix used to rotate/transform the reflection.
  117593. * @returns the reflection matrix
  117594. */
  117595. getReflectionTextureMatrix(): Matrix;
  117596. /**
  117597. * Set the texture reflection matrix used to rotate/transform the reflection.
  117598. * @param value Define the reflection matrix to set
  117599. */
  117600. setReflectionTextureMatrix(value: Matrix): void;
  117601. /**
  117602. * Parses a JSON representation of an HDR Texture in order to create the texture
  117603. * @param parsedTexture Define the JSON representation
  117604. * @param scene Define the scene the texture should be created in
  117605. * @param rootUrl Define the root url in case we need to load relative dependencies
  117606. * @returns the newly created texture after parsing
  117607. */
  117608. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117609. serialize(): any;
  117610. }
  117611. }
  117612. declare module BABYLON {
  117613. /**
  117614. * Class used to control physics engine
  117615. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117616. */
  117617. export class PhysicsEngine implements IPhysicsEngine {
  117618. private _physicsPlugin;
  117619. /**
  117620. * Global value used to control the smallest number supported by the simulation
  117621. */
  117622. static Epsilon: number;
  117623. private _impostors;
  117624. private _joints;
  117625. /**
  117626. * Gets the gravity vector used by the simulation
  117627. */
  117628. gravity: Vector3;
  117629. /**
  117630. * Factory used to create the default physics plugin.
  117631. * @returns The default physics plugin
  117632. */
  117633. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117634. /**
  117635. * Creates a new Physics Engine
  117636. * @param gravity defines the gravity vector used by the simulation
  117637. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117638. */
  117639. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117640. /**
  117641. * Sets the gravity vector used by the simulation
  117642. * @param gravity defines the gravity vector to use
  117643. */
  117644. setGravity(gravity: Vector3): void;
  117645. /**
  117646. * Set the time step of the physics engine.
  117647. * Default is 1/60.
  117648. * To slow it down, enter 1/600 for example.
  117649. * To speed it up, 1/30
  117650. * @param newTimeStep defines the new timestep to apply to this world.
  117651. */
  117652. setTimeStep(newTimeStep?: number): void;
  117653. /**
  117654. * Get the time step of the physics engine.
  117655. * @returns the current time step
  117656. */
  117657. getTimeStep(): number;
  117658. /**
  117659. * Release all resources
  117660. */
  117661. dispose(): void;
  117662. /**
  117663. * Gets the name of the current physics plugin
  117664. * @returns the name of the plugin
  117665. */
  117666. getPhysicsPluginName(): string;
  117667. /**
  117668. * Adding a new impostor for the impostor tracking.
  117669. * This will be done by the impostor itself.
  117670. * @param impostor the impostor to add
  117671. */
  117672. addImpostor(impostor: PhysicsImpostor): void;
  117673. /**
  117674. * Remove an impostor from the engine.
  117675. * This impostor and its mesh will not longer be updated by the physics engine.
  117676. * @param impostor the impostor to remove
  117677. */
  117678. removeImpostor(impostor: PhysicsImpostor): void;
  117679. /**
  117680. * Add a joint to the physics engine
  117681. * @param mainImpostor defines the main impostor to which the joint is added.
  117682. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117683. * @param joint defines the joint that will connect both impostors.
  117684. */
  117685. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117686. /**
  117687. * Removes a joint from the simulation
  117688. * @param mainImpostor defines the impostor used with the joint
  117689. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117690. * @param joint defines the joint to remove
  117691. */
  117692. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117693. /**
  117694. * Called by the scene. No need to call it.
  117695. * @param delta defines the timespam between frames
  117696. */
  117697. _step(delta: number): void;
  117698. /**
  117699. * Gets the current plugin used to run the simulation
  117700. * @returns current plugin
  117701. */
  117702. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117703. /**
  117704. * Gets the list of physic impostors
  117705. * @returns an array of PhysicsImpostor
  117706. */
  117707. getImpostors(): Array<PhysicsImpostor>;
  117708. /**
  117709. * Gets the impostor for a physics enabled object
  117710. * @param object defines the object impersonated by the impostor
  117711. * @returns the PhysicsImpostor or null if not found
  117712. */
  117713. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117714. /**
  117715. * Gets the impostor for a physics body object
  117716. * @param body defines physics body used by the impostor
  117717. * @returns the PhysicsImpostor or null if not found
  117718. */
  117719. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117720. /**
  117721. * Does a raycast in the physics world
  117722. * @param from when should the ray start?
  117723. * @param to when should the ray end?
  117724. * @returns PhysicsRaycastResult
  117725. */
  117726. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117727. }
  117728. }
  117729. declare module BABYLON {
  117730. /** @hidden */
  117731. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117732. private _useDeltaForWorldStep;
  117733. world: any;
  117734. name: string;
  117735. private _physicsMaterials;
  117736. private _fixedTimeStep;
  117737. private _cannonRaycastResult;
  117738. private _raycastResult;
  117739. private _physicsBodysToRemoveAfterStep;
  117740. BJSCANNON: any;
  117741. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117742. setGravity(gravity: Vector3): void;
  117743. setTimeStep(timeStep: number): void;
  117744. getTimeStep(): number;
  117745. executeStep(delta: number): void;
  117746. private _removeMarkedPhysicsBodiesFromWorld;
  117747. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117748. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117749. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117750. private _processChildMeshes;
  117751. removePhysicsBody(impostor: PhysicsImpostor): void;
  117752. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117753. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117754. private _addMaterial;
  117755. private _checkWithEpsilon;
  117756. private _createShape;
  117757. private _createHeightmap;
  117758. private _minus90X;
  117759. private _plus90X;
  117760. private _tmpPosition;
  117761. private _tmpDeltaPosition;
  117762. private _tmpUnityRotation;
  117763. private _updatePhysicsBodyTransformation;
  117764. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117765. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117766. isSupported(): boolean;
  117767. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117768. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117769. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117770. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117771. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117772. getBodyMass(impostor: PhysicsImpostor): number;
  117773. getBodyFriction(impostor: PhysicsImpostor): number;
  117774. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117775. getBodyRestitution(impostor: PhysicsImpostor): number;
  117776. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117777. sleepBody(impostor: PhysicsImpostor): void;
  117778. wakeUpBody(impostor: PhysicsImpostor): void;
  117779. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117780. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117781. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117782. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117783. getRadius(impostor: PhysicsImpostor): number;
  117784. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117785. dispose(): void;
  117786. private _extendNamespace;
  117787. /**
  117788. * Does a raycast in the physics world
  117789. * @param from when should the ray start?
  117790. * @param to when should the ray end?
  117791. * @returns PhysicsRaycastResult
  117792. */
  117793. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117794. }
  117795. }
  117796. declare module BABYLON {
  117797. /** @hidden */
  117798. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117799. world: any;
  117800. name: string;
  117801. BJSOIMO: any;
  117802. private _raycastResult;
  117803. constructor(iterations?: number, oimoInjection?: any);
  117804. setGravity(gravity: Vector3): void;
  117805. setTimeStep(timeStep: number): void;
  117806. getTimeStep(): number;
  117807. private _tmpImpostorsArray;
  117808. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117809. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117810. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117811. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117812. private _tmpPositionVector;
  117813. removePhysicsBody(impostor: PhysicsImpostor): void;
  117814. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117815. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117816. isSupported(): boolean;
  117817. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117818. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117819. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117820. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117821. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117822. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117823. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117824. getBodyMass(impostor: PhysicsImpostor): number;
  117825. getBodyFriction(impostor: PhysicsImpostor): number;
  117826. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117827. getBodyRestitution(impostor: PhysicsImpostor): number;
  117828. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117829. sleepBody(impostor: PhysicsImpostor): void;
  117830. wakeUpBody(impostor: PhysicsImpostor): void;
  117831. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117832. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117833. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117835. getRadius(impostor: PhysicsImpostor): number;
  117836. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117837. dispose(): void;
  117838. /**
  117839. * Does a raycast in the physics world
  117840. * @param from when should the ray start?
  117841. * @param to when should the ray end?
  117842. * @returns PhysicsRaycastResult
  117843. */
  117844. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117845. }
  117846. }
  117847. declare module BABYLON {
  117848. /**
  117849. * Class containing static functions to help procedurally build meshes
  117850. */
  117851. export class RibbonBuilder {
  117852. /**
  117853. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117854. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117855. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117856. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117857. * * 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
  117858. * * 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
  117859. * * 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
  117860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117863. * * 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
  117864. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117865. * * 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
  117866. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117868. * @param name defines the name of the mesh
  117869. * @param options defines the options used to create the mesh
  117870. * @param scene defines the hosting scene
  117871. * @returns the ribbon mesh
  117872. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117873. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117874. */
  117875. static CreateRibbon(name: string, options: {
  117876. pathArray: Vector3[][];
  117877. closeArray?: boolean;
  117878. closePath?: boolean;
  117879. offset?: number;
  117880. updatable?: boolean;
  117881. sideOrientation?: number;
  117882. frontUVs?: Vector4;
  117883. backUVs?: Vector4;
  117884. instance?: Mesh;
  117885. invertUV?: boolean;
  117886. uvs?: Vector2[];
  117887. colors?: Color4[];
  117888. }, scene?: Nullable<Scene>): Mesh;
  117889. }
  117890. }
  117891. declare module BABYLON {
  117892. /**
  117893. * Class containing static functions to help procedurally build meshes
  117894. */
  117895. export class ShapeBuilder {
  117896. /**
  117897. * 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.
  117898. * * 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.
  117899. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117900. * * 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.
  117901. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117902. * * 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
  117903. * * 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
  117904. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117909. * @param name defines the name of the mesh
  117910. * @param options defines the options used to create the mesh
  117911. * @param scene defines the hosting scene
  117912. * @returns the extruded shape mesh
  117913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117915. */
  117916. static ExtrudeShape(name: string, options: {
  117917. shape: Vector3[];
  117918. path: Vector3[];
  117919. scale?: number;
  117920. rotation?: number;
  117921. cap?: number;
  117922. updatable?: boolean;
  117923. sideOrientation?: number;
  117924. frontUVs?: Vector4;
  117925. backUVs?: Vector4;
  117926. instance?: Mesh;
  117927. invertUV?: boolean;
  117928. }, scene?: Nullable<Scene>): Mesh;
  117929. /**
  117930. * Creates an custom extruded shape mesh.
  117931. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117932. * * 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.
  117933. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117934. * * 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
  117935. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117936. * * 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
  117937. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117938. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117939. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117940. * * 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
  117941. * * 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
  117942. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117945. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117947. * @param name defines the name of the mesh
  117948. * @param options defines the options used to create the mesh
  117949. * @param scene defines the hosting scene
  117950. * @returns the custom extruded shape mesh
  117951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117952. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117954. */
  117955. static ExtrudeShapeCustom(name: string, options: {
  117956. shape: Vector3[];
  117957. path: Vector3[];
  117958. scaleFunction?: any;
  117959. rotationFunction?: any;
  117960. ribbonCloseArray?: boolean;
  117961. ribbonClosePath?: boolean;
  117962. cap?: number;
  117963. updatable?: boolean;
  117964. sideOrientation?: number;
  117965. frontUVs?: Vector4;
  117966. backUVs?: Vector4;
  117967. instance?: Mesh;
  117968. invertUV?: boolean;
  117969. }, scene?: Nullable<Scene>): Mesh;
  117970. private static _ExtrudeShapeGeneric;
  117971. }
  117972. }
  117973. declare module BABYLON {
  117974. /**
  117975. * AmmoJS Physics plugin
  117976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117977. * @see https://github.com/kripken/ammo.js/
  117978. */
  117979. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117980. private _useDeltaForWorldStep;
  117981. /**
  117982. * Reference to the Ammo library
  117983. */
  117984. bjsAMMO: any;
  117985. /**
  117986. * Created ammoJS world which physics bodies are added to
  117987. */
  117988. world: any;
  117989. /**
  117990. * Name of the plugin
  117991. */
  117992. name: string;
  117993. private _timeStep;
  117994. private _fixedTimeStep;
  117995. private _maxSteps;
  117996. private _tmpQuaternion;
  117997. private _tmpAmmoTransform;
  117998. private _tmpAmmoQuaternion;
  117999. private _tmpAmmoConcreteContactResultCallback;
  118000. private _collisionConfiguration;
  118001. private _dispatcher;
  118002. private _overlappingPairCache;
  118003. private _solver;
  118004. private _softBodySolver;
  118005. private _tmpAmmoVectorA;
  118006. private _tmpAmmoVectorB;
  118007. private _tmpAmmoVectorC;
  118008. private _tmpAmmoVectorD;
  118009. private _tmpContactCallbackResult;
  118010. private _tmpAmmoVectorRCA;
  118011. private _tmpAmmoVectorRCB;
  118012. private _raycastResult;
  118013. private static readonly DISABLE_COLLISION_FLAG;
  118014. private static readonly KINEMATIC_FLAG;
  118015. private static readonly DISABLE_DEACTIVATION_FLAG;
  118016. /**
  118017. * Initializes the ammoJS plugin
  118018. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118019. * @param ammoInjection can be used to inject your own ammo reference
  118020. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118021. */
  118022. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118023. /**
  118024. * Sets the gravity of the physics world (m/(s^2))
  118025. * @param gravity Gravity to set
  118026. */
  118027. setGravity(gravity: Vector3): void;
  118028. /**
  118029. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118030. * @param timeStep timestep to use in seconds
  118031. */
  118032. setTimeStep(timeStep: number): void;
  118033. /**
  118034. * 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)
  118035. * @param fixedTimeStep fixedTimeStep to use in seconds
  118036. */
  118037. setFixedTimeStep(fixedTimeStep: number): void;
  118038. /**
  118039. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118040. * @param maxSteps the maximum number of steps by the physics engine per frame
  118041. */
  118042. setMaxSteps(maxSteps: number): void;
  118043. /**
  118044. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118045. * @returns the current timestep in seconds
  118046. */
  118047. getTimeStep(): number;
  118048. private _isImpostorInContact;
  118049. private _isImpostorPairInContact;
  118050. private _stepSimulation;
  118051. /**
  118052. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118053. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118054. * After the step the babylon meshes are set to the position of the physics imposters
  118055. * @param delta amount of time to step forward
  118056. * @param impostors array of imposters to update before/after the step
  118057. */
  118058. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118059. /**
  118060. * Update babylon mesh to match physics world object
  118061. * @param impostor imposter to match
  118062. */
  118063. private _afterSoftStep;
  118064. /**
  118065. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118066. * @param impostor imposter to match
  118067. */
  118068. private _ropeStep;
  118069. /**
  118070. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118071. * @param impostor imposter to match
  118072. */
  118073. private _softbodyOrClothStep;
  118074. private _tmpVector;
  118075. private _tmpMatrix;
  118076. /**
  118077. * Applies an impulse on the imposter
  118078. * @param impostor imposter to apply impulse to
  118079. * @param force amount of force to be applied to the imposter
  118080. * @param contactPoint the location to apply the impulse on the imposter
  118081. */
  118082. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118083. /**
  118084. * Applies a force on the imposter
  118085. * @param impostor imposter to apply force
  118086. * @param force amount of force to be applied to the imposter
  118087. * @param contactPoint the location to apply the force on the imposter
  118088. */
  118089. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118090. /**
  118091. * Creates a physics body using the plugin
  118092. * @param impostor the imposter to create the physics body on
  118093. */
  118094. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118095. /**
  118096. * Removes the physics body from the imposter and disposes of the body's memory
  118097. * @param impostor imposter to remove the physics body from
  118098. */
  118099. removePhysicsBody(impostor: PhysicsImpostor): void;
  118100. /**
  118101. * Generates a joint
  118102. * @param impostorJoint the imposter joint to create the joint with
  118103. */
  118104. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118105. /**
  118106. * Removes a joint
  118107. * @param impostorJoint the imposter joint to remove the joint from
  118108. */
  118109. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118110. private _addMeshVerts;
  118111. /**
  118112. * Initialise the soft body vertices to match its object's (mesh) vertices
  118113. * Softbody vertices (nodes) are in world space and to match this
  118114. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118115. * @param impostor to create the softbody for
  118116. */
  118117. private _softVertexData;
  118118. /**
  118119. * Create an impostor's soft body
  118120. * @param impostor to create the softbody for
  118121. */
  118122. private _createSoftbody;
  118123. /**
  118124. * Create cloth for an impostor
  118125. * @param impostor to create the softbody for
  118126. */
  118127. private _createCloth;
  118128. /**
  118129. * Create rope for an impostor
  118130. * @param impostor to create the softbody for
  118131. */
  118132. private _createRope;
  118133. private _addHullVerts;
  118134. private _createShape;
  118135. /**
  118136. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118137. * @param impostor imposter containing the physics body and babylon object
  118138. */
  118139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118140. /**
  118141. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118142. * @param impostor imposter containing the physics body and babylon object
  118143. * @param newPosition new position
  118144. * @param newRotation new rotation
  118145. */
  118146. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118147. /**
  118148. * If this plugin is supported
  118149. * @returns true if its supported
  118150. */
  118151. isSupported(): boolean;
  118152. /**
  118153. * Sets the linear velocity of the physics body
  118154. * @param impostor imposter to set the velocity on
  118155. * @param velocity velocity to set
  118156. */
  118157. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118158. /**
  118159. * Sets the angular velocity of the physics body
  118160. * @param impostor imposter to set the velocity on
  118161. * @param velocity velocity to set
  118162. */
  118163. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118164. /**
  118165. * gets the linear velocity
  118166. * @param impostor imposter to get linear velocity from
  118167. * @returns linear velocity
  118168. */
  118169. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118170. /**
  118171. * gets the angular velocity
  118172. * @param impostor imposter to get angular velocity from
  118173. * @returns angular velocity
  118174. */
  118175. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118176. /**
  118177. * Sets the mass of physics body
  118178. * @param impostor imposter to set the mass on
  118179. * @param mass mass to set
  118180. */
  118181. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118182. /**
  118183. * Gets the mass of the physics body
  118184. * @param impostor imposter to get the mass from
  118185. * @returns mass
  118186. */
  118187. getBodyMass(impostor: PhysicsImpostor): number;
  118188. /**
  118189. * Gets friction of the impostor
  118190. * @param impostor impostor to get friction from
  118191. * @returns friction value
  118192. */
  118193. getBodyFriction(impostor: PhysicsImpostor): number;
  118194. /**
  118195. * Sets friction of the impostor
  118196. * @param impostor impostor to set friction on
  118197. * @param friction friction value
  118198. */
  118199. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118200. /**
  118201. * Gets restitution of the impostor
  118202. * @param impostor impostor to get restitution from
  118203. * @returns restitution value
  118204. */
  118205. getBodyRestitution(impostor: PhysicsImpostor): number;
  118206. /**
  118207. * Sets resitution of the impostor
  118208. * @param impostor impostor to set resitution on
  118209. * @param restitution resitution value
  118210. */
  118211. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118212. /**
  118213. * Gets pressure inside the impostor
  118214. * @param impostor impostor to get pressure from
  118215. * @returns pressure value
  118216. */
  118217. getBodyPressure(impostor: PhysicsImpostor): number;
  118218. /**
  118219. * Sets pressure inside a soft body impostor
  118220. * Cloth and rope must remain 0 pressure
  118221. * @param impostor impostor to set pressure on
  118222. * @param pressure pressure value
  118223. */
  118224. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118225. /**
  118226. * Gets stiffness of the impostor
  118227. * @param impostor impostor to get stiffness from
  118228. * @returns pressure value
  118229. */
  118230. getBodyStiffness(impostor: PhysicsImpostor): number;
  118231. /**
  118232. * Sets stiffness of the impostor
  118233. * @param impostor impostor to set stiffness on
  118234. * @param stiffness stiffness value from 0 to 1
  118235. */
  118236. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118237. /**
  118238. * Gets velocityIterations of the impostor
  118239. * @param impostor impostor to get velocity iterations from
  118240. * @returns velocityIterations value
  118241. */
  118242. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118243. /**
  118244. * Sets velocityIterations of the impostor
  118245. * @param impostor impostor to set velocity iterations on
  118246. * @param velocityIterations velocityIterations value
  118247. */
  118248. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118249. /**
  118250. * Gets positionIterations of the impostor
  118251. * @param impostor impostor to get position iterations from
  118252. * @returns positionIterations value
  118253. */
  118254. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118255. /**
  118256. * Sets positionIterations of the impostor
  118257. * @param impostor impostor to set position on
  118258. * @param positionIterations positionIterations value
  118259. */
  118260. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118261. /**
  118262. * Append an anchor to a cloth object
  118263. * @param impostor is the cloth impostor to add anchor to
  118264. * @param otherImpostor is the rigid impostor to anchor to
  118265. * @param width ratio across width from 0 to 1
  118266. * @param height ratio up height from 0 to 1
  118267. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118268. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118269. */
  118270. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118271. /**
  118272. * Append an hook to a rope object
  118273. * @param impostor is the rope impostor to add hook to
  118274. * @param otherImpostor is the rigid impostor to hook to
  118275. * @param length ratio along the rope from 0 to 1
  118276. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118277. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118278. */
  118279. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118280. /**
  118281. * Sleeps the physics body and stops it from being active
  118282. * @param impostor impostor to sleep
  118283. */
  118284. sleepBody(impostor: PhysicsImpostor): void;
  118285. /**
  118286. * Activates the physics body
  118287. * @param impostor impostor to activate
  118288. */
  118289. wakeUpBody(impostor: PhysicsImpostor): void;
  118290. /**
  118291. * Updates the distance parameters of the joint
  118292. * @param joint joint to update
  118293. * @param maxDistance maximum distance of the joint
  118294. * @param minDistance minimum distance of the joint
  118295. */
  118296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118297. /**
  118298. * Sets a motor on the joint
  118299. * @param joint joint to set motor on
  118300. * @param speed speed of the motor
  118301. * @param maxForce maximum force of the motor
  118302. * @param motorIndex index of the motor
  118303. */
  118304. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118305. /**
  118306. * Sets the motors limit
  118307. * @param joint joint to set limit on
  118308. * @param upperLimit upper limit
  118309. * @param lowerLimit lower limit
  118310. */
  118311. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118312. /**
  118313. * Syncs the position and rotation of a mesh with the impostor
  118314. * @param mesh mesh to sync
  118315. * @param impostor impostor to update the mesh with
  118316. */
  118317. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118318. /**
  118319. * Gets the radius of the impostor
  118320. * @param impostor impostor to get radius from
  118321. * @returns the radius
  118322. */
  118323. getRadius(impostor: PhysicsImpostor): number;
  118324. /**
  118325. * Gets the box size of the impostor
  118326. * @param impostor impostor to get box size from
  118327. * @param result the resulting box size
  118328. */
  118329. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118330. /**
  118331. * Disposes of the impostor
  118332. */
  118333. dispose(): void;
  118334. /**
  118335. * Does a raycast in the physics world
  118336. * @param from when should the ray start?
  118337. * @param to when should the ray end?
  118338. * @returns PhysicsRaycastResult
  118339. */
  118340. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118341. }
  118342. }
  118343. declare module BABYLON {
  118344. interface AbstractScene {
  118345. /**
  118346. * The list of reflection probes added to the scene
  118347. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118348. */
  118349. reflectionProbes: Array<ReflectionProbe>;
  118350. /**
  118351. * Removes the given reflection probe from this scene.
  118352. * @param toRemove The reflection probe to remove
  118353. * @returns The index of the removed reflection probe
  118354. */
  118355. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118356. /**
  118357. * Adds the given reflection probe to this scene.
  118358. * @param newReflectionProbe The reflection probe to add
  118359. */
  118360. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118361. }
  118362. /**
  118363. * Class used to generate realtime reflection / refraction cube textures
  118364. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118365. */
  118366. export class ReflectionProbe {
  118367. /** defines the name of the probe */
  118368. name: string;
  118369. private _scene;
  118370. private _renderTargetTexture;
  118371. private _projectionMatrix;
  118372. private _viewMatrix;
  118373. private _target;
  118374. private _add;
  118375. private _attachedMesh;
  118376. private _invertYAxis;
  118377. /** Gets or sets probe position (center of the cube map) */
  118378. position: Vector3;
  118379. /**
  118380. * Creates a new reflection probe
  118381. * @param name defines the name of the probe
  118382. * @param size defines the texture resolution (for each face)
  118383. * @param scene defines the hosting scene
  118384. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118385. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118386. */
  118387. constructor(
  118388. /** defines the name of the probe */
  118389. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118390. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118391. samples: number;
  118392. /** Gets or sets the refresh rate to use (on every frame by default) */
  118393. refreshRate: number;
  118394. /**
  118395. * Gets the hosting scene
  118396. * @returns a Scene
  118397. */
  118398. getScene(): Scene;
  118399. /** Gets the internal CubeTexture used to render to */
  118400. readonly cubeTexture: RenderTargetTexture;
  118401. /** Gets the list of meshes to render */
  118402. readonly renderList: Nullable<AbstractMesh[]>;
  118403. /**
  118404. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118405. * @param mesh defines the mesh to attach to
  118406. */
  118407. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118408. /**
  118409. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118410. * @param renderingGroupId The rendering group id corresponding to its index
  118411. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118412. */
  118413. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118414. /**
  118415. * Clean all associated resources
  118416. */
  118417. dispose(): void;
  118418. /**
  118419. * Converts the reflection probe information to a readable string for debug purpose.
  118420. * @param fullDetails Supports for multiple levels of logging within scene loading
  118421. * @returns the human readable reflection probe info
  118422. */
  118423. toString(fullDetails?: boolean): string;
  118424. /**
  118425. * Get the class name of the relfection probe.
  118426. * @returns "ReflectionProbe"
  118427. */
  118428. getClassName(): string;
  118429. /**
  118430. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118431. * @returns The JSON representation of the texture
  118432. */
  118433. serialize(): any;
  118434. /**
  118435. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118436. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118437. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118438. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118439. * @returns The parsed reflection probe if successful
  118440. */
  118441. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118442. }
  118443. }
  118444. declare module BABYLON {
  118445. /** @hidden */
  118446. export var _BabylonLoaderRegistered: boolean;
  118447. }
  118448. declare module BABYLON {
  118449. /**
  118450. * The Physically based simple base material of BJS.
  118451. *
  118452. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118453. * It is used as the base class for both the specGloss and metalRough conventions.
  118454. */
  118455. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118456. /**
  118457. * Number of Simultaneous lights allowed on the material.
  118458. */
  118459. maxSimultaneousLights: number;
  118460. /**
  118461. * If sets to true, disables all the lights affecting the material.
  118462. */
  118463. disableLighting: boolean;
  118464. /**
  118465. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118466. */
  118467. environmentTexture: BaseTexture;
  118468. /**
  118469. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118470. */
  118471. invertNormalMapX: boolean;
  118472. /**
  118473. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118474. */
  118475. invertNormalMapY: boolean;
  118476. /**
  118477. * Normal map used in the model.
  118478. */
  118479. normalTexture: BaseTexture;
  118480. /**
  118481. * Emissivie color used to self-illuminate the model.
  118482. */
  118483. emissiveColor: Color3;
  118484. /**
  118485. * Emissivie texture used to self-illuminate the model.
  118486. */
  118487. emissiveTexture: BaseTexture;
  118488. /**
  118489. * Occlusion Channel Strenght.
  118490. */
  118491. occlusionStrength: number;
  118492. /**
  118493. * Occlusion Texture of the material (adding extra occlusion effects).
  118494. */
  118495. occlusionTexture: BaseTexture;
  118496. /**
  118497. * Defines the alpha limits in alpha test mode.
  118498. */
  118499. alphaCutOff: number;
  118500. /**
  118501. * Gets the current double sided mode.
  118502. */
  118503. /**
  118504. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118505. */
  118506. doubleSided: boolean;
  118507. /**
  118508. * Stores the pre-calculated light information of a mesh in a texture.
  118509. */
  118510. lightmapTexture: BaseTexture;
  118511. /**
  118512. * If true, the light map contains occlusion information instead of lighting info.
  118513. */
  118514. useLightmapAsShadowmap: boolean;
  118515. /**
  118516. * Instantiates a new PBRMaterial instance.
  118517. *
  118518. * @param name The material name
  118519. * @param scene The scene the material will be use in.
  118520. */
  118521. constructor(name: string, scene: Scene);
  118522. getClassName(): string;
  118523. }
  118524. }
  118525. declare module BABYLON {
  118526. /**
  118527. * The PBR material of BJS following the metal roughness convention.
  118528. *
  118529. * This fits to the PBR convention in the GLTF definition:
  118530. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118531. */
  118532. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118533. /**
  118534. * The base color has two different interpretations depending on the value of metalness.
  118535. * When the material is a metal, the base color is the specific measured reflectance value
  118536. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118537. * of the material.
  118538. */
  118539. baseColor: Color3;
  118540. /**
  118541. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118542. * well as opacity information in the alpha channel.
  118543. */
  118544. baseTexture: BaseTexture;
  118545. /**
  118546. * Specifies the metallic scalar value of the material.
  118547. * Can also be used to scale the metalness values of the metallic texture.
  118548. */
  118549. metallic: number;
  118550. /**
  118551. * Specifies the roughness scalar value of the material.
  118552. * Can also be used to scale the roughness values of the metallic texture.
  118553. */
  118554. roughness: number;
  118555. /**
  118556. * Texture containing both the metallic value in the B channel and the
  118557. * roughness value in the G channel to keep better precision.
  118558. */
  118559. metallicRoughnessTexture: BaseTexture;
  118560. /**
  118561. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118562. *
  118563. * @param name The material name
  118564. * @param scene The scene the material will be use in.
  118565. */
  118566. constructor(name: string, scene: Scene);
  118567. /**
  118568. * Return the currrent class name of the material.
  118569. */
  118570. getClassName(): string;
  118571. /**
  118572. * Makes a duplicate of the current material.
  118573. * @param name - name to use for the new material.
  118574. */
  118575. clone(name: string): PBRMetallicRoughnessMaterial;
  118576. /**
  118577. * Serialize the material to a parsable JSON object.
  118578. */
  118579. serialize(): any;
  118580. /**
  118581. * Parses a JSON object correponding to the serialize function.
  118582. */
  118583. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118584. }
  118585. }
  118586. declare module BABYLON {
  118587. /**
  118588. * The PBR material of BJS following the specular glossiness convention.
  118589. *
  118590. * This fits to the PBR convention in the GLTF definition:
  118591. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118592. */
  118593. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118594. /**
  118595. * Specifies the diffuse color of the material.
  118596. */
  118597. diffuseColor: Color3;
  118598. /**
  118599. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118600. * channel.
  118601. */
  118602. diffuseTexture: BaseTexture;
  118603. /**
  118604. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118605. */
  118606. specularColor: Color3;
  118607. /**
  118608. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118609. */
  118610. glossiness: number;
  118611. /**
  118612. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118613. */
  118614. specularGlossinessTexture: BaseTexture;
  118615. /**
  118616. * Instantiates a new PBRSpecularGlossinessMaterial 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): PBRSpecularGlossinessMaterial;
  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): PBRSpecularGlossinessMaterial;
  118639. }
  118640. }
  118641. declare module BABYLON {
  118642. /**
  118643. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118644. * It can help converting any input color in a desired output one. This can then be used to create effects
  118645. * from sepia, black and white to sixties or futuristic rendering...
  118646. *
  118647. * The only supported format is currently 3dl.
  118648. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118649. */
  118650. export class ColorGradingTexture extends BaseTexture {
  118651. /**
  118652. * The current texture matrix. (will always be identity in color grading texture)
  118653. */
  118654. private _textureMatrix;
  118655. /**
  118656. * The texture URL.
  118657. */
  118658. url: string;
  118659. /**
  118660. * Empty line regex stored for GC.
  118661. */
  118662. private static _noneEmptyLineRegex;
  118663. private _engine;
  118664. /**
  118665. * Instantiates a ColorGradingTexture from the following parameters.
  118666. *
  118667. * @param url The location of the color gradind data (currently only supporting 3dl)
  118668. * @param scene The scene the texture will be used in
  118669. */
  118670. constructor(url: string, scene: Scene);
  118671. /**
  118672. * Returns the texture matrix used in most of the material.
  118673. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118674. */
  118675. getTextureMatrix(): Matrix;
  118676. /**
  118677. * Occurs when the file being loaded is a .3dl LUT file.
  118678. */
  118679. private load3dlTexture;
  118680. /**
  118681. * Starts the loading process of the texture.
  118682. */
  118683. private loadTexture;
  118684. /**
  118685. * Clones the color gradind texture.
  118686. */
  118687. clone(): ColorGradingTexture;
  118688. /**
  118689. * Called during delayed load for textures.
  118690. */
  118691. delayLoad(): void;
  118692. /**
  118693. * Parses a color grading texture serialized by Babylon.
  118694. * @param parsedTexture The texture information being parsedTexture
  118695. * @param scene The scene to load the texture in
  118696. * @param rootUrl The root url of the data assets to load
  118697. * @return A color gradind texture
  118698. */
  118699. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118700. /**
  118701. * Serializes the LUT texture to json format.
  118702. */
  118703. serialize(): any;
  118704. }
  118705. }
  118706. declare module BABYLON {
  118707. /**
  118708. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118709. */
  118710. export class EquiRectangularCubeTexture extends BaseTexture {
  118711. /** The six faces of the cube. */
  118712. private static _FacesMapping;
  118713. private _noMipmap;
  118714. private _onLoad;
  118715. private _onError;
  118716. /** The size of the cubemap. */
  118717. private _size;
  118718. /** The buffer of the image. */
  118719. private _buffer;
  118720. /** The width of the input image. */
  118721. private _width;
  118722. /** The height of the input image. */
  118723. private _height;
  118724. /** The URL to the image. */
  118725. url: string;
  118726. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118727. coordinatesMode: number;
  118728. /**
  118729. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118730. * @param url The location of the image
  118731. * @param scene The scene the texture will be used in
  118732. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118733. * @param noMipmap Forces to not generate the mipmap if true
  118734. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118735. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118736. * @param onLoad — defines a callback called when texture is loaded
  118737. * @param onError — defines a callback called if there is an error
  118738. */
  118739. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118740. /**
  118741. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118742. */
  118743. private loadImage;
  118744. /**
  118745. * Convert the image buffer into a cubemap and create a CubeTexture.
  118746. */
  118747. private loadTexture;
  118748. /**
  118749. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118750. * @param buffer The ArrayBuffer that should be converted.
  118751. * @returns The buffer as Float32Array.
  118752. */
  118753. private getFloat32ArrayFromArrayBuffer;
  118754. /**
  118755. * Get the current class name of the texture useful for serialization or dynamic coding.
  118756. * @returns "EquiRectangularCubeTexture"
  118757. */
  118758. getClassName(): string;
  118759. /**
  118760. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118761. * @returns A clone of the current EquiRectangularCubeTexture.
  118762. */
  118763. clone(): EquiRectangularCubeTexture;
  118764. }
  118765. }
  118766. declare module BABYLON {
  118767. /**
  118768. * Based on jsTGALoader - Javascript loader for TGA file
  118769. * By Vincent Thibault
  118770. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118771. */
  118772. export class TGATools {
  118773. private static _TYPE_INDEXED;
  118774. private static _TYPE_RGB;
  118775. private static _TYPE_GREY;
  118776. private static _TYPE_RLE_INDEXED;
  118777. private static _TYPE_RLE_RGB;
  118778. private static _TYPE_RLE_GREY;
  118779. private static _ORIGIN_MASK;
  118780. private static _ORIGIN_SHIFT;
  118781. private static _ORIGIN_BL;
  118782. private static _ORIGIN_BR;
  118783. private static _ORIGIN_UL;
  118784. private static _ORIGIN_UR;
  118785. /**
  118786. * Gets the header of a TGA file
  118787. * @param data defines the TGA data
  118788. * @returns the header
  118789. */
  118790. static GetTGAHeader(data: Uint8Array): any;
  118791. /**
  118792. * Uploads TGA content to a Babylon Texture
  118793. * @hidden
  118794. */
  118795. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118796. /** @hidden */
  118797. 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;
  118798. /** @hidden */
  118799. 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;
  118800. /** @hidden */
  118801. 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;
  118802. /** @hidden */
  118803. 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;
  118804. /** @hidden */
  118805. 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;
  118806. /** @hidden */
  118807. 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;
  118808. }
  118809. }
  118810. declare module BABYLON {
  118811. /**
  118812. * Implementation of the TGA Texture Loader.
  118813. * @hidden
  118814. */
  118815. export class _TGATextureLoader implements IInternalTextureLoader {
  118816. /**
  118817. * Defines wether the loader supports cascade loading the different faces.
  118818. */
  118819. readonly supportCascades: boolean;
  118820. /**
  118821. * This returns if the loader support the current file information.
  118822. * @param extension defines the file extension of the file being loaded
  118823. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118824. * @param fallback defines the fallback internal texture if any
  118825. * @param isBase64 defines whether the texture is encoded as a base64
  118826. * @param isBuffer defines whether the texture data are stored as a buffer
  118827. * @returns true if the loader can load the specified file
  118828. */
  118829. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118830. /**
  118831. * Transform the url before loading if required.
  118832. * @param rootUrl the url of the texture
  118833. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118834. * @returns the transformed texture
  118835. */
  118836. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118837. /**
  118838. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118839. * @param rootUrl the url of the texture
  118840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118841. * @returns the fallback texture
  118842. */
  118843. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118844. /**
  118845. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118846. * @param data contains the texture data
  118847. * @param texture defines the BabylonJS internal texture
  118848. * @param createPolynomials will be true if polynomials have been requested
  118849. * @param onLoad defines the callback to trigger once the texture is ready
  118850. * @param onError defines the callback to trigger in case of error
  118851. */
  118852. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118853. /**
  118854. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118855. * @param data contains the texture data
  118856. * @param texture defines the BabylonJS internal texture
  118857. * @param callback defines the method to call once ready to upload
  118858. */
  118859. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118860. }
  118861. }
  118862. declare module BABYLON {
  118863. /**
  118864. * Info about the .basis files
  118865. */
  118866. class BasisFileInfo {
  118867. /**
  118868. * If the file has alpha
  118869. */
  118870. hasAlpha: boolean;
  118871. /**
  118872. * Info about each image of the basis file
  118873. */
  118874. images: Array<{
  118875. levels: Array<{
  118876. width: number;
  118877. height: number;
  118878. transcodedPixels: ArrayBufferView;
  118879. }>;
  118880. }>;
  118881. }
  118882. /**
  118883. * Result of transcoding a basis file
  118884. */
  118885. class TranscodeResult {
  118886. /**
  118887. * Info about the .basis file
  118888. */
  118889. fileInfo: BasisFileInfo;
  118890. /**
  118891. * Format to use when loading the file
  118892. */
  118893. format: number;
  118894. }
  118895. /**
  118896. * Configuration options for the Basis transcoder
  118897. */
  118898. export class BasisTranscodeConfiguration {
  118899. /**
  118900. * Supported compression formats used to determine the supported output format of the transcoder
  118901. */
  118902. supportedCompressionFormats?: {
  118903. /**
  118904. * etc1 compression format
  118905. */
  118906. etc1?: boolean;
  118907. /**
  118908. * s3tc compression format
  118909. */
  118910. s3tc?: boolean;
  118911. /**
  118912. * pvrtc compression format
  118913. */
  118914. pvrtc?: boolean;
  118915. /**
  118916. * etc2 compression format
  118917. */
  118918. etc2?: boolean;
  118919. };
  118920. /**
  118921. * If mipmap levels should be loaded for transcoded images (Default: true)
  118922. */
  118923. loadMipmapLevels?: boolean;
  118924. /**
  118925. * Index of a single image to load (Default: all images)
  118926. */
  118927. loadSingleImage?: number;
  118928. }
  118929. /**
  118930. * Used to load .Basis files
  118931. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118932. */
  118933. export class BasisTools {
  118934. private static _IgnoreSupportedFormats;
  118935. /**
  118936. * URL to use when loading the basis transcoder
  118937. */
  118938. static JSModuleURL: string;
  118939. /**
  118940. * URL to use when loading the wasm module for the transcoder
  118941. */
  118942. static WasmModuleURL: string;
  118943. /**
  118944. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118945. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118946. * @returns internal format corresponding to the Basis format
  118947. */
  118948. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118949. private static _WorkerPromise;
  118950. private static _Worker;
  118951. private static _actionId;
  118952. private static _CreateWorkerAsync;
  118953. /**
  118954. * Transcodes a loaded image file to compressed pixel data
  118955. * @param imageData image data to transcode
  118956. * @param config configuration options for the transcoding
  118957. * @returns a promise resulting in the transcoded image
  118958. */
  118959. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118960. /**
  118961. * Loads a texture from the transcode result
  118962. * @param texture texture load to
  118963. * @param transcodeResult the result of transcoding the basis file to load from
  118964. */
  118965. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118966. }
  118967. }
  118968. declare module BABYLON {
  118969. /**
  118970. * Loader for .basis file format
  118971. */
  118972. export class _BasisTextureLoader implements IInternalTextureLoader {
  118973. /**
  118974. * Defines whether the loader supports cascade loading the different faces.
  118975. */
  118976. readonly supportCascades: boolean;
  118977. /**
  118978. * This returns if the loader support the current file information.
  118979. * @param extension defines the file extension of the file being loaded
  118980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118981. * @param fallback defines the fallback internal texture if any
  118982. * @param isBase64 defines whether the texture is encoded as a base64
  118983. * @param isBuffer defines whether the texture data are stored as a buffer
  118984. * @returns true if the loader can load the specified file
  118985. */
  118986. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118987. /**
  118988. * Transform the url before loading if required.
  118989. * @param rootUrl the url of the texture
  118990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118991. * @returns the transformed texture
  118992. */
  118993. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118994. /**
  118995. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118996. * @param rootUrl the url of the texture
  118997. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118998. * @returns the fallback texture
  118999. */
  119000. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119001. /**
  119002. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119003. * @param data contains the texture data
  119004. * @param texture defines the BabylonJS internal texture
  119005. * @param createPolynomials will be true if polynomials have been requested
  119006. * @param onLoad defines the callback to trigger once the texture is ready
  119007. * @param onError defines the callback to trigger in case of error
  119008. */
  119009. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119010. /**
  119011. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119012. * @param data contains the texture data
  119013. * @param texture defines the BabylonJS internal texture
  119014. * @param callback defines the method to call once ready to upload
  119015. */
  119016. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119017. }
  119018. }
  119019. declare module BABYLON {
  119020. /**
  119021. * 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.
  119022. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119023. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119024. */
  119025. export class CustomProceduralTexture extends ProceduralTexture {
  119026. private _animate;
  119027. private _time;
  119028. private _config;
  119029. private _texturePath;
  119030. /**
  119031. * Instantiates a new Custom Procedural Texture.
  119032. * 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.
  119033. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119034. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119035. * @param name Define the name of the texture
  119036. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119037. * @param size Define the size of the texture to create
  119038. * @param scene Define the scene the texture belongs to
  119039. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119040. * @param generateMipMaps Define if the texture should creates mip maps or not
  119041. */
  119042. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119043. private _loadJson;
  119044. /**
  119045. * Is the texture ready to be used ? (rendered at least once)
  119046. * @returns true if ready, otherwise, false.
  119047. */
  119048. isReady(): boolean;
  119049. /**
  119050. * Render the texture to its associated render target.
  119051. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119052. */
  119053. render(useCameraPostProcess?: boolean): void;
  119054. /**
  119055. * Update the list of dependant textures samplers in the shader.
  119056. */
  119057. updateTextures(): void;
  119058. /**
  119059. * Update the uniform values of the procedural texture in the shader.
  119060. */
  119061. updateShaderUniforms(): void;
  119062. /**
  119063. * Define if the texture animates or not.
  119064. */
  119065. animate: boolean;
  119066. }
  119067. }
  119068. declare module BABYLON {
  119069. /** @hidden */
  119070. export var noisePixelShader: {
  119071. name: string;
  119072. shader: string;
  119073. };
  119074. }
  119075. declare module BABYLON {
  119076. /**
  119077. * Class used to generate noise procedural textures
  119078. */
  119079. export class NoiseProceduralTexture extends ProceduralTexture {
  119080. private _time;
  119081. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119082. brightness: number;
  119083. /** Defines the number of octaves to process */
  119084. octaves: number;
  119085. /** Defines the level of persistence (0.8 by default) */
  119086. persistence: number;
  119087. /** Gets or sets animation speed factor (default is 1) */
  119088. animationSpeedFactor: number;
  119089. /**
  119090. * Creates a new NoiseProceduralTexture
  119091. * @param name defines the name fo the texture
  119092. * @param size defines the size of the texture (default is 256)
  119093. * @param scene defines the hosting scene
  119094. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119095. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119096. */
  119097. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119098. private _updateShaderUniforms;
  119099. protected _getDefines(): string;
  119100. /** Generate the current state of the procedural texture */
  119101. render(useCameraPostProcess?: boolean): void;
  119102. /**
  119103. * Serializes this noise procedural texture
  119104. * @returns a serialized noise procedural texture object
  119105. */
  119106. serialize(): any;
  119107. /**
  119108. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119109. * @param parsedTexture defines parsed texture data
  119110. * @param scene defines the current scene
  119111. * @param rootUrl defines the root URL containing noise procedural texture information
  119112. * @returns a parsed NoiseProceduralTexture
  119113. */
  119114. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119115. }
  119116. }
  119117. declare module BABYLON {
  119118. /**
  119119. * Raw cube texture where the raw buffers are passed in
  119120. */
  119121. export class RawCubeTexture extends CubeTexture {
  119122. /**
  119123. * Creates a cube texture where the raw buffers are passed in.
  119124. * @param scene defines the scene the texture is attached to
  119125. * @param data defines the array of data to use to create each face
  119126. * @param size defines the size of the textures
  119127. * @param format defines the format of the data
  119128. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119129. * @param generateMipMaps defines if the engine should generate the mip levels
  119130. * @param invertY defines if data must be stored with Y axis inverted
  119131. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119132. * @param compression defines the compression used (null by default)
  119133. */
  119134. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119135. /**
  119136. * Updates the raw cube texture.
  119137. * @param data defines the data to store
  119138. * @param format defines the data format
  119139. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119140. * @param invertY defines if data must be stored with Y axis inverted
  119141. * @param compression defines the compression used (null by default)
  119142. * @param level defines which level of the texture to update
  119143. */
  119144. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119145. /**
  119146. * Updates a raw cube texture with RGBD encoded data.
  119147. * @param data defines the array of data [mipmap][face] to use to create each face
  119148. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119149. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119150. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119151. * @returns a promsie that resolves when the operation is complete
  119152. */
  119153. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119154. /**
  119155. * Clones the raw cube texture.
  119156. * @return a new cube texture
  119157. */
  119158. clone(): CubeTexture;
  119159. /** @hidden */
  119160. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119161. }
  119162. }
  119163. declare module BABYLON {
  119164. /**
  119165. * Class used to store 3D textures containing user data
  119166. */
  119167. export class RawTexture3D extends Texture {
  119168. /** Gets or sets the texture format to use */
  119169. format: number;
  119170. private _engine;
  119171. /**
  119172. * Create a new RawTexture3D
  119173. * @param data defines the data of the texture
  119174. * @param width defines the width of the texture
  119175. * @param height defines the height of the texture
  119176. * @param depth defines the depth of the texture
  119177. * @param format defines the texture format to use
  119178. * @param scene defines the hosting scene
  119179. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119180. * @param invertY defines if texture must be stored with Y axis inverted
  119181. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119182. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119183. */
  119184. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119185. /** Gets or sets the texture format to use */
  119186. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119187. /**
  119188. * Update the texture with new data
  119189. * @param data defines the data to store in the texture
  119190. */
  119191. update(data: ArrayBufferView): void;
  119192. }
  119193. }
  119194. declare module BABYLON {
  119195. /**
  119196. * Creates a refraction texture used by refraction channel of the standard material.
  119197. * It is like a mirror but to see through a material.
  119198. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119199. */
  119200. export class RefractionTexture extends RenderTargetTexture {
  119201. /**
  119202. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119203. * 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.
  119204. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119205. */
  119206. refractionPlane: Plane;
  119207. /**
  119208. * Define how deep under the surface we should see.
  119209. */
  119210. depth: number;
  119211. /**
  119212. * Creates a refraction texture used by refraction channel of the standard material.
  119213. * It is like a mirror but to see through a material.
  119214. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119215. * @param name Define the texture name
  119216. * @param size Define the size of the underlying texture
  119217. * @param scene Define the scene the refraction belongs to
  119218. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119219. */
  119220. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119221. /**
  119222. * Clone the refraction texture.
  119223. * @returns the cloned texture
  119224. */
  119225. clone(): RefractionTexture;
  119226. /**
  119227. * Serialize the texture to a JSON representation you could use in Parse later on
  119228. * @returns the serialized JSON representation
  119229. */
  119230. serialize(): any;
  119231. }
  119232. }
  119233. declare module BABYLON {
  119234. /**
  119235. * Defines the options related to the creation of an HtmlElementTexture
  119236. */
  119237. export interface IHtmlElementTextureOptions {
  119238. /**
  119239. * Defines wether mip maps should be created or not.
  119240. */
  119241. generateMipMaps?: boolean;
  119242. /**
  119243. * Defines the sampling mode of the texture.
  119244. */
  119245. samplingMode?: number;
  119246. /**
  119247. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119248. */
  119249. engine: Nullable<ThinEngine>;
  119250. /**
  119251. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119252. */
  119253. scene: Nullable<Scene>;
  119254. }
  119255. /**
  119256. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119257. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119258. * is automatically managed.
  119259. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119260. * in your application.
  119261. *
  119262. * As the update is not automatic, you need to call them manually.
  119263. */
  119264. export class HtmlElementTexture extends BaseTexture {
  119265. /**
  119266. * The texture URL.
  119267. */
  119268. element: HTMLVideoElement | HTMLCanvasElement;
  119269. private static readonly DefaultOptions;
  119270. private _textureMatrix;
  119271. private _engine;
  119272. private _isVideo;
  119273. private _generateMipMaps;
  119274. private _samplingMode;
  119275. /**
  119276. * Instantiates a HtmlElementTexture from the following parameters.
  119277. *
  119278. * @param name Defines the name of the texture
  119279. * @param element Defines the video or canvas the texture is filled with
  119280. * @param options Defines the other none mandatory texture creation options
  119281. */
  119282. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119283. private _createInternalTexture;
  119284. /**
  119285. * Returns the texture matrix used in most of the material.
  119286. */
  119287. getTextureMatrix(): Matrix;
  119288. /**
  119289. * Updates the content of the texture.
  119290. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119291. */
  119292. update(invertY?: Nullable<boolean>): void;
  119293. }
  119294. }
  119295. declare module BABYLON {
  119296. /**
  119297. * Enum used to define the target of a block
  119298. */
  119299. export enum NodeMaterialBlockTargets {
  119300. /** Vertex shader */
  119301. Vertex = 1,
  119302. /** Fragment shader */
  119303. Fragment = 2,
  119304. /** Neutral */
  119305. Neutral = 4,
  119306. /** Vertex and Fragment */
  119307. VertexAndFragment = 3
  119308. }
  119309. }
  119310. declare module BABYLON {
  119311. /**
  119312. * Defines the kind of connection point for node based material
  119313. */
  119314. export enum NodeMaterialBlockConnectionPointTypes {
  119315. /** Float */
  119316. Float = 1,
  119317. /** Int */
  119318. Int = 2,
  119319. /** Vector2 */
  119320. Vector2 = 4,
  119321. /** Vector3 */
  119322. Vector3 = 8,
  119323. /** Vector4 */
  119324. Vector4 = 16,
  119325. /** Color3 */
  119326. Color3 = 32,
  119327. /** Color4 */
  119328. Color4 = 64,
  119329. /** Matrix */
  119330. Matrix = 128,
  119331. /** Detect type based on connection */
  119332. AutoDetect = 1024,
  119333. /** Output type that will be defined by input type */
  119334. BasedOnInput = 2048
  119335. }
  119336. }
  119337. declare module BABYLON {
  119338. /**
  119339. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119340. */
  119341. export enum NodeMaterialBlockConnectionPointMode {
  119342. /** Value is an uniform */
  119343. Uniform = 0,
  119344. /** Value is a mesh attribute */
  119345. Attribute = 1,
  119346. /** Value is a varying between vertex and fragment shaders */
  119347. Varying = 2,
  119348. /** Mode is undefined */
  119349. Undefined = 3
  119350. }
  119351. }
  119352. declare module BABYLON {
  119353. /**
  119354. * Enum used to define system values e.g. values automatically provided by the system
  119355. */
  119356. export enum NodeMaterialSystemValues {
  119357. /** World */
  119358. World = 1,
  119359. /** View */
  119360. View = 2,
  119361. /** Projection */
  119362. Projection = 3,
  119363. /** ViewProjection */
  119364. ViewProjection = 4,
  119365. /** WorldView */
  119366. WorldView = 5,
  119367. /** WorldViewProjection */
  119368. WorldViewProjection = 6,
  119369. /** CameraPosition */
  119370. CameraPosition = 7,
  119371. /** Fog Color */
  119372. FogColor = 8,
  119373. /** Delta time */
  119374. DeltaTime = 9
  119375. }
  119376. }
  119377. declare module BABYLON {
  119378. /**
  119379. * Root class for all node material optimizers
  119380. */
  119381. export class NodeMaterialOptimizer {
  119382. /**
  119383. * Function used to optimize a NodeMaterial graph
  119384. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119385. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119386. */
  119387. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119388. }
  119389. }
  119390. declare module BABYLON {
  119391. /**
  119392. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119393. */
  119394. export class TransformBlock extends NodeMaterialBlock {
  119395. /**
  119396. * Defines the value to use to complement W value to transform it to a Vector4
  119397. */
  119398. complementW: number;
  119399. /**
  119400. * Defines the value to use to complement z value to transform it to a Vector4
  119401. */
  119402. complementZ: number;
  119403. /**
  119404. * Creates a new TransformBlock
  119405. * @param name defines the block name
  119406. */
  119407. constructor(name: string);
  119408. /**
  119409. * Gets the current class name
  119410. * @returns the class name
  119411. */
  119412. getClassName(): string;
  119413. /**
  119414. * Gets the vector input
  119415. */
  119416. readonly vector: NodeMaterialConnectionPoint;
  119417. /**
  119418. * Gets the output component
  119419. */
  119420. readonly output: NodeMaterialConnectionPoint;
  119421. /**
  119422. * Gets the matrix transform input
  119423. */
  119424. readonly transform: NodeMaterialConnectionPoint;
  119425. protected _buildBlock(state: NodeMaterialBuildState): this;
  119426. serialize(): any;
  119427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119428. protected _dumpPropertiesCode(): string;
  119429. }
  119430. }
  119431. declare module BABYLON {
  119432. /**
  119433. * Block used to output the vertex position
  119434. */
  119435. export class VertexOutputBlock extends NodeMaterialBlock {
  119436. /**
  119437. * Creates a new VertexOutputBlock
  119438. * @param name defines the block name
  119439. */
  119440. constructor(name: string);
  119441. /**
  119442. * Gets the current class name
  119443. * @returns the class name
  119444. */
  119445. getClassName(): string;
  119446. /**
  119447. * Gets the vector input component
  119448. */
  119449. readonly vector: NodeMaterialConnectionPoint;
  119450. protected _buildBlock(state: NodeMaterialBuildState): this;
  119451. }
  119452. }
  119453. declare module BABYLON {
  119454. /**
  119455. * Block used to output the final color
  119456. */
  119457. export class FragmentOutputBlock extends NodeMaterialBlock {
  119458. /**
  119459. * Create a new FragmentOutputBlock
  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 rgba input component
  119470. */
  119471. readonly rgba: NodeMaterialConnectionPoint;
  119472. /**
  119473. * Gets the rgb input component
  119474. */
  119475. readonly rgb: NodeMaterialConnectionPoint;
  119476. /**
  119477. * Gets the a input component
  119478. */
  119479. readonly a: NodeMaterialConnectionPoint;
  119480. protected _buildBlock(state: NodeMaterialBuildState): this;
  119481. }
  119482. }
  119483. declare module BABYLON {
  119484. /**
  119485. * Block used to read a reflection texture from a sampler
  119486. */
  119487. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119488. private _define3DName;
  119489. private _defineCubicName;
  119490. private _defineExplicitName;
  119491. private _defineProjectionName;
  119492. private _defineLocalCubicName;
  119493. private _defineSphericalName;
  119494. private _definePlanarName;
  119495. private _defineEquirectangularName;
  119496. private _defineMirroredEquirectangularFixedName;
  119497. private _defineEquirectangularFixedName;
  119498. private _defineSkyboxName;
  119499. private _cubeSamplerName;
  119500. private _2DSamplerName;
  119501. private _positionUVWName;
  119502. private _directionWName;
  119503. private _reflectionCoordsName;
  119504. private _reflection2DCoordsName;
  119505. private _reflectionColorName;
  119506. private _reflectionMatrixName;
  119507. /**
  119508. * Gets or sets the texture associated with the node
  119509. */
  119510. texture: Nullable<BaseTexture>;
  119511. /**
  119512. * Create a new TextureBlock
  119513. * @param name defines the block name
  119514. */
  119515. constructor(name: string);
  119516. /**
  119517. * Gets the current class name
  119518. * @returns the class name
  119519. */
  119520. getClassName(): string;
  119521. /**
  119522. * Gets the world position input component
  119523. */
  119524. readonly position: NodeMaterialConnectionPoint;
  119525. /**
  119526. * Gets the world position input component
  119527. */
  119528. readonly worldPosition: NodeMaterialConnectionPoint;
  119529. /**
  119530. * Gets the world normal input component
  119531. */
  119532. readonly worldNormal: NodeMaterialConnectionPoint;
  119533. /**
  119534. * Gets the world input component
  119535. */
  119536. readonly world: NodeMaterialConnectionPoint;
  119537. /**
  119538. * Gets the camera (or eye) position component
  119539. */
  119540. readonly cameraPosition: NodeMaterialConnectionPoint;
  119541. /**
  119542. * Gets the view input component
  119543. */
  119544. readonly view: NodeMaterialConnectionPoint;
  119545. /**
  119546. * Gets the rgb output component
  119547. */
  119548. readonly rgb: NodeMaterialConnectionPoint;
  119549. /**
  119550. * Gets the r output component
  119551. */
  119552. readonly r: NodeMaterialConnectionPoint;
  119553. /**
  119554. * Gets the g output component
  119555. */
  119556. readonly g: NodeMaterialConnectionPoint;
  119557. /**
  119558. * Gets the b output component
  119559. */
  119560. readonly b: NodeMaterialConnectionPoint;
  119561. autoConfigure(material: NodeMaterial): void;
  119562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119563. isReady(): boolean;
  119564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119565. private _injectVertexCode;
  119566. private _writeOutput;
  119567. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119568. serialize(): any;
  119569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119570. }
  119571. }
  119572. declare module BABYLON {
  119573. /**
  119574. * Interface used to configure the node material editor
  119575. */
  119576. export interface INodeMaterialEditorOptions {
  119577. /** Define the URl to load node editor script */
  119578. editorURL?: string;
  119579. }
  119580. /** @hidden */
  119581. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119582. /** BONES */
  119583. NUM_BONE_INFLUENCERS: number;
  119584. BonesPerMesh: number;
  119585. BONETEXTURE: boolean;
  119586. /** MORPH TARGETS */
  119587. MORPHTARGETS: boolean;
  119588. MORPHTARGETS_NORMAL: boolean;
  119589. MORPHTARGETS_TANGENT: boolean;
  119590. MORPHTARGETS_UV: boolean;
  119591. NUM_MORPH_INFLUENCERS: number;
  119592. /** IMAGE PROCESSING */
  119593. IMAGEPROCESSING: boolean;
  119594. VIGNETTE: boolean;
  119595. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119596. VIGNETTEBLENDMODEOPAQUE: boolean;
  119597. TONEMAPPING: boolean;
  119598. TONEMAPPING_ACES: boolean;
  119599. CONTRAST: boolean;
  119600. EXPOSURE: boolean;
  119601. COLORCURVES: boolean;
  119602. COLORGRADING: boolean;
  119603. COLORGRADING3D: boolean;
  119604. SAMPLER3DGREENDEPTH: boolean;
  119605. SAMPLER3DBGRMAP: boolean;
  119606. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119607. /** MISC. */
  119608. BUMPDIRECTUV: number;
  119609. constructor();
  119610. setValue(name: string, value: boolean): void;
  119611. }
  119612. /**
  119613. * Class used to configure NodeMaterial
  119614. */
  119615. export interface INodeMaterialOptions {
  119616. /**
  119617. * Defines if blocks should emit comments
  119618. */
  119619. emitComments: boolean;
  119620. }
  119621. /**
  119622. * Class used to create a node based material built by assembling shader blocks
  119623. */
  119624. export class NodeMaterial extends PushMaterial {
  119625. private static _BuildIdGenerator;
  119626. private _options;
  119627. private _vertexCompilationState;
  119628. private _fragmentCompilationState;
  119629. private _sharedData;
  119630. private _buildId;
  119631. private _buildWasSuccessful;
  119632. private _cachedWorldViewMatrix;
  119633. private _cachedWorldViewProjectionMatrix;
  119634. private _optimizers;
  119635. private _animationFrame;
  119636. /** Define the URl to load node editor script */
  119637. static EditorURL: string;
  119638. private BJSNODEMATERIALEDITOR;
  119639. /** Get the inspector from bundle or global */
  119640. private _getGlobalNodeMaterialEditor;
  119641. /**
  119642. * 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)
  119643. */
  119644. ignoreAlpha: boolean;
  119645. /**
  119646. * Defines the maximum number of lights that can be used in the material
  119647. */
  119648. maxSimultaneousLights: number;
  119649. /**
  119650. * Observable raised when the material is built
  119651. */
  119652. onBuildObservable: Observable<NodeMaterial>;
  119653. /**
  119654. * Gets or sets the root nodes of the material vertex shader
  119655. */
  119656. _vertexOutputNodes: NodeMaterialBlock[];
  119657. /**
  119658. * Gets or sets the root nodes of the material fragment (pixel) shader
  119659. */
  119660. _fragmentOutputNodes: NodeMaterialBlock[];
  119661. /** Gets or sets options to control the node material overall behavior */
  119662. options: INodeMaterialOptions;
  119663. /**
  119664. * Default configuration related to image processing available in the standard Material.
  119665. */
  119666. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119667. /**
  119668. * Gets the image processing configuration used either in this material.
  119669. */
  119670. /**
  119671. * Sets the Default image processing configuration used either in the this material.
  119672. *
  119673. * If sets to null, the scene one is in use.
  119674. */
  119675. imageProcessingConfiguration: ImageProcessingConfiguration;
  119676. /**
  119677. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119678. */
  119679. attachedBlocks: NodeMaterialBlock[];
  119680. /**
  119681. * Create a new node based material
  119682. * @param name defines the material name
  119683. * @param scene defines the hosting scene
  119684. * @param options defines creation option
  119685. */
  119686. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119687. /**
  119688. * Gets the current class name of the material e.g. "NodeMaterial"
  119689. * @returns the class name
  119690. */
  119691. getClassName(): string;
  119692. /**
  119693. * Keep track of the image processing observer to allow dispose and replace.
  119694. */
  119695. private _imageProcessingObserver;
  119696. /**
  119697. * Attaches a new image processing configuration to the Standard Material.
  119698. * @param configuration
  119699. */
  119700. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119701. /**
  119702. * Get a block by its name
  119703. * @param name defines the name of the block to retrieve
  119704. * @returns the required block or null if not found
  119705. */
  119706. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119707. /**
  119708. * Get a block by its name
  119709. * @param predicate defines the predicate used to find the good candidate
  119710. * @returns the required block or null if not found
  119711. */
  119712. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119713. /**
  119714. * Get an input block by its name
  119715. * @param predicate defines the predicate used to find the good candidate
  119716. * @returns the required input block or null if not found
  119717. */
  119718. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119719. /**
  119720. * Gets the list of input blocks attached to this material
  119721. * @returns an array of InputBlocks
  119722. */
  119723. getInputBlocks(): InputBlock[];
  119724. /**
  119725. * Adds a new optimizer to the list of optimizers
  119726. * @param optimizer defines the optimizers to add
  119727. * @returns the current material
  119728. */
  119729. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119730. /**
  119731. * Remove an optimizer from the list of optimizers
  119732. * @param optimizer defines the optimizers to remove
  119733. * @returns the current material
  119734. */
  119735. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119736. /**
  119737. * Add a new block to the list of output nodes
  119738. * @param node defines the node to add
  119739. * @returns the current material
  119740. */
  119741. addOutputNode(node: NodeMaterialBlock): this;
  119742. /**
  119743. * Remove a block from the list of root nodes
  119744. * @param node defines the node to remove
  119745. * @returns the current material
  119746. */
  119747. removeOutputNode(node: NodeMaterialBlock): this;
  119748. private _addVertexOutputNode;
  119749. private _removeVertexOutputNode;
  119750. private _addFragmentOutputNode;
  119751. private _removeFragmentOutputNode;
  119752. /**
  119753. * Specifies if the material will require alpha blending
  119754. * @returns a boolean specifying if alpha blending is needed
  119755. */
  119756. needAlphaBlending(): boolean;
  119757. /**
  119758. * Specifies if this material should be rendered in alpha test mode
  119759. * @returns a boolean specifying if an alpha test is needed.
  119760. */
  119761. needAlphaTesting(): boolean;
  119762. private _initializeBlock;
  119763. private _resetDualBlocks;
  119764. /**
  119765. * Build the material and generates the inner effect
  119766. * @param verbose defines if the build should log activity
  119767. */
  119768. build(verbose?: boolean): void;
  119769. /**
  119770. * Runs an otpimization phase to try to improve the shader code
  119771. */
  119772. optimize(): void;
  119773. private _prepareDefinesForAttributes;
  119774. /**
  119775. * Get if the submesh is ready to be used and all its information available.
  119776. * Child classes can use it to update shaders
  119777. * @param mesh defines the mesh to check
  119778. * @param subMesh defines which submesh to check
  119779. * @param useInstances specifies that instances should be used
  119780. * @returns a boolean indicating that the submesh is ready or not
  119781. */
  119782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119783. /**
  119784. * Get a string representing the shaders built by the current node graph
  119785. */
  119786. readonly compiledShaders: string;
  119787. /**
  119788. * Binds the world matrix to the material
  119789. * @param world defines the world transformation matrix
  119790. */
  119791. bindOnlyWorldMatrix(world: Matrix): void;
  119792. /**
  119793. * Binds the submesh to this material by preparing the effect and shader to draw
  119794. * @param world defines the world transformation matrix
  119795. * @param mesh defines the mesh containing the submesh
  119796. * @param subMesh defines the submesh to bind the material to
  119797. */
  119798. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119799. /**
  119800. * Gets the active textures from the material
  119801. * @returns an array of textures
  119802. */
  119803. getActiveTextures(): BaseTexture[];
  119804. /**
  119805. * Gets the list of texture blocks
  119806. * @returns an array of texture blocks
  119807. */
  119808. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119809. /**
  119810. * Specifies if the material uses a texture
  119811. * @param texture defines the texture to check against the material
  119812. * @returns a boolean specifying if the material uses the texture
  119813. */
  119814. hasTexture(texture: BaseTexture): boolean;
  119815. /**
  119816. * Disposes the material
  119817. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119818. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119819. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119820. */
  119821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119822. /** Creates the node editor window. */
  119823. private _createNodeEditor;
  119824. /**
  119825. * Launch the node material editor
  119826. * @param config Define the configuration of the editor
  119827. * @return a promise fulfilled when the node editor is visible
  119828. */
  119829. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119830. /**
  119831. * Clear the current material
  119832. */
  119833. clear(): void;
  119834. /**
  119835. * Clear the current material and set it to a default state
  119836. */
  119837. setToDefault(): void;
  119838. /**
  119839. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119840. * @param url defines the url to load from
  119841. * @returns a promise that will fullfil when the material is fully loaded
  119842. */
  119843. loadAsync(url: string): Promise<unknown>;
  119844. private _gatherBlocks;
  119845. /**
  119846. * Generate a string containing the code declaration required to create an equivalent of this material
  119847. * @returns a string
  119848. */
  119849. generateCode(): string;
  119850. /**
  119851. * Serializes this material in a JSON representation
  119852. * @returns the serialized material object
  119853. */
  119854. serialize(): any;
  119855. private _restoreConnections;
  119856. /**
  119857. * Clear the current graph and load a new one from a serialization object
  119858. * @param source defines the JSON representation of the material
  119859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119860. */
  119861. loadFromSerialization(source: any, rootUrl?: string): void;
  119862. /**
  119863. * Creates a node material from parsed material data
  119864. * @param source defines the JSON representation of the material
  119865. * @param scene defines the hosting scene
  119866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119867. * @returns a new node material
  119868. */
  119869. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119870. /**
  119871. * Creates a new node material set to default basic configuration
  119872. * @param name defines the name of the material
  119873. * @param scene defines the hosting scene
  119874. * @returns a new NodeMaterial
  119875. */
  119876. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119877. }
  119878. }
  119879. declare module BABYLON {
  119880. /**
  119881. * Block used to read a texture from a sampler
  119882. */
  119883. export class TextureBlock extends NodeMaterialBlock {
  119884. private _defineName;
  119885. private _linearDefineName;
  119886. private _samplerName;
  119887. private _transformedUVName;
  119888. private _textureTransformName;
  119889. private _textureInfoName;
  119890. private _mainUVName;
  119891. private _mainUVDefineName;
  119892. /**
  119893. * Gets or sets the texture associated with the node
  119894. */
  119895. texture: Nullable<Texture>;
  119896. /**
  119897. * Create a new TextureBlock
  119898. * @param name defines the block name
  119899. */
  119900. constructor(name: string);
  119901. /**
  119902. * Gets the current class name
  119903. * @returns the class name
  119904. */
  119905. getClassName(): string;
  119906. /**
  119907. * Gets the uv input component
  119908. */
  119909. readonly uv: NodeMaterialConnectionPoint;
  119910. /**
  119911. * Gets the rgba output component
  119912. */
  119913. readonly rgba: NodeMaterialConnectionPoint;
  119914. /**
  119915. * Gets the rgb output component
  119916. */
  119917. readonly rgb: NodeMaterialConnectionPoint;
  119918. /**
  119919. * Gets the r output component
  119920. */
  119921. readonly r: NodeMaterialConnectionPoint;
  119922. /**
  119923. * Gets the g output component
  119924. */
  119925. readonly g: NodeMaterialConnectionPoint;
  119926. /**
  119927. * Gets the b output component
  119928. */
  119929. readonly b: NodeMaterialConnectionPoint;
  119930. /**
  119931. * Gets the a output component
  119932. */
  119933. readonly a: NodeMaterialConnectionPoint;
  119934. readonly target: NodeMaterialBlockTargets;
  119935. autoConfigure(material: NodeMaterial): void;
  119936. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119937. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119938. isReady(): boolean;
  119939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119940. private readonly _isMixed;
  119941. private _injectVertexCode;
  119942. private _writeOutput;
  119943. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119944. protected _dumpPropertiesCode(): string;
  119945. serialize(): any;
  119946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119947. }
  119948. }
  119949. declare module BABYLON {
  119950. /**
  119951. * Class used to store shared data between 2 NodeMaterialBuildState
  119952. */
  119953. export class NodeMaterialBuildStateSharedData {
  119954. /**
  119955. * Gets the list of emitted varyings
  119956. */
  119957. temps: string[];
  119958. /**
  119959. * Gets the list of emitted varyings
  119960. */
  119961. varyings: string[];
  119962. /**
  119963. * Gets the varying declaration string
  119964. */
  119965. varyingDeclaration: string;
  119966. /**
  119967. * Input blocks
  119968. */
  119969. inputBlocks: InputBlock[];
  119970. /**
  119971. * Input blocks
  119972. */
  119973. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119974. /**
  119975. * Bindable blocks (Blocks that need to set data to the effect)
  119976. */
  119977. bindableBlocks: NodeMaterialBlock[];
  119978. /**
  119979. * List of blocks that can provide a compilation fallback
  119980. */
  119981. blocksWithFallbacks: NodeMaterialBlock[];
  119982. /**
  119983. * List of blocks that can provide a define update
  119984. */
  119985. blocksWithDefines: NodeMaterialBlock[];
  119986. /**
  119987. * List of blocks that can provide a repeatable content
  119988. */
  119989. repeatableContentBlocks: NodeMaterialBlock[];
  119990. /**
  119991. * List of blocks that can provide a dynamic list of uniforms
  119992. */
  119993. dynamicUniformBlocks: NodeMaterialBlock[];
  119994. /**
  119995. * List of blocks that can block the isReady function for the material
  119996. */
  119997. blockingBlocks: NodeMaterialBlock[];
  119998. /**
  119999. * Gets the list of animated inputs
  120000. */
  120001. animatedInputs: InputBlock[];
  120002. /**
  120003. * Build Id used to avoid multiple recompilations
  120004. */
  120005. buildId: number;
  120006. /** List of emitted variables */
  120007. variableNames: {
  120008. [key: string]: number;
  120009. };
  120010. /** List of emitted defines */
  120011. defineNames: {
  120012. [key: string]: number;
  120013. };
  120014. /** Should emit comments? */
  120015. emitComments: boolean;
  120016. /** Emit build activity */
  120017. verbose: boolean;
  120018. /** Gets or sets the hosting scene */
  120019. scene: Scene;
  120020. /**
  120021. * Gets the compilation hints emitted at compilation time
  120022. */
  120023. hints: {
  120024. needWorldViewMatrix: boolean;
  120025. needWorldViewProjectionMatrix: boolean;
  120026. needAlphaBlending: boolean;
  120027. needAlphaTesting: boolean;
  120028. };
  120029. /**
  120030. * List of compilation checks
  120031. */
  120032. checks: {
  120033. emitVertex: boolean;
  120034. emitFragment: boolean;
  120035. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120036. };
  120037. /** Creates a new shared data */
  120038. constructor();
  120039. /**
  120040. * Emits console errors and exceptions if there is a failing check
  120041. */
  120042. emitErrors(): void;
  120043. }
  120044. }
  120045. declare module BABYLON {
  120046. /**
  120047. * Class used to store node based material build state
  120048. */
  120049. export class NodeMaterialBuildState {
  120050. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120051. supportUniformBuffers: boolean;
  120052. /**
  120053. * Gets the list of emitted attributes
  120054. */
  120055. attributes: string[];
  120056. /**
  120057. * Gets the list of emitted uniforms
  120058. */
  120059. uniforms: string[];
  120060. /**
  120061. * Gets the list of emitted constants
  120062. */
  120063. constants: string[];
  120064. /**
  120065. * Gets the list of emitted uniform buffers
  120066. */
  120067. uniformBuffers: string[];
  120068. /**
  120069. * Gets the list of emitted samplers
  120070. */
  120071. samplers: string[];
  120072. /**
  120073. * Gets the list of emitted functions
  120074. */
  120075. functions: {
  120076. [key: string]: string;
  120077. };
  120078. /**
  120079. * Gets the list of emitted extensions
  120080. */
  120081. extensions: {
  120082. [key: string]: string;
  120083. };
  120084. /**
  120085. * Gets the target of the compilation state
  120086. */
  120087. target: NodeMaterialBlockTargets;
  120088. /**
  120089. * Gets the list of emitted counters
  120090. */
  120091. counters: {
  120092. [key: string]: number;
  120093. };
  120094. /**
  120095. * Shared data between multiple NodeMaterialBuildState instances
  120096. */
  120097. sharedData: NodeMaterialBuildStateSharedData;
  120098. /** @hidden */
  120099. _vertexState: NodeMaterialBuildState;
  120100. /** @hidden */
  120101. _attributeDeclaration: string;
  120102. /** @hidden */
  120103. _uniformDeclaration: string;
  120104. /** @hidden */
  120105. _constantDeclaration: string;
  120106. /** @hidden */
  120107. _samplerDeclaration: string;
  120108. /** @hidden */
  120109. _varyingTransfer: string;
  120110. private _repeatableContentAnchorIndex;
  120111. /** @hidden */
  120112. _builtCompilationString: string;
  120113. /**
  120114. * Gets the emitted compilation strings
  120115. */
  120116. compilationString: string;
  120117. /**
  120118. * Finalize the compilation strings
  120119. * @param state defines the current compilation state
  120120. */
  120121. finalize(state: NodeMaterialBuildState): void;
  120122. /** @hidden */
  120123. readonly _repeatableContentAnchor: string;
  120124. /** @hidden */
  120125. _getFreeVariableName(prefix: string): string;
  120126. /** @hidden */
  120127. _getFreeDefineName(prefix: string): string;
  120128. /** @hidden */
  120129. _excludeVariableName(name: string): void;
  120130. /** @hidden */
  120131. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120132. /** @hidden */
  120133. _emitExtension(name: string, extension: string): void;
  120134. /** @hidden */
  120135. _emitFunction(name: string, code: string, comments: string): void;
  120136. /** @hidden */
  120137. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120138. replaceStrings?: {
  120139. search: RegExp;
  120140. replace: string;
  120141. }[];
  120142. repeatKey?: string;
  120143. }): string;
  120144. /** @hidden */
  120145. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120146. repeatKey?: string;
  120147. removeAttributes?: boolean;
  120148. removeUniforms?: boolean;
  120149. removeVaryings?: boolean;
  120150. removeIfDef?: boolean;
  120151. replaceStrings?: {
  120152. search: RegExp;
  120153. replace: string;
  120154. }[];
  120155. }, storeKey?: string): void;
  120156. /** @hidden */
  120157. _registerTempVariable(name: string): boolean;
  120158. /** @hidden */
  120159. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120160. /** @hidden */
  120161. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120162. /** @hidden */
  120163. _emitFloat(value: number): string;
  120164. }
  120165. }
  120166. declare module BABYLON {
  120167. /**
  120168. * Defines a block that can be used inside a node based material
  120169. */
  120170. export class NodeMaterialBlock {
  120171. private _buildId;
  120172. private _buildTarget;
  120173. private _target;
  120174. private _isFinalMerger;
  120175. private _isInput;
  120176. /** @hidden */
  120177. _codeVariableName: string;
  120178. /** @hidden */
  120179. _inputs: NodeMaterialConnectionPoint[];
  120180. /** @hidden */
  120181. _outputs: NodeMaterialConnectionPoint[];
  120182. /** @hidden */
  120183. _preparationId: number;
  120184. /**
  120185. * Gets or sets the name of the block
  120186. */
  120187. name: string;
  120188. /**
  120189. * Gets or sets the unique id of the node
  120190. */
  120191. uniqueId: number;
  120192. /**
  120193. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120194. */
  120195. readonly isFinalMerger: boolean;
  120196. /**
  120197. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120198. */
  120199. readonly isInput: boolean;
  120200. /**
  120201. * Gets or sets the build Id
  120202. */
  120203. buildId: number;
  120204. /**
  120205. * Gets or sets the target of the block
  120206. */
  120207. target: NodeMaterialBlockTargets;
  120208. /**
  120209. * Gets the list of input points
  120210. */
  120211. readonly inputs: NodeMaterialConnectionPoint[];
  120212. /** Gets the list of output points */
  120213. readonly outputs: NodeMaterialConnectionPoint[];
  120214. /**
  120215. * Find an input by its name
  120216. * @param name defines the name of the input to look for
  120217. * @returns the input or null if not found
  120218. */
  120219. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120220. /**
  120221. * Find an output by its name
  120222. * @param name defines the name of the outputto look for
  120223. * @returns the output or null if not found
  120224. */
  120225. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120226. /**
  120227. * Creates a new NodeMaterialBlock
  120228. * @param name defines the block name
  120229. * @param target defines the target of that block (Vertex by default)
  120230. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120231. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120232. */
  120233. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120234. /**
  120235. * Initialize the block and prepare the context for build
  120236. * @param state defines the state that will be used for the build
  120237. */
  120238. initialize(state: NodeMaterialBuildState): void;
  120239. /**
  120240. * Bind data to effect. Will only be called for blocks with isBindable === true
  120241. * @param effect defines the effect to bind data to
  120242. * @param nodeMaterial defines the hosting NodeMaterial
  120243. * @param mesh defines the mesh that will be rendered
  120244. */
  120245. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120246. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120247. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120248. protected _writeFloat(value: number): string;
  120249. /**
  120250. * Gets the current class name e.g. "NodeMaterialBlock"
  120251. * @returns the class name
  120252. */
  120253. getClassName(): string;
  120254. /**
  120255. * Register a new input. Must be called inside a block constructor
  120256. * @param name defines the connection point name
  120257. * @param type defines the connection point type
  120258. * @param isOptional defines a boolean indicating that this input can be omitted
  120259. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120260. * @returns the current block
  120261. */
  120262. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120263. /**
  120264. * Register a new output. Must be called inside a block constructor
  120265. * @param name defines the connection point name
  120266. * @param type defines the connection point type
  120267. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120268. * @returns the current block
  120269. */
  120270. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120271. /**
  120272. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120273. * @param forOutput defines an optional connection point to check compatibility with
  120274. * @returns the first available input or null
  120275. */
  120276. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120277. /**
  120278. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120279. * @param forBlock defines an optional block to check compatibility with
  120280. * @returns the first available input or null
  120281. */
  120282. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120283. /**
  120284. * Gets the sibling of the given output
  120285. * @param current defines the current output
  120286. * @returns the next output in the list or null
  120287. */
  120288. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120289. /**
  120290. * Connect current block with another block
  120291. * @param other defines the block to connect with
  120292. * @param options define the various options to help pick the right connections
  120293. * @returns the current block
  120294. */
  120295. connectTo(other: NodeMaterialBlock, options?: {
  120296. input?: string;
  120297. output?: string;
  120298. outputSwizzle?: string;
  120299. }): this | undefined;
  120300. protected _buildBlock(state: NodeMaterialBuildState): void;
  120301. /**
  120302. * Add uniforms, samplers and uniform buffers at compilation time
  120303. * @param state defines the state to update
  120304. * @param nodeMaterial defines the node material requesting the update
  120305. * @param defines defines the material defines to update
  120306. */
  120307. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120308. /**
  120309. * Add potential fallbacks if shader compilation fails
  120310. * @param mesh defines the mesh to be rendered
  120311. * @param fallbacks defines the current prioritized list of fallbacks
  120312. */
  120313. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120314. /**
  120315. * Initialize defines for shader compilation
  120316. * @param mesh defines the mesh to be rendered
  120317. * @param nodeMaterial defines the node material requesting the update
  120318. * @param defines defines the material defines to update
  120319. * @param useInstances specifies that instances should be used
  120320. */
  120321. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120322. /**
  120323. * Update defines for shader compilation
  120324. * @param mesh defines the mesh to be rendered
  120325. * @param nodeMaterial defines the node material requesting the update
  120326. * @param defines defines the material defines to update
  120327. * @param useInstances specifies that instances should be used
  120328. */
  120329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120330. /**
  120331. * Lets the block try to connect some inputs automatically
  120332. * @param material defines the hosting NodeMaterial
  120333. */
  120334. autoConfigure(material: NodeMaterial): void;
  120335. /**
  120336. * Function called when a block is declared as repeatable content generator
  120337. * @param vertexShaderState defines the current compilation state for the vertex shader
  120338. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120339. * @param mesh defines the mesh to be rendered
  120340. * @param defines defines the material defines to update
  120341. */
  120342. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120343. /**
  120344. * Checks if the block is ready
  120345. * @param mesh defines the mesh to be rendered
  120346. * @param nodeMaterial defines the node material requesting the update
  120347. * @param defines defines the material defines to update
  120348. * @param useInstances specifies that instances should be used
  120349. * @returns true if the block is ready
  120350. */
  120351. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120352. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120353. private _processBuild;
  120354. /**
  120355. * Compile the current node and generate the shader code
  120356. * @param state defines the current compilation state (uniforms, samplers, current string)
  120357. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120358. * @returns true if already built
  120359. */
  120360. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120361. protected _inputRename(name: string): string;
  120362. protected _outputRename(name: string): string;
  120363. protected _dumpPropertiesCode(): string;
  120364. /** @hidden */
  120365. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120366. /**
  120367. * Clone the current block to a new identical block
  120368. * @param scene defines the hosting scene
  120369. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120370. * @returns a copy of the current block
  120371. */
  120372. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120373. /**
  120374. * Serializes this block in a JSON representation
  120375. * @returns the serialized block object
  120376. */
  120377. serialize(): any;
  120378. /** @hidden */
  120379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120380. }
  120381. }
  120382. declare module BABYLON {
  120383. /**
  120384. * Enum defining the type of animations supported by InputBlock
  120385. */
  120386. export enum AnimatedInputBlockTypes {
  120387. /** No animation */
  120388. None = 0,
  120389. /** Time based animation. Will only work for floats */
  120390. Time = 1
  120391. }
  120392. }
  120393. declare module BABYLON {
  120394. /**
  120395. * Block used to expose an input value
  120396. */
  120397. export class InputBlock extends NodeMaterialBlock {
  120398. private _mode;
  120399. private _associatedVariableName;
  120400. private _storedValue;
  120401. private _valueCallback;
  120402. private _type;
  120403. private _animationType;
  120404. /** Gets or set a value used to limit the range of float values */
  120405. min: number;
  120406. /** Gets or set a value used to limit the range of float values */
  120407. max: number;
  120408. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120409. matrixMode: number;
  120410. /** @hidden */
  120411. _systemValue: Nullable<NodeMaterialSystemValues>;
  120412. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120413. visibleInInspector: boolean;
  120414. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120415. isConstant: boolean;
  120416. /**
  120417. * Gets or sets the connection point type (default is float)
  120418. */
  120419. readonly type: NodeMaterialBlockConnectionPointTypes;
  120420. /**
  120421. * Creates a new InputBlock
  120422. * @param name defines the block name
  120423. * @param target defines the target of that block (Vertex by default)
  120424. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120425. */
  120426. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120427. /**
  120428. * Gets the output component
  120429. */
  120430. readonly output: NodeMaterialConnectionPoint;
  120431. /**
  120432. * Set the source of this connection point to a vertex attribute
  120433. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120434. * @returns the current connection point
  120435. */
  120436. setAsAttribute(attributeName?: string): InputBlock;
  120437. /**
  120438. * Set the source of this connection point to a system value
  120439. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120440. * @returns the current connection point
  120441. */
  120442. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120443. /**
  120444. * Gets or sets the value of that point.
  120445. * Please note that this value will be ignored if valueCallback is defined
  120446. */
  120447. value: any;
  120448. /**
  120449. * Gets or sets a callback used to get the value of that point.
  120450. * Please note that setting this value will force the connection point to ignore the value property
  120451. */
  120452. valueCallback: () => any;
  120453. /**
  120454. * Gets or sets the associated variable name in the shader
  120455. */
  120456. associatedVariableName: string;
  120457. /** Gets or sets the type of animation applied to the input */
  120458. animationType: AnimatedInputBlockTypes;
  120459. /**
  120460. * Gets a boolean indicating that this connection point not defined yet
  120461. */
  120462. readonly isUndefined: boolean;
  120463. /**
  120464. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120465. * In this case the connection point name must be the name of the uniform to use.
  120466. * Can only be set on inputs
  120467. */
  120468. isUniform: boolean;
  120469. /**
  120470. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120471. * In this case the connection point name must be the name of the attribute to use
  120472. * Can only be set on inputs
  120473. */
  120474. isAttribute: boolean;
  120475. /**
  120476. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120477. * Can only be set on exit points
  120478. */
  120479. isVarying: boolean;
  120480. /**
  120481. * Gets a boolean indicating that the current connection point is a system value
  120482. */
  120483. readonly isSystemValue: boolean;
  120484. /**
  120485. * Gets or sets the current well known value or null if not defined as a system value
  120486. */
  120487. systemValue: Nullable<NodeMaterialSystemValues>;
  120488. /**
  120489. * Gets the current class name
  120490. * @returns the class name
  120491. */
  120492. getClassName(): string;
  120493. /**
  120494. * Animate the input if animationType !== None
  120495. * @param scene defines the rendering scene
  120496. */
  120497. animate(scene: Scene): void;
  120498. private _emitDefine;
  120499. initialize(state: NodeMaterialBuildState): void;
  120500. /**
  120501. * Set the input block to its default value (based on its type)
  120502. */
  120503. setDefaultValue(): void;
  120504. private _emitConstant;
  120505. private _emit;
  120506. /** @hidden */
  120507. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120508. /** @hidden */
  120509. _transmit(effect: Effect, scene: Scene): void;
  120510. protected _buildBlock(state: NodeMaterialBuildState): void;
  120511. protected _dumpPropertiesCode(): string;
  120512. serialize(): any;
  120513. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120514. }
  120515. }
  120516. declare module BABYLON {
  120517. /**
  120518. * Defines a connection point for a block
  120519. */
  120520. export class NodeMaterialConnectionPoint {
  120521. /** @hidden */
  120522. _ownerBlock: NodeMaterialBlock;
  120523. /** @hidden */
  120524. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120525. private _endpoints;
  120526. private _associatedVariableName;
  120527. /** @hidden */
  120528. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120529. /** @hidden */
  120530. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120531. private _type;
  120532. /** @hidden */
  120533. _enforceAssociatedVariableName: boolean;
  120534. /**
  120535. * Gets or sets the additional types supported by this connection point
  120536. */
  120537. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120538. /**
  120539. * Gets or sets the additional types excluded by this connection point
  120540. */
  120541. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120542. /**
  120543. * Gets or sets the associated variable name in the shader
  120544. */
  120545. associatedVariableName: string;
  120546. /**
  120547. * Gets or sets the connection point type (default is float)
  120548. */
  120549. type: NodeMaterialBlockConnectionPointTypes;
  120550. /**
  120551. * Gets or sets the connection point name
  120552. */
  120553. name: string;
  120554. /**
  120555. * Gets or sets a boolean indicating that this connection point can be omitted
  120556. */
  120557. isOptional: boolean;
  120558. /**
  120559. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120560. */
  120561. define: string;
  120562. /** Gets or sets the target of that connection point */
  120563. target: NodeMaterialBlockTargets;
  120564. /**
  120565. * Gets a boolean indicating that the current point is connected
  120566. */
  120567. readonly isConnected: boolean;
  120568. /**
  120569. * Gets a boolean indicating that the current point is connected to an input block
  120570. */
  120571. readonly isConnectedToInputBlock: boolean;
  120572. /**
  120573. * Gets a the connected input block (if any)
  120574. */
  120575. readonly connectInputBlock: Nullable<InputBlock>;
  120576. /** Get the other side of the connection (if any) */
  120577. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120578. /** Get the block that owns this connection point */
  120579. readonly ownerBlock: NodeMaterialBlock;
  120580. /** Get the block connected on the other side of this connection (if any) */
  120581. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120582. /** Get the block connected on the endpoints of this connection (if any) */
  120583. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120584. /** Gets the list of connected endpoints */
  120585. readonly endpoints: NodeMaterialConnectionPoint[];
  120586. /** Gets a boolean indicating if that output point is connected to at least one input */
  120587. readonly hasEndpoints: boolean;
  120588. /**
  120589. * Creates a new connection point
  120590. * @param name defines the connection point name
  120591. * @param ownerBlock defines the block hosting this connection point
  120592. */
  120593. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120594. /**
  120595. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120596. * @returns the class name
  120597. */
  120598. getClassName(): string;
  120599. /**
  120600. * Gets an boolean indicating if the current point can be connected to another point
  120601. * @param connectionPoint defines the other connection point
  120602. * @returns true if the connection is possible
  120603. */
  120604. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120605. /**
  120606. * Connect this point to another connection point
  120607. * @param connectionPoint defines the other connection point
  120608. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120609. * @returns the current connection point
  120610. */
  120611. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120612. /**
  120613. * Disconnect this point from one of his endpoint
  120614. * @param endpoint defines the other connection point
  120615. * @returns the current connection point
  120616. */
  120617. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120618. /**
  120619. * Serializes this point in a JSON representation
  120620. * @returns the serialized point object
  120621. */
  120622. serialize(): any;
  120623. }
  120624. }
  120625. declare module BABYLON {
  120626. /**
  120627. * Block used to add support for vertex skinning (bones)
  120628. */
  120629. export class BonesBlock extends NodeMaterialBlock {
  120630. /**
  120631. * Creates a new BonesBlock
  120632. * @param name defines the block name
  120633. */
  120634. constructor(name: string);
  120635. /**
  120636. * Initialize the block and prepare the context for build
  120637. * @param state defines the state that will be used for the build
  120638. */
  120639. initialize(state: NodeMaterialBuildState): void;
  120640. /**
  120641. * Gets the current class name
  120642. * @returns the class name
  120643. */
  120644. getClassName(): string;
  120645. /**
  120646. * Gets the matrix indices input component
  120647. */
  120648. readonly matricesIndices: NodeMaterialConnectionPoint;
  120649. /**
  120650. * Gets the matrix weights input component
  120651. */
  120652. readonly matricesWeights: NodeMaterialConnectionPoint;
  120653. /**
  120654. * Gets the extra matrix indices input component
  120655. */
  120656. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120657. /**
  120658. * Gets the extra matrix weights input component
  120659. */
  120660. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120661. /**
  120662. * Gets the world input component
  120663. */
  120664. readonly world: NodeMaterialConnectionPoint;
  120665. /**
  120666. * Gets the output component
  120667. */
  120668. readonly output: NodeMaterialConnectionPoint;
  120669. autoConfigure(material: NodeMaterial): void;
  120670. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120672. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120673. protected _buildBlock(state: NodeMaterialBuildState): this;
  120674. }
  120675. }
  120676. declare module BABYLON {
  120677. /**
  120678. * Block used to add support for instances
  120679. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120680. */
  120681. export class InstancesBlock extends NodeMaterialBlock {
  120682. /**
  120683. * Creates a new InstancesBlock
  120684. * @param name defines the block name
  120685. */
  120686. constructor(name: string);
  120687. /**
  120688. * Gets the current class name
  120689. * @returns the class name
  120690. */
  120691. getClassName(): string;
  120692. /**
  120693. * Gets the first world row input component
  120694. */
  120695. readonly world0: NodeMaterialConnectionPoint;
  120696. /**
  120697. * Gets the second world row input component
  120698. */
  120699. readonly world1: NodeMaterialConnectionPoint;
  120700. /**
  120701. * Gets the third world row input component
  120702. */
  120703. readonly world2: NodeMaterialConnectionPoint;
  120704. /**
  120705. * Gets the forth world row input component
  120706. */
  120707. readonly world3: NodeMaterialConnectionPoint;
  120708. /**
  120709. * Gets the world input component
  120710. */
  120711. readonly world: NodeMaterialConnectionPoint;
  120712. /**
  120713. * Gets the output component
  120714. */
  120715. readonly output: NodeMaterialConnectionPoint;
  120716. autoConfigure(material: NodeMaterial): void;
  120717. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120718. protected _buildBlock(state: NodeMaterialBuildState): this;
  120719. }
  120720. }
  120721. declare module BABYLON {
  120722. /**
  120723. * Block used to add morph targets support to vertex shader
  120724. */
  120725. export class MorphTargetsBlock extends NodeMaterialBlock {
  120726. private _repeatableContentAnchor;
  120727. private _repeatebleContentGenerated;
  120728. /**
  120729. * Create a new MorphTargetsBlock
  120730. * @param name defines the block name
  120731. */
  120732. constructor(name: string);
  120733. /**
  120734. * Gets the current class name
  120735. * @returns the class name
  120736. */
  120737. getClassName(): string;
  120738. /**
  120739. * Gets the position input component
  120740. */
  120741. readonly position: NodeMaterialConnectionPoint;
  120742. /**
  120743. * Gets the normal input component
  120744. */
  120745. readonly normal: NodeMaterialConnectionPoint;
  120746. /**
  120747. * Gets the tangent input component
  120748. */
  120749. readonly tangent: NodeMaterialConnectionPoint;
  120750. /**
  120751. * Gets the tangent input component
  120752. */
  120753. readonly uv: NodeMaterialConnectionPoint;
  120754. /**
  120755. * Gets the position output component
  120756. */
  120757. readonly positionOutput: NodeMaterialConnectionPoint;
  120758. /**
  120759. * Gets the normal output component
  120760. */
  120761. readonly normalOutput: NodeMaterialConnectionPoint;
  120762. /**
  120763. * Gets the tangent output component
  120764. */
  120765. readonly tangentOutput: NodeMaterialConnectionPoint;
  120766. /**
  120767. * Gets the tangent output component
  120768. */
  120769. readonly uvOutput: NodeMaterialConnectionPoint;
  120770. initialize(state: NodeMaterialBuildState): void;
  120771. autoConfigure(material: NodeMaterial): void;
  120772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120773. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120774. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120775. protected _buildBlock(state: NodeMaterialBuildState): this;
  120776. }
  120777. }
  120778. declare module BABYLON {
  120779. /**
  120780. * Block used to get data information from a light
  120781. */
  120782. export class LightInformationBlock extends NodeMaterialBlock {
  120783. private _lightDataUniformName;
  120784. private _lightColorUniformName;
  120785. private _lightTypeDefineName;
  120786. /**
  120787. * Gets or sets the light associated with this block
  120788. */
  120789. light: Nullable<Light>;
  120790. /**
  120791. * Creates a new LightInformationBlock
  120792. * @param name defines the block name
  120793. */
  120794. constructor(name: string);
  120795. /**
  120796. * Gets the current class name
  120797. * @returns the class name
  120798. */
  120799. getClassName(): string;
  120800. /**
  120801. * Gets the world position input component
  120802. */
  120803. readonly worldPosition: NodeMaterialConnectionPoint;
  120804. /**
  120805. * Gets the direction output component
  120806. */
  120807. readonly direction: NodeMaterialConnectionPoint;
  120808. /**
  120809. * Gets the direction output component
  120810. */
  120811. readonly color: NodeMaterialConnectionPoint;
  120812. /**
  120813. * Gets the direction output component
  120814. */
  120815. readonly intensity: NodeMaterialConnectionPoint;
  120816. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120818. protected _buildBlock(state: NodeMaterialBuildState): this;
  120819. serialize(): any;
  120820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120821. }
  120822. }
  120823. declare module BABYLON {
  120824. /**
  120825. * Block used to add image processing support to fragment shader
  120826. */
  120827. export class ImageProcessingBlock extends NodeMaterialBlock {
  120828. /**
  120829. * Create a new ImageProcessingBlock
  120830. * @param name defines the block name
  120831. */
  120832. constructor(name: string);
  120833. /**
  120834. * Gets the current class name
  120835. * @returns the class name
  120836. */
  120837. getClassName(): string;
  120838. /**
  120839. * Gets the color input component
  120840. */
  120841. readonly color: NodeMaterialConnectionPoint;
  120842. /**
  120843. * Gets the output component
  120844. */
  120845. readonly output: NodeMaterialConnectionPoint;
  120846. /**
  120847. * Initialize the block and prepare the context for build
  120848. * @param state defines the state that will be used for the build
  120849. */
  120850. initialize(state: NodeMaterialBuildState): void;
  120851. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120853. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120854. protected _buildBlock(state: NodeMaterialBuildState): this;
  120855. }
  120856. }
  120857. declare module BABYLON {
  120858. /**
  120859. * Block used to pertub normals based on a normal map
  120860. */
  120861. export class PerturbNormalBlock extends NodeMaterialBlock {
  120862. private _tangentSpaceParameterName;
  120863. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120864. invertX: boolean;
  120865. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120866. invertY: boolean;
  120867. /**
  120868. * Create a new PerturbNormalBlock
  120869. * @param name defines the block name
  120870. */
  120871. constructor(name: string);
  120872. /**
  120873. * Gets the current class name
  120874. * @returns the class name
  120875. */
  120876. getClassName(): string;
  120877. /**
  120878. * Gets the world position input component
  120879. */
  120880. readonly worldPosition: NodeMaterialConnectionPoint;
  120881. /**
  120882. * Gets the world normal input component
  120883. */
  120884. readonly worldNormal: NodeMaterialConnectionPoint;
  120885. /**
  120886. * Gets the uv input component
  120887. */
  120888. readonly uv: NodeMaterialConnectionPoint;
  120889. /**
  120890. * Gets the normal map color input component
  120891. */
  120892. readonly normalMapColor: NodeMaterialConnectionPoint;
  120893. /**
  120894. * Gets the strength input component
  120895. */
  120896. readonly strength: NodeMaterialConnectionPoint;
  120897. /**
  120898. * Gets the output component
  120899. */
  120900. readonly output: NodeMaterialConnectionPoint;
  120901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120903. autoConfigure(material: NodeMaterial): void;
  120904. protected _buildBlock(state: NodeMaterialBuildState): this;
  120905. protected _dumpPropertiesCode(): string;
  120906. serialize(): any;
  120907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120908. }
  120909. }
  120910. declare module BABYLON {
  120911. /**
  120912. * Block used to discard a pixel if a value is smaller than a cutoff
  120913. */
  120914. export class DiscardBlock extends NodeMaterialBlock {
  120915. /**
  120916. * Create a new DiscardBlock
  120917. * @param name defines the block name
  120918. */
  120919. constructor(name: string);
  120920. /**
  120921. * Gets the current class name
  120922. * @returns the class name
  120923. */
  120924. getClassName(): string;
  120925. /**
  120926. * Gets the color input component
  120927. */
  120928. readonly value: NodeMaterialConnectionPoint;
  120929. /**
  120930. * Gets the cutoff input component
  120931. */
  120932. readonly cutoff: NodeMaterialConnectionPoint;
  120933. protected _buildBlock(state: NodeMaterialBuildState): this;
  120934. }
  120935. }
  120936. declare module BABYLON {
  120937. /**
  120938. * Block used to add support for scene fog
  120939. */
  120940. export class FogBlock extends NodeMaterialBlock {
  120941. private _fogDistanceName;
  120942. private _fogParameters;
  120943. /**
  120944. * Create a new FogBlock
  120945. * @param name defines the block name
  120946. */
  120947. constructor(name: string);
  120948. /**
  120949. * Gets the current class name
  120950. * @returns the class name
  120951. */
  120952. getClassName(): string;
  120953. /**
  120954. * Gets the world position input component
  120955. */
  120956. readonly worldPosition: NodeMaterialConnectionPoint;
  120957. /**
  120958. * Gets the view input component
  120959. */
  120960. readonly view: NodeMaterialConnectionPoint;
  120961. /**
  120962. * Gets the color input component
  120963. */
  120964. readonly input: NodeMaterialConnectionPoint;
  120965. /**
  120966. * Gets the fog color input component
  120967. */
  120968. readonly fogColor: NodeMaterialConnectionPoint;
  120969. /**
  120970. * Gets the output component
  120971. */
  120972. readonly output: NodeMaterialConnectionPoint;
  120973. autoConfigure(material: NodeMaterial): void;
  120974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120975. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120976. protected _buildBlock(state: NodeMaterialBuildState): this;
  120977. }
  120978. }
  120979. declare module BABYLON {
  120980. /**
  120981. * Block used to add light in the fragment shader
  120982. */
  120983. export class LightBlock extends NodeMaterialBlock {
  120984. private _lightId;
  120985. /**
  120986. * Gets or sets the light associated with this block
  120987. */
  120988. light: Nullable<Light>;
  120989. /**
  120990. * Create a new LightBlock
  120991. * @param name defines the block name
  120992. */
  120993. constructor(name: string);
  120994. /**
  120995. * Gets the current class name
  120996. * @returns the class name
  120997. */
  120998. getClassName(): string;
  120999. /**
  121000. * Gets the world position input component
  121001. */
  121002. readonly worldPosition: NodeMaterialConnectionPoint;
  121003. /**
  121004. * Gets the world normal input component
  121005. */
  121006. readonly worldNormal: NodeMaterialConnectionPoint;
  121007. /**
  121008. * Gets the camera (or eye) position component
  121009. */
  121010. readonly cameraPosition: NodeMaterialConnectionPoint;
  121011. /**
  121012. * Gets the glossiness component
  121013. */
  121014. readonly glossiness: NodeMaterialConnectionPoint;
  121015. /**
  121016. * Gets the glossinness power component
  121017. */
  121018. readonly glossPower: NodeMaterialConnectionPoint;
  121019. /**
  121020. * Gets the diffuse color component
  121021. */
  121022. readonly diffuseColor: NodeMaterialConnectionPoint;
  121023. /**
  121024. * Gets the specular color component
  121025. */
  121026. readonly specularColor: NodeMaterialConnectionPoint;
  121027. /**
  121028. * Gets the diffuse output component
  121029. */
  121030. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121031. /**
  121032. * Gets the specular output component
  121033. */
  121034. readonly specularOutput: NodeMaterialConnectionPoint;
  121035. autoConfigure(material: NodeMaterial): void;
  121036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121037. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121038. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121039. private _injectVertexCode;
  121040. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121041. serialize(): any;
  121042. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121043. }
  121044. }
  121045. declare module BABYLON {
  121046. /**
  121047. * Block used to multiply 2 values
  121048. */
  121049. export class MultiplyBlock extends NodeMaterialBlock {
  121050. /**
  121051. * Creates a new MultiplyBlock
  121052. * @param name defines the block name
  121053. */
  121054. constructor(name: string);
  121055. /**
  121056. * Gets the current class name
  121057. * @returns the class name
  121058. */
  121059. getClassName(): string;
  121060. /**
  121061. * Gets the left operand input component
  121062. */
  121063. readonly left: NodeMaterialConnectionPoint;
  121064. /**
  121065. * Gets the right operand input component
  121066. */
  121067. readonly right: NodeMaterialConnectionPoint;
  121068. /**
  121069. * Gets the output component
  121070. */
  121071. readonly output: NodeMaterialConnectionPoint;
  121072. protected _buildBlock(state: NodeMaterialBuildState): this;
  121073. }
  121074. }
  121075. declare module BABYLON {
  121076. /**
  121077. * Block used to add 2 vectors
  121078. */
  121079. export class AddBlock extends NodeMaterialBlock {
  121080. /**
  121081. * Creates a new AddBlock
  121082. * @param name defines the block name
  121083. */
  121084. constructor(name: string);
  121085. /**
  121086. * Gets the current class name
  121087. * @returns the class name
  121088. */
  121089. getClassName(): string;
  121090. /**
  121091. * Gets the left operand input component
  121092. */
  121093. readonly left: NodeMaterialConnectionPoint;
  121094. /**
  121095. * Gets the right operand input component
  121096. */
  121097. readonly right: NodeMaterialConnectionPoint;
  121098. /**
  121099. * Gets the output component
  121100. */
  121101. readonly output: NodeMaterialConnectionPoint;
  121102. protected _buildBlock(state: NodeMaterialBuildState): this;
  121103. }
  121104. }
  121105. declare module BABYLON {
  121106. /**
  121107. * Block used to scale a vector by a float
  121108. */
  121109. export class ScaleBlock extends NodeMaterialBlock {
  121110. /**
  121111. * Creates a new ScaleBlock
  121112. * @param name defines the block name
  121113. */
  121114. constructor(name: string);
  121115. /**
  121116. * Gets the current class name
  121117. * @returns the class name
  121118. */
  121119. getClassName(): string;
  121120. /**
  121121. * Gets the input component
  121122. */
  121123. readonly input: NodeMaterialConnectionPoint;
  121124. /**
  121125. * Gets the factor input component
  121126. */
  121127. readonly factor: NodeMaterialConnectionPoint;
  121128. /**
  121129. * Gets the output component
  121130. */
  121131. readonly output: NodeMaterialConnectionPoint;
  121132. protected _buildBlock(state: NodeMaterialBuildState): this;
  121133. }
  121134. }
  121135. declare module BABYLON {
  121136. /**
  121137. * Block used to clamp a float
  121138. */
  121139. export class ClampBlock extends NodeMaterialBlock {
  121140. /** Gets or sets the minimum range */
  121141. minimum: number;
  121142. /** Gets or sets the maximum range */
  121143. maximum: number;
  121144. /**
  121145. * Creates a new ClampBlock
  121146. * @param name defines the block name
  121147. */
  121148. constructor(name: string);
  121149. /**
  121150. * Gets the current class name
  121151. * @returns the class name
  121152. */
  121153. getClassName(): string;
  121154. /**
  121155. * Gets the value input component
  121156. */
  121157. readonly value: NodeMaterialConnectionPoint;
  121158. /**
  121159. * Gets the output component
  121160. */
  121161. readonly output: NodeMaterialConnectionPoint;
  121162. protected _buildBlock(state: NodeMaterialBuildState): this;
  121163. protected _dumpPropertiesCode(): string;
  121164. serialize(): any;
  121165. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121166. }
  121167. }
  121168. declare module BABYLON {
  121169. /**
  121170. * Block used to apply a cross product between 2 vectors
  121171. */
  121172. export class CrossBlock extends NodeMaterialBlock {
  121173. /**
  121174. * Creates a new CrossBlock
  121175. * @param name defines the block name
  121176. */
  121177. constructor(name: string);
  121178. /**
  121179. * Gets the current class name
  121180. * @returns the class name
  121181. */
  121182. getClassName(): string;
  121183. /**
  121184. * Gets the left operand input component
  121185. */
  121186. readonly left: NodeMaterialConnectionPoint;
  121187. /**
  121188. * Gets the right operand input component
  121189. */
  121190. readonly right: NodeMaterialConnectionPoint;
  121191. /**
  121192. * Gets the output component
  121193. */
  121194. readonly output: NodeMaterialConnectionPoint;
  121195. protected _buildBlock(state: NodeMaterialBuildState): this;
  121196. }
  121197. }
  121198. declare module BABYLON {
  121199. /**
  121200. * Block used to apply a dot product between 2 vectors
  121201. */
  121202. export class DotBlock extends NodeMaterialBlock {
  121203. /**
  121204. * Creates a new DotBlock
  121205. * @param name defines the block name
  121206. */
  121207. constructor(name: string);
  121208. /**
  121209. * Gets the current class name
  121210. * @returns the class name
  121211. */
  121212. getClassName(): string;
  121213. /**
  121214. * Gets the left operand input component
  121215. */
  121216. readonly left: NodeMaterialConnectionPoint;
  121217. /**
  121218. * Gets the right operand input component
  121219. */
  121220. readonly right: NodeMaterialConnectionPoint;
  121221. /**
  121222. * Gets the output component
  121223. */
  121224. readonly output: NodeMaterialConnectionPoint;
  121225. protected _buildBlock(state: NodeMaterialBuildState): this;
  121226. }
  121227. }
  121228. declare module BABYLON {
  121229. /**
  121230. * Block used to remap a float from a range to a new one
  121231. */
  121232. export class RemapBlock extends NodeMaterialBlock {
  121233. /**
  121234. * Gets or sets the source range
  121235. */
  121236. sourceRange: Vector2;
  121237. /**
  121238. * Gets or sets the target range
  121239. */
  121240. targetRange: Vector2;
  121241. /**
  121242. * Creates a new RemapBlock
  121243. * @param name defines the block name
  121244. */
  121245. constructor(name: string);
  121246. /**
  121247. * Gets the current class name
  121248. * @returns the class name
  121249. */
  121250. getClassName(): string;
  121251. /**
  121252. * Gets the input component
  121253. */
  121254. readonly input: NodeMaterialConnectionPoint;
  121255. /**
  121256. * Gets the source min input component
  121257. */
  121258. readonly sourceMin: NodeMaterialConnectionPoint;
  121259. /**
  121260. * Gets the source max input component
  121261. */
  121262. readonly sourceMax: NodeMaterialConnectionPoint;
  121263. /**
  121264. * Gets the target min input component
  121265. */
  121266. readonly targetMin: NodeMaterialConnectionPoint;
  121267. /**
  121268. * Gets the target max input component
  121269. */
  121270. readonly targetMax: NodeMaterialConnectionPoint;
  121271. /**
  121272. * Gets the output component
  121273. */
  121274. readonly output: NodeMaterialConnectionPoint;
  121275. protected _buildBlock(state: NodeMaterialBuildState): this;
  121276. protected _dumpPropertiesCode(): string;
  121277. serialize(): any;
  121278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121279. }
  121280. }
  121281. declare module BABYLON {
  121282. /**
  121283. * Block used to normalize a vector
  121284. */
  121285. export class NormalizeBlock extends NodeMaterialBlock {
  121286. /**
  121287. * Creates a new NormalizeBlock
  121288. * @param name defines the block name
  121289. */
  121290. constructor(name: string);
  121291. /**
  121292. * Gets the current class name
  121293. * @returns the class name
  121294. */
  121295. getClassName(): string;
  121296. /**
  121297. * Gets the input component
  121298. */
  121299. readonly input: NodeMaterialConnectionPoint;
  121300. /**
  121301. * Gets the output component
  121302. */
  121303. readonly output: NodeMaterialConnectionPoint;
  121304. protected _buildBlock(state: NodeMaterialBuildState): this;
  121305. }
  121306. }
  121307. declare module BABYLON {
  121308. /**
  121309. * Operations supported by the Trigonometry block
  121310. */
  121311. export enum TrigonometryBlockOperations {
  121312. /** Cos */
  121313. Cos = 0,
  121314. /** Sin */
  121315. Sin = 1,
  121316. /** Abs */
  121317. Abs = 2,
  121318. /** Exp */
  121319. Exp = 3,
  121320. /** Exp2 */
  121321. Exp2 = 4,
  121322. /** Round */
  121323. Round = 5,
  121324. /** Floor */
  121325. Floor = 6,
  121326. /** Ceiling */
  121327. Ceiling = 7,
  121328. /** Square root */
  121329. Sqrt = 8,
  121330. /** Log */
  121331. Log = 9,
  121332. /** Tangent */
  121333. Tan = 10,
  121334. /** Arc tangent */
  121335. ArcTan = 11,
  121336. /** Arc cosinus */
  121337. ArcCos = 12,
  121338. /** Arc sinus */
  121339. ArcSin = 13,
  121340. /** Fraction */
  121341. Fract = 14,
  121342. /** Sign */
  121343. Sign = 15,
  121344. /** To radians (from degrees) */
  121345. Radians = 16,
  121346. /** To degrees (from radians) */
  121347. Degrees = 17
  121348. }
  121349. /**
  121350. * Block used to apply trigonometry operation to floats
  121351. */
  121352. export class TrigonometryBlock extends NodeMaterialBlock {
  121353. /**
  121354. * Gets or sets the operation applied by the block
  121355. */
  121356. operation: TrigonometryBlockOperations;
  121357. /**
  121358. * Creates a new TrigonometryBlock
  121359. * @param name defines the block name
  121360. */
  121361. constructor(name: string);
  121362. /**
  121363. * Gets the current class name
  121364. * @returns the class name
  121365. */
  121366. getClassName(): string;
  121367. /**
  121368. * Gets the input component
  121369. */
  121370. readonly input: NodeMaterialConnectionPoint;
  121371. /**
  121372. * Gets the output component
  121373. */
  121374. readonly output: NodeMaterialConnectionPoint;
  121375. protected _buildBlock(state: NodeMaterialBuildState): this;
  121376. serialize(): any;
  121377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121378. }
  121379. }
  121380. declare module BABYLON {
  121381. /**
  121382. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121383. */
  121384. export class ColorMergerBlock extends NodeMaterialBlock {
  121385. /**
  121386. * Create a new ColorMergerBlock
  121387. * @param name defines the block name
  121388. */
  121389. constructor(name: string);
  121390. /**
  121391. * Gets the current class name
  121392. * @returns the class name
  121393. */
  121394. getClassName(): string;
  121395. /**
  121396. * Gets the r component (input)
  121397. */
  121398. readonly r: NodeMaterialConnectionPoint;
  121399. /**
  121400. * Gets the g component (input)
  121401. */
  121402. readonly g: NodeMaterialConnectionPoint;
  121403. /**
  121404. * Gets the b component (input)
  121405. */
  121406. readonly b: NodeMaterialConnectionPoint;
  121407. /**
  121408. * Gets the a component (input)
  121409. */
  121410. readonly a: NodeMaterialConnectionPoint;
  121411. /**
  121412. * Gets the rgba component (output)
  121413. */
  121414. readonly rgba: NodeMaterialConnectionPoint;
  121415. /**
  121416. * Gets the rgb component (output)
  121417. */
  121418. readonly rgb: NodeMaterialConnectionPoint;
  121419. protected _buildBlock(state: NodeMaterialBuildState): this;
  121420. }
  121421. }
  121422. declare module BABYLON {
  121423. /**
  121424. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121425. */
  121426. export class VectorMergerBlock extends NodeMaterialBlock {
  121427. /**
  121428. * Create a new VectorMergerBlock
  121429. * @param name defines the block name
  121430. */
  121431. constructor(name: string);
  121432. /**
  121433. * Gets the current class name
  121434. * @returns the class name
  121435. */
  121436. getClassName(): string;
  121437. /**
  121438. * Gets the x component (input)
  121439. */
  121440. readonly x: NodeMaterialConnectionPoint;
  121441. /**
  121442. * Gets the y component (input)
  121443. */
  121444. readonly y: NodeMaterialConnectionPoint;
  121445. /**
  121446. * Gets the z component (input)
  121447. */
  121448. readonly z: NodeMaterialConnectionPoint;
  121449. /**
  121450. * Gets the w component (input)
  121451. */
  121452. readonly w: NodeMaterialConnectionPoint;
  121453. /**
  121454. * Gets the xyzw component (output)
  121455. */
  121456. readonly xyzw: NodeMaterialConnectionPoint;
  121457. /**
  121458. * Gets the xyz component (output)
  121459. */
  121460. readonly xyz: NodeMaterialConnectionPoint;
  121461. /**
  121462. * Gets the xy component (output)
  121463. */
  121464. readonly xy: NodeMaterialConnectionPoint;
  121465. protected _buildBlock(state: NodeMaterialBuildState): this;
  121466. }
  121467. }
  121468. declare module BABYLON {
  121469. /**
  121470. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121471. */
  121472. export class ColorSplitterBlock extends NodeMaterialBlock {
  121473. /**
  121474. * Create a new ColorSplitterBlock
  121475. * @param name defines the block name
  121476. */
  121477. constructor(name: string);
  121478. /**
  121479. * Gets the current class name
  121480. * @returns the class name
  121481. */
  121482. getClassName(): string;
  121483. /**
  121484. * Gets the rgba component (input)
  121485. */
  121486. readonly rgba: NodeMaterialConnectionPoint;
  121487. /**
  121488. * Gets the rgb component (input)
  121489. */
  121490. readonly rgbIn: NodeMaterialConnectionPoint;
  121491. /**
  121492. * Gets the rgb component (output)
  121493. */
  121494. readonly rgbOut: NodeMaterialConnectionPoint;
  121495. /**
  121496. * Gets the r component (output)
  121497. */
  121498. readonly r: NodeMaterialConnectionPoint;
  121499. /**
  121500. * Gets the g component (output)
  121501. */
  121502. readonly g: NodeMaterialConnectionPoint;
  121503. /**
  121504. * Gets the b component (output)
  121505. */
  121506. readonly b: NodeMaterialConnectionPoint;
  121507. /**
  121508. * Gets the a component (output)
  121509. */
  121510. readonly a: NodeMaterialConnectionPoint;
  121511. protected _inputRename(name: string): string;
  121512. protected _outputRename(name: string): string;
  121513. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121514. }
  121515. }
  121516. declare module BABYLON {
  121517. /**
  121518. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121519. */
  121520. export class VectorSplitterBlock extends NodeMaterialBlock {
  121521. /**
  121522. * Create a new VectorSplitterBlock
  121523. * @param name defines the block name
  121524. */
  121525. constructor(name: string);
  121526. /**
  121527. * Gets the current class name
  121528. * @returns the class name
  121529. */
  121530. getClassName(): string;
  121531. /**
  121532. * Gets the xyzw component (input)
  121533. */
  121534. readonly xyzw: NodeMaterialConnectionPoint;
  121535. /**
  121536. * Gets the xyz component (input)
  121537. */
  121538. readonly xyzIn: NodeMaterialConnectionPoint;
  121539. /**
  121540. * Gets the xy component (input)
  121541. */
  121542. readonly xyIn: NodeMaterialConnectionPoint;
  121543. /**
  121544. * Gets the xyz component (output)
  121545. */
  121546. readonly xyzOut: NodeMaterialConnectionPoint;
  121547. /**
  121548. * Gets the xy component (output)
  121549. */
  121550. readonly xyOut: NodeMaterialConnectionPoint;
  121551. /**
  121552. * Gets the x component (output)
  121553. */
  121554. readonly x: NodeMaterialConnectionPoint;
  121555. /**
  121556. * Gets the y component (output)
  121557. */
  121558. readonly y: NodeMaterialConnectionPoint;
  121559. /**
  121560. * Gets the z component (output)
  121561. */
  121562. readonly z: NodeMaterialConnectionPoint;
  121563. /**
  121564. * Gets the w component (output)
  121565. */
  121566. readonly w: NodeMaterialConnectionPoint;
  121567. protected _inputRename(name: string): string;
  121568. protected _outputRename(name: string): string;
  121569. protected _buildBlock(state: NodeMaterialBuildState): this;
  121570. }
  121571. }
  121572. declare module BABYLON {
  121573. /**
  121574. * Block used to lerp between 2 values
  121575. */
  121576. export class LerpBlock extends NodeMaterialBlock {
  121577. /**
  121578. * Creates a new LerpBlock
  121579. * @param name defines the block name
  121580. */
  121581. constructor(name: string);
  121582. /**
  121583. * Gets the current class name
  121584. * @returns the class name
  121585. */
  121586. getClassName(): string;
  121587. /**
  121588. * Gets the left operand input component
  121589. */
  121590. readonly left: NodeMaterialConnectionPoint;
  121591. /**
  121592. * Gets the right operand input component
  121593. */
  121594. readonly right: NodeMaterialConnectionPoint;
  121595. /**
  121596. * Gets the gradient operand input component
  121597. */
  121598. readonly gradient: NodeMaterialConnectionPoint;
  121599. /**
  121600. * Gets the output component
  121601. */
  121602. readonly output: NodeMaterialConnectionPoint;
  121603. protected _buildBlock(state: NodeMaterialBuildState): this;
  121604. }
  121605. }
  121606. declare module BABYLON {
  121607. /**
  121608. * Block used to divide 2 vectors
  121609. */
  121610. export class DivideBlock extends NodeMaterialBlock {
  121611. /**
  121612. * Creates a new DivideBlock
  121613. * @param name defines the block name
  121614. */
  121615. constructor(name: string);
  121616. /**
  121617. * Gets the current class name
  121618. * @returns the class name
  121619. */
  121620. getClassName(): string;
  121621. /**
  121622. * Gets the left operand input component
  121623. */
  121624. readonly left: NodeMaterialConnectionPoint;
  121625. /**
  121626. * Gets the right operand input component
  121627. */
  121628. readonly right: NodeMaterialConnectionPoint;
  121629. /**
  121630. * Gets the output component
  121631. */
  121632. readonly output: NodeMaterialConnectionPoint;
  121633. protected _buildBlock(state: NodeMaterialBuildState): this;
  121634. }
  121635. }
  121636. declare module BABYLON {
  121637. /**
  121638. * Block used to subtract 2 vectors
  121639. */
  121640. export class SubtractBlock extends NodeMaterialBlock {
  121641. /**
  121642. * Creates a new SubtractBlock
  121643. * @param name defines the block name
  121644. */
  121645. constructor(name: string);
  121646. /**
  121647. * Gets the current class name
  121648. * @returns the class name
  121649. */
  121650. getClassName(): string;
  121651. /**
  121652. * Gets the left operand input component
  121653. */
  121654. readonly left: NodeMaterialConnectionPoint;
  121655. /**
  121656. * Gets the right operand input component
  121657. */
  121658. readonly right: NodeMaterialConnectionPoint;
  121659. /**
  121660. * Gets the output component
  121661. */
  121662. readonly output: NodeMaterialConnectionPoint;
  121663. protected _buildBlock(state: NodeMaterialBuildState): this;
  121664. }
  121665. }
  121666. declare module BABYLON {
  121667. /**
  121668. * Block used to step a value
  121669. */
  121670. export class StepBlock extends NodeMaterialBlock {
  121671. /**
  121672. * Creates a new StepBlock
  121673. * @param name defines the block name
  121674. */
  121675. constructor(name: string);
  121676. /**
  121677. * Gets the current class name
  121678. * @returns the class name
  121679. */
  121680. getClassName(): string;
  121681. /**
  121682. * Gets the value operand input component
  121683. */
  121684. readonly value: NodeMaterialConnectionPoint;
  121685. /**
  121686. * Gets the edge operand input component
  121687. */
  121688. readonly edge: NodeMaterialConnectionPoint;
  121689. /**
  121690. * Gets the output component
  121691. */
  121692. readonly output: NodeMaterialConnectionPoint;
  121693. protected _buildBlock(state: NodeMaterialBuildState): this;
  121694. }
  121695. }
  121696. declare module BABYLON {
  121697. /**
  121698. * Block used to get the opposite (1 - x) of a value
  121699. */
  121700. export class OneMinusBlock extends NodeMaterialBlock {
  121701. /**
  121702. * Creates a new OneMinusBlock
  121703. * @param name defines the block name
  121704. */
  121705. constructor(name: string);
  121706. /**
  121707. * Gets the current class name
  121708. * @returns the class name
  121709. */
  121710. getClassName(): string;
  121711. /**
  121712. * Gets the input component
  121713. */
  121714. readonly input: NodeMaterialConnectionPoint;
  121715. /**
  121716. * Gets the output component
  121717. */
  121718. readonly output: NodeMaterialConnectionPoint;
  121719. protected _buildBlock(state: NodeMaterialBuildState): this;
  121720. }
  121721. }
  121722. declare module BABYLON {
  121723. /**
  121724. * Block used to get the view direction
  121725. */
  121726. export class ViewDirectionBlock extends NodeMaterialBlock {
  121727. /**
  121728. * Creates a new ViewDirectionBlock
  121729. * @param name defines the block name
  121730. */
  121731. constructor(name: string);
  121732. /**
  121733. * Gets the current class name
  121734. * @returns the class name
  121735. */
  121736. getClassName(): string;
  121737. /**
  121738. * Gets the world position component
  121739. */
  121740. readonly worldPosition: NodeMaterialConnectionPoint;
  121741. /**
  121742. * Gets the camera position component
  121743. */
  121744. readonly cameraPosition: NodeMaterialConnectionPoint;
  121745. /**
  121746. * Gets the output component
  121747. */
  121748. readonly output: NodeMaterialConnectionPoint;
  121749. autoConfigure(material: NodeMaterial): void;
  121750. protected _buildBlock(state: NodeMaterialBuildState): this;
  121751. }
  121752. }
  121753. declare module BABYLON {
  121754. /**
  121755. * Block used to compute fresnel value
  121756. */
  121757. export class FresnelBlock extends NodeMaterialBlock {
  121758. /**
  121759. * Create a new FresnelBlock
  121760. * @param name defines the block name
  121761. */
  121762. constructor(name: string);
  121763. /**
  121764. * Gets the current class name
  121765. * @returns the class name
  121766. */
  121767. getClassName(): string;
  121768. /**
  121769. * Gets the world normal input component
  121770. */
  121771. readonly worldNormal: NodeMaterialConnectionPoint;
  121772. /**
  121773. * Gets the view direction input component
  121774. */
  121775. readonly viewDirection: NodeMaterialConnectionPoint;
  121776. /**
  121777. * Gets the bias input component
  121778. */
  121779. readonly bias: NodeMaterialConnectionPoint;
  121780. /**
  121781. * Gets the camera (or eye) position component
  121782. */
  121783. readonly power: NodeMaterialConnectionPoint;
  121784. /**
  121785. * Gets the fresnel output component
  121786. */
  121787. readonly fresnel: NodeMaterialConnectionPoint;
  121788. autoConfigure(material: NodeMaterial): void;
  121789. protected _buildBlock(state: NodeMaterialBuildState): this;
  121790. }
  121791. }
  121792. declare module BABYLON {
  121793. /**
  121794. * Block used to get the max of 2 values
  121795. */
  121796. export class MaxBlock extends NodeMaterialBlock {
  121797. /**
  121798. * Creates a new MaxBlock
  121799. * @param name defines the block name
  121800. */
  121801. constructor(name: string);
  121802. /**
  121803. * Gets the current class name
  121804. * @returns the class name
  121805. */
  121806. getClassName(): string;
  121807. /**
  121808. * Gets the left operand input component
  121809. */
  121810. readonly left: NodeMaterialConnectionPoint;
  121811. /**
  121812. * Gets the right operand input component
  121813. */
  121814. readonly right: NodeMaterialConnectionPoint;
  121815. /**
  121816. * Gets the output component
  121817. */
  121818. readonly output: NodeMaterialConnectionPoint;
  121819. protected _buildBlock(state: NodeMaterialBuildState): this;
  121820. }
  121821. }
  121822. declare module BABYLON {
  121823. /**
  121824. * Block used to get the min of 2 values
  121825. */
  121826. export class MinBlock extends NodeMaterialBlock {
  121827. /**
  121828. * Creates a new MinBlock
  121829. * @param name defines the block name
  121830. */
  121831. constructor(name: string);
  121832. /**
  121833. * Gets the current class name
  121834. * @returns the class name
  121835. */
  121836. getClassName(): string;
  121837. /**
  121838. * Gets the left operand input component
  121839. */
  121840. readonly left: NodeMaterialConnectionPoint;
  121841. /**
  121842. * Gets the right operand input component
  121843. */
  121844. readonly right: NodeMaterialConnectionPoint;
  121845. /**
  121846. * Gets the output component
  121847. */
  121848. readonly output: NodeMaterialConnectionPoint;
  121849. protected _buildBlock(state: NodeMaterialBuildState): this;
  121850. }
  121851. }
  121852. declare module BABYLON {
  121853. /**
  121854. * Block used to get the distance between 2 values
  121855. */
  121856. export class DistanceBlock extends NodeMaterialBlock {
  121857. /**
  121858. * Creates a new DistanceBlock
  121859. * @param name defines the block name
  121860. */
  121861. constructor(name: string);
  121862. /**
  121863. * Gets the current class name
  121864. * @returns the class name
  121865. */
  121866. getClassName(): string;
  121867. /**
  121868. * Gets the left operand input component
  121869. */
  121870. readonly left: NodeMaterialConnectionPoint;
  121871. /**
  121872. * Gets the right operand input component
  121873. */
  121874. readonly right: NodeMaterialConnectionPoint;
  121875. /**
  121876. * Gets the output component
  121877. */
  121878. readonly output: NodeMaterialConnectionPoint;
  121879. protected _buildBlock(state: NodeMaterialBuildState): this;
  121880. }
  121881. }
  121882. declare module BABYLON {
  121883. /**
  121884. * Block used to get the length of a vector
  121885. */
  121886. export class LengthBlock extends NodeMaterialBlock {
  121887. /**
  121888. * Creates a new LengthBlock
  121889. * @param name defines the block name
  121890. */
  121891. constructor(name: string);
  121892. /**
  121893. * Gets the current class name
  121894. * @returns the class name
  121895. */
  121896. getClassName(): string;
  121897. /**
  121898. * Gets the value input component
  121899. */
  121900. readonly value: NodeMaterialConnectionPoint;
  121901. /**
  121902. * Gets the output component
  121903. */
  121904. readonly output: NodeMaterialConnectionPoint;
  121905. protected _buildBlock(state: NodeMaterialBuildState): this;
  121906. }
  121907. }
  121908. declare module BABYLON {
  121909. /**
  121910. * Block used to get negative version of a value (i.e. x * -1)
  121911. */
  121912. export class NegateBlock extends NodeMaterialBlock {
  121913. /**
  121914. * Creates a new NegateBlock
  121915. * @param name defines the block name
  121916. */
  121917. constructor(name: string);
  121918. /**
  121919. * Gets the current class name
  121920. * @returns the class name
  121921. */
  121922. getClassName(): string;
  121923. /**
  121924. * Gets the value input component
  121925. */
  121926. readonly value: NodeMaterialConnectionPoint;
  121927. /**
  121928. * Gets the output component
  121929. */
  121930. readonly output: NodeMaterialConnectionPoint;
  121931. protected _buildBlock(state: NodeMaterialBuildState): this;
  121932. }
  121933. }
  121934. declare module BABYLON {
  121935. /**
  121936. * Block used to get the value of the first parameter raised to the power of the second
  121937. */
  121938. export class PowBlock extends NodeMaterialBlock {
  121939. /**
  121940. * Creates a new PowBlock
  121941. * @param name defines the block name
  121942. */
  121943. constructor(name: string);
  121944. /**
  121945. * Gets the current class name
  121946. * @returns the class name
  121947. */
  121948. getClassName(): string;
  121949. /**
  121950. * Gets the value operand input component
  121951. */
  121952. readonly value: NodeMaterialConnectionPoint;
  121953. /**
  121954. * Gets the power operand input component
  121955. */
  121956. readonly power: NodeMaterialConnectionPoint;
  121957. /**
  121958. * Gets the output component
  121959. */
  121960. readonly output: NodeMaterialConnectionPoint;
  121961. protected _buildBlock(state: NodeMaterialBuildState): this;
  121962. }
  121963. }
  121964. declare module BABYLON {
  121965. /**
  121966. * Block used to get a random number
  121967. */
  121968. export class RandomNumberBlock extends NodeMaterialBlock {
  121969. /**
  121970. * Creates a new RandomNumberBlock
  121971. * @param name defines the block name
  121972. */
  121973. constructor(name: string);
  121974. /**
  121975. * Gets the current class name
  121976. * @returns the class name
  121977. */
  121978. getClassName(): string;
  121979. /**
  121980. * Gets the seed input component
  121981. */
  121982. readonly seed: NodeMaterialConnectionPoint;
  121983. /**
  121984. * Gets the output component
  121985. */
  121986. readonly output: NodeMaterialConnectionPoint;
  121987. protected _buildBlock(state: NodeMaterialBuildState): this;
  121988. }
  121989. }
  121990. declare module BABYLON {
  121991. /**
  121992. * Block used to compute arc tangent of 2 values
  121993. */
  121994. export class ArcTan2Block extends NodeMaterialBlock {
  121995. /**
  121996. * Creates a new ArcTan2Block
  121997. * @param name defines the block name
  121998. */
  121999. constructor(name: string);
  122000. /**
  122001. * Gets the current class name
  122002. * @returns the class name
  122003. */
  122004. getClassName(): string;
  122005. /**
  122006. * Gets the x operand input component
  122007. */
  122008. readonly x: NodeMaterialConnectionPoint;
  122009. /**
  122010. * Gets the y operand input component
  122011. */
  122012. readonly y: NodeMaterialConnectionPoint;
  122013. /**
  122014. * Gets the output component
  122015. */
  122016. readonly output: NodeMaterialConnectionPoint;
  122017. protected _buildBlock(state: NodeMaterialBuildState): this;
  122018. }
  122019. }
  122020. declare module BABYLON {
  122021. /**
  122022. * Block used to smooth step a value
  122023. */
  122024. export class SmoothStepBlock extends NodeMaterialBlock {
  122025. /**
  122026. * Creates a new SmoothStepBlock
  122027. * @param name defines the block name
  122028. */
  122029. constructor(name: string);
  122030. /**
  122031. * Gets the current class name
  122032. * @returns the class name
  122033. */
  122034. getClassName(): string;
  122035. /**
  122036. * Gets the value operand input component
  122037. */
  122038. readonly value: NodeMaterialConnectionPoint;
  122039. /**
  122040. * Gets the first edge operand input component
  122041. */
  122042. readonly edge0: NodeMaterialConnectionPoint;
  122043. /**
  122044. * Gets the second edge operand input component
  122045. */
  122046. readonly edge1: NodeMaterialConnectionPoint;
  122047. /**
  122048. * Gets the output component
  122049. */
  122050. readonly output: NodeMaterialConnectionPoint;
  122051. protected _buildBlock(state: NodeMaterialBuildState): this;
  122052. }
  122053. }
  122054. declare module BABYLON {
  122055. /**
  122056. * Block used to get the reciprocal (1 / x) of a value
  122057. */
  122058. export class ReciprocalBlock extends NodeMaterialBlock {
  122059. /**
  122060. * Creates a new ReciprocalBlock
  122061. * @param name defines the block name
  122062. */
  122063. constructor(name: string);
  122064. /**
  122065. * Gets the current class name
  122066. * @returns the class name
  122067. */
  122068. getClassName(): string;
  122069. /**
  122070. * Gets the input component
  122071. */
  122072. readonly input: NodeMaterialConnectionPoint;
  122073. /**
  122074. * Gets the output component
  122075. */
  122076. readonly output: NodeMaterialConnectionPoint;
  122077. protected _buildBlock(state: NodeMaterialBuildState): this;
  122078. }
  122079. }
  122080. declare module BABYLON {
  122081. /**
  122082. * Block used to replace a color by another one
  122083. */
  122084. export class ReplaceColorBlock extends NodeMaterialBlock {
  122085. /**
  122086. * Creates a new ReplaceColorBlock
  122087. * @param name defines the block name
  122088. */
  122089. constructor(name: string);
  122090. /**
  122091. * Gets the current class name
  122092. * @returns the class name
  122093. */
  122094. getClassName(): string;
  122095. /**
  122096. * Gets the value input component
  122097. */
  122098. readonly value: NodeMaterialConnectionPoint;
  122099. /**
  122100. * Gets the reference input component
  122101. */
  122102. readonly reference: NodeMaterialConnectionPoint;
  122103. /**
  122104. * Gets the distance input component
  122105. */
  122106. readonly distance: NodeMaterialConnectionPoint;
  122107. /**
  122108. * Gets the replacement input component
  122109. */
  122110. readonly replacement: NodeMaterialConnectionPoint;
  122111. /**
  122112. * Gets the output component
  122113. */
  122114. readonly output: NodeMaterialConnectionPoint;
  122115. protected _buildBlock(state: NodeMaterialBuildState): this;
  122116. }
  122117. }
  122118. declare module BABYLON {
  122119. /**
  122120. * Block used to posterize a value
  122121. * @see https://en.wikipedia.org/wiki/Posterization
  122122. */
  122123. export class PosterizeBlock extends NodeMaterialBlock {
  122124. /**
  122125. * Creates a new PosterizeBlock
  122126. * @param name defines the block name
  122127. */
  122128. constructor(name: string);
  122129. /**
  122130. * Gets the current class name
  122131. * @returns the class name
  122132. */
  122133. getClassName(): string;
  122134. /**
  122135. * Gets the value input component
  122136. */
  122137. readonly value: NodeMaterialConnectionPoint;
  122138. /**
  122139. * Gets the steps input component
  122140. */
  122141. readonly steps: NodeMaterialConnectionPoint;
  122142. /**
  122143. * Gets the output component
  122144. */
  122145. readonly output: NodeMaterialConnectionPoint;
  122146. protected _buildBlock(state: NodeMaterialBuildState): this;
  122147. }
  122148. }
  122149. declare module BABYLON {
  122150. /**
  122151. * Operations supported by the Wave block
  122152. */
  122153. export enum WaveBlockKind {
  122154. /** SawTooth */
  122155. SawTooth = 0,
  122156. /** Square */
  122157. Square = 1,
  122158. /** Triangle */
  122159. Triangle = 2
  122160. }
  122161. /**
  122162. * Block used to apply wave operation to floats
  122163. */
  122164. export class WaveBlock extends NodeMaterialBlock {
  122165. /**
  122166. * Gets or sets the kibnd of wave to be applied by the block
  122167. */
  122168. kind: WaveBlockKind;
  122169. /**
  122170. * Creates a new WaveBlock
  122171. * @param name defines the block name
  122172. */
  122173. constructor(name: string);
  122174. /**
  122175. * Gets the current class name
  122176. * @returns the class name
  122177. */
  122178. getClassName(): string;
  122179. /**
  122180. * Gets the input component
  122181. */
  122182. readonly input: NodeMaterialConnectionPoint;
  122183. /**
  122184. * Gets the output component
  122185. */
  122186. readonly output: NodeMaterialConnectionPoint;
  122187. protected _buildBlock(state: NodeMaterialBuildState): this;
  122188. serialize(): any;
  122189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122190. }
  122191. }
  122192. declare module BABYLON {
  122193. /**
  122194. * Class used to store a color step for the GradientBlock
  122195. */
  122196. export class GradientBlockColorStep {
  122197. /**
  122198. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122199. */
  122200. step: number;
  122201. /**
  122202. * Gets or sets the color associated with this step
  122203. */
  122204. color: Color3;
  122205. /**
  122206. * Creates a new GradientBlockColorStep
  122207. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122208. * @param color defines the color associated with this step
  122209. */
  122210. constructor(
  122211. /**
  122212. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122213. */
  122214. step: number,
  122215. /**
  122216. * Gets or sets the color associated with this step
  122217. */
  122218. color: Color3);
  122219. }
  122220. /**
  122221. * Block used to return a color from a gradient based on an input value between 0 and 1
  122222. */
  122223. export class GradientBlock extends NodeMaterialBlock {
  122224. /**
  122225. * Gets or sets the list of color steps
  122226. */
  122227. colorSteps: GradientBlockColorStep[];
  122228. /**
  122229. * Creates a new GradientBlock
  122230. * @param name defines the block name
  122231. */
  122232. constructor(name: string);
  122233. /**
  122234. * Gets the current class name
  122235. * @returns the class name
  122236. */
  122237. getClassName(): string;
  122238. /**
  122239. * Gets the gradient input component
  122240. */
  122241. readonly gradient: NodeMaterialConnectionPoint;
  122242. /**
  122243. * Gets the output component
  122244. */
  122245. readonly output: NodeMaterialConnectionPoint;
  122246. private _writeColorConstant;
  122247. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122248. serialize(): any;
  122249. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122250. protected _dumpPropertiesCode(): string;
  122251. }
  122252. }
  122253. declare module BABYLON {
  122254. /**
  122255. * Block used to normalize lerp between 2 values
  122256. */
  122257. export class NLerpBlock extends NodeMaterialBlock {
  122258. /**
  122259. * Creates a new NLerpBlock
  122260. * @param name defines the block name
  122261. */
  122262. constructor(name: string);
  122263. /**
  122264. * Gets the current class name
  122265. * @returns the class name
  122266. */
  122267. getClassName(): string;
  122268. /**
  122269. * Gets the left operand input component
  122270. */
  122271. readonly left: NodeMaterialConnectionPoint;
  122272. /**
  122273. * Gets the right operand input component
  122274. */
  122275. readonly right: NodeMaterialConnectionPoint;
  122276. /**
  122277. * Gets the gradient operand input component
  122278. */
  122279. readonly gradient: NodeMaterialConnectionPoint;
  122280. /**
  122281. * Gets the output component
  122282. */
  122283. readonly output: NodeMaterialConnectionPoint;
  122284. protected _buildBlock(state: NodeMaterialBuildState): this;
  122285. }
  122286. }
  122287. declare module BABYLON {
  122288. /**
  122289. * Effect Render Options
  122290. */
  122291. export interface IEffectRendererOptions {
  122292. /**
  122293. * Defines the vertices positions.
  122294. */
  122295. positions?: number[];
  122296. /**
  122297. * Defines the indices.
  122298. */
  122299. indices?: number[];
  122300. }
  122301. /**
  122302. * Helper class to render one or more effects
  122303. */
  122304. export class EffectRenderer {
  122305. private engine;
  122306. private static _DefaultOptions;
  122307. private _vertexBuffers;
  122308. private _indexBuffer;
  122309. private _ringBufferIndex;
  122310. private _ringScreenBuffer;
  122311. private _fullscreenViewport;
  122312. private _getNextFrameBuffer;
  122313. /**
  122314. * Creates an effect renderer
  122315. * @param engine the engine to use for rendering
  122316. * @param options defines the options of the effect renderer
  122317. */
  122318. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122319. /**
  122320. * Sets the current viewport in normalized coordinates 0-1
  122321. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122322. */
  122323. setViewport(viewport?: Viewport): void;
  122324. /**
  122325. * Binds the embedded attributes buffer to the effect.
  122326. * @param effect Defines the effect to bind the attributes for
  122327. */
  122328. bindBuffers(effect: Effect): void;
  122329. /**
  122330. * Sets the current effect wrapper to use during draw.
  122331. * The effect needs to be ready before calling this api.
  122332. * This also sets the default full screen position attribute.
  122333. * @param effectWrapper Defines the effect to draw with
  122334. */
  122335. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122336. /**
  122337. * Draws a full screen quad.
  122338. */
  122339. draw(): void;
  122340. /**
  122341. * renders one or more effects to a specified texture
  122342. * @param effectWrappers list of effects to renderer
  122343. * @param outputTexture texture to draw to, if null it will render to the screen
  122344. */
  122345. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122346. /**
  122347. * Disposes of the effect renderer
  122348. */
  122349. dispose(): void;
  122350. }
  122351. /**
  122352. * Options to create an EffectWrapper
  122353. */
  122354. interface EffectWrapperCreationOptions {
  122355. /**
  122356. * Engine to use to create the effect
  122357. */
  122358. engine: ThinEngine;
  122359. /**
  122360. * Fragment shader for the effect
  122361. */
  122362. fragmentShader: string;
  122363. /**
  122364. * Vertex shader for the effect
  122365. */
  122366. vertexShader?: string;
  122367. /**
  122368. * Attributes to use in the shader
  122369. */
  122370. attributeNames?: Array<string>;
  122371. /**
  122372. * Uniforms to use in the shader
  122373. */
  122374. uniformNames?: Array<string>;
  122375. /**
  122376. * Texture sampler names to use in the shader
  122377. */
  122378. samplerNames?: Array<string>;
  122379. /**
  122380. * The friendly name of the effect displayed in Spector.
  122381. */
  122382. name?: string;
  122383. }
  122384. /**
  122385. * Wraps an effect to be used for rendering
  122386. */
  122387. export class EffectWrapper {
  122388. /**
  122389. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122390. */
  122391. onApplyObservable: Observable<{}>;
  122392. /**
  122393. * The underlying effect
  122394. */
  122395. effect: Effect;
  122396. /**
  122397. * Creates an effect to be renderer
  122398. * @param creationOptions options to create the effect
  122399. */
  122400. constructor(creationOptions: EffectWrapperCreationOptions);
  122401. /**
  122402. * Disposes of the effect wrapper
  122403. */
  122404. dispose(): void;
  122405. }
  122406. }
  122407. declare module BABYLON {
  122408. /**
  122409. * Helper class to push actions to a pool of workers.
  122410. */
  122411. export class WorkerPool implements IDisposable {
  122412. private _workerInfos;
  122413. private _pendingActions;
  122414. /**
  122415. * Constructor
  122416. * @param workers Array of workers to use for actions
  122417. */
  122418. constructor(workers: Array<Worker>);
  122419. /**
  122420. * Terminates all workers and clears any pending actions.
  122421. */
  122422. dispose(): void;
  122423. /**
  122424. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122425. * pended until a worker has completed its action.
  122426. * @param action The action to perform. Call onComplete when the action is complete.
  122427. */
  122428. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122429. private _execute;
  122430. }
  122431. }
  122432. declare module BABYLON {
  122433. /**
  122434. * Configuration for Draco compression
  122435. */
  122436. export interface IDracoCompressionConfiguration {
  122437. /**
  122438. * Configuration for the decoder.
  122439. */
  122440. decoder: {
  122441. /**
  122442. * The url to the WebAssembly module.
  122443. */
  122444. wasmUrl?: string;
  122445. /**
  122446. * The url to the WebAssembly binary.
  122447. */
  122448. wasmBinaryUrl?: string;
  122449. /**
  122450. * The url to the fallback JavaScript module.
  122451. */
  122452. fallbackUrl?: string;
  122453. };
  122454. }
  122455. /**
  122456. * Draco compression (https://google.github.io/draco/)
  122457. *
  122458. * This class wraps the Draco module.
  122459. *
  122460. * **Encoder**
  122461. *
  122462. * The encoder is not currently implemented.
  122463. *
  122464. * **Decoder**
  122465. *
  122466. * 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.
  122467. *
  122468. * To update the configuration, use the following code:
  122469. * ```javascript
  122470. * DracoCompression.Configuration = {
  122471. * decoder: {
  122472. * wasmUrl: "<url to the WebAssembly library>",
  122473. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122474. * fallbackUrl: "<url to the fallback JavaScript library>",
  122475. * }
  122476. * };
  122477. * ```
  122478. *
  122479. * 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.
  122480. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122481. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122482. *
  122483. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122484. * ```javascript
  122485. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122486. * ```
  122487. *
  122488. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122489. */
  122490. export class DracoCompression implements IDisposable {
  122491. private _workerPoolPromise?;
  122492. private _decoderModulePromise?;
  122493. /**
  122494. * The configuration. Defaults to the following urls:
  122495. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122496. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122497. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122498. */
  122499. static Configuration: IDracoCompressionConfiguration;
  122500. /**
  122501. * Returns true if the decoder configuration is available.
  122502. */
  122503. static readonly DecoderAvailable: boolean;
  122504. /**
  122505. * Default number of workers to create when creating the draco compression object.
  122506. */
  122507. static DefaultNumWorkers: number;
  122508. private static GetDefaultNumWorkers;
  122509. private static _Default;
  122510. /**
  122511. * Default instance for the draco compression object.
  122512. */
  122513. static readonly Default: DracoCompression;
  122514. /**
  122515. * Constructor
  122516. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122517. */
  122518. constructor(numWorkers?: number);
  122519. /**
  122520. * Stop all async operations and release resources.
  122521. */
  122522. dispose(): void;
  122523. /**
  122524. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122525. * @returns a promise that resolves when ready
  122526. */
  122527. whenReadyAsync(): Promise<void>;
  122528. /**
  122529. * Decode Draco compressed mesh data to vertex data.
  122530. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122531. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122532. * @returns A promise that resolves with the decoded vertex data
  122533. */
  122534. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122535. [kind: string]: number;
  122536. }): Promise<VertexData>;
  122537. }
  122538. }
  122539. declare module BABYLON {
  122540. /**
  122541. * Class for building Constructive Solid Geometry
  122542. */
  122543. export class CSG {
  122544. private polygons;
  122545. /**
  122546. * The world matrix
  122547. */
  122548. matrix: Matrix;
  122549. /**
  122550. * Stores the position
  122551. */
  122552. position: Vector3;
  122553. /**
  122554. * Stores the rotation
  122555. */
  122556. rotation: Vector3;
  122557. /**
  122558. * Stores the rotation quaternion
  122559. */
  122560. rotationQuaternion: Nullable<Quaternion>;
  122561. /**
  122562. * Stores the scaling vector
  122563. */
  122564. scaling: Vector3;
  122565. /**
  122566. * Convert the Mesh to CSG
  122567. * @param mesh The Mesh to convert to CSG
  122568. * @returns A new CSG from the Mesh
  122569. */
  122570. static FromMesh(mesh: Mesh): CSG;
  122571. /**
  122572. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122573. * @param polygons Polygons used to construct a CSG solid
  122574. */
  122575. private static FromPolygons;
  122576. /**
  122577. * Clones, or makes a deep copy, of the CSG
  122578. * @returns A new CSG
  122579. */
  122580. clone(): CSG;
  122581. /**
  122582. * Unions this CSG with another CSG
  122583. * @param csg The CSG to union against this CSG
  122584. * @returns The unioned CSG
  122585. */
  122586. union(csg: CSG): CSG;
  122587. /**
  122588. * Unions this CSG with another CSG in place
  122589. * @param csg The CSG to union against this CSG
  122590. */
  122591. unionInPlace(csg: CSG): void;
  122592. /**
  122593. * Subtracts this CSG with another CSG
  122594. * @param csg The CSG to subtract against this CSG
  122595. * @returns A new CSG
  122596. */
  122597. subtract(csg: CSG): CSG;
  122598. /**
  122599. * Subtracts this CSG with another CSG in place
  122600. * @param csg The CSG to subtact against this CSG
  122601. */
  122602. subtractInPlace(csg: CSG): void;
  122603. /**
  122604. * Intersect this CSG with another CSG
  122605. * @param csg The CSG to intersect against this CSG
  122606. * @returns A new CSG
  122607. */
  122608. intersect(csg: CSG): CSG;
  122609. /**
  122610. * Intersects this CSG with another CSG in place
  122611. * @param csg The CSG to intersect against this CSG
  122612. */
  122613. intersectInPlace(csg: CSG): void;
  122614. /**
  122615. * Return a new CSG solid with solid and empty space switched. This solid is
  122616. * not modified.
  122617. * @returns A new CSG solid with solid and empty space switched
  122618. */
  122619. inverse(): CSG;
  122620. /**
  122621. * Inverses the CSG in place
  122622. */
  122623. inverseInPlace(): void;
  122624. /**
  122625. * This is used to keep meshes transformations so they can be restored
  122626. * when we build back a Babylon Mesh
  122627. * NB : All CSG operations are performed in world coordinates
  122628. * @param csg The CSG to copy the transform attributes from
  122629. * @returns This CSG
  122630. */
  122631. copyTransformAttributes(csg: CSG): CSG;
  122632. /**
  122633. * Build Raw mesh from CSG
  122634. * Coordinates here are in world space
  122635. * @param name The name of the mesh geometry
  122636. * @param scene The Scene
  122637. * @param keepSubMeshes Specifies if the submeshes should be kept
  122638. * @returns A new Mesh
  122639. */
  122640. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122641. /**
  122642. * Build Mesh from CSG taking material and transforms into account
  122643. * @param name The name of the Mesh
  122644. * @param material The material of the Mesh
  122645. * @param scene The Scene
  122646. * @param keepSubMeshes Specifies if submeshes should be kept
  122647. * @returns The new Mesh
  122648. */
  122649. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122650. }
  122651. }
  122652. declare module BABYLON {
  122653. /**
  122654. * Class used to create a trail following a mesh
  122655. */
  122656. export class TrailMesh extends Mesh {
  122657. private _generator;
  122658. private _autoStart;
  122659. private _running;
  122660. private _diameter;
  122661. private _length;
  122662. private _sectionPolygonPointsCount;
  122663. private _sectionVectors;
  122664. private _sectionNormalVectors;
  122665. private _beforeRenderObserver;
  122666. /**
  122667. * @constructor
  122668. * @param name The value used by scene.getMeshByName() to do a lookup.
  122669. * @param generator The mesh to generate a trail.
  122670. * @param scene The scene to add this mesh to.
  122671. * @param diameter Diameter of trailing mesh. Default is 1.
  122672. * @param length Length of trailing mesh. Default is 60.
  122673. * @param autoStart Automatically start trailing mesh. Default true.
  122674. */
  122675. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122676. /**
  122677. * "TrailMesh"
  122678. * @returns "TrailMesh"
  122679. */
  122680. getClassName(): string;
  122681. private _createMesh;
  122682. /**
  122683. * Start trailing mesh.
  122684. */
  122685. start(): void;
  122686. /**
  122687. * Stop trailing mesh.
  122688. */
  122689. stop(): void;
  122690. /**
  122691. * Update trailing mesh geometry.
  122692. */
  122693. update(): void;
  122694. /**
  122695. * Returns a new TrailMesh object.
  122696. * @param name is a string, the name given to the new mesh
  122697. * @param newGenerator use new generator object for cloned trail mesh
  122698. * @returns a new mesh
  122699. */
  122700. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122701. /**
  122702. * Serializes this trail mesh
  122703. * @param serializationObject object to write serialization to
  122704. */
  122705. serialize(serializationObject: any): void;
  122706. /**
  122707. * Parses a serialized trail mesh
  122708. * @param parsedMesh the serialized mesh
  122709. * @param scene the scene to create the trail mesh in
  122710. * @returns the created trail mesh
  122711. */
  122712. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122713. }
  122714. }
  122715. declare module BABYLON {
  122716. /**
  122717. * Class containing static functions to help procedurally build meshes
  122718. */
  122719. export class TiledBoxBuilder {
  122720. /**
  122721. * Creates a box mesh
  122722. * 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)
  122723. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122727. * @param name defines the name of the mesh
  122728. * @param options defines the options used to create the mesh
  122729. * @param scene defines the hosting scene
  122730. * @returns the box mesh
  122731. */
  122732. static CreateTiledBox(name: string, options: {
  122733. pattern?: number;
  122734. width?: number;
  122735. height?: number;
  122736. depth?: number;
  122737. tileSize?: number;
  122738. tileWidth?: number;
  122739. tileHeight?: number;
  122740. alignHorizontal?: number;
  122741. alignVertical?: number;
  122742. faceUV?: Vector4[];
  122743. faceColors?: Color4[];
  122744. sideOrientation?: number;
  122745. updatable?: boolean;
  122746. }, scene?: Nullable<Scene>): Mesh;
  122747. }
  122748. }
  122749. declare module BABYLON {
  122750. /**
  122751. * Class containing static functions to help procedurally build meshes
  122752. */
  122753. export class TorusKnotBuilder {
  122754. /**
  122755. * Creates a torus knot mesh
  122756. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122757. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122758. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122759. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122763. * @param name defines the name of the mesh
  122764. * @param options defines the options used to create the mesh
  122765. * @param scene defines the hosting scene
  122766. * @returns the torus knot mesh
  122767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122768. */
  122769. static CreateTorusKnot(name: string, options: {
  122770. radius?: number;
  122771. tube?: number;
  122772. radialSegments?: number;
  122773. tubularSegments?: number;
  122774. p?: number;
  122775. q?: number;
  122776. updatable?: boolean;
  122777. sideOrientation?: number;
  122778. frontUVs?: Vector4;
  122779. backUVs?: Vector4;
  122780. }, scene: any): Mesh;
  122781. }
  122782. }
  122783. declare module BABYLON {
  122784. /**
  122785. * Polygon
  122786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122787. */
  122788. export class Polygon {
  122789. /**
  122790. * Creates a rectangle
  122791. * @param xmin bottom X coord
  122792. * @param ymin bottom Y coord
  122793. * @param xmax top X coord
  122794. * @param ymax top Y coord
  122795. * @returns points that make the resulting rectation
  122796. */
  122797. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122798. /**
  122799. * Creates a circle
  122800. * @param radius radius of circle
  122801. * @param cx scale in x
  122802. * @param cy scale in y
  122803. * @param numberOfSides number of sides that make up the circle
  122804. * @returns points that make the resulting circle
  122805. */
  122806. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122807. /**
  122808. * Creates a polygon from input string
  122809. * @param input Input polygon data
  122810. * @returns the parsed points
  122811. */
  122812. static Parse(input: string): Vector2[];
  122813. /**
  122814. * Starts building a polygon from x and y coordinates
  122815. * @param x x coordinate
  122816. * @param y y coordinate
  122817. * @returns the started path2
  122818. */
  122819. static StartingAt(x: number, y: number): Path2;
  122820. }
  122821. /**
  122822. * Builds a polygon
  122823. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122824. */
  122825. export class PolygonMeshBuilder {
  122826. private _points;
  122827. private _outlinepoints;
  122828. private _holes;
  122829. private _name;
  122830. private _scene;
  122831. private _epoints;
  122832. private _eholes;
  122833. private _addToepoint;
  122834. /**
  122835. * Babylon reference to the earcut plugin.
  122836. */
  122837. bjsEarcut: any;
  122838. /**
  122839. * Creates a PolygonMeshBuilder
  122840. * @param name name of the builder
  122841. * @param contours Path of the polygon
  122842. * @param scene scene to add to when creating the mesh
  122843. * @param earcutInjection can be used to inject your own earcut reference
  122844. */
  122845. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122846. /**
  122847. * Adds a whole within the polygon
  122848. * @param hole Array of points defining the hole
  122849. * @returns this
  122850. */
  122851. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122852. /**
  122853. * Creates the polygon
  122854. * @param updatable If the mesh should be updatable
  122855. * @param depth The depth of the mesh created
  122856. * @returns the created mesh
  122857. */
  122858. build(updatable?: boolean, depth?: number): Mesh;
  122859. /**
  122860. * Creates the polygon
  122861. * @param depth The depth of the mesh created
  122862. * @returns the created VertexData
  122863. */
  122864. buildVertexData(depth?: number): VertexData;
  122865. /**
  122866. * Adds a side to the polygon
  122867. * @param positions points that make the polygon
  122868. * @param normals normals of the polygon
  122869. * @param uvs uvs of the polygon
  122870. * @param indices indices of the polygon
  122871. * @param bounds bounds of the polygon
  122872. * @param points points of the polygon
  122873. * @param depth depth of the polygon
  122874. * @param flip flip of the polygon
  122875. */
  122876. private addSide;
  122877. }
  122878. }
  122879. declare module BABYLON {
  122880. /**
  122881. * Class containing static functions to help procedurally build meshes
  122882. */
  122883. export class PolygonBuilder {
  122884. /**
  122885. * Creates a polygon mesh
  122886. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122887. * * 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
  122888. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122891. * * Remember you can only change the shape positions, not their number when updating a polygon
  122892. * @param name defines the name of the mesh
  122893. * @param options defines the options used to create the mesh
  122894. * @param scene defines the hosting scene
  122895. * @param earcutInjection can be used to inject your own earcut reference
  122896. * @returns the polygon mesh
  122897. */
  122898. static CreatePolygon(name: string, options: {
  122899. shape: Vector3[];
  122900. holes?: Vector3[][];
  122901. depth?: number;
  122902. faceUV?: Vector4[];
  122903. faceColors?: Color4[];
  122904. updatable?: boolean;
  122905. sideOrientation?: number;
  122906. frontUVs?: Vector4;
  122907. backUVs?: Vector4;
  122908. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122909. /**
  122910. * Creates an extruded polygon mesh, with depth in the Y direction.
  122911. * * 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)
  122912. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122913. * @param name defines the name of the mesh
  122914. * @param options defines the options used to create the mesh
  122915. * @param scene defines the hosting scene
  122916. * @param earcutInjection can be used to inject your own earcut reference
  122917. * @returns the polygon mesh
  122918. */
  122919. static ExtrudePolygon(name: string, options: {
  122920. shape: Vector3[];
  122921. holes?: Vector3[][];
  122922. depth?: number;
  122923. faceUV?: Vector4[];
  122924. faceColors?: Color4[];
  122925. updatable?: boolean;
  122926. sideOrientation?: number;
  122927. frontUVs?: Vector4;
  122928. backUVs?: Vector4;
  122929. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122930. }
  122931. }
  122932. declare module BABYLON {
  122933. /**
  122934. * Class containing static functions to help procedurally build meshes
  122935. */
  122936. export class LatheBuilder {
  122937. /**
  122938. * Creates lathe mesh.
  122939. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122940. * * 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
  122941. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122942. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122943. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122944. * * 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
  122945. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122946. * * 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
  122947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122951. * @param name defines the name of the mesh
  122952. * @param options defines the options used to create the mesh
  122953. * @param scene defines the hosting scene
  122954. * @returns the lathe mesh
  122955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122956. */
  122957. static CreateLathe(name: string, options: {
  122958. shape: Vector3[];
  122959. radius?: number;
  122960. tessellation?: number;
  122961. clip?: number;
  122962. arc?: number;
  122963. closed?: boolean;
  122964. updatable?: boolean;
  122965. sideOrientation?: number;
  122966. frontUVs?: Vector4;
  122967. backUVs?: Vector4;
  122968. cap?: number;
  122969. invertUV?: boolean;
  122970. }, scene?: Nullable<Scene>): Mesh;
  122971. }
  122972. }
  122973. declare module BABYLON {
  122974. /**
  122975. * Class containing static functions to help procedurally build meshes
  122976. */
  122977. export class TiledPlaneBuilder {
  122978. /**
  122979. * Creates a tiled plane mesh
  122980. * * The parameter `pattern` will, depending on value, do nothing or
  122981. * * * flip (reflect about central vertical) alternate tiles across and up
  122982. * * * flip every tile on alternate rows
  122983. * * * rotate (180 degs) alternate tiles across and up
  122984. * * * rotate every tile on alternate rows
  122985. * * * flip and rotate alternate tiles across and up
  122986. * * * flip and rotate every tile on alternate rows
  122987. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122988. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122991. * * 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)
  122992. * * 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)
  122993. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122994. * @param name defines the name of the mesh
  122995. * @param options defines the options used to create the mesh
  122996. * @param scene defines the hosting scene
  122997. * @returns the box mesh
  122998. */
  122999. static CreateTiledPlane(name: string, options: {
  123000. pattern?: number;
  123001. tileSize?: number;
  123002. tileWidth?: number;
  123003. tileHeight?: number;
  123004. size?: number;
  123005. width?: number;
  123006. height?: number;
  123007. alignHorizontal?: number;
  123008. alignVertical?: number;
  123009. sideOrientation?: number;
  123010. frontUVs?: Vector4;
  123011. backUVs?: Vector4;
  123012. updatable?: boolean;
  123013. }, scene?: Nullable<Scene>): Mesh;
  123014. }
  123015. }
  123016. declare module BABYLON {
  123017. /**
  123018. * Class containing static functions to help procedurally build meshes
  123019. */
  123020. export class TubeBuilder {
  123021. /**
  123022. * Creates a tube mesh.
  123023. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123024. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123025. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123026. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123027. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123028. * * 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)
  123029. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123030. * * 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
  123031. * * 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
  123032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123036. * @param name defines the name of the mesh
  123037. * @param options defines the options used to create the mesh
  123038. * @param scene defines the hosting scene
  123039. * @returns the tube mesh
  123040. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123041. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123042. */
  123043. static CreateTube(name: string, options: {
  123044. path: Vector3[];
  123045. radius?: number;
  123046. tessellation?: number;
  123047. radiusFunction?: {
  123048. (i: number, distance: number): number;
  123049. };
  123050. cap?: number;
  123051. arc?: number;
  123052. updatable?: boolean;
  123053. sideOrientation?: number;
  123054. frontUVs?: Vector4;
  123055. backUVs?: Vector4;
  123056. instance?: Mesh;
  123057. invertUV?: boolean;
  123058. }, scene?: Nullable<Scene>): Mesh;
  123059. }
  123060. }
  123061. declare module BABYLON {
  123062. /**
  123063. * Class containing static functions to help procedurally build meshes
  123064. */
  123065. export class IcoSphereBuilder {
  123066. /**
  123067. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123068. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123069. * * 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`)
  123070. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123071. * * 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
  123072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123075. * @param name defines the name of the mesh
  123076. * @param options defines the options used to create the mesh
  123077. * @param scene defines the hosting scene
  123078. * @returns the icosahedron mesh
  123079. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123080. */
  123081. static CreateIcoSphere(name: string, options: {
  123082. radius?: number;
  123083. radiusX?: number;
  123084. radiusY?: number;
  123085. radiusZ?: number;
  123086. flat?: boolean;
  123087. subdivisions?: number;
  123088. sideOrientation?: number;
  123089. frontUVs?: Vector4;
  123090. backUVs?: Vector4;
  123091. updatable?: boolean;
  123092. }, scene?: Nullable<Scene>): Mesh;
  123093. }
  123094. }
  123095. declare module BABYLON {
  123096. /**
  123097. * Class containing static functions to help procedurally build meshes
  123098. */
  123099. export class DecalBuilder {
  123100. /**
  123101. * Creates a decal mesh.
  123102. * 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
  123103. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123104. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123105. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123106. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123107. * @param name defines the name of the mesh
  123108. * @param sourceMesh defines the mesh where the decal must be applied
  123109. * @param options defines the options used to create the mesh
  123110. * @param scene defines the hosting scene
  123111. * @returns the decal mesh
  123112. * @see https://doc.babylonjs.com/how_to/decals
  123113. */
  123114. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123115. position?: Vector3;
  123116. normal?: Vector3;
  123117. size?: Vector3;
  123118. angle?: number;
  123119. }): Mesh;
  123120. }
  123121. }
  123122. declare module BABYLON {
  123123. /**
  123124. * Class containing static functions to help procedurally build meshes
  123125. */
  123126. export class MeshBuilder {
  123127. /**
  123128. * Creates a box mesh
  123129. * * The parameter `size` sets the size (float) of each box side (default 1)
  123130. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123131. * * 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)
  123132. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123136. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123137. * @param name defines the name of the mesh
  123138. * @param options defines the options used to create the mesh
  123139. * @param scene defines the hosting scene
  123140. * @returns the box mesh
  123141. */
  123142. static CreateBox(name: string, options: {
  123143. size?: number;
  123144. width?: number;
  123145. height?: number;
  123146. depth?: number;
  123147. faceUV?: Vector4[];
  123148. faceColors?: Color4[];
  123149. sideOrientation?: number;
  123150. frontUVs?: Vector4;
  123151. backUVs?: Vector4;
  123152. updatable?: boolean;
  123153. }, scene?: Nullable<Scene>): Mesh;
  123154. /**
  123155. * Creates a tiled box mesh
  123156. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123158. * @param name defines the name of the mesh
  123159. * @param options defines the options used to create the mesh
  123160. * @param scene defines the hosting scene
  123161. * @returns the tiled box mesh
  123162. */
  123163. static CreateTiledBox(name: string, options: {
  123164. pattern?: number;
  123165. size?: number;
  123166. width?: number;
  123167. height?: number;
  123168. depth: number;
  123169. tileSize?: number;
  123170. tileWidth?: number;
  123171. tileHeight?: number;
  123172. faceUV?: Vector4[];
  123173. faceColors?: Color4[];
  123174. alignHorizontal?: number;
  123175. alignVertical?: number;
  123176. sideOrientation?: number;
  123177. updatable?: boolean;
  123178. }, scene?: Nullable<Scene>): Mesh;
  123179. /**
  123180. * Creates a sphere mesh
  123181. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123182. * * 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`)
  123183. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123184. * * 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
  123185. * * 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)
  123186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123189. * @param name defines the name of the mesh
  123190. * @param options defines the options used to create the mesh
  123191. * @param scene defines the hosting scene
  123192. * @returns the sphere mesh
  123193. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123194. */
  123195. static CreateSphere(name: string, options: {
  123196. segments?: number;
  123197. diameter?: number;
  123198. diameterX?: number;
  123199. diameterY?: number;
  123200. diameterZ?: number;
  123201. arc?: number;
  123202. slice?: number;
  123203. sideOrientation?: number;
  123204. frontUVs?: Vector4;
  123205. backUVs?: Vector4;
  123206. updatable?: boolean;
  123207. }, scene?: Nullable<Scene>): Mesh;
  123208. /**
  123209. * Creates a plane polygonal mesh. By default, this is a disc
  123210. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123211. * * 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
  123212. * * 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
  123213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123216. * @param name defines the name of the mesh
  123217. * @param options defines the options used to create the mesh
  123218. * @param scene defines the hosting scene
  123219. * @returns the plane polygonal mesh
  123220. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123221. */
  123222. static CreateDisc(name: string, options: {
  123223. radius?: number;
  123224. tessellation?: number;
  123225. arc?: number;
  123226. updatable?: boolean;
  123227. sideOrientation?: number;
  123228. frontUVs?: Vector4;
  123229. backUVs?: Vector4;
  123230. }, scene?: Nullable<Scene>): Mesh;
  123231. /**
  123232. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123233. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123234. * * 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`)
  123235. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123236. * * 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
  123237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123240. * @param name defines the name of the mesh
  123241. * @param options defines the options used to create the mesh
  123242. * @param scene defines the hosting scene
  123243. * @returns the icosahedron mesh
  123244. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123245. */
  123246. static CreateIcoSphere(name: string, options: {
  123247. radius?: number;
  123248. radiusX?: number;
  123249. radiusY?: number;
  123250. radiusZ?: number;
  123251. flat?: boolean;
  123252. subdivisions?: number;
  123253. sideOrientation?: number;
  123254. frontUVs?: Vector4;
  123255. backUVs?: Vector4;
  123256. updatable?: boolean;
  123257. }, scene?: Nullable<Scene>): Mesh;
  123258. /**
  123259. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123260. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123261. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123262. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123263. * * 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
  123264. * * 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
  123265. * * 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
  123266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123268. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123269. * * 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
  123270. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123271. * * 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
  123272. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123274. * @param name defines the name of the mesh
  123275. * @param options defines the options used to create the mesh
  123276. * @param scene defines the hosting scene
  123277. * @returns the ribbon mesh
  123278. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123279. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123280. */
  123281. static CreateRibbon(name: string, options: {
  123282. pathArray: Vector3[][];
  123283. closeArray?: boolean;
  123284. closePath?: boolean;
  123285. offset?: number;
  123286. updatable?: boolean;
  123287. sideOrientation?: number;
  123288. frontUVs?: Vector4;
  123289. backUVs?: Vector4;
  123290. instance?: Mesh;
  123291. invertUV?: boolean;
  123292. uvs?: Vector2[];
  123293. colors?: Color4[];
  123294. }, scene?: Nullable<Scene>): Mesh;
  123295. /**
  123296. * Creates a cylinder or a cone mesh
  123297. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123298. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123299. * * 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.
  123300. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123301. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123302. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123303. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123304. * * 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).
  123305. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123306. * * 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).
  123307. * * 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
  123308. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123309. * * 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
  123310. * * 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.
  123311. * * If `enclose` is false, a ring surface is one element.
  123312. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123313. * * 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
  123314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123317. * @param name defines the name of the mesh
  123318. * @param options defines the options used to create the mesh
  123319. * @param scene defines the hosting scene
  123320. * @returns the cylinder mesh
  123321. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123322. */
  123323. static CreateCylinder(name: string, options: {
  123324. height?: number;
  123325. diameterTop?: number;
  123326. diameterBottom?: number;
  123327. diameter?: number;
  123328. tessellation?: number;
  123329. subdivisions?: number;
  123330. arc?: number;
  123331. faceColors?: Color4[];
  123332. faceUV?: Vector4[];
  123333. updatable?: boolean;
  123334. hasRings?: boolean;
  123335. enclose?: boolean;
  123336. cap?: number;
  123337. sideOrientation?: number;
  123338. frontUVs?: Vector4;
  123339. backUVs?: Vector4;
  123340. }, scene?: Nullable<Scene>): Mesh;
  123341. /**
  123342. * Creates a torus mesh
  123343. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123344. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123345. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123349. * @param name defines the name of the mesh
  123350. * @param options defines the options used to create the mesh
  123351. * @param scene defines the hosting scene
  123352. * @returns the torus mesh
  123353. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123354. */
  123355. static CreateTorus(name: string, options: {
  123356. diameter?: number;
  123357. thickness?: number;
  123358. tessellation?: number;
  123359. updatable?: boolean;
  123360. sideOrientation?: number;
  123361. frontUVs?: Vector4;
  123362. backUVs?: Vector4;
  123363. }, scene?: Nullable<Scene>): Mesh;
  123364. /**
  123365. * Creates a torus knot mesh
  123366. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123367. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123368. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123369. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123373. * @param name defines the name of the mesh
  123374. * @param options defines the options used to create the mesh
  123375. * @param scene defines the hosting scene
  123376. * @returns the torus knot mesh
  123377. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123378. */
  123379. static CreateTorusKnot(name: string, options: {
  123380. radius?: number;
  123381. tube?: number;
  123382. radialSegments?: number;
  123383. tubularSegments?: number;
  123384. p?: number;
  123385. q?: number;
  123386. updatable?: boolean;
  123387. sideOrientation?: number;
  123388. frontUVs?: Vector4;
  123389. backUVs?: Vector4;
  123390. }, scene?: Nullable<Scene>): Mesh;
  123391. /**
  123392. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123393. * * 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
  123394. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123395. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123396. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123397. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123398. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123399. * * 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
  123400. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123403. * @param name defines the name of the new line system
  123404. * @param options defines the options used to create the line system
  123405. * @param scene defines the hosting scene
  123406. * @returns a new line system mesh
  123407. */
  123408. static CreateLineSystem(name: string, options: {
  123409. lines: Vector3[][];
  123410. updatable?: boolean;
  123411. instance?: Nullable<LinesMesh>;
  123412. colors?: Nullable<Color4[][]>;
  123413. useVertexAlpha?: boolean;
  123414. }, scene: Nullable<Scene>): LinesMesh;
  123415. /**
  123416. * Creates a line mesh
  123417. * 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
  123418. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123419. * * The parameter `points` is an array successive Vector3
  123420. * * 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
  123421. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123422. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123423. * * When updating an instance, remember that only point positions can change, not the number of points
  123424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123426. * @param name defines the name of the new line system
  123427. * @param options defines the options used to create the line system
  123428. * @param scene defines the hosting scene
  123429. * @returns a new line mesh
  123430. */
  123431. static CreateLines(name: string, options: {
  123432. points: Vector3[];
  123433. updatable?: boolean;
  123434. instance?: Nullable<LinesMesh>;
  123435. colors?: Color4[];
  123436. useVertexAlpha?: boolean;
  123437. }, scene?: Nullable<Scene>): LinesMesh;
  123438. /**
  123439. * Creates a dashed line mesh
  123440. * * 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
  123441. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123442. * * The parameter `points` is an array successive Vector3
  123443. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123444. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123445. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123446. * * 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
  123447. * * When updating an instance, remember that only point positions can change, not the number of points
  123448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123449. * @param name defines the name of the mesh
  123450. * @param options defines the options used to create the mesh
  123451. * @param scene defines the hosting scene
  123452. * @returns the dashed line mesh
  123453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123454. */
  123455. static CreateDashedLines(name: string, options: {
  123456. points: Vector3[];
  123457. dashSize?: number;
  123458. gapSize?: number;
  123459. dashNb?: number;
  123460. updatable?: boolean;
  123461. instance?: LinesMesh;
  123462. }, scene?: Nullable<Scene>): LinesMesh;
  123463. /**
  123464. * 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.
  123465. * * 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.
  123466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123467. * * 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.
  123468. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123469. * * 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
  123470. * * 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
  123471. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123476. * @param name defines the name of the mesh
  123477. * @param options defines the options used to create the mesh
  123478. * @param scene defines the hosting scene
  123479. * @returns the extruded shape mesh
  123480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123482. */
  123483. static ExtrudeShape(name: string, options: {
  123484. shape: Vector3[];
  123485. path: Vector3[];
  123486. scale?: number;
  123487. rotation?: number;
  123488. cap?: number;
  123489. updatable?: boolean;
  123490. sideOrientation?: number;
  123491. frontUVs?: Vector4;
  123492. backUVs?: Vector4;
  123493. instance?: Mesh;
  123494. invertUV?: boolean;
  123495. }, scene?: Nullable<Scene>): Mesh;
  123496. /**
  123497. * Creates an custom extruded shape mesh.
  123498. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123499. * * 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.
  123500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123501. * * 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
  123502. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123503. * * 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
  123504. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123505. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123506. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123507. * * 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
  123508. * * 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
  123509. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123514. * @param name defines the name of the mesh
  123515. * @param options defines the options used to create the mesh
  123516. * @param scene defines the hosting scene
  123517. * @returns the custom extruded shape mesh
  123518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123521. */
  123522. static ExtrudeShapeCustom(name: string, options: {
  123523. shape: Vector3[];
  123524. path: Vector3[];
  123525. scaleFunction?: any;
  123526. rotationFunction?: any;
  123527. ribbonCloseArray?: boolean;
  123528. ribbonClosePath?: boolean;
  123529. cap?: number;
  123530. updatable?: boolean;
  123531. sideOrientation?: number;
  123532. frontUVs?: Vector4;
  123533. backUVs?: Vector4;
  123534. instance?: Mesh;
  123535. invertUV?: boolean;
  123536. }, scene?: Nullable<Scene>): Mesh;
  123537. /**
  123538. * Creates lathe mesh.
  123539. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123540. * * 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
  123541. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123542. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123543. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123544. * * 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
  123545. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123546. * * 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
  123547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123551. * @param name defines the name of the mesh
  123552. * @param options defines the options used to create the mesh
  123553. * @param scene defines the hosting scene
  123554. * @returns the lathe mesh
  123555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123556. */
  123557. static CreateLathe(name: string, options: {
  123558. shape: Vector3[];
  123559. radius?: number;
  123560. tessellation?: number;
  123561. clip?: number;
  123562. arc?: number;
  123563. closed?: boolean;
  123564. updatable?: boolean;
  123565. sideOrientation?: number;
  123566. frontUVs?: Vector4;
  123567. backUVs?: Vector4;
  123568. cap?: number;
  123569. invertUV?: boolean;
  123570. }, scene?: Nullable<Scene>): Mesh;
  123571. /**
  123572. * Creates a tiled plane mesh
  123573. * * You can set a limited pattern arrangement with the tiles
  123574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123577. * @param name defines the name of the mesh
  123578. * @param options defines the options used to create the mesh
  123579. * @param scene defines the hosting scene
  123580. * @returns the plane mesh
  123581. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123582. */
  123583. static CreateTiledPlane(name: string, options: {
  123584. pattern?: number;
  123585. tileSize?: number;
  123586. tileWidth?: number;
  123587. tileHeight?: number;
  123588. size?: number;
  123589. width?: number;
  123590. height?: number;
  123591. alignHorizontal?: number;
  123592. alignVertical?: number;
  123593. sideOrientation?: number;
  123594. frontUVs?: Vector4;
  123595. backUVs?: Vector4;
  123596. updatable?: boolean;
  123597. }, scene?: Nullable<Scene>): Mesh;
  123598. /**
  123599. * Creates a plane mesh
  123600. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123601. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123602. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 plane mesh
  123610. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123611. */
  123612. static CreatePlane(name: string, options: {
  123613. size?: number;
  123614. width?: number;
  123615. height?: number;
  123616. sideOrientation?: number;
  123617. frontUVs?: Vector4;
  123618. backUVs?: Vector4;
  123619. updatable?: boolean;
  123620. sourcePlane?: Plane;
  123621. }, scene?: Nullable<Scene>): Mesh;
  123622. /**
  123623. * Creates a ground mesh
  123624. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123625. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123627. * @param name defines the name of the mesh
  123628. * @param options defines the options used to create the mesh
  123629. * @param scene defines the hosting scene
  123630. * @returns the ground mesh
  123631. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123632. */
  123633. static CreateGround(name: string, options: {
  123634. width?: number;
  123635. height?: number;
  123636. subdivisions?: number;
  123637. subdivisionsX?: number;
  123638. subdivisionsY?: number;
  123639. updatable?: boolean;
  123640. }, scene?: Nullable<Scene>): Mesh;
  123641. /**
  123642. * Creates a tiled ground mesh
  123643. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123644. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123645. * * 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
  123646. * * 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
  123647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123648. * @param name defines the name of the mesh
  123649. * @param options defines the options used to create the mesh
  123650. * @param scene defines the hosting scene
  123651. * @returns the tiled ground mesh
  123652. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123653. */
  123654. static CreateTiledGround(name: string, options: {
  123655. xmin: number;
  123656. zmin: number;
  123657. xmax: number;
  123658. zmax: number;
  123659. subdivisions?: {
  123660. w: number;
  123661. h: number;
  123662. };
  123663. precision?: {
  123664. w: number;
  123665. h: number;
  123666. };
  123667. updatable?: boolean;
  123668. }, scene?: Nullable<Scene>): Mesh;
  123669. /**
  123670. * Creates a ground mesh from a height map
  123671. * * The parameter `url` sets the URL of the height map image resource.
  123672. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123673. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123674. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123675. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123676. * * 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.
  123677. * * 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).
  123678. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123680. * @param name defines the name of the mesh
  123681. * @param url defines the url to the height map
  123682. * @param options defines the options used to create the mesh
  123683. * @param scene defines the hosting scene
  123684. * @returns the ground mesh
  123685. * @see https://doc.babylonjs.com/babylon101/height_map
  123686. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123687. */
  123688. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123689. width?: number;
  123690. height?: number;
  123691. subdivisions?: number;
  123692. minHeight?: number;
  123693. maxHeight?: number;
  123694. colorFilter?: Color3;
  123695. alphaFilter?: number;
  123696. updatable?: boolean;
  123697. onReady?: (mesh: GroundMesh) => void;
  123698. }, scene?: Nullable<Scene>): GroundMesh;
  123699. /**
  123700. * Creates a polygon mesh
  123701. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123702. * * 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
  123703. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123706. * * Remember you can only change the shape positions, not their number when updating a polygon
  123707. * @param name defines the name of the mesh
  123708. * @param options defines the options used to create the mesh
  123709. * @param scene defines the hosting scene
  123710. * @param earcutInjection can be used to inject your own earcut reference
  123711. * @returns the polygon mesh
  123712. */
  123713. static CreatePolygon(name: string, options: {
  123714. shape: Vector3[];
  123715. holes?: Vector3[][];
  123716. depth?: number;
  123717. faceUV?: Vector4[];
  123718. faceColors?: Color4[];
  123719. updatable?: boolean;
  123720. sideOrientation?: number;
  123721. frontUVs?: Vector4;
  123722. backUVs?: Vector4;
  123723. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123724. /**
  123725. * Creates an extruded polygon mesh, with depth in the Y direction.
  123726. * * 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)
  123727. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123728. * @param name defines the name of the mesh
  123729. * @param options defines the options used to create the mesh
  123730. * @param scene defines the hosting scene
  123731. * @param earcutInjection can be used to inject your own earcut reference
  123732. * @returns the polygon mesh
  123733. */
  123734. static ExtrudePolygon(name: string, options: {
  123735. shape: Vector3[];
  123736. holes?: Vector3[][];
  123737. depth?: number;
  123738. faceUV?: Vector4[];
  123739. faceColors?: Color4[];
  123740. updatable?: boolean;
  123741. sideOrientation?: number;
  123742. frontUVs?: Vector4;
  123743. backUVs?: Vector4;
  123744. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123745. /**
  123746. * Creates a tube mesh.
  123747. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123748. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123749. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123750. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123751. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123752. * * 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)
  123753. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123754. * * 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
  123755. * * 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
  123756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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. * @param name defines the name of the mesh
  123761. * @param options defines the options used to create the mesh
  123762. * @param scene defines the hosting scene
  123763. * @returns the tube mesh
  123764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123765. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123766. */
  123767. static CreateTube(name: string, options: {
  123768. path: Vector3[];
  123769. radius?: number;
  123770. tessellation?: number;
  123771. radiusFunction?: {
  123772. (i: number, distance: number): number;
  123773. };
  123774. cap?: number;
  123775. arc?: number;
  123776. updatable?: boolean;
  123777. sideOrientation?: number;
  123778. frontUVs?: Vector4;
  123779. backUVs?: Vector4;
  123780. instance?: Mesh;
  123781. invertUV?: boolean;
  123782. }, scene?: Nullable<Scene>): Mesh;
  123783. /**
  123784. * Creates a polyhedron mesh
  123785. * * 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
  123786. * * The parameter `size` (positive float, default 1) sets the polygon size
  123787. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123788. * * 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`
  123789. * * 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
  123790. * * 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)`)
  123791. * * 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
  123792. * * 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
  123793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123796. * @param name defines the name of the mesh
  123797. * @param options defines the options used to create the mesh
  123798. * @param scene defines the hosting scene
  123799. * @returns the polyhedron mesh
  123800. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123801. */
  123802. static CreatePolyhedron(name: string, options: {
  123803. type?: number;
  123804. size?: number;
  123805. sizeX?: number;
  123806. sizeY?: number;
  123807. sizeZ?: number;
  123808. custom?: any;
  123809. faceUV?: Vector4[];
  123810. faceColors?: Color4[];
  123811. flat?: boolean;
  123812. updatable?: boolean;
  123813. sideOrientation?: number;
  123814. frontUVs?: Vector4;
  123815. backUVs?: Vector4;
  123816. }, scene?: Nullable<Scene>): Mesh;
  123817. /**
  123818. * Creates a decal mesh.
  123819. * 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
  123820. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123821. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123822. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123823. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123824. * @param name defines the name of the mesh
  123825. * @param sourceMesh defines the mesh where the decal must be applied
  123826. * @param options defines the options used to create the mesh
  123827. * @param scene defines the hosting scene
  123828. * @returns the decal mesh
  123829. * @see https://doc.babylonjs.com/how_to/decals
  123830. */
  123831. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123832. position?: Vector3;
  123833. normal?: Vector3;
  123834. size?: Vector3;
  123835. angle?: number;
  123836. }): Mesh;
  123837. }
  123838. }
  123839. declare module BABYLON {
  123840. /**
  123841. * A simplifier interface for future simplification implementations
  123842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123843. */
  123844. export interface ISimplifier {
  123845. /**
  123846. * Simplification of a given mesh according to the given settings.
  123847. * Since this requires computation, it is assumed that the function runs async.
  123848. * @param settings The settings of the simplification, including quality and distance
  123849. * @param successCallback A callback that will be called after the mesh was simplified.
  123850. * @param errorCallback in case of an error, this callback will be called. optional.
  123851. */
  123852. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123853. }
  123854. /**
  123855. * Expected simplification settings.
  123856. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123857. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123858. */
  123859. export interface ISimplificationSettings {
  123860. /**
  123861. * Gets or sets the expected quality
  123862. */
  123863. quality: number;
  123864. /**
  123865. * Gets or sets the distance when this optimized version should be used
  123866. */
  123867. distance: number;
  123868. /**
  123869. * Gets an already optimized mesh
  123870. */
  123871. optimizeMesh?: boolean;
  123872. }
  123873. /**
  123874. * Class used to specify simplification options
  123875. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123876. */
  123877. export class SimplificationSettings implements ISimplificationSettings {
  123878. /** expected quality */
  123879. quality: number;
  123880. /** distance when this optimized version should be used */
  123881. distance: number;
  123882. /** already optimized mesh */
  123883. optimizeMesh?: boolean | undefined;
  123884. /**
  123885. * Creates a SimplificationSettings
  123886. * @param quality expected quality
  123887. * @param distance distance when this optimized version should be used
  123888. * @param optimizeMesh already optimized mesh
  123889. */
  123890. constructor(
  123891. /** expected quality */
  123892. quality: number,
  123893. /** distance when this optimized version should be used */
  123894. distance: number,
  123895. /** already optimized mesh */
  123896. optimizeMesh?: boolean | undefined);
  123897. }
  123898. /**
  123899. * Interface used to define a simplification task
  123900. */
  123901. export interface ISimplificationTask {
  123902. /**
  123903. * Array of settings
  123904. */
  123905. settings: Array<ISimplificationSettings>;
  123906. /**
  123907. * Simplification type
  123908. */
  123909. simplificationType: SimplificationType;
  123910. /**
  123911. * Mesh to simplify
  123912. */
  123913. mesh: Mesh;
  123914. /**
  123915. * Callback called on success
  123916. */
  123917. successCallback?: () => void;
  123918. /**
  123919. * Defines if parallel processing can be used
  123920. */
  123921. parallelProcessing: boolean;
  123922. }
  123923. /**
  123924. * Queue used to order the simplification tasks
  123925. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123926. */
  123927. export class SimplificationQueue {
  123928. private _simplificationArray;
  123929. /**
  123930. * Gets a boolean indicating that the process is still running
  123931. */
  123932. running: boolean;
  123933. /**
  123934. * Creates a new queue
  123935. */
  123936. constructor();
  123937. /**
  123938. * Adds a new simplification task
  123939. * @param task defines a task to add
  123940. */
  123941. addTask(task: ISimplificationTask): void;
  123942. /**
  123943. * Execute next task
  123944. */
  123945. executeNext(): void;
  123946. /**
  123947. * Execute a simplification task
  123948. * @param task defines the task to run
  123949. */
  123950. runSimplification(task: ISimplificationTask): void;
  123951. private getSimplifier;
  123952. }
  123953. /**
  123954. * The implemented types of simplification
  123955. * At the moment only Quadratic Error Decimation is implemented
  123956. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123957. */
  123958. export enum SimplificationType {
  123959. /** Quadratic error decimation */
  123960. QUADRATIC = 0
  123961. }
  123962. }
  123963. declare module BABYLON {
  123964. interface Scene {
  123965. /** @hidden (Backing field) */
  123966. _simplificationQueue: SimplificationQueue;
  123967. /**
  123968. * Gets or sets the simplification queue attached to the scene
  123969. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123970. */
  123971. simplificationQueue: SimplificationQueue;
  123972. }
  123973. interface Mesh {
  123974. /**
  123975. * Simplify the mesh according to the given array of settings.
  123976. * Function will return immediately and will simplify async
  123977. * @param settings a collection of simplification settings
  123978. * @param parallelProcessing should all levels calculate parallel or one after the other
  123979. * @param simplificationType the type of simplification to run
  123980. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123981. * @returns the current mesh
  123982. */
  123983. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123984. }
  123985. /**
  123986. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123987. * created in a scene
  123988. */
  123989. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123990. /**
  123991. * The component name helpfull to identify the component in the list of scene components.
  123992. */
  123993. readonly name: string;
  123994. /**
  123995. * The scene the component belongs to.
  123996. */
  123997. scene: Scene;
  123998. /**
  123999. * Creates a new instance of the component for the given scene
  124000. * @param scene Defines the scene to register the component in
  124001. */
  124002. constructor(scene: Scene);
  124003. /**
  124004. * Registers the component in a given scene
  124005. */
  124006. register(): void;
  124007. /**
  124008. * Rebuilds the elements related to this component in case of
  124009. * context lost for instance.
  124010. */
  124011. rebuild(): void;
  124012. /**
  124013. * Disposes the component and the associated ressources
  124014. */
  124015. dispose(): void;
  124016. private _beforeCameraUpdate;
  124017. }
  124018. }
  124019. declare module BABYLON {
  124020. /**
  124021. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124022. */
  124023. export interface INavigationEnginePlugin {
  124024. /**
  124025. * plugin name
  124026. */
  124027. name: string;
  124028. /**
  124029. * Creates a navigation mesh
  124030. * @param meshes array of all the geometry used to compute the navigatio mesh
  124031. * @param parameters bunch of parameters used to filter geometry
  124032. */
  124033. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124034. /**
  124035. * Create a navigation mesh debug mesh
  124036. * @param scene is where the mesh will be added
  124037. * @returns debug display mesh
  124038. */
  124039. createDebugNavMesh(scene: Scene): Mesh;
  124040. /**
  124041. * Get a navigation mesh constrained position, closest to the parameter position
  124042. * @param position world position
  124043. * @returns the closest point to position constrained by the navigation mesh
  124044. */
  124045. getClosestPoint(position: Vector3): Vector3;
  124046. /**
  124047. * Get a navigation mesh constrained position, within a particular radius
  124048. * @param position world position
  124049. * @param maxRadius the maximum distance to the constrained world position
  124050. * @returns the closest point to position constrained by the navigation mesh
  124051. */
  124052. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124053. /**
  124054. * Compute the final position from a segment made of destination-position
  124055. * @param position world position
  124056. * @param destination world position
  124057. * @returns the resulting point along the navmesh
  124058. */
  124059. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124060. /**
  124061. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124062. * @param start world position
  124063. * @param end world position
  124064. * @returns array containing world position composing the path
  124065. */
  124066. computePath(start: Vector3, end: Vector3): Vector3[];
  124067. /**
  124068. * If this plugin is supported
  124069. * @returns true if plugin is supported
  124070. */
  124071. isSupported(): boolean;
  124072. /**
  124073. * Create a new Crowd so you can add agents
  124074. * @param maxAgents the maximum agent count in the crowd
  124075. * @param maxAgentRadius the maximum radius an agent can have
  124076. * @param scene to attach the crowd to
  124077. * @returns the crowd you can add agents to
  124078. */
  124079. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124080. /**
  124081. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124082. * The queries will try to find a solution within those bounds
  124083. * default is (1,1,1)
  124084. * @param extent x,y,z value that define the extent around the queries point of reference
  124085. */
  124086. setDefaultQueryExtent(extent: Vector3): void;
  124087. /**
  124088. * Get the Bounding box extent specified by setDefaultQueryExtent
  124089. * @returns the box extent values
  124090. */
  124091. getDefaultQueryExtent(): Vector3;
  124092. /**
  124093. * Release all resources
  124094. */
  124095. dispose(): void;
  124096. }
  124097. /**
  124098. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124099. */
  124100. export interface ICrowd {
  124101. /**
  124102. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124103. * You can attach anything to that node. The node position is updated in the scene update tick.
  124104. * @param pos world position that will be constrained by the navigation mesh
  124105. * @param parameters agent parameters
  124106. * @param transform hooked to the agent that will be update by the scene
  124107. * @returns agent index
  124108. */
  124109. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124110. /**
  124111. * Returns the agent position in world space
  124112. * @param index agent index returned by addAgent
  124113. * @returns world space position
  124114. */
  124115. getAgentPosition(index: number): Vector3;
  124116. /**
  124117. * Gets the agent velocity in world space
  124118. * @param index agent index returned by addAgent
  124119. * @returns world space velocity
  124120. */
  124121. getAgentVelocity(index: number): Vector3;
  124122. /**
  124123. * remove a particular agent previously created
  124124. * @param index agent index returned by addAgent
  124125. */
  124126. removeAgent(index: number): void;
  124127. /**
  124128. * get the list of all agents attached to this crowd
  124129. * @returns list of agent indices
  124130. */
  124131. getAgents(): number[];
  124132. /**
  124133. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124134. * @param deltaTime in seconds
  124135. */
  124136. update(deltaTime: number): void;
  124137. /**
  124138. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124139. * @param index agent index returned by addAgent
  124140. * @param destination targeted world position
  124141. */
  124142. agentGoto(index: number, destination: Vector3): void;
  124143. /**
  124144. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124145. * The queries will try to find a solution within those bounds
  124146. * default is (1,1,1)
  124147. * @param extent x,y,z value that define the extent around the queries point of reference
  124148. */
  124149. setDefaultQueryExtent(extent: Vector3): void;
  124150. /**
  124151. * Get the Bounding box extent specified by setDefaultQueryExtent
  124152. * @returns the box extent values
  124153. */
  124154. getDefaultQueryExtent(): Vector3;
  124155. /**
  124156. * Release all resources
  124157. */
  124158. dispose(): void;
  124159. }
  124160. /**
  124161. * Configures an agent
  124162. */
  124163. export interface IAgentParameters {
  124164. /**
  124165. * Agent radius. [Limit: >= 0]
  124166. */
  124167. radius: number;
  124168. /**
  124169. * Agent height. [Limit: > 0]
  124170. */
  124171. height: number;
  124172. /**
  124173. * Maximum allowed acceleration. [Limit: >= 0]
  124174. */
  124175. maxAcceleration: number;
  124176. /**
  124177. * Maximum allowed speed. [Limit: >= 0]
  124178. */
  124179. maxSpeed: number;
  124180. /**
  124181. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124182. */
  124183. collisionQueryRange: number;
  124184. /**
  124185. * The path visibility optimization range. [Limit: > 0]
  124186. */
  124187. pathOptimizationRange: number;
  124188. /**
  124189. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124190. */
  124191. separationWeight: number;
  124192. }
  124193. /**
  124194. * Configures the navigation mesh creation
  124195. */
  124196. export interface INavMeshParameters {
  124197. /**
  124198. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124199. */
  124200. cs: number;
  124201. /**
  124202. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124203. */
  124204. ch: number;
  124205. /**
  124206. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124207. */
  124208. walkableSlopeAngle: number;
  124209. /**
  124210. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124211. * be considered walkable. [Limit: >= 3] [Units: vx]
  124212. */
  124213. walkableHeight: number;
  124214. /**
  124215. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124216. */
  124217. walkableClimb: number;
  124218. /**
  124219. * The distance to erode/shrink the walkable area of the heightfield away from
  124220. * obstructions. [Limit: >=0] [Units: vx]
  124221. */
  124222. walkableRadius: number;
  124223. /**
  124224. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124225. */
  124226. maxEdgeLen: number;
  124227. /**
  124228. * The maximum distance a simplfied contour's border edges should deviate
  124229. * the original raw contour. [Limit: >=0] [Units: vx]
  124230. */
  124231. maxSimplificationError: number;
  124232. /**
  124233. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124234. */
  124235. minRegionArea: number;
  124236. /**
  124237. * Any regions with a span count smaller than this value will, if possible,
  124238. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124239. */
  124240. mergeRegionArea: number;
  124241. /**
  124242. * The maximum number of vertices allowed for polygons generated during the
  124243. * contour to polygon conversion process. [Limit: >= 3]
  124244. */
  124245. maxVertsPerPoly: number;
  124246. /**
  124247. * Sets the sampling distance to use when generating the detail mesh.
  124248. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124249. */
  124250. detailSampleDist: number;
  124251. /**
  124252. * The maximum distance the detail mesh surface should deviate from heightfield
  124253. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124254. */
  124255. detailSampleMaxError: number;
  124256. }
  124257. }
  124258. declare module BABYLON {
  124259. /**
  124260. * RecastJS navigation plugin
  124261. */
  124262. export class RecastJSPlugin implements INavigationEnginePlugin {
  124263. /**
  124264. * Reference to the Recast library
  124265. */
  124266. bjsRECAST: any;
  124267. /**
  124268. * plugin name
  124269. */
  124270. name: string;
  124271. /**
  124272. * the first navmesh created. We might extend this to support multiple navmeshes
  124273. */
  124274. navMesh: any;
  124275. /**
  124276. * Initializes the recastJS plugin
  124277. * @param recastInjection can be used to inject your own recast reference
  124278. */
  124279. constructor(recastInjection?: any);
  124280. /**
  124281. * Creates a navigation mesh
  124282. * @param meshes array of all the geometry used to compute the navigatio mesh
  124283. * @param parameters bunch of parameters used to filter geometry
  124284. */
  124285. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124286. /**
  124287. * Create a navigation mesh debug mesh
  124288. * @param scene is where the mesh will be added
  124289. * @returns debug display mesh
  124290. */
  124291. createDebugNavMesh(scene: Scene): Mesh;
  124292. /**
  124293. * Get a navigation mesh constrained position, closest to the parameter position
  124294. * @param position world position
  124295. * @returns the closest point to position constrained by the navigation mesh
  124296. */
  124297. getClosestPoint(position: Vector3): Vector3;
  124298. /**
  124299. * Get a navigation mesh constrained position, within a particular radius
  124300. * @param position world position
  124301. * @param maxRadius the maximum distance to the constrained world position
  124302. * @returns the closest point to position constrained by the navigation mesh
  124303. */
  124304. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124305. /**
  124306. * Compute the final position from a segment made of destination-position
  124307. * @param position world position
  124308. * @param destination world position
  124309. * @returns the resulting point along the navmesh
  124310. */
  124311. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124312. /**
  124313. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124314. * @param start world position
  124315. * @param end world position
  124316. * @returns array containing world position composing the path
  124317. */
  124318. computePath(start: Vector3, end: Vector3): Vector3[];
  124319. /**
  124320. * Create a new Crowd so you can add agents
  124321. * @param maxAgents the maximum agent count in the crowd
  124322. * @param maxAgentRadius the maximum radius an agent can have
  124323. * @param scene to attach the crowd to
  124324. * @returns the crowd you can add agents to
  124325. */
  124326. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124327. /**
  124328. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124329. * The queries will try to find a solution within those bounds
  124330. * default is (1,1,1)
  124331. * @param extent x,y,z value that define the extent around the queries point of reference
  124332. */
  124333. setDefaultQueryExtent(extent: Vector3): void;
  124334. /**
  124335. * Get the Bounding box extent specified by setDefaultQueryExtent
  124336. * @returns the box extent values
  124337. */
  124338. getDefaultQueryExtent(): Vector3;
  124339. /**
  124340. * Disposes
  124341. */
  124342. dispose(): void;
  124343. /**
  124344. * If this plugin is supported
  124345. * @returns true if plugin is supported
  124346. */
  124347. isSupported(): boolean;
  124348. }
  124349. /**
  124350. * Recast detour crowd implementation
  124351. */
  124352. export class RecastJSCrowd implements ICrowd {
  124353. /**
  124354. * Recast/detour plugin
  124355. */
  124356. bjsRECASTPlugin: RecastJSPlugin;
  124357. /**
  124358. * Link to the detour crowd
  124359. */
  124360. recastCrowd: any;
  124361. /**
  124362. * One transform per agent
  124363. */
  124364. transforms: TransformNode[];
  124365. /**
  124366. * All agents created
  124367. */
  124368. agents: number[];
  124369. /**
  124370. * Link to the scene is kept to unregister the crowd from the scene
  124371. */
  124372. private _scene;
  124373. /**
  124374. * Observer for crowd updates
  124375. */
  124376. private _onBeforeAnimationsObserver;
  124377. /**
  124378. * Constructor
  124379. * @param plugin recastJS plugin
  124380. * @param maxAgents the maximum agent count in the crowd
  124381. * @param maxAgentRadius the maximum radius an agent can have
  124382. * @param scene to attach the crowd to
  124383. * @returns the crowd you can add agents to
  124384. */
  124385. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124386. /**
  124387. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124388. * You can attach anything to that node. The node position is updated in the scene update tick.
  124389. * @param pos world position that will be constrained by the navigation mesh
  124390. * @param parameters agent parameters
  124391. * @param transform hooked to the agent that will be update by the scene
  124392. * @returns agent index
  124393. */
  124394. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124395. /**
  124396. * Returns the agent position in world space
  124397. * @param index agent index returned by addAgent
  124398. * @returns world space position
  124399. */
  124400. getAgentPosition(index: number): Vector3;
  124401. /**
  124402. * Returns the agent velocity in world space
  124403. * @param index agent index returned by addAgent
  124404. * @returns world space velocity
  124405. */
  124406. getAgentVelocity(index: number): Vector3;
  124407. /**
  124408. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124409. * @param index agent index returned by addAgent
  124410. * @param destination targeted world position
  124411. */
  124412. agentGoto(index: number, destination: Vector3): void;
  124413. /**
  124414. * remove a particular agent previously created
  124415. * @param index agent index returned by addAgent
  124416. */
  124417. removeAgent(index: number): void;
  124418. /**
  124419. * get the list of all agents attached to this crowd
  124420. * @returns list of agent indices
  124421. */
  124422. getAgents(): number[];
  124423. /**
  124424. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124425. * @param deltaTime in seconds
  124426. */
  124427. update(deltaTime: number): void;
  124428. /**
  124429. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124430. * The queries will try to find a solution within those bounds
  124431. * default is (1,1,1)
  124432. * @param extent x,y,z value that define the extent around the queries point of reference
  124433. */
  124434. setDefaultQueryExtent(extent: Vector3): void;
  124435. /**
  124436. * Get the Bounding box extent specified by setDefaultQueryExtent
  124437. * @returns the box extent values
  124438. */
  124439. getDefaultQueryExtent(): Vector3;
  124440. /**
  124441. * Release all resources
  124442. */
  124443. dispose(): void;
  124444. }
  124445. }
  124446. declare module BABYLON {
  124447. /**
  124448. * Class used to enable access to IndexedDB
  124449. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124450. */
  124451. export class Database implements IOfflineProvider {
  124452. private _callbackManifestChecked;
  124453. private _currentSceneUrl;
  124454. private _db;
  124455. private _enableSceneOffline;
  124456. private _enableTexturesOffline;
  124457. private _manifestVersionFound;
  124458. private _mustUpdateRessources;
  124459. private _hasReachedQuota;
  124460. private _isSupported;
  124461. private _idbFactory;
  124462. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124463. private static IsUASupportingBlobStorage;
  124464. /**
  124465. * Gets a boolean indicating if Database storate is enabled (off by default)
  124466. */
  124467. static IDBStorageEnabled: boolean;
  124468. /**
  124469. * Gets a boolean indicating if scene must be saved in the database
  124470. */
  124471. readonly enableSceneOffline: boolean;
  124472. /**
  124473. * Gets a boolean indicating if textures must be saved in the database
  124474. */
  124475. readonly enableTexturesOffline: boolean;
  124476. /**
  124477. * Creates a new Database
  124478. * @param urlToScene defines the url to load the scene
  124479. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124480. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124481. */
  124482. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124483. private static _ParseURL;
  124484. private static _ReturnFullUrlLocation;
  124485. private _checkManifestFile;
  124486. /**
  124487. * Open the database and make it available
  124488. * @param successCallback defines the callback to call on success
  124489. * @param errorCallback defines the callback to call on error
  124490. */
  124491. open(successCallback: () => void, errorCallback: () => void): void;
  124492. /**
  124493. * Loads an image from the database
  124494. * @param url defines the url to load from
  124495. * @param image defines the target DOM image
  124496. */
  124497. loadImage(url: string, image: HTMLImageElement): void;
  124498. private _loadImageFromDBAsync;
  124499. private _saveImageIntoDBAsync;
  124500. private _checkVersionFromDB;
  124501. private _loadVersionFromDBAsync;
  124502. private _saveVersionIntoDBAsync;
  124503. /**
  124504. * Loads a file from database
  124505. * @param url defines the URL to load from
  124506. * @param sceneLoaded defines a callback to call on success
  124507. * @param progressCallBack defines a callback to call when progress changed
  124508. * @param errorCallback defines a callback to call on error
  124509. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124510. */
  124511. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124512. private _loadFileAsync;
  124513. private _saveFileAsync;
  124514. /**
  124515. * Validates if xhr data is correct
  124516. * @param xhr defines the request to validate
  124517. * @param dataType defines the expected data type
  124518. * @returns true if data is correct
  124519. */
  124520. private static _ValidateXHRData;
  124521. }
  124522. }
  124523. declare module BABYLON {
  124524. /** @hidden */
  124525. export var gpuUpdateParticlesPixelShader: {
  124526. name: string;
  124527. shader: string;
  124528. };
  124529. }
  124530. declare module BABYLON {
  124531. /** @hidden */
  124532. export var gpuUpdateParticlesVertexShader: {
  124533. name: string;
  124534. shader: string;
  124535. };
  124536. }
  124537. declare module BABYLON {
  124538. /** @hidden */
  124539. export var clipPlaneFragmentDeclaration2: {
  124540. name: string;
  124541. shader: string;
  124542. };
  124543. }
  124544. declare module BABYLON {
  124545. /** @hidden */
  124546. export var gpuRenderParticlesPixelShader: {
  124547. name: string;
  124548. shader: string;
  124549. };
  124550. }
  124551. declare module BABYLON {
  124552. /** @hidden */
  124553. export var clipPlaneVertexDeclaration2: {
  124554. name: string;
  124555. shader: string;
  124556. };
  124557. }
  124558. declare module BABYLON {
  124559. /** @hidden */
  124560. export var gpuRenderParticlesVertexShader: {
  124561. name: string;
  124562. shader: string;
  124563. };
  124564. }
  124565. declare module BABYLON {
  124566. /**
  124567. * This represents a GPU particle system in Babylon
  124568. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124569. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124570. */
  124571. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124572. /**
  124573. * The layer mask we are rendering the particles through.
  124574. */
  124575. layerMask: number;
  124576. private _capacity;
  124577. private _activeCount;
  124578. private _currentActiveCount;
  124579. private _accumulatedCount;
  124580. private _renderEffect;
  124581. private _updateEffect;
  124582. private _buffer0;
  124583. private _buffer1;
  124584. private _spriteBuffer;
  124585. private _updateVAO;
  124586. private _renderVAO;
  124587. private _targetIndex;
  124588. private _sourceBuffer;
  124589. private _targetBuffer;
  124590. private _engine;
  124591. private _currentRenderId;
  124592. private _started;
  124593. private _stopped;
  124594. private _timeDelta;
  124595. private _randomTexture;
  124596. private _randomTexture2;
  124597. private _attributesStrideSize;
  124598. private _updateEffectOptions;
  124599. private _randomTextureSize;
  124600. private _actualFrame;
  124601. private readonly _rawTextureWidth;
  124602. /**
  124603. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124604. */
  124605. static readonly IsSupported: boolean;
  124606. /**
  124607. * An event triggered when the system is disposed.
  124608. */
  124609. onDisposeObservable: Observable<GPUParticleSystem>;
  124610. /**
  124611. * Gets the maximum number of particles active at the same time.
  124612. * @returns The max number of active particles.
  124613. */
  124614. getCapacity(): number;
  124615. /**
  124616. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124617. * to override the particles.
  124618. */
  124619. forceDepthWrite: boolean;
  124620. /**
  124621. * Gets or set the number of active particles
  124622. */
  124623. activeParticleCount: number;
  124624. private _preWarmDone;
  124625. /**
  124626. * Is this system ready to be used/rendered
  124627. * @return true if the system is ready
  124628. */
  124629. isReady(): boolean;
  124630. /**
  124631. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124632. * @returns True if it has been started, otherwise false.
  124633. */
  124634. isStarted(): boolean;
  124635. /**
  124636. * Starts the particle system and begins to emit
  124637. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124638. */
  124639. start(delay?: number): void;
  124640. /**
  124641. * Stops the particle system.
  124642. */
  124643. stop(): void;
  124644. /**
  124645. * Remove all active particles
  124646. */
  124647. reset(): void;
  124648. /**
  124649. * Returns the string "GPUParticleSystem"
  124650. * @returns a string containing the class name
  124651. */
  124652. getClassName(): string;
  124653. private _colorGradientsTexture;
  124654. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124655. /**
  124656. * Adds a new color gradient
  124657. * @param gradient defines the gradient to use (between 0 and 1)
  124658. * @param color1 defines the color to affect to the specified gradient
  124659. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124660. * @returns the current particle system
  124661. */
  124662. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124663. /**
  124664. * Remove a specific color gradient
  124665. * @param gradient defines the gradient to remove
  124666. * @returns the current particle system
  124667. */
  124668. removeColorGradient(gradient: number): GPUParticleSystem;
  124669. private _angularSpeedGradientsTexture;
  124670. private _sizeGradientsTexture;
  124671. private _velocityGradientsTexture;
  124672. private _limitVelocityGradientsTexture;
  124673. private _dragGradientsTexture;
  124674. private _addFactorGradient;
  124675. /**
  124676. * Adds a new size gradient
  124677. * @param gradient defines the gradient to use (between 0 and 1)
  124678. * @param factor defines the size factor to affect to the specified gradient
  124679. * @returns the current particle system
  124680. */
  124681. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124682. /**
  124683. * Remove a specific size gradient
  124684. * @param gradient defines the gradient to remove
  124685. * @returns the current particle system
  124686. */
  124687. removeSizeGradient(gradient: number): GPUParticleSystem;
  124688. /**
  124689. * Adds a new angular speed gradient
  124690. * @param gradient defines the gradient to use (between 0 and 1)
  124691. * @param factor defines the angular speed to affect to the specified gradient
  124692. * @returns the current particle system
  124693. */
  124694. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124695. /**
  124696. * Remove a specific angular speed gradient
  124697. * @param gradient defines the gradient to remove
  124698. * @returns the current particle system
  124699. */
  124700. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124701. /**
  124702. * Adds a new velocity gradient
  124703. * @param gradient defines the gradient to use (between 0 and 1)
  124704. * @param factor defines the velocity to affect to the specified gradient
  124705. * @returns the current particle system
  124706. */
  124707. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124708. /**
  124709. * Remove a specific velocity gradient
  124710. * @param gradient defines the gradient to remove
  124711. * @returns the current particle system
  124712. */
  124713. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124714. /**
  124715. * Adds a new limit velocity gradient
  124716. * @param gradient defines the gradient to use (between 0 and 1)
  124717. * @param factor defines the limit velocity value to affect to the specified gradient
  124718. * @returns the current particle system
  124719. */
  124720. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124721. /**
  124722. * Remove a specific limit velocity gradient
  124723. * @param gradient defines the gradient to remove
  124724. * @returns the current particle system
  124725. */
  124726. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124727. /**
  124728. * Adds a new drag gradient
  124729. * @param gradient defines the gradient to use (between 0 and 1)
  124730. * @param factor defines the drag value to affect to the specified gradient
  124731. * @returns the current particle system
  124732. */
  124733. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124734. /**
  124735. * Remove a specific drag gradient
  124736. * @param gradient defines the gradient to remove
  124737. * @returns the current particle system
  124738. */
  124739. removeDragGradient(gradient: number): GPUParticleSystem;
  124740. /**
  124741. * Not supported by GPUParticleSystem
  124742. * @param gradient defines the gradient to use (between 0 and 1)
  124743. * @param factor defines the emit rate value to affect to the specified gradient
  124744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124745. * @returns the current particle system
  124746. */
  124747. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124748. /**
  124749. * Not supported by GPUParticleSystem
  124750. * @param gradient defines the gradient to remove
  124751. * @returns the current particle system
  124752. */
  124753. removeEmitRateGradient(gradient: number): IParticleSystem;
  124754. /**
  124755. * Not supported by GPUParticleSystem
  124756. * @param gradient defines the gradient to use (between 0 and 1)
  124757. * @param factor defines the start size value to affect to the specified gradient
  124758. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124759. * @returns the current particle system
  124760. */
  124761. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124762. /**
  124763. * Not supported by GPUParticleSystem
  124764. * @param gradient defines the gradient to remove
  124765. * @returns the current particle system
  124766. */
  124767. removeStartSizeGradient(gradient: number): IParticleSystem;
  124768. /**
  124769. * Not supported by GPUParticleSystem
  124770. * @param gradient defines the gradient to use (between 0 and 1)
  124771. * @param min defines the color remap minimal range
  124772. * @param max defines the color remap maximal range
  124773. * @returns the current particle system
  124774. */
  124775. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124776. /**
  124777. * Not supported by GPUParticleSystem
  124778. * @param gradient defines the gradient to remove
  124779. * @returns the current particle system
  124780. */
  124781. removeColorRemapGradient(): IParticleSystem;
  124782. /**
  124783. * Not supported by GPUParticleSystem
  124784. * @param gradient defines the gradient to use (between 0 and 1)
  124785. * @param min defines the alpha remap minimal range
  124786. * @param max defines the alpha remap maximal range
  124787. * @returns the current particle system
  124788. */
  124789. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124790. /**
  124791. * Not supported by GPUParticleSystem
  124792. * @param gradient defines the gradient to remove
  124793. * @returns the current particle system
  124794. */
  124795. removeAlphaRemapGradient(): IParticleSystem;
  124796. /**
  124797. * Not supported by GPUParticleSystem
  124798. * @param gradient defines the gradient to use (between 0 and 1)
  124799. * @param color defines the color to affect to the specified gradient
  124800. * @returns the current particle system
  124801. */
  124802. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124803. /**
  124804. * Not supported by GPUParticleSystem
  124805. * @param gradient defines the gradient to remove
  124806. * @returns the current particle system
  124807. */
  124808. removeRampGradient(): IParticleSystem;
  124809. /**
  124810. * Not supported by GPUParticleSystem
  124811. * @returns the list of ramp gradients
  124812. */
  124813. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124814. /**
  124815. * Not supported by GPUParticleSystem
  124816. * Gets or sets a boolean indicating that ramp gradients must be used
  124817. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124818. */
  124819. useRampGradients: boolean;
  124820. /**
  124821. * Not supported by GPUParticleSystem
  124822. * @param gradient defines the gradient to use (between 0 and 1)
  124823. * @param factor defines the life time factor to affect to the specified gradient
  124824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124825. * @returns the current particle system
  124826. */
  124827. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124828. /**
  124829. * Not supported by GPUParticleSystem
  124830. * @param gradient defines the gradient to remove
  124831. * @returns the current particle system
  124832. */
  124833. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124834. /**
  124835. * Instantiates a GPU particle system.
  124836. * 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.
  124837. * @param name The name of the particle system
  124838. * @param options The options used to create the system
  124839. * @param scene The scene the particle system belongs to
  124840. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124841. */
  124842. constructor(name: string, options: Partial<{
  124843. capacity: number;
  124844. randomTextureSize: number;
  124845. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124846. protected _reset(): void;
  124847. private _createUpdateVAO;
  124848. private _createRenderVAO;
  124849. private _initialize;
  124850. /** @hidden */
  124851. _recreateUpdateEffect(): void;
  124852. /** @hidden */
  124853. _recreateRenderEffect(): void;
  124854. /**
  124855. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124856. * @param preWarm defines if we are in the pre-warmimg phase
  124857. */
  124858. animate(preWarm?: boolean): void;
  124859. private _createFactorGradientTexture;
  124860. private _createSizeGradientTexture;
  124861. private _createAngularSpeedGradientTexture;
  124862. private _createVelocityGradientTexture;
  124863. private _createLimitVelocityGradientTexture;
  124864. private _createDragGradientTexture;
  124865. private _createColorGradientTexture;
  124866. /**
  124867. * Renders the particle system in its current state
  124868. * @param preWarm defines if the system should only update the particles but not render them
  124869. * @returns the current number of particles
  124870. */
  124871. render(preWarm?: boolean): number;
  124872. /**
  124873. * Rebuilds the particle system
  124874. */
  124875. rebuild(): void;
  124876. private _releaseBuffers;
  124877. private _releaseVAOs;
  124878. /**
  124879. * Disposes the particle system and free the associated resources
  124880. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124881. */
  124882. dispose(disposeTexture?: boolean): void;
  124883. /**
  124884. * Clones the particle system.
  124885. * @param name The name of the cloned object
  124886. * @param newEmitter The new emitter to use
  124887. * @returns the cloned particle system
  124888. */
  124889. clone(name: string, newEmitter: any): GPUParticleSystem;
  124890. /**
  124891. * Serializes the particle system to a JSON object.
  124892. * @returns the JSON object
  124893. */
  124894. serialize(): any;
  124895. /**
  124896. * Parses a JSON object to create a GPU particle system.
  124897. * @param parsedParticleSystem The JSON object to parse
  124898. * @param scene The scene to create the particle system in
  124899. * @param rootUrl The root url to use to load external dependencies like texture
  124900. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124901. * @returns the parsed GPU particle system
  124902. */
  124903. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124904. }
  124905. }
  124906. declare module BABYLON {
  124907. /**
  124908. * Represents a set of particle systems working together to create a specific effect
  124909. */
  124910. export class ParticleSystemSet implements IDisposable {
  124911. private _emitterCreationOptions;
  124912. private _emitterNode;
  124913. /**
  124914. * Gets the particle system list
  124915. */
  124916. systems: IParticleSystem[];
  124917. /**
  124918. * Gets the emitter node used with this set
  124919. */
  124920. readonly emitterNode: Nullable<TransformNode>;
  124921. /**
  124922. * Creates a new emitter mesh as a sphere
  124923. * @param options defines the options used to create the sphere
  124924. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124925. * @param scene defines the hosting scene
  124926. */
  124927. setEmitterAsSphere(options: {
  124928. diameter: number;
  124929. segments: number;
  124930. color: Color3;
  124931. }, renderingGroupId: number, scene: Scene): void;
  124932. /**
  124933. * Starts all particle systems of the set
  124934. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124935. */
  124936. start(emitter?: AbstractMesh): void;
  124937. /**
  124938. * Release all associated resources
  124939. */
  124940. dispose(): void;
  124941. /**
  124942. * Serialize the set into a JSON compatible object
  124943. * @returns a JSON compatible representation of the set
  124944. */
  124945. serialize(): any;
  124946. /**
  124947. * Parse a new ParticleSystemSet from a serialized source
  124948. * @param data defines a JSON compatible representation of the set
  124949. * @param scene defines the hosting scene
  124950. * @param gpu defines if we want GPU particles or CPU particles
  124951. * @returns a new ParticleSystemSet
  124952. */
  124953. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124954. }
  124955. }
  124956. declare module BABYLON {
  124957. /**
  124958. * This class is made for on one-liner static method to help creating particle system set.
  124959. */
  124960. export class ParticleHelper {
  124961. /**
  124962. * Gets or sets base Assets URL
  124963. */
  124964. static BaseAssetsUrl: string;
  124965. /**
  124966. * Create a default particle system that you can tweak
  124967. * @param emitter defines the emitter to use
  124968. * @param capacity defines the system capacity (default is 500 particles)
  124969. * @param scene defines the hosting scene
  124970. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124971. * @returns the new Particle system
  124972. */
  124973. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124974. /**
  124975. * This is the main static method (one-liner) of this helper to create different particle systems
  124976. * @param type This string represents the type to the particle system to create
  124977. * @param scene The scene where the particle system should live
  124978. * @param gpu If the system will use gpu
  124979. * @returns the ParticleSystemSet created
  124980. */
  124981. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124982. /**
  124983. * Static function used to export a particle system to a ParticleSystemSet variable.
  124984. * Please note that the emitter shape is not exported
  124985. * @param systems defines the particle systems to export
  124986. * @returns the created particle system set
  124987. */
  124988. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124989. }
  124990. }
  124991. declare module BABYLON {
  124992. interface Engine {
  124993. /**
  124994. * Create an effect to use with particle systems.
  124995. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124996. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124997. * @param uniformsNames defines a list of attribute names
  124998. * @param samplers defines an array of string used to represent textures
  124999. * @param defines defines the string containing the defines to use to compile the shaders
  125000. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125001. * @param onCompiled defines a function to call when the effect creation is successful
  125002. * @param onError defines a function to call when the effect creation has failed
  125003. * @returns the new Effect
  125004. */
  125005. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125006. }
  125007. interface Mesh {
  125008. /**
  125009. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125010. * @returns an array of IParticleSystem
  125011. */
  125012. getEmittedParticleSystems(): IParticleSystem[];
  125013. /**
  125014. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125015. * @returns an array of IParticleSystem
  125016. */
  125017. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125018. }
  125019. /**
  125020. * @hidden
  125021. */
  125022. export var _IDoNeedToBeInTheBuild: number;
  125023. }
  125024. declare module BABYLON {
  125025. interface Scene {
  125026. /** @hidden (Backing field) */
  125027. _physicsEngine: Nullable<IPhysicsEngine>;
  125028. /**
  125029. * Gets the current physics engine
  125030. * @returns a IPhysicsEngine or null if none attached
  125031. */
  125032. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125033. /**
  125034. * Enables physics to the current scene
  125035. * @param gravity defines the scene's gravity for the physics engine
  125036. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125037. * @return a boolean indicating if the physics engine was initialized
  125038. */
  125039. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125040. /**
  125041. * Disables and disposes the physics engine associated with the scene
  125042. */
  125043. disablePhysicsEngine(): void;
  125044. /**
  125045. * Gets a boolean indicating if there is an active physics engine
  125046. * @returns a boolean indicating if there is an active physics engine
  125047. */
  125048. isPhysicsEnabled(): boolean;
  125049. /**
  125050. * Deletes a physics compound impostor
  125051. * @param compound defines the compound to delete
  125052. */
  125053. deleteCompoundImpostor(compound: any): void;
  125054. /**
  125055. * An event triggered when physic simulation is about to be run
  125056. */
  125057. onBeforePhysicsObservable: Observable<Scene>;
  125058. /**
  125059. * An event triggered when physic simulation has been done
  125060. */
  125061. onAfterPhysicsObservable: Observable<Scene>;
  125062. }
  125063. interface AbstractMesh {
  125064. /** @hidden */
  125065. _physicsImpostor: Nullable<PhysicsImpostor>;
  125066. /**
  125067. * Gets or sets impostor used for physic simulation
  125068. * @see http://doc.babylonjs.com/features/physics_engine
  125069. */
  125070. physicsImpostor: Nullable<PhysicsImpostor>;
  125071. /**
  125072. * Gets the current physics impostor
  125073. * @see http://doc.babylonjs.com/features/physics_engine
  125074. * @returns a physics impostor or null
  125075. */
  125076. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125077. /** Apply a physic impulse to the mesh
  125078. * @param force defines the force to apply
  125079. * @param contactPoint defines where to apply the force
  125080. * @returns the current mesh
  125081. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125082. */
  125083. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125084. /**
  125085. * Creates a physic joint between two meshes
  125086. * @param otherMesh defines the other mesh to use
  125087. * @param pivot1 defines the pivot to use on this mesh
  125088. * @param pivot2 defines the pivot to use on the other mesh
  125089. * @param options defines additional options (can be plugin dependent)
  125090. * @returns the current mesh
  125091. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125092. */
  125093. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125094. /** @hidden */
  125095. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125096. }
  125097. /**
  125098. * Defines the physics engine scene component responsible to manage a physics engine
  125099. */
  125100. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125101. /**
  125102. * The component name helpful to identify the component in the list of scene components.
  125103. */
  125104. readonly name: string;
  125105. /**
  125106. * The scene the component belongs to.
  125107. */
  125108. scene: Scene;
  125109. /**
  125110. * Creates a new instance of the component for the given scene
  125111. * @param scene Defines the scene to register the component in
  125112. */
  125113. constructor(scene: Scene);
  125114. /**
  125115. * Registers the component in a given scene
  125116. */
  125117. register(): void;
  125118. /**
  125119. * Rebuilds the elements related to this component in case of
  125120. * context lost for instance.
  125121. */
  125122. rebuild(): void;
  125123. /**
  125124. * Disposes the component and the associated ressources
  125125. */
  125126. dispose(): void;
  125127. }
  125128. }
  125129. declare module BABYLON {
  125130. /**
  125131. * A helper for physics simulations
  125132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125133. */
  125134. export class PhysicsHelper {
  125135. private _scene;
  125136. private _physicsEngine;
  125137. /**
  125138. * Initializes the Physics helper
  125139. * @param scene Babylon.js scene
  125140. */
  125141. constructor(scene: Scene);
  125142. /**
  125143. * Applies a radial explosion impulse
  125144. * @param origin the origin of the explosion
  125145. * @param radiusOrEventOptions the radius or the options of radial explosion
  125146. * @param strength the explosion strength
  125147. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125148. * @returns A physics radial explosion event, or null
  125149. */
  125150. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125151. /**
  125152. * Applies a radial explosion force
  125153. * @param origin the origin of the explosion
  125154. * @param radiusOrEventOptions the radius or the options of radial explosion
  125155. * @param strength the explosion strength
  125156. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125157. * @returns A physics radial explosion event, or null
  125158. */
  125159. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125160. /**
  125161. * Creates a gravitational field
  125162. * @param origin the origin of the explosion
  125163. * @param radiusOrEventOptions the radius or the options of radial explosion
  125164. * @param strength the explosion strength
  125165. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125166. * @returns A physics gravitational field event, or null
  125167. */
  125168. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125169. /**
  125170. * Creates a physics updraft event
  125171. * @param origin the origin of the updraft
  125172. * @param radiusOrEventOptions the radius or the options of the updraft
  125173. * @param strength the strength of the updraft
  125174. * @param height the height of the updraft
  125175. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125176. * @returns A physics updraft event, or null
  125177. */
  125178. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125179. /**
  125180. * Creates a physics vortex event
  125181. * @param origin the of the vortex
  125182. * @param radiusOrEventOptions the radius or the options of the vortex
  125183. * @param strength the strength of the vortex
  125184. * @param height the height of the vortex
  125185. * @returns a Physics vortex event, or null
  125186. * A physics vortex event or null
  125187. */
  125188. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125189. }
  125190. /**
  125191. * Represents a physics radial explosion event
  125192. */
  125193. class PhysicsRadialExplosionEvent {
  125194. private _scene;
  125195. private _options;
  125196. private _sphere;
  125197. private _dataFetched;
  125198. /**
  125199. * Initializes a radial explosioin event
  125200. * @param _scene BabylonJS scene
  125201. * @param _options The options for the vortex event
  125202. */
  125203. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125204. /**
  125205. * Returns the data related to the radial explosion event (sphere).
  125206. * @returns The radial explosion event data
  125207. */
  125208. getData(): PhysicsRadialExplosionEventData;
  125209. /**
  125210. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125211. * @param impostor A physics imposter
  125212. * @param origin the origin of the explosion
  125213. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125214. */
  125215. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125216. /**
  125217. * Triggers affecterd impostors callbacks
  125218. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125219. */
  125220. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125221. /**
  125222. * Disposes the sphere.
  125223. * @param force Specifies if the sphere should be disposed by force
  125224. */
  125225. dispose(force?: boolean): void;
  125226. /*** Helpers ***/
  125227. private _prepareSphere;
  125228. private _intersectsWithSphere;
  125229. }
  125230. /**
  125231. * Represents a gravitational field event
  125232. */
  125233. class PhysicsGravitationalFieldEvent {
  125234. private _physicsHelper;
  125235. private _scene;
  125236. private _origin;
  125237. private _options;
  125238. private _tickCallback;
  125239. private _sphere;
  125240. private _dataFetched;
  125241. /**
  125242. * Initializes the physics gravitational field event
  125243. * @param _physicsHelper A physics helper
  125244. * @param _scene BabylonJS scene
  125245. * @param _origin The origin position of the gravitational field event
  125246. * @param _options The options for the vortex event
  125247. */
  125248. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125249. /**
  125250. * Returns the data related to the gravitational field event (sphere).
  125251. * @returns A gravitational field event
  125252. */
  125253. getData(): PhysicsGravitationalFieldEventData;
  125254. /**
  125255. * Enables the gravitational field.
  125256. */
  125257. enable(): void;
  125258. /**
  125259. * Disables the gravitational field.
  125260. */
  125261. disable(): void;
  125262. /**
  125263. * Disposes the sphere.
  125264. * @param force The force to dispose from the gravitational field event
  125265. */
  125266. dispose(force?: boolean): void;
  125267. private _tick;
  125268. }
  125269. /**
  125270. * Represents a physics updraft event
  125271. */
  125272. class PhysicsUpdraftEvent {
  125273. private _scene;
  125274. private _origin;
  125275. private _options;
  125276. private _physicsEngine;
  125277. private _originTop;
  125278. private _originDirection;
  125279. private _tickCallback;
  125280. private _cylinder;
  125281. private _cylinderPosition;
  125282. private _dataFetched;
  125283. /**
  125284. * Initializes the physics updraft event
  125285. * @param _scene BabylonJS scene
  125286. * @param _origin The origin position of the updraft
  125287. * @param _options The options for the updraft event
  125288. */
  125289. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125290. /**
  125291. * Returns the data related to the updraft event (cylinder).
  125292. * @returns A physics updraft event
  125293. */
  125294. getData(): PhysicsUpdraftEventData;
  125295. /**
  125296. * Enables the updraft.
  125297. */
  125298. enable(): void;
  125299. /**
  125300. * Disables the updraft.
  125301. */
  125302. disable(): void;
  125303. /**
  125304. * Disposes the cylinder.
  125305. * @param force Specifies if the updraft should be disposed by force
  125306. */
  125307. dispose(force?: boolean): void;
  125308. private getImpostorHitData;
  125309. private _tick;
  125310. /*** Helpers ***/
  125311. private _prepareCylinder;
  125312. private _intersectsWithCylinder;
  125313. }
  125314. /**
  125315. * Represents a physics vortex event
  125316. */
  125317. class PhysicsVortexEvent {
  125318. private _scene;
  125319. private _origin;
  125320. private _options;
  125321. private _physicsEngine;
  125322. private _originTop;
  125323. private _tickCallback;
  125324. private _cylinder;
  125325. private _cylinderPosition;
  125326. private _dataFetched;
  125327. /**
  125328. * Initializes the physics vortex event
  125329. * @param _scene The BabylonJS scene
  125330. * @param _origin The origin position of the vortex
  125331. * @param _options The options for the vortex event
  125332. */
  125333. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125334. /**
  125335. * Returns the data related to the vortex event (cylinder).
  125336. * @returns The physics vortex event data
  125337. */
  125338. getData(): PhysicsVortexEventData;
  125339. /**
  125340. * Enables the vortex.
  125341. */
  125342. enable(): void;
  125343. /**
  125344. * Disables the cortex.
  125345. */
  125346. disable(): void;
  125347. /**
  125348. * Disposes the sphere.
  125349. * @param force
  125350. */
  125351. dispose(force?: boolean): void;
  125352. private getImpostorHitData;
  125353. private _tick;
  125354. /*** Helpers ***/
  125355. private _prepareCylinder;
  125356. private _intersectsWithCylinder;
  125357. }
  125358. /**
  125359. * Options fot the radial explosion event
  125360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125361. */
  125362. export class PhysicsRadialExplosionEventOptions {
  125363. /**
  125364. * The radius of the sphere for the radial explosion.
  125365. */
  125366. radius: number;
  125367. /**
  125368. * The strenth of the explosion.
  125369. */
  125370. strength: number;
  125371. /**
  125372. * The strenght of the force in correspondence to the distance of the affected object
  125373. */
  125374. falloff: PhysicsRadialImpulseFalloff;
  125375. /**
  125376. * Sphere options for the radial explosion.
  125377. */
  125378. sphere: {
  125379. segments: number;
  125380. diameter: number;
  125381. };
  125382. /**
  125383. * Sphere options for the radial explosion.
  125384. */
  125385. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125386. }
  125387. /**
  125388. * Options fot the updraft event
  125389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125390. */
  125391. export class PhysicsUpdraftEventOptions {
  125392. /**
  125393. * The radius of the cylinder for the vortex
  125394. */
  125395. radius: number;
  125396. /**
  125397. * The strenth of the updraft.
  125398. */
  125399. strength: number;
  125400. /**
  125401. * The height of the cylinder for the updraft.
  125402. */
  125403. height: number;
  125404. /**
  125405. * The mode for the the updraft.
  125406. */
  125407. updraftMode: PhysicsUpdraftMode;
  125408. }
  125409. /**
  125410. * Options fot the vortex event
  125411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125412. */
  125413. export class PhysicsVortexEventOptions {
  125414. /**
  125415. * The radius of the cylinder for the vortex
  125416. */
  125417. radius: number;
  125418. /**
  125419. * The strenth of the vortex.
  125420. */
  125421. strength: number;
  125422. /**
  125423. * The height of the cylinder for the vortex.
  125424. */
  125425. height: number;
  125426. /**
  125427. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125428. */
  125429. centripetalForceThreshold: number;
  125430. /**
  125431. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125432. */
  125433. centripetalForceMultiplier: number;
  125434. /**
  125435. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125436. */
  125437. centrifugalForceMultiplier: number;
  125438. /**
  125439. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125440. */
  125441. updraftForceMultiplier: number;
  125442. }
  125443. /**
  125444. * The strenght of the force in correspondence to the distance of the affected object
  125445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125446. */
  125447. export enum PhysicsRadialImpulseFalloff {
  125448. /** Defines that impulse is constant in strength across it's whole radius */
  125449. Constant = 0,
  125450. /** Defines that impulse gets weaker if it's further from the origin */
  125451. Linear = 1
  125452. }
  125453. /**
  125454. * The strength of the force in correspondence to the distance of the affected object
  125455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125456. */
  125457. export enum PhysicsUpdraftMode {
  125458. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125459. Center = 0,
  125460. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125461. Perpendicular = 1
  125462. }
  125463. /**
  125464. * Interface for a physics hit data
  125465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125466. */
  125467. export interface PhysicsHitData {
  125468. /**
  125469. * The force applied at the contact point
  125470. */
  125471. force: Vector3;
  125472. /**
  125473. * The contact point
  125474. */
  125475. contactPoint: Vector3;
  125476. /**
  125477. * The distance from the origin to the contact point
  125478. */
  125479. distanceFromOrigin: number;
  125480. }
  125481. /**
  125482. * Interface for radial explosion event data
  125483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125484. */
  125485. export interface PhysicsRadialExplosionEventData {
  125486. /**
  125487. * A sphere used for the radial explosion event
  125488. */
  125489. sphere: Mesh;
  125490. }
  125491. /**
  125492. * Interface for gravitational field event data
  125493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125494. */
  125495. export interface PhysicsGravitationalFieldEventData {
  125496. /**
  125497. * A sphere mesh used for the gravitational field event
  125498. */
  125499. sphere: Mesh;
  125500. }
  125501. /**
  125502. * Interface for updraft event data
  125503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125504. */
  125505. export interface PhysicsUpdraftEventData {
  125506. /**
  125507. * A cylinder used for the updraft event
  125508. */
  125509. cylinder: Mesh;
  125510. }
  125511. /**
  125512. * Interface for vortex event data
  125513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125514. */
  125515. export interface PhysicsVortexEventData {
  125516. /**
  125517. * A cylinder used for the vortex event
  125518. */
  125519. cylinder: Mesh;
  125520. }
  125521. /**
  125522. * Interface for an affected physics impostor
  125523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125524. */
  125525. export interface PhysicsAffectedImpostorWithData {
  125526. /**
  125527. * The impostor affected by the effect
  125528. */
  125529. impostor: PhysicsImpostor;
  125530. /**
  125531. * The data about the hit/horce from the explosion
  125532. */
  125533. hitData: PhysicsHitData;
  125534. }
  125535. }
  125536. declare module BABYLON {
  125537. /** @hidden */
  125538. export var blackAndWhitePixelShader: {
  125539. name: string;
  125540. shader: string;
  125541. };
  125542. }
  125543. declare module BABYLON {
  125544. /**
  125545. * Post process used to render in black and white
  125546. */
  125547. export class BlackAndWhitePostProcess extends PostProcess {
  125548. /**
  125549. * Linear about to convert he result to black and white (default: 1)
  125550. */
  125551. degree: number;
  125552. /**
  125553. * Creates a black and white post process
  125554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125555. * @param name The name of the effect.
  125556. * @param options The required width/height ratio to downsize to before computing the render pass.
  125557. * @param camera The camera to apply the render pass to.
  125558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125559. * @param engine The engine which the post process will be applied. (default: current engine)
  125560. * @param reusable If the post process can be reused on the same frame. (default: false)
  125561. */
  125562. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125563. }
  125564. }
  125565. declare module BABYLON {
  125566. /**
  125567. * This represents a set of one or more post processes in Babylon.
  125568. * A post process can be used to apply a shader to a texture after it is rendered.
  125569. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125570. */
  125571. export class PostProcessRenderEffect {
  125572. private _postProcesses;
  125573. private _getPostProcesses;
  125574. private _singleInstance;
  125575. private _cameras;
  125576. private _indicesForCamera;
  125577. /**
  125578. * Name of the effect
  125579. * @hidden
  125580. */
  125581. _name: string;
  125582. /**
  125583. * Instantiates a post process render effect.
  125584. * A post process can be used to apply a shader to a texture after it is rendered.
  125585. * @param engine The engine the effect is tied to
  125586. * @param name The name of the effect
  125587. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125588. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125589. */
  125590. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125591. /**
  125592. * Checks if all the post processes in the effect are supported.
  125593. */
  125594. readonly isSupported: boolean;
  125595. /**
  125596. * Updates the current state of the effect
  125597. * @hidden
  125598. */
  125599. _update(): void;
  125600. /**
  125601. * Attaches the effect on cameras
  125602. * @param cameras The camera to attach to.
  125603. * @hidden
  125604. */
  125605. _attachCameras(cameras: Camera): void;
  125606. /**
  125607. * Attaches the effect on cameras
  125608. * @param cameras The camera to attach to.
  125609. * @hidden
  125610. */
  125611. _attachCameras(cameras: Camera[]): void;
  125612. /**
  125613. * Detaches the effect on cameras
  125614. * @param cameras The camera to detatch from.
  125615. * @hidden
  125616. */
  125617. _detachCameras(cameras: Camera): void;
  125618. /**
  125619. * Detatches the effect on cameras
  125620. * @param cameras The camera to detatch from.
  125621. * @hidden
  125622. */
  125623. _detachCameras(cameras: Camera[]): void;
  125624. /**
  125625. * Enables the effect on given cameras
  125626. * @param cameras The camera to enable.
  125627. * @hidden
  125628. */
  125629. _enable(cameras: Camera): void;
  125630. /**
  125631. * Enables the effect on given cameras
  125632. * @param cameras The camera to enable.
  125633. * @hidden
  125634. */
  125635. _enable(cameras: Nullable<Camera[]>): void;
  125636. /**
  125637. * Disables the effect on the given cameras
  125638. * @param cameras The camera to disable.
  125639. * @hidden
  125640. */
  125641. _disable(cameras: Camera): void;
  125642. /**
  125643. * Disables the effect on the given cameras
  125644. * @param cameras The camera to disable.
  125645. * @hidden
  125646. */
  125647. _disable(cameras: Nullable<Camera[]>): void;
  125648. /**
  125649. * Gets a list of the post processes contained in the effect.
  125650. * @param camera The camera to get the post processes on.
  125651. * @returns The list of the post processes in the effect.
  125652. */
  125653. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125654. }
  125655. }
  125656. declare module BABYLON {
  125657. /** @hidden */
  125658. export var extractHighlightsPixelShader: {
  125659. name: string;
  125660. shader: string;
  125661. };
  125662. }
  125663. declare module BABYLON {
  125664. /**
  125665. * 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.
  125666. */
  125667. export class ExtractHighlightsPostProcess extends PostProcess {
  125668. /**
  125669. * The luminance threshold, pixels below this value will be set to black.
  125670. */
  125671. threshold: number;
  125672. /** @hidden */
  125673. _exposure: number;
  125674. /**
  125675. * Post process which has the input texture to be used when performing highlight extraction
  125676. * @hidden
  125677. */
  125678. _inputPostProcess: Nullable<PostProcess>;
  125679. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125680. }
  125681. }
  125682. declare module BABYLON {
  125683. /** @hidden */
  125684. export var bloomMergePixelShader: {
  125685. name: string;
  125686. shader: string;
  125687. };
  125688. }
  125689. declare module BABYLON {
  125690. /**
  125691. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125692. */
  125693. export class BloomMergePostProcess extends PostProcess {
  125694. /** Weight of the bloom to be added to the original input. */
  125695. weight: number;
  125696. /**
  125697. * Creates a new instance of @see BloomMergePostProcess
  125698. * @param name The name of the effect.
  125699. * @param originalFromInput Post process which's input will be used for the merge.
  125700. * @param blurred Blurred highlights post process which's output will be used.
  125701. * @param weight Weight of the bloom to be added to the original input.
  125702. * @param options The required width/height ratio to downsize to before computing the render pass.
  125703. * @param camera The camera to apply the render pass to.
  125704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125705. * @param engine The engine which the post process will be applied. (default: current engine)
  125706. * @param reusable If the post process can be reused on the same frame. (default: false)
  125707. * @param textureType Type of textures used when performing the post process. (default: 0)
  125708. * @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)
  125709. */
  125710. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125711. /** Weight of the bloom to be added to the original input. */
  125712. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125713. }
  125714. }
  125715. declare module BABYLON {
  125716. /**
  125717. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125718. */
  125719. export class BloomEffect extends PostProcessRenderEffect {
  125720. private bloomScale;
  125721. /**
  125722. * @hidden Internal
  125723. */
  125724. _effects: Array<PostProcess>;
  125725. /**
  125726. * @hidden Internal
  125727. */
  125728. _downscale: ExtractHighlightsPostProcess;
  125729. private _blurX;
  125730. private _blurY;
  125731. private _merge;
  125732. /**
  125733. * The luminance threshold to find bright areas of the image to bloom.
  125734. */
  125735. threshold: number;
  125736. /**
  125737. * The strength of the bloom.
  125738. */
  125739. weight: number;
  125740. /**
  125741. * Specifies the size of the bloom blur kernel, relative to the final output size
  125742. */
  125743. kernel: number;
  125744. /**
  125745. * Creates a new instance of @see BloomEffect
  125746. * @param scene The scene the effect belongs to.
  125747. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125748. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125749. * @param bloomWeight The the strength of bloom.
  125750. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125751. * @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)
  125752. */
  125753. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125754. /**
  125755. * Disposes each of the internal effects for a given camera.
  125756. * @param camera The camera to dispose the effect on.
  125757. */
  125758. disposeEffects(camera: Camera): void;
  125759. /**
  125760. * @hidden Internal
  125761. */
  125762. _updateEffects(): void;
  125763. /**
  125764. * Internal
  125765. * @returns if all the contained post processes are ready.
  125766. * @hidden
  125767. */
  125768. _isReady(): boolean;
  125769. }
  125770. }
  125771. declare module BABYLON {
  125772. /** @hidden */
  125773. export var chromaticAberrationPixelShader: {
  125774. name: string;
  125775. shader: string;
  125776. };
  125777. }
  125778. declare module BABYLON {
  125779. /**
  125780. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125781. */
  125782. export class ChromaticAberrationPostProcess extends PostProcess {
  125783. /**
  125784. * The amount of seperation of rgb channels (default: 30)
  125785. */
  125786. aberrationAmount: number;
  125787. /**
  125788. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125789. */
  125790. radialIntensity: number;
  125791. /**
  125792. * 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))
  125793. */
  125794. direction: Vector2;
  125795. /**
  125796. * 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))
  125797. */
  125798. centerPosition: Vector2;
  125799. /**
  125800. * Creates a new instance ChromaticAberrationPostProcess
  125801. * @param name The name of the effect.
  125802. * @param screenWidth The width of the screen to apply the effect on.
  125803. * @param screenHeight The height of the screen to apply the effect on.
  125804. * @param options The required width/height ratio to downsize to before computing the render pass.
  125805. * @param camera The camera to apply the render pass to.
  125806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125807. * @param engine The engine which the post process will be applied. (default: current engine)
  125808. * @param reusable If the post process can be reused on the same frame. (default: false)
  125809. * @param textureType Type of textures used when performing the post process. (default: 0)
  125810. * @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)
  125811. */
  125812. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125813. }
  125814. }
  125815. declare module BABYLON {
  125816. /** @hidden */
  125817. export var circleOfConfusionPixelShader: {
  125818. name: string;
  125819. shader: string;
  125820. };
  125821. }
  125822. declare module BABYLON {
  125823. /**
  125824. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125825. */
  125826. export class CircleOfConfusionPostProcess extends PostProcess {
  125827. /**
  125828. * 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.
  125829. */
  125830. lensSize: number;
  125831. /**
  125832. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125833. */
  125834. fStop: number;
  125835. /**
  125836. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125837. */
  125838. focusDistance: number;
  125839. /**
  125840. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125841. */
  125842. focalLength: number;
  125843. private _depthTexture;
  125844. /**
  125845. * Creates a new instance CircleOfConfusionPostProcess
  125846. * @param name The name of the effect.
  125847. * @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.
  125848. * @param options The required width/height ratio to downsize to before computing the render pass.
  125849. * @param camera The camera to apply the render pass to.
  125850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125851. * @param engine The engine which the post process will be applied. (default: current engine)
  125852. * @param reusable If the post process can be reused on the same frame. (default: false)
  125853. * @param textureType Type of textures used when performing the post process. (default: 0)
  125854. * @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)
  125855. */
  125856. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125857. /**
  125858. * 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.
  125859. */
  125860. depthTexture: RenderTargetTexture;
  125861. }
  125862. }
  125863. declare module BABYLON {
  125864. /** @hidden */
  125865. export var colorCorrectionPixelShader: {
  125866. name: string;
  125867. shader: string;
  125868. };
  125869. }
  125870. declare module BABYLON {
  125871. /**
  125872. *
  125873. * This post-process allows the modification of rendered colors by using
  125874. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125875. *
  125876. * The object needs to be provided an url to a texture containing the color
  125877. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125878. * Use an image editing software to tweak the LUT to match your needs.
  125879. *
  125880. * For an example of a color LUT, see here:
  125881. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125882. * For explanations on color grading, see here:
  125883. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125884. *
  125885. */
  125886. export class ColorCorrectionPostProcess extends PostProcess {
  125887. private _colorTableTexture;
  125888. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125889. }
  125890. }
  125891. declare module BABYLON {
  125892. /** @hidden */
  125893. export var convolutionPixelShader: {
  125894. name: string;
  125895. shader: string;
  125896. };
  125897. }
  125898. declare module BABYLON {
  125899. /**
  125900. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125901. * input texture to perform effects such as edge detection or sharpening
  125902. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125903. */
  125904. export class ConvolutionPostProcess extends PostProcess {
  125905. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125906. kernel: number[];
  125907. /**
  125908. * Creates a new instance ConvolutionPostProcess
  125909. * @param name The name of the effect.
  125910. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125911. * @param options The required width/height ratio to downsize to before computing the render pass.
  125912. * @param camera The camera to apply the render pass to.
  125913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125914. * @param engine The engine which the post process will be applied. (default: current engine)
  125915. * @param reusable If the post process can be reused on the same frame. (default: false)
  125916. * @param textureType Type of textures used when performing the post process. (default: 0)
  125917. */
  125918. constructor(name: string,
  125919. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125920. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125921. /**
  125922. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125923. */
  125924. static EdgeDetect0Kernel: number[];
  125925. /**
  125926. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125927. */
  125928. static EdgeDetect1Kernel: number[];
  125929. /**
  125930. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125931. */
  125932. static EdgeDetect2Kernel: number[];
  125933. /**
  125934. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125935. */
  125936. static SharpenKernel: number[];
  125937. /**
  125938. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125939. */
  125940. static EmbossKernel: number[];
  125941. /**
  125942. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125943. */
  125944. static GaussianKernel: number[];
  125945. }
  125946. }
  125947. declare module BABYLON {
  125948. /**
  125949. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125950. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125951. * based on samples that have a large difference in distance than the center pixel.
  125952. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125953. */
  125954. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125955. direction: Vector2;
  125956. /**
  125957. * Creates a new instance CircleOfConfusionPostProcess
  125958. * @param name The name of the effect.
  125959. * @param scene The scene the effect belongs to.
  125960. * @param direction The direction the blur should be applied.
  125961. * @param kernel The size of the kernel used to blur.
  125962. * @param options The required width/height ratio to downsize to before computing the render pass.
  125963. * @param camera The camera to apply the render pass to.
  125964. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125965. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125967. * @param engine The engine which the post process will be applied. (default: current engine)
  125968. * @param reusable If the post process can be reused on the same frame. (default: false)
  125969. * @param textureType Type of textures used when performing the post process. (default: 0)
  125970. * @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)
  125971. */
  125972. 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);
  125973. }
  125974. }
  125975. declare module BABYLON {
  125976. /** @hidden */
  125977. export var depthOfFieldMergePixelShader: {
  125978. name: string;
  125979. shader: string;
  125980. };
  125981. }
  125982. declare module BABYLON {
  125983. /**
  125984. * Options to be set when merging outputs from the default pipeline.
  125985. */
  125986. export class DepthOfFieldMergePostProcessOptions {
  125987. /**
  125988. * The original image to merge on top of
  125989. */
  125990. originalFromInput: PostProcess;
  125991. /**
  125992. * Parameters to perform the merge of the depth of field effect
  125993. */
  125994. depthOfField?: {
  125995. circleOfConfusion: PostProcess;
  125996. blurSteps: Array<PostProcess>;
  125997. };
  125998. /**
  125999. * Parameters to perform the merge of bloom effect
  126000. */
  126001. bloom?: {
  126002. blurred: PostProcess;
  126003. weight: number;
  126004. };
  126005. }
  126006. /**
  126007. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126008. */
  126009. export class DepthOfFieldMergePostProcess extends PostProcess {
  126010. private blurSteps;
  126011. /**
  126012. * Creates a new instance of DepthOfFieldMergePostProcess
  126013. * @param name The name of the effect.
  126014. * @param originalFromInput Post process which's input will be used for the merge.
  126015. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126016. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  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 samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126020. * @param engine The engine which the post process will be applied. (default: current engine)
  126021. * @param reusable If the post process can be reused on the same frame. (default: false)
  126022. * @param textureType Type of textures used when performing the post process. (default: 0)
  126023. * @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)
  126024. */
  126025. 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);
  126026. /**
  126027. * Updates the effect with the current post process compile time values and recompiles the shader.
  126028. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126029. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126030. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126031. * @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
  126032. * @param onCompiled Called when the shader has been compiled.
  126033. * @param onError Called if there is an error when compiling a shader.
  126034. */
  126035. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126036. }
  126037. }
  126038. declare module BABYLON {
  126039. /**
  126040. * Specifies the level of max blur that should be applied when using the depth of field effect
  126041. */
  126042. export enum DepthOfFieldEffectBlurLevel {
  126043. /**
  126044. * Subtle blur
  126045. */
  126046. Low = 0,
  126047. /**
  126048. * Medium blur
  126049. */
  126050. Medium = 1,
  126051. /**
  126052. * Large blur
  126053. */
  126054. High = 2
  126055. }
  126056. /**
  126057. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126058. */
  126059. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126060. private _circleOfConfusion;
  126061. /**
  126062. * @hidden Internal, blurs from high to low
  126063. */
  126064. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126065. private _depthOfFieldBlurY;
  126066. private _dofMerge;
  126067. /**
  126068. * @hidden Internal post processes in depth of field effect
  126069. */
  126070. _effects: Array<PostProcess>;
  126071. /**
  126072. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126073. */
  126074. focalLength: number;
  126075. /**
  126076. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126077. */
  126078. fStop: number;
  126079. /**
  126080. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126081. */
  126082. focusDistance: number;
  126083. /**
  126084. * 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.
  126085. */
  126086. lensSize: number;
  126087. /**
  126088. * Creates a new instance DepthOfFieldEffect
  126089. * @param scene The scene the effect belongs to.
  126090. * @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.
  126091. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126092. * @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)
  126093. */
  126094. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126095. /**
  126096. * Get the current class name of the current effet
  126097. * @returns "DepthOfFieldEffect"
  126098. */
  126099. getClassName(): string;
  126100. /**
  126101. * 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.
  126102. */
  126103. depthTexture: RenderTargetTexture;
  126104. /**
  126105. * Disposes each of the internal effects for a given camera.
  126106. * @param camera The camera to dispose the effect on.
  126107. */
  126108. disposeEffects(camera: Camera): void;
  126109. /**
  126110. * @hidden Internal
  126111. */
  126112. _updateEffects(): void;
  126113. /**
  126114. * Internal
  126115. * @returns if all the contained post processes are ready.
  126116. * @hidden
  126117. */
  126118. _isReady(): boolean;
  126119. }
  126120. }
  126121. declare module BABYLON {
  126122. /** @hidden */
  126123. export var displayPassPixelShader: {
  126124. name: string;
  126125. shader: string;
  126126. };
  126127. }
  126128. declare module BABYLON {
  126129. /**
  126130. * DisplayPassPostProcess which produces an output the same as it's input
  126131. */
  126132. export class DisplayPassPostProcess extends PostProcess {
  126133. /**
  126134. * Creates the DisplayPassPostProcess
  126135. * @param name The name of the effect.
  126136. * @param options The required width/height ratio to downsize to before computing the render pass.
  126137. * @param camera The camera to apply the render pass to.
  126138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126139. * @param engine The engine which the post process will be applied. (default: current engine)
  126140. * @param reusable If the post process can be reused on the same frame. (default: false)
  126141. */
  126142. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126143. }
  126144. }
  126145. declare module BABYLON {
  126146. /** @hidden */
  126147. export var filterPixelShader: {
  126148. name: string;
  126149. shader: string;
  126150. };
  126151. }
  126152. declare module BABYLON {
  126153. /**
  126154. * Applies a kernel filter to the image
  126155. */
  126156. export class FilterPostProcess extends PostProcess {
  126157. /** The matrix to be applied to the image */
  126158. kernelMatrix: Matrix;
  126159. /**
  126160. *
  126161. * @param name The name of the effect.
  126162. * @param kernelMatrix The matrix to be applied to the image
  126163. * @param options The required width/height ratio to downsize to before computing the render pass.
  126164. * @param camera The camera to apply the render pass to.
  126165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126166. * @param engine The engine which the post process will be applied. (default: current engine)
  126167. * @param reusable If the post process can be reused on the same frame. (default: false)
  126168. */
  126169. constructor(name: string,
  126170. /** The matrix to be applied to the image */
  126171. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126172. }
  126173. }
  126174. declare module BABYLON {
  126175. /** @hidden */
  126176. export var fxaaPixelShader: {
  126177. name: string;
  126178. shader: string;
  126179. };
  126180. }
  126181. declare module BABYLON {
  126182. /** @hidden */
  126183. export var fxaaVertexShader: {
  126184. name: string;
  126185. shader: string;
  126186. };
  126187. }
  126188. declare module BABYLON {
  126189. /**
  126190. * Fxaa post process
  126191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126192. */
  126193. export class FxaaPostProcess extends PostProcess {
  126194. /** @hidden */
  126195. texelWidth: number;
  126196. /** @hidden */
  126197. texelHeight: number;
  126198. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126199. private _getDefines;
  126200. }
  126201. }
  126202. declare module BABYLON {
  126203. /** @hidden */
  126204. export var grainPixelShader: {
  126205. name: string;
  126206. shader: string;
  126207. };
  126208. }
  126209. declare module BABYLON {
  126210. /**
  126211. * The GrainPostProcess adds noise to the image at mid luminance levels
  126212. */
  126213. export class GrainPostProcess extends PostProcess {
  126214. /**
  126215. * The intensity of the grain added (default: 30)
  126216. */
  126217. intensity: number;
  126218. /**
  126219. * If the grain should be randomized on every frame
  126220. */
  126221. animated: boolean;
  126222. /**
  126223. * Creates a new instance of @see GrainPostProcess
  126224. * @param name The name of the effect.
  126225. * @param options The required width/height ratio to downsize to before computing the render pass.
  126226. * @param camera The camera to apply the render pass to.
  126227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126228. * @param engine The engine which the post process will be applied. (default: current engine)
  126229. * @param reusable If the post process can be reused on the same frame. (default: false)
  126230. * @param textureType Type of textures used when performing the post process. (default: 0)
  126231. * @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)
  126232. */
  126233. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126234. }
  126235. }
  126236. declare module BABYLON {
  126237. /** @hidden */
  126238. export var highlightsPixelShader: {
  126239. name: string;
  126240. shader: string;
  126241. };
  126242. }
  126243. declare module BABYLON {
  126244. /**
  126245. * Extracts highlights from the image
  126246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126247. */
  126248. export class HighlightsPostProcess extends PostProcess {
  126249. /**
  126250. * Extracts highlights from the image
  126251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126252. * @param name The name of the effect.
  126253. * @param options The required width/height ratio to downsize to before computing the render pass.
  126254. * @param camera The camera to apply the render pass to.
  126255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126256. * @param engine The engine which the post process will be applied. (default: current engine)
  126257. * @param reusable If the post process can be reused on the same frame. (default: false)
  126258. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126259. */
  126260. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126261. }
  126262. }
  126263. declare module BABYLON {
  126264. /** @hidden */
  126265. export var mrtFragmentDeclaration: {
  126266. name: string;
  126267. shader: string;
  126268. };
  126269. }
  126270. declare module BABYLON {
  126271. /** @hidden */
  126272. export var geometryPixelShader: {
  126273. name: string;
  126274. shader: string;
  126275. };
  126276. }
  126277. declare module BABYLON {
  126278. /** @hidden */
  126279. export var geometryVertexShader: {
  126280. name: string;
  126281. shader: string;
  126282. };
  126283. }
  126284. declare module BABYLON {
  126285. /** @hidden */
  126286. interface ISavedTransformationMatrix {
  126287. world: Matrix;
  126288. viewProjection: Matrix;
  126289. }
  126290. /**
  126291. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126292. */
  126293. export class GeometryBufferRenderer {
  126294. /**
  126295. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126296. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126297. */
  126298. static readonly POSITION_TEXTURE_TYPE: number;
  126299. /**
  126300. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126301. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126302. */
  126303. static readonly VELOCITY_TEXTURE_TYPE: number;
  126304. /**
  126305. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126306. * in order to compute objects velocities when enableVelocity is set to "true"
  126307. * @hidden
  126308. */
  126309. _previousTransformationMatrices: {
  126310. [index: number]: ISavedTransformationMatrix;
  126311. };
  126312. /**
  126313. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126314. * in order to compute objects velocities when enableVelocity is set to "true"
  126315. * @hidden
  126316. */
  126317. _previousBonesTransformationMatrices: {
  126318. [index: number]: Float32Array;
  126319. };
  126320. /**
  126321. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126322. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126323. */
  126324. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126325. private _scene;
  126326. private _multiRenderTarget;
  126327. private _ratio;
  126328. private _enablePosition;
  126329. private _enableVelocity;
  126330. private _positionIndex;
  126331. private _velocityIndex;
  126332. protected _effect: Effect;
  126333. protected _cachedDefines: string;
  126334. /**
  126335. * Set the render list (meshes to be rendered) used in the G buffer.
  126336. */
  126337. renderList: Mesh[];
  126338. /**
  126339. * Gets wether or not G buffer are supported by the running hardware.
  126340. * This requires draw buffer supports
  126341. */
  126342. readonly isSupported: boolean;
  126343. /**
  126344. * Returns the index of the given texture type in the G-Buffer textures array
  126345. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126346. * @returns the index of the given texture type in the G-Buffer textures array
  126347. */
  126348. getTextureIndex(textureType: number): number;
  126349. /**
  126350. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126351. */
  126352. /**
  126353. * Sets whether or not objects positions are enabled for the G buffer.
  126354. */
  126355. enablePosition: boolean;
  126356. /**
  126357. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126358. */
  126359. /**
  126360. * Sets wether or not objects velocities are enabled for the G buffer.
  126361. */
  126362. enableVelocity: boolean;
  126363. /**
  126364. * Gets the scene associated with the buffer.
  126365. */
  126366. readonly scene: Scene;
  126367. /**
  126368. * Gets the ratio used by the buffer during its creation.
  126369. * How big is the buffer related to the main canvas.
  126370. */
  126371. readonly ratio: number;
  126372. /** @hidden */
  126373. static _SceneComponentInitialization: (scene: Scene) => void;
  126374. /**
  126375. * Creates a new G Buffer for the scene
  126376. * @param scene The scene the buffer belongs to
  126377. * @param ratio How big is the buffer related to the main canvas.
  126378. */
  126379. constructor(scene: Scene, ratio?: number);
  126380. /**
  126381. * Checks wether everything is ready to render a submesh to the G buffer.
  126382. * @param subMesh the submesh to check readiness for
  126383. * @param useInstances is the mesh drawn using instance or not
  126384. * @returns true if ready otherwise false
  126385. */
  126386. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126387. /**
  126388. * Gets the current underlying G Buffer.
  126389. * @returns the buffer
  126390. */
  126391. getGBuffer(): MultiRenderTarget;
  126392. /**
  126393. * Gets the number of samples used to render the buffer (anti aliasing).
  126394. */
  126395. /**
  126396. * Sets the number of samples used to render the buffer (anti aliasing).
  126397. */
  126398. samples: number;
  126399. /**
  126400. * Disposes the renderer and frees up associated resources.
  126401. */
  126402. dispose(): void;
  126403. protected _createRenderTargets(): void;
  126404. private _copyBonesTransformationMatrices;
  126405. }
  126406. }
  126407. declare module BABYLON {
  126408. interface Scene {
  126409. /** @hidden (Backing field) */
  126410. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126411. /**
  126412. * Gets or Sets the current geometry buffer associated to the scene.
  126413. */
  126414. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126415. /**
  126416. * Enables a GeometryBufferRender and associates it with the scene
  126417. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126418. * @returns the GeometryBufferRenderer
  126419. */
  126420. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126421. /**
  126422. * Disables the GeometryBufferRender associated with the scene
  126423. */
  126424. disableGeometryBufferRenderer(): void;
  126425. }
  126426. /**
  126427. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126428. * in several rendering techniques.
  126429. */
  126430. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126431. /**
  126432. * The component name helpful to identify the component in the list of scene components.
  126433. */
  126434. readonly name: string;
  126435. /**
  126436. * The scene the component belongs to.
  126437. */
  126438. scene: Scene;
  126439. /**
  126440. * Creates a new instance of the component for the given scene
  126441. * @param scene Defines the scene to register the component in
  126442. */
  126443. constructor(scene: Scene);
  126444. /**
  126445. * Registers the component in a given scene
  126446. */
  126447. register(): void;
  126448. /**
  126449. * Rebuilds the elements related to this component in case of
  126450. * context lost for instance.
  126451. */
  126452. rebuild(): void;
  126453. /**
  126454. * Disposes the component and the associated ressources
  126455. */
  126456. dispose(): void;
  126457. private _gatherRenderTargets;
  126458. }
  126459. }
  126460. declare module BABYLON {
  126461. /** @hidden */
  126462. export var motionBlurPixelShader: {
  126463. name: string;
  126464. shader: string;
  126465. };
  126466. }
  126467. declare module BABYLON {
  126468. /**
  126469. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126470. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126471. * As an example, all you have to do is to create the post-process:
  126472. * var mb = new BABYLON.MotionBlurPostProcess(
  126473. * 'mb', // The name of the effect.
  126474. * scene, // The scene containing the objects to blur according to their velocity.
  126475. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126476. * camera // The camera to apply the render pass to.
  126477. * );
  126478. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126479. */
  126480. export class MotionBlurPostProcess extends PostProcess {
  126481. /**
  126482. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126483. */
  126484. motionStrength: number;
  126485. /**
  126486. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126487. */
  126488. /**
  126489. * Sets the number of iterations to be used for motion blur quality
  126490. */
  126491. motionBlurSamples: number;
  126492. private _motionBlurSamples;
  126493. private _geometryBufferRenderer;
  126494. /**
  126495. * Creates a new instance MotionBlurPostProcess
  126496. * @param name The name of the effect.
  126497. * @param scene The scene containing the objects to blur according to their velocity.
  126498. * @param options The required width/height ratio to downsize to before computing the render pass.
  126499. * @param camera The camera to apply the render pass to.
  126500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126501. * @param engine The engine which the post process will be applied. (default: current engine)
  126502. * @param reusable If the post process can be reused on the same frame. (default: false)
  126503. * @param textureType Type of textures used when performing the post process. (default: 0)
  126504. * @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)
  126505. */
  126506. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126507. /**
  126508. * Excludes the given skinned mesh from computing bones velocities.
  126509. * 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.
  126510. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126511. */
  126512. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126513. /**
  126514. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126515. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126516. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126517. */
  126518. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126519. /**
  126520. * Disposes the post process.
  126521. * @param camera The camera to dispose the post process on.
  126522. */
  126523. dispose(camera?: Camera): void;
  126524. }
  126525. }
  126526. declare module BABYLON {
  126527. /** @hidden */
  126528. export var refractionPixelShader: {
  126529. name: string;
  126530. shader: string;
  126531. };
  126532. }
  126533. declare module BABYLON {
  126534. /**
  126535. * Post process which applies a refractin texture
  126536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126537. */
  126538. export class RefractionPostProcess extends PostProcess {
  126539. /** the base color of the refraction (used to taint the rendering) */
  126540. color: Color3;
  126541. /** simulated refraction depth */
  126542. depth: number;
  126543. /** the coefficient of the base color (0 to remove base color tainting) */
  126544. colorLevel: number;
  126545. private _refTexture;
  126546. private _ownRefractionTexture;
  126547. /**
  126548. * Gets or sets the refraction texture
  126549. * Please note that you are responsible for disposing the texture if you set it manually
  126550. */
  126551. refractionTexture: Texture;
  126552. /**
  126553. * Initializes the RefractionPostProcess
  126554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126555. * @param name The name of the effect.
  126556. * @param refractionTextureUrl Url of the refraction texture to use
  126557. * @param color the base color of the refraction (used to taint the rendering)
  126558. * @param depth simulated refraction depth
  126559. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126560. * @param camera The camera to apply the render pass to.
  126561. * @param options The required width/height ratio to downsize to before computing the render pass.
  126562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126563. * @param engine The engine which the post process will be applied. (default: current engine)
  126564. * @param reusable If the post process can be reused on the same frame. (default: false)
  126565. */
  126566. constructor(name: string, refractionTextureUrl: string,
  126567. /** the base color of the refraction (used to taint the rendering) */
  126568. color: Color3,
  126569. /** simulated refraction depth */
  126570. depth: number,
  126571. /** the coefficient of the base color (0 to remove base color tainting) */
  126572. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126573. /**
  126574. * Disposes of the post process
  126575. * @param camera Camera to dispose post process on
  126576. */
  126577. dispose(camera: Camera): void;
  126578. }
  126579. }
  126580. declare module BABYLON {
  126581. /** @hidden */
  126582. export var sharpenPixelShader: {
  126583. name: string;
  126584. shader: string;
  126585. };
  126586. }
  126587. declare module BABYLON {
  126588. /**
  126589. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126590. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126591. */
  126592. export class SharpenPostProcess extends PostProcess {
  126593. /**
  126594. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126595. */
  126596. colorAmount: number;
  126597. /**
  126598. * How much sharpness should be applied (default: 0.3)
  126599. */
  126600. edgeAmount: number;
  126601. /**
  126602. * Creates a new instance ConvolutionPostProcess
  126603. * @param name The name of the effect.
  126604. * @param options The required width/height ratio to downsize to before computing the render pass.
  126605. * @param camera The camera to apply the render pass to.
  126606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126607. * @param engine The engine which the post process will be applied. (default: current engine)
  126608. * @param reusable If the post process can be reused on the same frame. (default: false)
  126609. * @param textureType Type of textures used when performing the post process. (default: 0)
  126610. * @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)
  126611. */
  126612. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126613. }
  126614. }
  126615. declare module BABYLON {
  126616. /**
  126617. * PostProcessRenderPipeline
  126618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126619. */
  126620. export class PostProcessRenderPipeline {
  126621. private engine;
  126622. private _renderEffects;
  126623. private _renderEffectsForIsolatedPass;
  126624. /**
  126625. * List of inspectable custom properties (used by the Inspector)
  126626. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126627. */
  126628. inspectableCustomProperties: IInspectable[];
  126629. /**
  126630. * @hidden
  126631. */
  126632. protected _cameras: Camera[];
  126633. /** @hidden */
  126634. _name: string;
  126635. /**
  126636. * Gets pipeline name
  126637. */
  126638. readonly name: string;
  126639. /**
  126640. * Initializes a PostProcessRenderPipeline
  126641. * @param engine engine to add the pipeline to
  126642. * @param name name of the pipeline
  126643. */
  126644. constructor(engine: Engine, name: string);
  126645. /**
  126646. * Gets the class name
  126647. * @returns "PostProcessRenderPipeline"
  126648. */
  126649. getClassName(): string;
  126650. /**
  126651. * If all the render effects in the pipeline are supported
  126652. */
  126653. readonly isSupported: boolean;
  126654. /**
  126655. * Adds an effect to the pipeline
  126656. * @param renderEffect the effect to add
  126657. */
  126658. addEffect(renderEffect: PostProcessRenderEffect): void;
  126659. /** @hidden */
  126660. _rebuild(): void;
  126661. /** @hidden */
  126662. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126663. /** @hidden */
  126664. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126665. /** @hidden */
  126666. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126667. /** @hidden */
  126668. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126669. /** @hidden */
  126670. _attachCameras(cameras: Camera, unique: boolean): void;
  126671. /** @hidden */
  126672. _attachCameras(cameras: Camera[], unique: boolean): void;
  126673. /** @hidden */
  126674. _detachCameras(cameras: Camera): void;
  126675. /** @hidden */
  126676. _detachCameras(cameras: Nullable<Camera[]>): void;
  126677. /** @hidden */
  126678. _update(): void;
  126679. /** @hidden */
  126680. _reset(): void;
  126681. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126682. /**
  126683. * Disposes of the pipeline
  126684. */
  126685. dispose(): void;
  126686. }
  126687. }
  126688. declare module BABYLON {
  126689. /**
  126690. * PostProcessRenderPipelineManager class
  126691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126692. */
  126693. export class PostProcessRenderPipelineManager {
  126694. private _renderPipelines;
  126695. /**
  126696. * Initializes a PostProcessRenderPipelineManager
  126697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126698. */
  126699. constructor();
  126700. /**
  126701. * Gets the list of supported render pipelines
  126702. */
  126703. readonly supportedPipelines: PostProcessRenderPipeline[];
  126704. /**
  126705. * Adds a pipeline to the manager
  126706. * @param renderPipeline The pipeline to add
  126707. */
  126708. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126709. /**
  126710. * Attaches a camera to the pipeline
  126711. * @param renderPipelineName The name of the pipeline to attach to
  126712. * @param cameras the camera to attach
  126713. * @param unique if the camera can be attached multiple times to the pipeline
  126714. */
  126715. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126716. /**
  126717. * Detaches a camera from the pipeline
  126718. * @param renderPipelineName The name of the pipeline to detach from
  126719. * @param cameras the camera to detach
  126720. */
  126721. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126722. /**
  126723. * Enables an effect by name on a pipeline
  126724. * @param renderPipelineName the name of the pipeline to enable the effect in
  126725. * @param renderEffectName the name of the effect to enable
  126726. * @param cameras the cameras that the effect should be enabled on
  126727. */
  126728. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126729. /**
  126730. * Disables an effect by name on a pipeline
  126731. * @param renderPipelineName the name of the pipeline to disable the effect in
  126732. * @param renderEffectName the name of the effect to disable
  126733. * @param cameras the cameras that the effect should be disabled on
  126734. */
  126735. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126736. /**
  126737. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126738. */
  126739. update(): void;
  126740. /** @hidden */
  126741. _rebuild(): void;
  126742. /**
  126743. * Disposes of the manager and pipelines
  126744. */
  126745. dispose(): void;
  126746. }
  126747. }
  126748. declare module BABYLON {
  126749. interface Scene {
  126750. /** @hidden (Backing field) */
  126751. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126752. /**
  126753. * Gets the postprocess render pipeline manager
  126754. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126755. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126756. */
  126757. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126758. }
  126759. /**
  126760. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126761. */
  126762. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126763. /**
  126764. * The component name helpfull to identify the component in the list of scene components.
  126765. */
  126766. readonly name: string;
  126767. /**
  126768. * The scene the component belongs to.
  126769. */
  126770. scene: Scene;
  126771. /**
  126772. * Creates a new instance of the component for the given scene
  126773. * @param scene Defines the scene to register the component in
  126774. */
  126775. constructor(scene: Scene);
  126776. /**
  126777. * Registers the component in a given scene
  126778. */
  126779. register(): void;
  126780. /**
  126781. * Rebuilds the elements related to this component in case of
  126782. * context lost for instance.
  126783. */
  126784. rebuild(): void;
  126785. /**
  126786. * Disposes the component and the associated ressources
  126787. */
  126788. dispose(): void;
  126789. private _gatherRenderTargets;
  126790. }
  126791. }
  126792. declare module BABYLON {
  126793. /**
  126794. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126795. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126796. */
  126797. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126798. private _scene;
  126799. private _camerasToBeAttached;
  126800. /**
  126801. * ID of the sharpen post process,
  126802. */
  126803. private readonly SharpenPostProcessId;
  126804. /**
  126805. * @ignore
  126806. * ID of the image processing post process;
  126807. */
  126808. readonly ImageProcessingPostProcessId: string;
  126809. /**
  126810. * @ignore
  126811. * ID of the Fast Approximate Anti-Aliasing post process;
  126812. */
  126813. readonly FxaaPostProcessId: string;
  126814. /**
  126815. * ID of the chromatic aberration post process,
  126816. */
  126817. private readonly ChromaticAberrationPostProcessId;
  126818. /**
  126819. * ID of the grain post process
  126820. */
  126821. private readonly GrainPostProcessId;
  126822. /**
  126823. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126824. */
  126825. sharpen: SharpenPostProcess;
  126826. private _sharpenEffect;
  126827. private bloom;
  126828. /**
  126829. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126830. */
  126831. depthOfField: DepthOfFieldEffect;
  126832. /**
  126833. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126834. */
  126835. fxaa: FxaaPostProcess;
  126836. /**
  126837. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126838. */
  126839. imageProcessing: ImageProcessingPostProcess;
  126840. /**
  126841. * Chromatic aberration post process which will shift rgb colors in the image
  126842. */
  126843. chromaticAberration: ChromaticAberrationPostProcess;
  126844. private _chromaticAberrationEffect;
  126845. /**
  126846. * Grain post process which add noise to the image
  126847. */
  126848. grain: GrainPostProcess;
  126849. private _grainEffect;
  126850. /**
  126851. * Glow post process which adds a glow to emissive areas of the image
  126852. */
  126853. private _glowLayer;
  126854. /**
  126855. * Animations which can be used to tweak settings over a period of time
  126856. */
  126857. animations: Animation[];
  126858. private _imageProcessingConfigurationObserver;
  126859. private _sharpenEnabled;
  126860. private _bloomEnabled;
  126861. private _depthOfFieldEnabled;
  126862. private _depthOfFieldBlurLevel;
  126863. private _fxaaEnabled;
  126864. private _imageProcessingEnabled;
  126865. private _defaultPipelineTextureType;
  126866. private _bloomScale;
  126867. private _chromaticAberrationEnabled;
  126868. private _grainEnabled;
  126869. private _buildAllowed;
  126870. /**
  126871. * Gets active scene
  126872. */
  126873. readonly scene: Scene;
  126874. /**
  126875. * Enable or disable the sharpen process from the pipeline
  126876. */
  126877. sharpenEnabled: boolean;
  126878. private _resizeObserver;
  126879. private _hardwareScaleLevel;
  126880. private _bloomKernel;
  126881. /**
  126882. * Specifies the size of the bloom blur kernel, relative to the final output size
  126883. */
  126884. bloomKernel: number;
  126885. /**
  126886. * Specifies the weight of the bloom in the final rendering
  126887. */
  126888. private _bloomWeight;
  126889. /**
  126890. * Specifies the luma threshold for the area that will be blurred by the bloom
  126891. */
  126892. private _bloomThreshold;
  126893. private _hdr;
  126894. /**
  126895. * The strength of the bloom.
  126896. */
  126897. bloomWeight: number;
  126898. /**
  126899. * The strength of the bloom.
  126900. */
  126901. bloomThreshold: number;
  126902. /**
  126903. * The scale of the bloom, lower value will provide better performance.
  126904. */
  126905. bloomScale: number;
  126906. /**
  126907. * Enable or disable the bloom from the pipeline
  126908. */
  126909. bloomEnabled: boolean;
  126910. private _rebuildBloom;
  126911. /**
  126912. * If the depth of field is enabled.
  126913. */
  126914. depthOfFieldEnabled: boolean;
  126915. /**
  126916. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126917. */
  126918. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126919. /**
  126920. * If the anti aliasing is enabled.
  126921. */
  126922. fxaaEnabled: boolean;
  126923. private _samples;
  126924. /**
  126925. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126926. */
  126927. samples: number;
  126928. /**
  126929. * If image processing is enabled.
  126930. */
  126931. imageProcessingEnabled: boolean;
  126932. /**
  126933. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126934. */
  126935. glowLayerEnabled: boolean;
  126936. /**
  126937. * Gets the glow layer (or null if not defined)
  126938. */
  126939. readonly glowLayer: Nullable<GlowLayer>;
  126940. /**
  126941. * Enable or disable the chromaticAberration process from the pipeline
  126942. */
  126943. chromaticAberrationEnabled: boolean;
  126944. /**
  126945. * Enable or disable the grain process from the pipeline
  126946. */
  126947. grainEnabled: boolean;
  126948. /**
  126949. * @constructor
  126950. * @param name - The rendering pipeline name (default: "")
  126951. * @param hdr - If high dynamic range textures should be used (default: true)
  126952. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126953. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126954. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126955. */
  126956. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126957. /**
  126958. * Get the class name
  126959. * @returns "DefaultRenderingPipeline"
  126960. */
  126961. getClassName(): string;
  126962. /**
  126963. * Force the compilation of the entire pipeline.
  126964. */
  126965. prepare(): void;
  126966. private _hasCleared;
  126967. private _prevPostProcess;
  126968. private _prevPrevPostProcess;
  126969. private _setAutoClearAndTextureSharing;
  126970. private _depthOfFieldSceneObserver;
  126971. private _buildPipeline;
  126972. private _disposePostProcesses;
  126973. /**
  126974. * Adds a camera to the pipeline
  126975. * @param camera the camera to be added
  126976. */
  126977. addCamera(camera: Camera): void;
  126978. /**
  126979. * Removes a camera from the pipeline
  126980. * @param camera the camera to remove
  126981. */
  126982. removeCamera(camera: Camera): void;
  126983. /**
  126984. * Dispose of the pipeline and stop all post processes
  126985. */
  126986. dispose(): void;
  126987. /**
  126988. * Serialize the rendering pipeline (Used when exporting)
  126989. * @returns the serialized object
  126990. */
  126991. serialize(): any;
  126992. /**
  126993. * Parse the serialized pipeline
  126994. * @param source Source pipeline.
  126995. * @param scene The scene to load the pipeline to.
  126996. * @param rootUrl The URL of the serialized pipeline.
  126997. * @returns An instantiated pipeline from the serialized object.
  126998. */
  126999. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127000. }
  127001. }
  127002. declare module BABYLON {
  127003. /** @hidden */
  127004. export var lensHighlightsPixelShader: {
  127005. name: string;
  127006. shader: string;
  127007. };
  127008. }
  127009. declare module BABYLON {
  127010. /** @hidden */
  127011. export var depthOfFieldPixelShader: {
  127012. name: string;
  127013. shader: string;
  127014. };
  127015. }
  127016. declare module BABYLON {
  127017. /**
  127018. * BABYLON.JS Chromatic Aberration GLSL Shader
  127019. * Author: Olivier Guyot
  127020. * Separates very slightly R, G and B colors on the edges of the screen
  127021. * Inspired by Francois Tarlier & Martins Upitis
  127022. */
  127023. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127024. /**
  127025. * @ignore
  127026. * The chromatic aberration PostProcess id in the pipeline
  127027. */
  127028. LensChromaticAberrationEffect: string;
  127029. /**
  127030. * @ignore
  127031. * The highlights enhancing PostProcess id in the pipeline
  127032. */
  127033. HighlightsEnhancingEffect: string;
  127034. /**
  127035. * @ignore
  127036. * The depth-of-field PostProcess id in the pipeline
  127037. */
  127038. LensDepthOfFieldEffect: string;
  127039. private _scene;
  127040. private _depthTexture;
  127041. private _grainTexture;
  127042. private _chromaticAberrationPostProcess;
  127043. private _highlightsPostProcess;
  127044. private _depthOfFieldPostProcess;
  127045. private _edgeBlur;
  127046. private _grainAmount;
  127047. private _chromaticAberration;
  127048. private _distortion;
  127049. private _highlightsGain;
  127050. private _highlightsThreshold;
  127051. private _dofDistance;
  127052. private _dofAperture;
  127053. private _dofDarken;
  127054. private _dofPentagon;
  127055. private _blurNoise;
  127056. /**
  127057. * @constructor
  127058. *
  127059. * Effect parameters are as follow:
  127060. * {
  127061. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127062. * edge_blur: number; // from 0 to x (1 for realism)
  127063. * distortion: number; // from 0 to x (1 for realism)
  127064. * grain_amount: number; // from 0 to 1
  127065. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127066. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127067. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127068. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127069. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127070. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127071. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127072. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127073. * }
  127074. * Note: if an effect parameter is unset, effect is disabled
  127075. *
  127076. * @param name The rendering pipeline name
  127077. * @param parameters - An object containing all parameters (see above)
  127078. * @param scene The scene linked to this pipeline
  127079. * @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)
  127080. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127081. */
  127082. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127083. /**
  127084. * Get the class name
  127085. * @returns "LensRenderingPipeline"
  127086. */
  127087. getClassName(): string;
  127088. /**
  127089. * Gets associated scene
  127090. */
  127091. readonly scene: Scene;
  127092. /**
  127093. * Gets or sets the edge blur
  127094. */
  127095. edgeBlur: number;
  127096. /**
  127097. * Gets or sets the grain amount
  127098. */
  127099. grainAmount: number;
  127100. /**
  127101. * Gets or sets the chromatic aberration amount
  127102. */
  127103. chromaticAberration: number;
  127104. /**
  127105. * Gets or sets the depth of field aperture
  127106. */
  127107. dofAperture: number;
  127108. /**
  127109. * Gets or sets the edge distortion
  127110. */
  127111. edgeDistortion: number;
  127112. /**
  127113. * Gets or sets the depth of field distortion
  127114. */
  127115. dofDistortion: number;
  127116. /**
  127117. * Gets or sets the darken out of focus amount
  127118. */
  127119. darkenOutOfFocus: number;
  127120. /**
  127121. * Gets or sets a boolean indicating if blur noise is enabled
  127122. */
  127123. blurNoise: boolean;
  127124. /**
  127125. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127126. */
  127127. pentagonBokeh: boolean;
  127128. /**
  127129. * Gets or sets the highlight grain amount
  127130. */
  127131. highlightsGain: number;
  127132. /**
  127133. * Gets or sets the highlight threshold
  127134. */
  127135. highlightsThreshold: number;
  127136. /**
  127137. * Sets the amount of blur at the edges
  127138. * @param amount blur amount
  127139. */
  127140. setEdgeBlur(amount: number): void;
  127141. /**
  127142. * Sets edge blur to 0
  127143. */
  127144. disableEdgeBlur(): void;
  127145. /**
  127146. * Sets the amout of grain
  127147. * @param amount Amount of grain
  127148. */
  127149. setGrainAmount(amount: number): void;
  127150. /**
  127151. * Set grain amount to 0
  127152. */
  127153. disableGrain(): void;
  127154. /**
  127155. * Sets the chromatic aberration amount
  127156. * @param amount amount of chromatic aberration
  127157. */
  127158. setChromaticAberration(amount: number): void;
  127159. /**
  127160. * Sets chromatic aberration amount to 0
  127161. */
  127162. disableChromaticAberration(): void;
  127163. /**
  127164. * Sets the EdgeDistortion amount
  127165. * @param amount amount of EdgeDistortion
  127166. */
  127167. setEdgeDistortion(amount: number): void;
  127168. /**
  127169. * Sets edge distortion to 0
  127170. */
  127171. disableEdgeDistortion(): void;
  127172. /**
  127173. * Sets the FocusDistance amount
  127174. * @param amount amount of FocusDistance
  127175. */
  127176. setFocusDistance(amount: number): void;
  127177. /**
  127178. * Disables depth of field
  127179. */
  127180. disableDepthOfField(): void;
  127181. /**
  127182. * Sets the Aperture amount
  127183. * @param amount amount of Aperture
  127184. */
  127185. setAperture(amount: number): void;
  127186. /**
  127187. * Sets the DarkenOutOfFocus amount
  127188. * @param amount amount of DarkenOutOfFocus
  127189. */
  127190. setDarkenOutOfFocus(amount: number): void;
  127191. private _pentagonBokehIsEnabled;
  127192. /**
  127193. * Creates a pentagon bokeh effect
  127194. */
  127195. enablePentagonBokeh(): void;
  127196. /**
  127197. * Disables the pentagon bokeh effect
  127198. */
  127199. disablePentagonBokeh(): void;
  127200. /**
  127201. * Enables noise blur
  127202. */
  127203. enableNoiseBlur(): void;
  127204. /**
  127205. * Disables noise blur
  127206. */
  127207. disableNoiseBlur(): void;
  127208. /**
  127209. * Sets the HighlightsGain amount
  127210. * @param amount amount of HighlightsGain
  127211. */
  127212. setHighlightsGain(amount: number): void;
  127213. /**
  127214. * Sets the HighlightsThreshold amount
  127215. * @param amount amount of HighlightsThreshold
  127216. */
  127217. setHighlightsThreshold(amount: number): void;
  127218. /**
  127219. * Disables highlights
  127220. */
  127221. disableHighlights(): void;
  127222. /**
  127223. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127224. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127225. */
  127226. dispose(disableDepthRender?: boolean): void;
  127227. private _createChromaticAberrationPostProcess;
  127228. private _createHighlightsPostProcess;
  127229. private _createDepthOfFieldPostProcess;
  127230. private _createGrainTexture;
  127231. }
  127232. }
  127233. declare module BABYLON {
  127234. /** @hidden */
  127235. export var ssao2PixelShader: {
  127236. name: string;
  127237. shader: string;
  127238. };
  127239. }
  127240. declare module BABYLON {
  127241. /** @hidden */
  127242. export var ssaoCombinePixelShader: {
  127243. name: string;
  127244. shader: string;
  127245. };
  127246. }
  127247. declare module BABYLON {
  127248. /**
  127249. * Render pipeline to produce ssao effect
  127250. */
  127251. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127252. /**
  127253. * @ignore
  127254. * The PassPostProcess id in the pipeline that contains the original scene color
  127255. */
  127256. SSAOOriginalSceneColorEffect: string;
  127257. /**
  127258. * @ignore
  127259. * The SSAO PostProcess id in the pipeline
  127260. */
  127261. SSAORenderEffect: string;
  127262. /**
  127263. * @ignore
  127264. * The horizontal blur PostProcess id in the pipeline
  127265. */
  127266. SSAOBlurHRenderEffect: string;
  127267. /**
  127268. * @ignore
  127269. * The vertical blur PostProcess id in the pipeline
  127270. */
  127271. SSAOBlurVRenderEffect: string;
  127272. /**
  127273. * @ignore
  127274. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127275. */
  127276. SSAOCombineRenderEffect: string;
  127277. /**
  127278. * The output strength of the SSAO post-process. Default value is 1.0.
  127279. */
  127280. totalStrength: number;
  127281. /**
  127282. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127283. */
  127284. maxZ: number;
  127285. /**
  127286. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127287. */
  127288. minZAspect: number;
  127289. private _samples;
  127290. /**
  127291. * Number of samples used for the SSAO calculations. Default value is 8
  127292. */
  127293. samples: number;
  127294. private _textureSamples;
  127295. /**
  127296. * Number of samples to use for antialiasing
  127297. */
  127298. textureSamples: number;
  127299. /**
  127300. * Ratio object used for SSAO ratio and blur ratio
  127301. */
  127302. private _ratio;
  127303. /**
  127304. * Dynamically generated sphere sampler.
  127305. */
  127306. private _sampleSphere;
  127307. /**
  127308. * Blur filter offsets
  127309. */
  127310. private _samplerOffsets;
  127311. private _expensiveBlur;
  127312. /**
  127313. * If bilateral blur should be used
  127314. */
  127315. expensiveBlur: boolean;
  127316. /**
  127317. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127318. */
  127319. radius: number;
  127320. /**
  127321. * The base color of the SSAO post-process
  127322. * The final result is "base + ssao" between [0, 1]
  127323. */
  127324. base: number;
  127325. /**
  127326. * Support test.
  127327. */
  127328. static readonly IsSupported: boolean;
  127329. private _scene;
  127330. private _depthTexture;
  127331. private _normalTexture;
  127332. private _randomTexture;
  127333. private _originalColorPostProcess;
  127334. private _ssaoPostProcess;
  127335. private _blurHPostProcess;
  127336. private _blurVPostProcess;
  127337. private _ssaoCombinePostProcess;
  127338. private _firstUpdate;
  127339. /**
  127340. * Gets active scene
  127341. */
  127342. readonly scene: Scene;
  127343. /**
  127344. * @constructor
  127345. * @param name The rendering pipeline name
  127346. * @param scene The scene linked to this pipeline
  127347. * @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 }
  127348. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127349. */
  127350. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127351. /**
  127352. * Get the class name
  127353. * @returns "SSAO2RenderingPipeline"
  127354. */
  127355. getClassName(): string;
  127356. /**
  127357. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127358. */
  127359. dispose(disableGeometryBufferRenderer?: boolean): void;
  127360. private _createBlurPostProcess;
  127361. /** @hidden */
  127362. _rebuild(): void;
  127363. private _bits;
  127364. private _radicalInverse_VdC;
  127365. private _hammersley;
  127366. private _hemisphereSample_uniform;
  127367. private _generateHemisphere;
  127368. private _createSSAOPostProcess;
  127369. private _createSSAOCombinePostProcess;
  127370. private _createRandomTexture;
  127371. /**
  127372. * Serialize the rendering pipeline (Used when exporting)
  127373. * @returns the serialized object
  127374. */
  127375. serialize(): any;
  127376. /**
  127377. * Parse the serialized pipeline
  127378. * @param source Source pipeline.
  127379. * @param scene The scene to load the pipeline to.
  127380. * @param rootUrl The URL of the serialized pipeline.
  127381. * @returns An instantiated pipeline from the serialized object.
  127382. */
  127383. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127384. }
  127385. }
  127386. declare module BABYLON {
  127387. /** @hidden */
  127388. export var ssaoPixelShader: {
  127389. name: string;
  127390. shader: string;
  127391. };
  127392. }
  127393. declare module BABYLON {
  127394. /**
  127395. * Render pipeline to produce ssao effect
  127396. */
  127397. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127398. /**
  127399. * @ignore
  127400. * The PassPostProcess id in the pipeline that contains the original scene color
  127401. */
  127402. SSAOOriginalSceneColorEffect: string;
  127403. /**
  127404. * @ignore
  127405. * The SSAO PostProcess id in the pipeline
  127406. */
  127407. SSAORenderEffect: string;
  127408. /**
  127409. * @ignore
  127410. * The horizontal blur PostProcess id in the pipeline
  127411. */
  127412. SSAOBlurHRenderEffect: string;
  127413. /**
  127414. * @ignore
  127415. * The vertical blur PostProcess id in the pipeline
  127416. */
  127417. SSAOBlurVRenderEffect: string;
  127418. /**
  127419. * @ignore
  127420. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127421. */
  127422. SSAOCombineRenderEffect: string;
  127423. /**
  127424. * The output strength of the SSAO post-process. Default value is 1.0.
  127425. */
  127426. totalStrength: number;
  127427. /**
  127428. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127429. */
  127430. radius: number;
  127431. /**
  127432. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127433. * Must not be equal to fallOff and superior to fallOff.
  127434. * Default value is 0.0075
  127435. */
  127436. area: number;
  127437. /**
  127438. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127439. * Must not be equal to area and inferior to area.
  127440. * Default value is 0.000001
  127441. */
  127442. fallOff: number;
  127443. /**
  127444. * The base color of the SSAO post-process
  127445. * The final result is "base + ssao" between [0, 1]
  127446. */
  127447. base: number;
  127448. private _scene;
  127449. private _depthTexture;
  127450. private _randomTexture;
  127451. private _originalColorPostProcess;
  127452. private _ssaoPostProcess;
  127453. private _blurHPostProcess;
  127454. private _blurVPostProcess;
  127455. private _ssaoCombinePostProcess;
  127456. private _firstUpdate;
  127457. /**
  127458. * Gets active scene
  127459. */
  127460. readonly scene: Scene;
  127461. /**
  127462. * @constructor
  127463. * @param name - The rendering pipeline name
  127464. * @param scene - The scene linked to this pipeline
  127465. * @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 }
  127466. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127467. */
  127468. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127469. /**
  127470. * Get the class name
  127471. * @returns "SSAORenderingPipeline"
  127472. */
  127473. getClassName(): string;
  127474. /**
  127475. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127476. */
  127477. dispose(disableDepthRender?: boolean): void;
  127478. private _createBlurPostProcess;
  127479. /** @hidden */
  127480. _rebuild(): void;
  127481. private _createSSAOPostProcess;
  127482. private _createSSAOCombinePostProcess;
  127483. private _createRandomTexture;
  127484. }
  127485. }
  127486. declare module BABYLON {
  127487. /** @hidden */
  127488. export var standardPixelShader: {
  127489. name: string;
  127490. shader: string;
  127491. };
  127492. }
  127493. declare module BABYLON {
  127494. /**
  127495. * Standard rendering pipeline
  127496. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127497. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127498. */
  127499. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127500. /**
  127501. * Public members
  127502. */
  127503. /**
  127504. * Post-process which contains the original scene color before the pipeline applies all the effects
  127505. */
  127506. originalPostProcess: Nullable<PostProcess>;
  127507. /**
  127508. * Post-process used to down scale an image x4
  127509. */
  127510. downSampleX4PostProcess: Nullable<PostProcess>;
  127511. /**
  127512. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127513. */
  127514. brightPassPostProcess: Nullable<PostProcess>;
  127515. /**
  127516. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127517. */
  127518. blurHPostProcesses: PostProcess[];
  127519. /**
  127520. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127521. */
  127522. blurVPostProcesses: PostProcess[];
  127523. /**
  127524. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127525. */
  127526. textureAdderPostProcess: Nullable<PostProcess>;
  127527. /**
  127528. * Post-process used to create volumetric lighting effect
  127529. */
  127530. volumetricLightPostProcess: Nullable<PostProcess>;
  127531. /**
  127532. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127533. */
  127534. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127535. /**
  127536. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127537. */
  127538. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127539. /**
  127540. * Post-process used to merge the volumetric light effect and the real scene color
  127541. */
  127542. volumetricLightMergePostProces: Nullable<PostProcess>;
  127543. /**
  127544. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127545. */
  127546. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127547. /**
  127548. * Base post-process used to calculate the average luminance of the final image for HDR
  127549. */
  127550. luminancePostProcess: Nullable<PostProcess>;
  127551. /**
  127552. * Post-processes used to create down sample post-processes in order to get
  127553. * the average luminance of the final image for HDR
  127554. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127555. */
  127556. luminanceDownSamplePostProcesses: PostProcess[];
  127557. /**
  127558. * Post-process used to create a HDR effect (light adaptation)
  127559. */
  127560. hdrPostProcess: Nullable<PostProcess>;
  127561. /**
  127562. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127563. */
  127564. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127565. /**
  127566. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127567. */
  127568. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127569. /**
  127570. * Post-process used to merge the final HDR post-process and the real scene color
  127571. */
  127572. hdrFinalPostProcess: Nullable<PostProcess>;
  127573. /**
  127574. * Post-process used to create a lens flare effect
  127575. */
  127576. lensFlarePostProcess: Nullable<PostProcess>;
  127577. /**
  127578. * Post-process that merges the result of the lens flare post-process and the real scene color
  127579. */
  127580. lensFlareComposePostProcess: Nullable<PostProcess>;
  127581. /**
  127582. * Post-process used to create a motion blur effect
  127583. */
  127584. motionBlurPostProcess: Nullable<PostProcess>;
  127585. /**
  127586. * Post-process used to create a depth of field effect
  127587. */
  127588. depthOfFieldPostProcess: Nullable<PostProcess>;
  127589. /**
  127590. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127591. */
  127592. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127593. /**
  127594. * Represents the brightness threshold in order to configure the illuminated surfaces
  127595. */
  127596. brightThreshold: number;
  127597. /**
  127598. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127599. */
  127600. blurWidth: number;
  127601. /**
  127602. * Sets if the blur for highlighted surfaces must be only horizontal
  127603. */
  127604. horizontalBlur: boolean;
  127605. /**
  127606. * Gets the overall exposure used by the pipeline
  127607. */
  127608. /**
  127609. * Sets the overall exposure used by the pipeline
  127610. */
  127611. exposure: number;
  127612. /**
  127613. * Texture used typically to simulate "dirty" on camera lens
  127614. */
  127615. lensTexture: Nullable<Texture>;
  127616. /**
  127617. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127618. */
  127619. volumetricLightCoefficient: number;
  127620. /**
  127621. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127622. */
  127623. volumetricLightPower: number;
  127624. /**
  127625. * Used the set the blur intensity to smooth the volumetric lights
  127626. */
  127627. volumetricLightBlurScale: number;
  127628. /**
  127629. * Light (spot or directional) used to generate the volumetric lights rays
  127630. * The source light must have a shadow generate so the pipeline can get its
  127631. * depth map
  127632. */
  127633. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127634. /**
  127635. * For eye adaptation, represents the minimum luminance the eye can see
  127636. */
  127637. hdrMinimumLuminance: number;
  127638. /**
  127639. * For eye adaptation, represents the decrease luminance speed
  127640. */
  127641. hdrDecreaseRate: number;
  127642. /**
  127643. * For eye adaptation, represents the increase luminance speed
  127644. */
  127645. hdrIncreaseRate: number;
  127646. /**
  127647. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127648. */
  127649. /**
  127650. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127651. */
  127652. hdrAutoExposure: boolean;
  127653. /**
  127654. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127655. */
  127656. lensColorTexture: Nullable<Texture>;
  127657. /**
  127658. * The overall strengh for the lens flare effect
  127659. */
  127660. lensFlareStrength: number;
  127661. /**
  127662. * Dispersion coefficient for lens flare ghosts
  127663. */
  127664. lensFlareGhostDispersal: number;
  127665. /**
  127666. * Main lens flare halo width
  127667. */
  127668. lensFlareHaloWidth: number;
  127669. /**
  127670. * Based on the lens distortion effect, defines how much the lens flare result
  127671. * is distorted
  127672. */
  127673. lensFlareDistortionStrength: number;
  127674. /**
  127675. * Configures the blur intensity used for for lens flare (halo)
  127676. */
  127677. lensFlareBlurWidth: number;
  127678. /**
  127679. * Lens star texture must be used to simulate rays on the flares and is available
  127680. * in the documentation
  127681. */
  127682. lensStarTexture: Nullable<Texture>;
  127683. /**
  127684. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127685. * flare effect by taking account of the dirt texture
  127686. */
  127687. lensFlareDirtTexture: Nullable<Texture>;
  127688. /**
  127689. * Represents the focal length for the depth of field effect
  127690. */
  127691. depthOfFieldDistance: number;
  127692. /**
  127693. * Represents the blur intensity for the blurred part of the depth of field effect
  127694. */
  127695. depthOfFieldBlurWidth: number;
  127696. /**
  127697. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127698. */
  127699. /**
  127700. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127701. */
  127702. motionStrength: number;
  127703. /**
  127704. * Gets wether or not the motion blur post-process is object based or screen based.
  127705. */
  127706. /**
  127707. * Sets wether or not the motion blur post-process should be object based or screen based
  127708. */
  127709. objectBasedMotionBlur: boolean;
  127710. /**
  127711. * List of animations for the pipeline (IAnimatable implementation)
  127712. */
  127713. animations: Animation[];
  127714. /**
  127715. * Private members
  127716. */
  127717. private _scene;
  127718. private _currentDepthOfFieldSource;
  127719. private _basePostProcess;
  127720. private _fixedExposure;
  127721. private _currentExposure;
  127722. private _hdrAutoExposure;
  127723. private _hdrCurrentLuminance;
  127724. private _motionStrength;
  127725. private _isObjectBasedMotionBlur;
  127726. private _floatTextureType;
  127727. private _camerasToBeAttached;
  127728. private _ratio;
  127729. private _bloomEnabled;
  127730. private _depthOfFieldEnabled;
  127731. private _vlsEnabled;
  127732. private _lensFlareEnabled;
  127733. private _hdrEnabled;
  127734. private _motionBlurEnabled;
  127735. private _fxaaEnabled;
  127736. private _motionBlurSamples;
  127737. private _volumetricLightStepsCount;
  127738. private _samples;
  127739. /**
  127740. * @ignore
  127741. * Specifies if the bloom pipeline is enabled
  127742. */
  127743. BloomEnabled: boolean;
  127744. /**
  127745. * @ignore
  127746. * Specifies if the depth of field pipeline is enabed
  127747. */
  127748. DepthOfFieldEnabled: boolean;
  127749. /**
  127750. * @ignore
  127751. * Specifies if the lens flare pipeline is enabed
  127752. */
  127753. LensFlareEnabled: boolean;
  127754. /**
  127755. * @ignore
  127756. * Specifies if the HDR pipeline is enabled
  127757. */
  127758. HDREnabled: boolean;
  127759. /**
  127760. * @ignore
  127761. * Specifies if the volumetric lights scattering effect is enabled
  127762. */
  127763. VLSEnabled: boolean;
  127764. /**
  127765. * @ignore
  127766. * Specifies if the motion blur effect is enabled
  127767. */
  127768. MotionBlurEnabled: boolean;
  127769. /**
  127770. * Specifies if anti-aliasing is enabled
  127771. */
  127772. fxaaEnabled: boolean;
  127773. /**
  127774. * Specifies the number of steps used to calculate the volumetric lights
  127775. * Typically in interval [50, 200]
  127776. */
  127777. volumetricLightStepsCount: number;
  127778. /**
  127779. * Specifies the number of samples used for the motion blur effect
  127780. * Typically in interval [16, 64]
  127781. */
  127782. motionBlurSamples: number;
  127783. /**
  127784. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127785. */
  127786. samples: number;
  127787. /**
  127788. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127789. * @constructor
  127790. * @param name The rendering pipeline name
  127791. * @param scene The scene linked to this pipeline
  127792. * @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)
  127793. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127794. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127795. */
  127796. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127797. private _buildPipeline;
  127798. private _createDownSampleX4PostProcess;
  127799. private _createBrightPassPostProcess;
  127800. private _createBlurPostProcesses;
  127801. private _createTextureAdderPostProcess;
  127802. private _createVolumetricLightPostProcess;
  127803. private _createLuminancePostProcesses;
  127804. private _createHdrPostProcess;
  127805. private _createLensFlarePostProcess;
  127806. private _createDepthOfFieldPostProcess;
  127807. private _createMotionBlurPostProcess;
  127808. private _getDepthTexture;
  127809. private _disposePostProcesses;
  127810. /**
  127811. * Dispose of the pipeline and stop all post processes
  127812. */
  127813. dispose(): void;
  127814. /**
  127815. * Serialize the rendering pipeline (Used when exporting)
  127816. * @returns the serialized object
  127817. */
  127818. serialize(): any;
  127819. /**
  127820. * Parse the serialized pipeline
  127821. * @param source Source pipeline.
  127822. * @param scene The scene to load the pipeline to.
  127823. * @param rootUrl The URL of the serialized pipeline.
  127824. * @returns An instantiated pipeline from the serialized object.
  127825. */
  127826. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127827. /**
  127828. * Luminance steps
  127829. */
  127830. static LuminanceSteps: number;
  127831. }
  127832. }
  127833. declare module BABYLON {
  127834. /** @hidden */
  127835. export var tonemapPixelShader: {
  127836. name: string;
  127837. shader: string;
  127838. };
  127839. }
  127840. declare module BABYLON {
  127841. /** Defines operator used for tonemapping */
  127842. export enum TonemappingOperator {
  127843. /** Hable */
  127844. Hable = 0,
  127845. /** Reinhard */
  127846. Reinhard = 1,
  127847. /** HejiDawson */
  127848. HejiDawson = 2,
  127849. /** Photographic */
  127850. Photographic = 3
  127851. }
  127852. /**
  127853. * Defines a post process to apply tone mapping
  127854. */
  127855. export class TonemapPostProcess extends PostProcess {
  127856. private _operator;
  127857. /** Defines the required exposure adjustement */
  127858. exposureAdjustment: number;
  127859. /**
  127860. * Creates a new TonemapPostProcess
  127861. * @param name defines the name of the postprocess
  127862. * @param _operator defines the operator to use
  127863. * @param exposureAdjustment defines the required exposure adjustement
  127864. * @param camera defines the camera to use (can be null)
  127865. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127866. * @param engine defines the hosting engine (can be ignore if camera is set)
  127867. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127868. */
  127869. constructor(name: string, _operator: TonemappingOperator,
  127870. /** Defines the required exposure adjustement */
  127871. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127872. }
  127873. }
  127874. declare module BABYLON {
  127875. /** @hidden */
  127876. export var depthVertexShader: {
  127877. name: string;
  127878. shader: string;
  127879. };
  127880. }
  127881. declare module BABYLON {
  127882. /** @hidden */
  127883. export var volumetricLightScatteringPixelShader: {
  127884. name: string;
  127885. shader: string;
  127886. };
  127887. }
  127888. declare module BABYLON {
  127889. /** @hidden */
  127890. export var volumetricLightScatteringPassVertexShader: {
  127891. name: string;
  127892. shader: string;
  127893. };
  127894. }
  127895. declare module BABYLON {
  127896. /** @hidden */
  127897. export var volumetricLightScatteringPassPixelShader: {
  127898. name: string;
  127899. shader: string;
  127900. };
  127901. }
  127902. declare module BABYLON {
  127903. /**
  127904. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127905. */
  127906. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127907. private _volumetricLightScatteringPass;
  127908. private _volumetricLightScatteringRTT;
  127909. private _viewPort;
  127910. private _screenCoordinates;
  127911. private _cachedDefines;
  127912. /**
  127913. * If not undefined, the mesh position is computed from the attached node position
  127914. */
  127915. attachedNode: {
  127916. position: Vector3;
  127917. };
  127918. /**
  127919. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127920. */
  127921. customMeshPosition: Vector3;
  127922. /**
  127923. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127924. */
  127925. useCustomMeshPosition: boolean;
  127926. /**
  127927. * If the post-process should inverse the light scattering direction
  127928. */
  127929. invert: boolean;
  127930. /**
  127931. * The internal mesh used by the post-process
  127932. */
  127933. mesh: Mesh;
  127934. /**
  127935. * @hidden
  127936. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127937. */
  127938. useDiffuseColor: boolean;
  127939. /**
  127940. * Array containing the excluded meshes not rendered in the internal pass
  127941. */
  127942. excludedMeshes: AbstractMesh[];
  127943. /**
  127944. * Controls the overall intensity of the post-process
  127945. */
  127946. exposure: number;
  127947. /**
  127948. * Dissipates each sample's contribution in range [0, 1]
  127949. */
  127950. decay: number;
  127951. /**
  127952. * Controls the overall intensity of each sample
  127953. */
  127954. weight: number;
  127955. /**
  127956. * Controls the density of each sample
  127957. */
  127958. density: number;
  127959. /**
  127960. * @constructor
  127961. * @param name The post-process name
  127962. * @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)
  127963. * @param camera The camera that the post-process will be attached to
  127964. * @param mesh The mesh used to create the light scattering
  127965. * @param samples The post-process quality, default 100
  127966. * @param samplingModeThe post-process filtering mode
  127967. * @param engine The babylon engine
  127968. * @param reusable If the post-process is reusable
  127969. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127970. */
  127971. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127972. /**
  127973. * Returns the string "VolumetricLightScatteringPostProcess"
  127974. * @returns "VolumetricLightScatteringPostProcess"
  127975. */
  127976. getClassName(): string;
  127977. private _isReady;
  127978. /**
  127979. * Sets the new light position for light scattering effect
  127980. * @param position The new custom light position
  127981. */
  127982. setCustomMeshPosition(position: Vector3): void;
  127983. /**
  127984. * Returns the light position for light scattering effect
  127985. * @return Vector3 The custom light position
  127986. */
  127987. getCustomMeshPosition(): Vector3;
  127988. /**
  127989. * Disposes the internal assets and detaches the post-process from the camera
  127990. */
  127991. dispose(camera: Camera): void;
  127992. /**
  127993. * Returns the render target texture used by the post-process
  127994. * @return the render target texture used by the post-process
  127995. */
  127996. getPass(): RenderTargetTexture;
  127997. private _meshExcluded;
  127998. private _createPass;
  127999. private _updateMeshScreenCoordinates;
  128000. /**
  128001. * Creates a default mesh for the Volumeric Light Scattering post-process
  128002. * @param name The mesh name
  128003. * @param scene The scene where to create the mesh
  128004. * @return the default mesh
  128005. */
  128006. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128007. }
  128008. }
  128009. declare module BABYLON {
  128010. interface Scene {
  128011. /** @hidden (Backing field) */
  128012. _boundingBoxRenderer: BoundingBoxRenderer;
  128013. /** @hidden (Backing field) */
  128014. _forceShowBoundingBoxes: boolean;
  128015. /**
  128016. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128017. */
  128018. forceShowBoundingBoxes: boolean;
  128019. /**
  128020. * Gets the bounding box renderer associated with the scene
  128021. * @returns a BoundingBoxRenderer
  128022. */
  128023. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128024. }
  128025. interface AbstractMesh {
  128026. /** @hidden (Backing field) */
  128027. _showBoundingBox: boolean;
  128028. /**
  128029. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128030. */
  128031. showBoundingBox: boolean;
  128032. }
  128033. /**
  128034. * Component responsible of rendering the bounding box of the meshes in a scene.
  128035. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128036. */
  128037. export class BoundingBoxRenderer implements ISceneComponent {
  128038. /**
  128039. * The component name helpfull to identify the component in the list of scene components.
  128040. */
  128041. readonly name: string;
  128042. /**
  128043. * The scene the component belongs to.
  128044. */
  128045. scene: Scene;
  128046. /**
  128047. * Color of the bounding box lines placed in front of an object
  128048. */
  128049. frontColor: Color3;
  128050. /**
  128051. * Color of the bounding box lines placed behind an object
  128052. */
  128053. backColor: Color3;
  128054. /**
  128055. * Defines if the renderer should show the back lines or not
  128056. */
  128057. showBackLines: boolean;
  128058. /**
  128059. * @hidden
  128060. */
  128061. renderList: SmartArray<BoundingBox>;
  128062. private _colorShader;
  128063. private _vertexBuffers;
  128064. private _indexBuffer;
  128065. private _fillIndexBuffer;
  128066. private _fillIndexData;
  128067. /**
  128068. * Instantiates a new bounding box renderer in a scene.
  128069. * @param scene the scene the renderer renders in
  128070. */
  128071. constructor(scene: Scene);
  128072. /**
  128073. * Registers the component in a given scene
  128074. */
  128075. register(): void;
  128076. private _evaluateSubMesh;
  128077. private _activeMesh;
  128078. private _prepareRessources;
  128079. private _createIndexBuffer;
  128080. /**
  128081. * Rebuilds the elements related to this component in case of
  128082. * context lost for instance.
  128083. */
  128084. rebuild(): void;
  128085. /**
  128086. * @hidden
  128087. */
  128088. reset(): void;
  128089. /**
  128090. * Render the bounding boxes of a specific rendering group
  128091. * @param renderingGroupId defines the rendering group to render
  128092. */
  128093. render(renderingGroupId: number): void;
  128094. /**
  128095. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128096. * @param mesh Define the mesh to render the occlusion bounding box for
  128097. */
  128098. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128099. /**
  128100. * Dispose and release the resources attached to this renderer.
  128101. */
  128102. dispose(): void;
  128103. }
  128104. }
  128105. declare module BABYLON {
  128106. /** @hidden */
  128107. export var depthPixelShader: {
  128108. name: string;
  128109. shader: string;
  128110. };
  128111. }
  128112. declare module BABYLON {
  128113. /**
  128114. * This represents a depth renderer in Babylon.
  128115. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128116. */
  128117. export class DepthRenderer {
  128118. private _scene;
  128119. private _depthMap;
  128120. private _effect;
  128121. private readonly _storeNonLinearDepth;
  128122. private readonly _clearColor;
  128123. /** Get if the depth renderer is using packed depth or not */
  128124. readonly isPacked: boolean;
  128125. private _cachedDefines;
  128126. private _camera;
  128127. /**
  128128. * Specifiess that the depth renderer will only be used within
  128129. * the camera it is created for.
  128130. * This can help forcing its rendering during the camera processing.
  128131. */
  128132. useOnlyInActiveCamera: boolean;
  128133. /** @hidden */
  128134. static _SceneComponentInitialization: (scene: Scene) => void;
  128135. /**
  128136. * Instantiates a depth renderer
  128137. * @param scene The scene the renderer belongs to
  128138. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128139. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128140. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128141. */
  128142. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128143. /**
  128144. * Creates the depth rendering effect and checks if the effect is ready.
  128145. * @param subMesh The submesh to be used to render the depth map of
  128146. * @param useInstances If multiple world instances should be used
  128147. * @returns if the depth renderer is ready to render the depth map
  128148. */
  128149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128150. /**
  128151. * Gets the texture which the depth map will be written to.
  128152. * @returns The depth map texture
  128153. */
  128154. getDepthMap(): RenderTargetTexture;
  128155. /**
  128156. * Disposes of the depth renderer.
  128157. */
  128158. dispose(): void;
  128159. }
  128160. }
  128161. declare module BABYLON {
  128162. interface Scene {
  128163. /** @hidden (Backing field) */
  128164. _depthRenderer: {
  128165. [id: string]: DepthRenderer;
  128166. };
  128167. /**
  128168. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128169. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128170. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128171. * @returns the created depth renderer
  128172. */
  128173. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128174. /**
  128175. * Disables a depth renderer for a given camera
  128176. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128177. */
  128178. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128179. }
  128180. /**
  128181. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128182. * in several rendering techniques.
  128183. */
  128184. export class DepthRendererSceneComponent implements ISceneComponent {
  128185. /**
  128186. * The component name helpfull to identify the component in the list of scene components.
  128187. */
  128188. readonly name: string;
  128189. /**
  128190. * The scene the component belongs to.
  128191. */
  128192. scene: Scene;
  128193. /**
  128194. * Creates a new instance of the component for the given scene
  128195. * @param scene Defines the scene to register the component in
  128196. */
  128197. constructor(scene: Scene);
  128198. /**
  128199. * Registers the component in a given scene
  128200. */
  128201. register(): void;
  128202. /**
  128203. * Rebuilds the elements related to this component in case of
  128204. * context lost for instance.
  128205. */
  128206. rebuild(): void;
  128207. /**
  128208. * Disposes the component and the associated ressources
  128209. */
  128210. dispose(): void;
  128211. private _gatherRenderTargets;
  128212. private _gatherActiveCameraRenderTargets;
  128213. }
  128214. }
  128215. declare module BABYLON {
  128216. /** @hidden */
  128217. export var outlinePixelShader: {
  128218. name: string;
  128219. shader: string;
  128220. };
  128221. }
  128222. declare module BABYLON {
  128223. /** @hidden */
  128224. export var outlineVertexShader: {
  128225. name: string;
  128226. shader: string;
  128227. };
  128228. }
  128229. declare module BABYLON {
  128230. interface Scene {
  128231. /** @hidden */
  128232. _outlineRenderer: OutlineRenderer;
  128233. /**
  128234. * Gets the outline renderer associated with the scene
  128235. * @returns a OutlineRenderer
  128236. */
  128237. getOutlineRenderer(): OutlineRenderer;
  128238. }
  128239. interface AbstractMesh {
  128240. /** @hidden (Backing field) */
  128241. _renderOutline: boolean;
  128242. /**
  128243. * Gets or sets a boolean indicating if the outline must be rendered as well
  128244. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128245. */
  128246. renderOutline: boolean;
  128247. /** @hidden (Backing field) */
  128248. _renderOverlay: boolean;
  128249. /**
  128250. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128251. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128252. */
  128253. renderOverlay: boolean;
  128254. }
  128255. /**
  128256. * This class is responsible to draw bothe outline/overlay of meshes.
  128257. * It should not be used directly but through the available method on mesh.
  128258. */
  128259. export class OutlineRenderer implements ISceneComponent {
  128260. /**
  128261. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128262. */
  128263. private static _StencilReference;
  128264. /**
  128265. * The name of the component. Each component must have a unique name.
  128266. */
  128267. name: string;
  128268. /**
  128269. * The scene the component belongs to.
  128270. */
  128271. scene: Scene;
  128272. /**
  128273. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128274. */
  128275. zOffset: number;
  128276. private _engine;
  128277. private _effect;
  128278. private _cachedDefines;
  128279. private _savedDepthWrite;
  128280. /**
  128281. * Instantiates a new outline renderer. (There could be only one per scene).
  128282. * @param scene Defines the scene it belongs to
  128283. */
  128284. constructor(scene: Scene);
  128285. /**
  128286. * Register the component to one instance of a scene.
  128287. */
  128288. register(): void;
  128289. /**
  128290. * Rebuilds the elements related to this component in case of
  128291. * context lost for instance.
  128292. */
  128293. rebuild(): void;
  128294. /**
  128295. * Disposes the component and the associated ressources.
  128296. */
  128297. dispose(): void;
  128298. /**
  128299. * Renders the outline in the canvas.
  128300. * @param subMesh Defines the sumesh to render
  128301. * @param batch Defines the batch of meshes in case of instances
  128302. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128303. */
  128304. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128305. /**
  128306. * Returns whether or not the outline renderer is ready for a given submesh.
  128307. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128308. * @param subMesh Defines the submesh to check readyness for
  128309. * @param useInstances Defines wheter wee are trying to render instances or not
  128310. * @returns true if ready otherwise false
  128311. */
  128312. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128313. private _beforeRenderingMesh;
  128314. private _afterRenderingMesh;
  128315. }
  128316. }
  128317. declare module BABYLON {
  128318. /**
  128319. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128320. * @see http://doc.babylonjs.com/babylon101/sprites
  128321. */
  128322. export class SpritePackedManager extends SpriteManager {
  128323. /** defines the packed manager's name */
  128324. name: string;
  128325. /**
  128326. * Creates a new sprite manager from a packed sprite sheet
  128327. * @param name defines the manager's name
  128328. * @param imgUrl defines the sprite sheet url
  128329. * @param capacity defines the maximum allowed number of sprites
  128330. * @param scene defines the hosting scene
  128331. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128332. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128333. * @param samplingMode defines the smapling mode to use with spritesheet
  128334. * @param fromPacked set to true; do not alter
  128335. */
  128336. constructor(
  128337. /** defines the packed manager's name */
  128338. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128339. }
  128340. }
  128341. declare module BABYLON {
  128342. /**
  128343. * Defines the list of states available for a task inside a AssetsManager
  128344. */
  128345. export enum AssetTaskState {
  128346. /**
  128347. * Initialization
  128348. */
  128349. INIT = 0,
  128350. /**
  128351. * Running
  128352. */
  128353. RUNNING = 1,
  128354. /**
  128355. * Done
  128356. */
  128357. DONE = 2,
  128358. /**
  128359. * Error
  128360. */
  128361. ERROR = 3
  128362. }
  128363. /**
  128364. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128365. */
  128366. export abstract class AbstractAssetTask {
  128367. /**
  128368. * Task name
  128369. */ name: string;
  128370. /**
  128371. * Callback called when the task is successful
  128372. */
  128373. onSuccess: (task: any) => void;
  128374. /**
  128375. * Callback called when the task is not successful
  128376. */
  128377. onError: (task: any, message?: string, exception?: any) => void;
  128378. /**
  128379. * Creates a new AssetsManager
  128380. * @param name defines the name of the task
  128381. */
  128382. constructor(
  128383. /**
  128384. * Task name
  128385. */ name: string);
  128386. private _isCompleted;
  128387. private _taskState;
  128388. private _errorObject;
  128389. /**
  128390. * Get if the task is completed
  128391. */
  128392. readonly isCompleted: boolean;
  128393. /**
  128394. * Gets the current state of the task
  128395. */
  128396. readonly taskState: AssetTaskState;
  128397. /**
  128398. * Gets the current error object (if task is in error)
  128399. */
  128400. readonly errorObject: {
  128401. message?: string;
  128402. exception?: any;
  128403. };
  128404. /**
  128405. * Internal only
  128406. * @hidden
  128407. */
  128408. _setErrorObject(message?: string, exception?: any): void;
  128409. /**
  128410. * Execute the current task
  128411. * @param scene defines the scene where you want your assets to be loaded
  128412. * @param onSuccess is a callback called when the task is successfully executed
  128413. * @param onError is a callback called if an error occurs
  128414. */
  128415. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128416. /**
  128417. * Execute the current task
  128418. * @param scene defines the scene where you want your assets to be loaded
  128419. * @param onSuccess is a callback called when the task is successfully executed
  128420. * @param onError is a callback called if an error occurs
  128421. */
  128422. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128423. /**
  128424. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128425. * This can be used with failed tasks that have the reason for failure fixed.
  128426. */
  128427. reset(): void;
  128428. private onErrorCallback;
  128429. private onDoneCallback;
  128430. }
  128431. /**
  128432. * Define the interface used by progress events raised during assets loading
  128433. */
  128434. export interface IAssetsProgressEvent {
  128435. /**
  128436. * Defines the number of remaining tasks to process
  128437. */
  128438. remainingCount: number;
  128439. /**
  128440. * Defines the total number of tasks
  128441. */
  128442. totalCount: number;
  128443. /**
  128444. * Defines the task that was just processed
  128445. */
  128446. task: AbstractAssetTask;
  128447. }
  128448. /**
  128449. * Class used to share progress information about assets loading
  128450. */
  128451. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128452. /**
  128453. * Defines the number of remaining tasks to process
  128454. */
  128455. remainingCount: number;
  128456. /**
  128457. * Defines the total number of tasks
  128458. */
  128459. totalCount: number;
  128460. /**
  128461. * Defines the task that was just processed
  128462. */
  128463. task: AbstractAssetTask;
  128464. /**
  128465. * Creates a AssetsProgressEvent
  128466. * @param remainingCount defines the number of remaining tasks to process
  128467. * @param totalCount defines the total number of tasks
  128468. * @param task defines the task that was just processed
  128469. */
  128470. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128471. }
  128472. /**
  128473. * Define a task used by AssetsManager to load meshes
  128474. */
  128475. export class MeshAssetTask extends AbstractAssetTask {
  128476. /**
  128477. * Defines the name of the task
  128478. */
  128479. name: string;
  128480. /**
  128481. * Defines the list of mesh's names you want to load
  128482. */
  128483. meshesNames: any;
  128484. /**
  128485. * Defines the root url to use as a base to load your meshes and associated resources
  128486. */
  128487. rootUrl: string;
  128488. /**
  128489. * Defines the filename of the scene to load from
  128490. */
  128491. sceneFilename: string;
  128492. /**
  128493. * Gets the list of loaded meshes
  128494. */
  128495. loadedMeshes: Array<AbstractMesh>;
  128496. /**
  128497. * Gets the list of loaded particle systems
  128498. */
  128499. loadedParticleSystems: Array<IParticleSystem>;
  128500. /**
  128501. * Gets the list of loaded skeletons
  128502. */
  128503. loadedSkeletons: Array<Skeleton>;
  128504. /**
  128505. * Gets the list of loaded animation groups
  128506. */
  128507. loadedAnimationGroups: Array<AnimationGroup>;
  128508. /**
  128509. * Callback called when the task is successful
  128510. */
  128511. onSuccess: (task: MeshAssetTask) => void;
  128512. /**
  128513. * Callback called when the task is successful
  128514. */
  128515. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128516. /**
  128517. * Creates a new MeshAssetTask
  128518. * @param name defines the name of the task
  128519. * @param meshesNames defines the list of mesh's names you want to load
  128520. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128521. * @param sceneFilename defines the filename of the scene to load from
  128522. */
  128523. constructor(
  128524. /**
  128525. * Defines the name of the task
  128526. */
  128527. name: string,
  128528. /**
  128529. * Defines the list of mesh's names you want to load
  128530. */
  128531. meshesNames: any,
  128532. /**
  128533. * Defines the root url to use as a base to load your meshes and associated resources
  128534. */
  128535. rootUrl: string,
  128536. /**
  128537. * Defines the filename of the scene to load from
  128538. */
  128539. sceneFilename: string);
  128540. /**
  128541. * Execute the current task
  128542. * @param scene defines the scene where you want your assets to be loaded
  128543. * @param onSuccess is a callback called when the task is successfully executed
  128544. * @param onError is a callback called if an error occurs
  128545. */
  128546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128547. }
  128548. /**
  128549. * Define a task used by AssetsManager to load text content
  128550. */
  128551. export class TextFileAssetTask extends AbstractAssetTask {
  128552. /**
  128553. * Defines the name of the task
  128554. */
  128555. name: string;
  128556. /**
  128557. * Defines the location of the file to load
  128558. */
  128559. url: string;
  128560. /**
  128561. * Gets the loaded text string
  128562. */
  128563. text: string;
  128564. /**
  128565. * Callback called when the task is successful
  128566. */
  128567. onSuccess: (task: TextFileAssetTask) => void;
  128568. /**
  128569. * Callback called when the task is successful
  128570. */
  128571. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128572. /**
  128573. * Creates a new TextFileAssetTask object
  128574. * @param name defines the name of the task
  128575. * @param url defines the location of the file to load
  128576. */
  128577. constructor(
  128578. /**
  128579. * Defines the name of the task
  128580. */
  128581. name: string,
  128582. /**
  128583. * Defines the location of the file to load
  128584. */
  128585. url: string);
  128586. /**
  128587. * Execute the current task
  128588. * @param scene defines the scene where you want your assets to be loaded
  128589. * @param onSuccess is a callback called when the task is successfully executed
  128590. * @param onError is a callback called if an error occurs
  128591. */
  128592. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128593. }
  128594. /**
  128595. * Define a task used by AssetsManager to load binary data
  128596. */
  128597. export class BinaryFileAssetTask extends AbstractAssetTask {
  128598. /**
  128599. * Defines the name of the task
  128600. */
  128601. name: string;
  128602. /**
  128603. * Defines the location of the file to load
  128604. */
  128605. url: string;
  128606. /**
  128607. * Gets the lodaded data (as an array buffer)
  128608. */
  128609. data: ArrayBuffer;
  128610. /**
  128611. * Callback called when the task is successful
  128612. */
  128613. onSuccess: (task: BinaryFileAssetTask) => void;
  128614. /**
  128615. * Callback called when the task is successful
  128616. */
  128617. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128618. /**
  128619. * Creates a new BinaryFileAssetTask object
  128620. * @param name defines the name of the new task
  128621. * @param url defines the location of the file to load
  128622. */
  128623. constructor(
  128624. /**
  128625. * Defines the name of the task
  128626. */
  128627. name: string,
  128628. /**
  128629. * Defines the location of the file to load
  128630. */
  128631. url: string);
  128632. /**
  128633. * Execute the current task
  128634. * @param scene defines the scene where you want your assets to be loaded
  128635. * @param onSuccess is a callback called when the task is successfully executed
  128636. * @param onError is a callback called if an error occurs
  128637. */
  128638. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128639. }
  128640. /**
  128641. * Define a task used by AssetsManager to load images
  128642. */
  128643. export class ImageAssetTask extends AbstractAssetTask {
  128644. /**
  128645. * Defines the name of the task
  128646. */
  128647. name: string;
  128648. /**
  128649. * Defines the location of the image to load
  128650. */
  128651. url: string;
  128652. /**
  128653. * Gets the loaded images
  128654. */
  128655. image: HTMLImageElement;
  128656. /**
  128657. * Callback called when the task is successful
  128658. */
  128659. onSuccess: (task: ImageAssetTask) => void;
  128660. /**
  128661. * Callback called when the task is successful
  128662. */
  128663. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128664. /**
  128665. * Creates a new ImageAssetTask
  128666. * @param name defines the name of the task
  128667. * @param url defines the location of the image to load
  128668. */
  128669. constructor(
  128670. /**
  128671. * Defines the name of the task
  128672. */
  128673. name: string,
  128674. /**
  128675. * Defines the location of the image to load
  128676. */
  128677. url: string);
  128678. /**
  128679. * Execute the current task
  128680. * @param scene defines the scene where you want your assets to be loaded
  128681. * @param onSuccess is a callback called when the task is successfully executed
  128682. * @param onError is a callback called if an error occurs
  128683. */
  128684. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128685. }
  128686. /**
  128687. * Defines the interface used by texture loading tasks
  128688. */
  128689. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128690. /**
  128691. * Gets the loaded texture
  128692. */
  128693. texture: TEX;
  128694. }
  128695. /**
  128696. * Define a task used by AssetsManager to load 2D textures
  128697. */
  128698. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128699. /**
  128700. * Defines the name of the task
  128701. */
  128702. name: string;
  128703. /**
  128704. * Defines the location of the file to load
  128705. */
  128706. url: string;
  128707. /**
  128708. * Defines if mipmap should not be generated (default is false)
  128709. */
  128710. noMipmap?: boolean | undefined;
  128711. /**
  128712. * Defines if texture must be inverted on Y axis (default is false)
  128713. */
  128714. invertY?: boolean | undefined;
  128715. /**
  128716. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128717. */
  128718. samplingMode: number;
  128719. /**
  128720. * Gets the loaded texture
  128721. */
  128722. texture: Texture;
  128723. /**
  128724. * Callback called when the task is successful
  128725. */
  128726. onSuccess: (task: TextureAssetTask) => void;
  128727. /**
  128728. * Callback called when the task is successful
  128729. */
  128730. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128731. /**
  128732. * Creates a new TextureAssetTask object
  128733. * @param name defines the name of the task
  128734. * @param url defines the location of the file to load
  128735. * @param noMipmap defines if mipmap should not be generated (default is false)
  128736. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128737. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128738. */
  128739. constructor(
  128740. /**
  128741. * Defines the name of the task
  128742. */
  128743. name: string,
  128744. /**
  128745. * Defines the location of the file to load
  128746. */
  128747. url: string,
  128748. /**
  128749. * Defines if mipmap should not be generated (default is false)
  128750. */
  128751. noMipmap?: boolean | undefined,
  128752. /**
  128753. * Defines if texture must be inverted on Y axis (default is false)
  128754. */
  128755. invertY?: boolean | undefined,
  128756. /**
  128757. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128758. */
  128759. samplingMode?: number);
  128760. /**
  128761. * Execute the current task
  128762. * @param scene defines the scene where you want your assets to be loaded
  128763. * @param onSuccess is a callback called when the task is successfully executed
  128764. * @param onError is a callback called if an error occurs
  128765. */
  128766. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128767. }
  128768. /**
  128769. * Define a task used by AssetsManager to load cube textures
  128770. */
  128771. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128772. /**
  128773. * Defines the name of the task
  128774. */
  128775. name: string;
  128776. /**
  128777. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128778. */
  128779. url: string;
  128780. /**
  128781. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128782. */
  128783. extensions?: string[] | undefined;
  128784. /**
  128785. * Defines if mipmaps should not be generated (default is false)
  128786. */
  128787. noMipmap?: boolean | undefined;
  128788. /**
  128789. * Defines the explicit list of files (undefined by default)
  128790. */
  128791. files?: string[] | undefined;
  128792. /**
  128793. * Gets the loaded texture
  128794. */
  128795. texture: CubeTexture;
  128796. /**
  128797. * Callback called when the task is successful
  128798. */
  128799. onSuccess: (task: CubeTextureAssetTask) => void;
  128800. /**
  128801. * Callback called when the task is successful
  128802. */
  128803. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128804. /**
  128805. * Creates a new CubeTextureAssetTask
  128806. * @param name defines the name of the task
  128807. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128808. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128809. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128810. * @param files defines the explicit list of files (undefined by default)
  128811. */
  128812. constructor(
  128813. /**
  128814. * Defines the name of the task
  128815. */
  128816. name: string,
  128817. /**
  128818. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128819. */
  128820. url: string,
  128821. /**
  128822. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128823. */
  128824. extensions?: string[] | undefined,
  128825. /**
  128826. * Defines if mipmaps should not be generated (default is false)
  128827. */
  128828. noMipmap?: boolean | undefined,
  128829. /**
  128830. * Defines the explicit list of files (undefined by default)
  128831. */
  128832. files?: string[] | undefined);
  128833. /**
  128834. * Execute the current task
  128835. * @param scene defines the scene where you want your assets to be loaded
  128836. * @param onSuccess is a callback called when the task is successfully executed
  128837. * @param onError is a callback called if an error occurs
  128838. */
  128839. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128840. }
  128841. /**
  128842. * Define a task used by AssetsManager to load HDR cube textures
  128843. */
  128844. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128845. /**
  128846. * Defines the name of the task
  128847. */
  128848. name: string;
  128849. /**
  128850. * Defines the location of the file to load
  128851. */
  128852. url: string;
  128853. /**
  128854. * Defines the desired size (the more it increases the longer the generation will be)
  128855. */
  128856. size: number;
  128857. /**
  128858. * Defines if mipmaps should not be generated (default is false)
  128859. */
  128860. noMipmap: boolean;
  128861. /**
  128862. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128863. */
  128864. generateHarmonics: boolean;
  128865. /**
  128866. * 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)
  128867. */
  128868. gammaSpace: boolean;
  128869. /**
  128870. * Internal Use Only
  128871. */
  128872. reserved: boolean;
  128873. /**
  128874. * Gets the loaded texture
  128875. */
  128876. texture: HDRCubeTexture;
  128877. /**
  128878. * Callback called when the task is successful
  128879. */
  128880. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128881. /**
  128882. * Callback called when the task is successful
  128883. */
  128884. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128885. /**
  128886. * Creates a new HDRCubeTextureAssetTask object
  128887. * @param name defines the name of the task
  128888. * @param url defines the location of the file to load
  128889. * @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.
  128890. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128891. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128892. * @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)
  128893. * @param reserved Internal use only
  128894. */
  128895. constructor(
  128896. /**
  128897. * Defines the name of the task
  128898. */
  128899. name: string,
  128900. /**
  128901. * Defines the location of the file to load
  128902. */
  128903. url: string,
  128904. /**
  128905. * Defines the desired size (the more it increases the longer the generation will be)
  128906. */
  128907. size: number,
  128908. /**
  128909. * Defines if mipmaps should not be generated (default is false)
  128910. */
  128911. noMipmap?: boolean,
  128912. /**
  128913. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128914. */
  128915. generateHarmonics?: boolean,
  128916. /**
  128917. * 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)
  128918. */
  128919. gammaSpace?: boolean,
  128920. /**
  128921. * Internal Use Only
  128922. */
  128923. reserved?: boolean);
  128924. /**
  128925. * Execute the current task
  128926. * @param scene defines the scene where you want your assets to be loaded
  128927. * @param onSuccess is a callback called when the task is successfully executed
  128928. * @param onError is a callback called if an error occurs
  128929. */
  128930. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128931. }
  128932. /**
  128933. * Define a task used by AssetsManager to load Equirectangular cube textures
  128934. */
  128935. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128936. /**
  128937. * Defines the name of the task
  128938. */
  128939. name: string;
  128940. /**
  128941. * Defines the location of the file to load
  128942. */
  128943. url: string;
  128944. /**
  128945. * Defines the desired size (the more it increases the longer the generation will be)
  128946. */
  128947. size: number;
  128948. /**
  128949. * Defines if mipmaps should not be generated (default is false)
  128950. */
  128951. noMipmap: boolean;
  128952. /**
  128953. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128954. * but the standard material would require them in Gamma space) (default is true)
  128955. */
  128956. gammaSpace: boolean;
  128957. /**
  128958. * Gets the loaded texture
  128959. */
  128960. texture: EquiRectangularCubeTexture;
  128961. /**
  128962. * Callback called when the task is successful
  128963. */
  128964. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128965. /**
  128966. * Callback called when the task is successful
  128967. */
  128968. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128969. /**
  128970. * Creates a new EquiRectangularCubeTextureAssetTask object
  128971. * @param name defines the name of the task
  128972. * @param url defines the location of the file to load
  128973. * @param size defines the desired size (the more it increases the longer the generation will be)
  128974. * If the size is omitted this implies you are using a preprocessed cubemap.
  128975. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128976. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128977. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128978. * (default is true)
  128979. */
  128980. constructor(
  128981. /**
  128982. * Defines the name of the task
  128983. */
  128984. name: string,
  128985. /**
  128986. * Defines the location of the file to load
  128987. */
  128988. url: string,
  128989. /**
  128990. * Defines the desired size (the more it increases the longer the generation will be)
  128991. */
  128992. size: number,
  128993. /**
  128994. * Defines if mipmaps should not be generated (default is false)
  128995. */
  128996. noMipmap?: boolean,
  128997. /**
  128998. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128999. * but the standard material would require them in Gamma space) (default is true)
  129000. */
  129001. gammaSpace?: boolean);
  129002. /**
  129003. * Execute the current task
  129004. * @param scene defines the scene where you want your assets to be loaded
  129005. * @param onSuccess is a callback called when the task is successfully executed
  129006. * @param onError is a callback called if an error occurs
  129007. */
  129008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129009. }
  129010. /**
  129011. * This class can be used to easily import assets into a scene
  129012. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129013. */
  129014. export class AssetsManager {
  129015. private _scene;
  129016. private _isLoading;
  129017. protected _tasks: AbstractAssetTask[];
  129018. protected _waitingTasksCount: number;
  129019. protected _totalTasksCount: number;
  129020. /**
  129021. * Callback called when all tasks are processed
  129022. */
  129023. onFinish: (tasks: AbstractAssetTask[]) => void;
  129024. /**
  129025. * Callback called when a task is successful
  129026. */
  129027. onTaskSuccess: (task: AbstractAssetTask) => void;
  129028. /**
  129029. * Callback called when a task had an error
  129030. */
  129031. onTaskError: (task: AbstractAssetTask) => void;
  129032. /**
  129033. * Callback called when a task is done (whatever the result is)
  129034. */
  129035. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129036. /**
  129037. * Observable called when all tasks are processed
  129038. */
  129039. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129040. /**
  129041. * Observable called when a task had an error
  129042. */
  129043. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129044. /**
  129045. * Observable called when all tasks were executed
  129046. */
  129047. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129048. /**
  129049. * Observable called when a task is done (whatever the result is)
  129050. */
  129051. onProgressObservable: Observable<IAssetsProgressEvent>;
  129052. /**
  129053. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129054. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129055. */
  129056. useDefaultLoadingScreen: boolean;
  129057. /**
  129058. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129059. * when all assets have been downloaded.
  129060. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129061. */
  129062. autoHideLoadingUI: boolean;
  129063. /**
  129064. * Creates a new AssetsManager
  129065. * @param scene defines the scene to work on
  129066. */
  129067. constructor(scene: Scene);
  129068. /**
  129069. * Add a MeshAssetTask to the list of active tasks
  129070. * @param taskName defines the name of the new task
  129071. * @param meshesNames defines the name of meshes to load
  129072. * @param rootUrl defines the root url to use to locate files
  129073. * @param sceneFilename defines the filename of the scene file
  129074. * @returns a new MeshAssetTask object
  129075. */
  129076. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129077. /**
  129078. * Add a TextFileAssetTask to the list of active tasks
  129079. * @param taskName defines the name of the new task
  129080. * @param url defines the url of the file to load
  129081. * @returns a new TextFileAssetTask object
  129082. */
  129083. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129084. /**
  129085. * Add a BinaryFileAssetTask to the list of active tasks
  129086. * @param taskName defines the name of the new task
  129087. * @param url defines the url of the file to load
  129088. * @returns a new BinaryFileAssetTask object
  129089. */
  129090. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129091. /**
  129092. * Add a ImageAssetTask to the list of active tasks
  129093. * @param taskName defines the name of the new task
  129094. * @param url defines the url of the file to load
  129095. * @returns a new ImageAssetTask object
  129096. */
  129097. addImageTask(taskName: string, url: string): ImageAssetTask;
  129098. /**
  129099. * Add a TextureAssetTask to the list of active tasks
  129100. * @param taskName defines the name of the new task
  129101. * @param url defines the url of the file to load
  129102. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129103. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129104. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129105. * @returns a new TextureAssetTask object
  129106. */
  129107. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129108. /**
  129109. * Add a CubeTextureAssetTask to the list of active tasks
  129110. * @param taskName defines the name of the new task
  129111. * @param url defines the url of the file to load
  129112. * @param extensions defines the extension to use to load the cube map (can be null)
  129113. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129114. * @param files defines the list of files to load (can be null)
  129115. * @returns a new CubeTextureAssetTask object
  129116. */
  129117. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129118. /**
  129119. *
  129120. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129121. * @param taskName defines the name of the new task
  129122. * @param url defines the url of the file to load
  129123. * @param size defines the size you want for the cubemap (can be null)
  129124. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129125. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129126. * @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)
  129127. * @param reserved Internal use only
  129128. * @returns a new HDRCubeTextureAssetTask object
  129129. */
  129130. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129131. /**
  129132. *
  129133. * Add a EquiRectangularCubeTextureAssetTask 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. * @param size defines the size you want for the cubemap (can be null)
  129137. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129138. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129139. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129140. * @returns a new EquiRectangularCubeTextureAssetTask object
  129141. */
  129142. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129143. /**
  129144. * Remove a task from the assets manager.
  129145. * @param task the task to remove
  129146. */
  129147. removeTask(task: AbstractAssetTask): void;
  129148. private _decreaseWaitingTasksCount;
  129149. private _runTask;
  129150. /**
  129151. * Reset the AssetsManager and remove all tasks
  129152. * @return the current instance of the AssetsManager
  129153. */
  129154. reset(): AssetsManager;
  129155. /**
  129156. * Start the loading process
  129157. * @return the current instance of the AssetsManager
  129158. */
  129159. load(): AssetsManager;
  129160. /**
  129161. * Start the loading process as an async operation
  129162. * @return a promise returning the list of failed tasks
  129163. */
  129164. loadAsync(): Promise<void>;
  129165. }
  129166. }
  129167. declare module BABYLON {
  129168. /**
  129169. * Wrapper class for promise with external resolve and reject.
  129170. */
  129171. export class Deferred<T> {
  129172. /**
  129173. * The promise associated with this deferred object.
  129174. */
  129175. readonly promise: Promise<T>;
  129176. private _resolve;
  129177. private _reject;
  129178. /**
  129179. * The resolve method of the promise associated with this deferred object.
  129180. */
  129181. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129182. /**
  129183. * The reject method of the promise associated with this deferred object.
  129184. */
  129185. readonly reject: (reason?: any) => void;
  129186. /**
  129187. * Constructor for this deferred object.
  129188. */
  129189. constructor();
  129190. }
  129191. }
  129192. declare module BABYLON {
  129193. /**
  129194. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129195. */
  129196. export class MeshExploder {
  129197. private _centerMesh;
  129198. private _meshes;
  129199. private _meshesOrigins;
  129200. private _toCenterVectors;
  129201. private _scaledDirection;
  129202. private _newPosition;
  129203. private _centerPosition;
  129204. /**
  129205. * Explodes meshes from a center mesh.
  129206. * @param meshes The meshes to explode.
  129207. * @param centerMesh The mesh to be center of explosion.
  129208. */
  129209. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129210. private _setCenterMesh;
  129211. /**
  129212. * Get class name
  129213. * @returns "MeshExploder"
  129214. */
  129215. getClassName(): string;
  129216. /**
  129217. * "Exploded meshes"
  129218. * @returns Array of meshes with the centerMesh at index 0.
  129219. */
  129220. getMeshes(): Array<Mesh>;
  129221. /**
  129222. * Explodes meshes giving a specific direction
  129223. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129224. */
  129225. explode(direction?: number): void;
  129226. }
  129227. }
  129228. declare module BABYLON {
  129229. /**
  129230. * Class used to help managing file picking and drag'n'drop
  129231. */
  129232. export class FilesInput {
  129233. /**
  129234. * List of files ready to be loaded
  129235. */
  129236. static readonly FilesToLoad: {
  129237. [key: string]: File;
  129238. };
  129239. /**
  129240. * Callback called when a file is processed
  129241. */
  129242. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129243. private _engine;
  129244. private _currentScene;
  129245. private _sceneLoadedCallback;
  129246. private _progressCallback;
  129247. private _additionalRenderLoopLogicCallback;
  129248. private _textureLoadingCallback;
  129249. private _startingProcessingFilesCallback;
  129250. private _onReloadCallback;
  129251. private _errorCallback;
  129252. private _elementToMonitor;
  129253. private _sceneFileToLoad;
  129254. private _filesToLoad;
  129255. /**
  129256. * Creates a new FilesInput
  129257. * @param engine defines the rendering engine
  129258. * @param scene defines the hosting scene
  129259. * @param sceneLoadedCallback callback called when scene is loaded
  129260. * @param progressCallback callback called to track progress
  129261. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129262. * @param textureLoadingCallback callback called when a texture is loading
  129263. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129264. * @param onReloadCallback callback called when a reload is requested
  129265. * @param errorCallback callback call if an error occurs
  129266. */
  129267. 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);
  129268. private _dragEnterHandler;
  129269. private _dragOverHandler;
  129270. private _dropHandler;
  129271. /**
  129272. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129273. * @param elementToMonitor defines the DOM element to track
  129274. */
  129275. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129276. /**
  129277. * Release all associated resources
  129278. */
  129279. dispose(): void;
  129280. private renderFunction;
  129281. private drag;
  129282. private drop;
  129283. private _traverseFolder;
  129284. private _processFiles;
  129285. /**
  129286. * Load files from a drop event
  129287. * @param event defines the drop event to use as source
  129288. */
  129289. loadFiles(event: any): void;
  129290. private _processReload;
  129291. /**
  129292. * Reload the current scene from the loaded files
  129293. */
  129294. reload(): void;
  129295. }
  129296. }
  129297. declare module BABYLON {
  129298. /**
  129299. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129301. */
  129302. export class SceneOptimization {
  129303. /**
  129304. * Defines the priority of this optimization (0 by default which means first in the list)
  129305. */
  129306. priority: number;
  129307. /**
  129308. * Gets a string describing the action executed by the current optimization
  129309. * @returns description string
  129310. */
  129311. getDescription(): string;
  129312. /**
  129313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129314. * @param scene defines the current scene where to apply this optimization
  129315. * @param optimizer defines the current optimizer
  129316. * @returns true if everything that can be done was applied
  129317. */
  129318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129319. /**
  129320. * Creates the SceneOptimization object
  129321. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129322. * @param desc defines the description associated with the optimization
  129323. */
  129324. constructor(
  129325. /**
  129326. * Defines the priority of this optimization (0 by default which means first in the list)
  129327. */
  129328. priority?: number);
  129329. }
  129330. /**
  129331. * Defines an optimization used to reduce the size of render target textures
  129332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129333. */
  129334. export class TextureOptimization extends SceneOptimization {
  129335. /**
  129336. * Defines the priority of this optimization (0 by default which means first in the list)
  129337. */
  129338. priority: number;
  129339. /**
  129340. * 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
  129341. */
  129342. maximumSize: number;
  129343. /**
  129344. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129345. */
  129346. step: number;
  129347. /**
  129348. * Gets a string describing the action executed by the current optimization
  129349. * @returns description string
  129350. */
  129351. getDescription(): string;
  129352. /**
  129353. * Creates the TextureOptimization object
  129354. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129355. * @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
  129356. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129357. */
  129358. constructor(
  129359. /**
  129360. * Defines the priority of this optimization (0 by default which means first in the list)
  129361. */
  129362. priority?: number,
  129363. /**
  129364. * 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
  129365. */
  129366. maximumSize?: number,
  129367. /**
  129368. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129369. */
  129370. step?: number);
  129371. /**
  129372. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129373. * @param scene defines the current scene where to apply this optimization
  129374. * @param optimizer defines the current optimizer
  129375. * @returns true if everything that can be done was applied
  129376. */
  129377. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129378. }
  129379. /**
  129380. * Defines an optimization used to increase or decrease the rendering resolution
  129381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129382. */
  129383. export class HardwareScalingOptimization extends SceneOptimization {
  129384. /**
  129385. * Defines the priority of this optimization (0 by default which means first in the list)
  129386. */
  129387. priority: number;
  129388. /**
  129389. * Defines the maximum scale to use (2 by default)
  129390. */
  129391. maximumScale: number;
  129392. /**
  129393. * Defines the step to use between two passes (0.5 by default)
  129394. */
  129395. step: number;
  129396. private _currentScale;
  129397. private _directionOffset;
  129398. /**
  129399. * Gets a string describing the action executed by the current optimization
  129400. * @return description string
  129401. */
  129402. getDescription(): string;
  129403. /**
  129404. * Creates the HardwareScalingOptimization object
  129405. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129406. * @param maximumScale defines the maximum scale to use (2 by default)
  129407. * @param step defines the step to use between two passes (0.5 by default)
  129408. */
  129409. constructor(
  129410. /**
  129411. * Defines the priority of this optimization (0 by default which means first in the list)
  129412. */
  129413. priority?: number,
  129414. /**
  129415. * Defines the maximum scale to use (2 by default)
  129416. */
  129417. maximumScale?: number,
  129418. /**
  129419. * Defines the step to use between two passes (0.5 by default)
  129420. */
  129421. step?: number);
  129422. /**
  129423. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129424. * @param scene defines the current scene where to apply this optimization
  129425. * @param optimizer defines the current optimizer
  129426. * @returns true if everything that can be done was applied
  129427. */
  129428. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129429. }
  129430. /**
  129431. * Defines an optimization used to remove shadows
  129432. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129433. */
  129434. export class ShadowsOptimization extends SceneOptimization {
  129435. /**
  129436. * Gets a string describing the action executed by the current optimization
  129437. * @return description string
  129438. */
  129439. getDescription(): string;
  129440. /**
  129441. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129442. * @param scene defines the current scene where to apply this optimization
  129443. * @param optimizer defines the current optimizer
  129444. * @returns true if everything that can be done was applied
  129445. */
  129446. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129447. }
  129448. /**
  129449. * Defines an optimization used to turn post-processes off
  129450. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129451. */
  129452. export class PostProcessesOptimization extends SceneOptimization {
  129453. /**
  129454. * Gets a string describing the action executed by the current optimization
  129455. * @return description string
  129456. */
  129457. getDescription(): string;
  129458. /**
  129459. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129460. * @param scene defines the current scene where to apply this optimization
  129461. * @param optimizer defines the current optimizer
  129462. * @returns true if everything that can be done was applied
  129463. */
  129464. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129465. }
  129466. /**
  129467. * Defines an optimization used to turn lens flares off
  129468. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129469. */
  129470. export class LensFlaresOptimization extends SceneOptimization {
  129471. /**
  129472. * Gets a string describing the action executed by the current optimization
  129473. * @return description string
  129474. */
  129475. getDescription(): string;
  129476. /**
  129477. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129478. * @param scene defines the current scene where to apply this optimization
  129479. * @param optimizer defines the current optimizer
  129480. * @returns true if everything that can be done was applied
  129481. */
  129482. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129483. }
  129484. /**
  129485. * Defines an optimization based on user defined callback.
  129486. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129487. */
  129488. export class CustomOptimization extends SceneOptimization {
  129489. /**
  129490. * Callback called to apply the custom optimization.
  129491. */
  129492. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129493. /**
  129494. * Callback called to get custom description
  129495. */
  129496. onGetDescription: () => string;
  129497. /**
  129498. * Gets a string describing the action executed by the current optimization
  129499. * @returns description string
  129500. */
  129501. getDescription(): string;
  129502. /**
  129503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129504. * @param scene defines the current scene where to apply this optimization
  129505. * @param optimizer defines the current optimizer
  129506. * @returns true if everything that can be done was applied
  129507. */
  129508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129509. }
  129510. /**
  129511. * Defines an optimization used to turn particles off
  129512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129513. */
  129514. export class ParticlesOptimization extends SceneOptimization {
  129515. /**
  129516. * Gets a string describing the action executed by the current optimization
  129517. * @return description string
  129518. */
  129519. getDescription(): string;
  129520. /**
  129521. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129522. * @param scene defines the current scene where to apply this optimization
  129523. * @param optimizer defines the current optimizer
  129524. * @returns true if everything that can be done was applied
  129525. */
  129526. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129527. }
  129528. /**
  129529. * Defines an optimization used to turn render targets off
  129530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129531. */
  129532. export class RenderTargetsOptimization extends SceneOptimization {
  129533. /**
  129534. * Gets a string describing the action executed by the current optimization
  129535. * @return description string
  129536. */
  129537. getDescription(): string;
  129538. /**
  129539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129540. * @param scene defines the current scene where to apply this optimization
  129541. * @param optimizer defines the current optimizer
  129542. * @returns true if everything that can be done was applied
  129543. */
  129544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129545. }
  129546. /**
  129547. * Defines an optimization used to merge meshes with compatible materials
  129548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129549. */
  129550. export class MergeMeshesOptimization extends SceneOptimization {
  129551. private static _UpdateSelectionTree;
  129552. /**
  129553. * Gets or sets a boolean which defines if optimization octree has to be updated
  129554. */
  129555. /**
  129556. * Gets or sets a boolean which defines if optimization octree has to be updated
  129557. */
  129558. static UpdateSelectionTree: boolean;
  129559. /**
  129560. * Gets a string describing the action executed by the current optimization
  129561. * @return description string
  129562. */
  129563. getDescription(): string;
  129564. private _canBeMerged;
  129565. /**
  129566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129567. * @param scene defines the current scene where to apply this optimization
  129568. * @param optimizer defines the current optimizer
  129569. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129570. * @returns true if everything that can be done was applied
  129571. */
  129572. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129573. }
  129574. /**
  129575. * Defines a list of options used by SceneOptimizer
  129576. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129577. */
  129578. export class SceneOptimizerOptions {
  129579. /**
  129580. * Defines the target frame rate to reach (60 by default)
  129581. */
  129582. targetFrameRate: number;
  129583. /**
  129584. * Defines the interval between two checkes (2000ms by default)
  129585. */
  129586. trackerDuration: number;
  129587. /**
  129588. * Gets the list of optimizations to apply
  129589. */
  129590. optimizations: SceneOptimization[];
  129591. /**
  129592. * Creates a new list of options used by SceneOptimizer
  129593. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129594. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129595. */
  129596. constructor(
  129597. /**
  129598. * Defines the target frame rate to reach (60 by default)
  129599. */
  129600. targetFrameRate?: number,
  129601. /**
  129602. * Defines the interval between two checkes (2000ms by default)
  129603. */
  129604. trackerDuration?: number);
  129605. /**
  129606. * Add a new optimization
  129607. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129608. * @returns the current SceneOptimizerOptions
  129609. */
  129610. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129611. /**
  129612. * Add a new custom optimization
  129613. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129614. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129615. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129616. * @returns the current SceneOptimizerOptions
  129617. */
  129618. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129619. /**
  129620. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129621. * @param targetFrameRate defines the target frame rate (60 by default)
  129622. * @returns a SceneOptimizerOptions object
  129623. */
  129624. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129625. /**
  129626. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129627. * @param targetFrameRate defines the target frame rate (60 by default)
  129628. * @returns a SceneOptimizerOptions object
  129629. */
  129630. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129631. /**
  129632. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129633. * @param targetFrameRate defines the target frame rate (60 by default)
  129634. * @returns a SceneOptimizerOptions object
  129635. */
  129636. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129637. }
  129638. /**
  129639. * Class used to run optimizations in order to reach a target frame rate
  129640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129641. */
  129642. export class SceneOptimizer implements IDisposable {
  129643. private _isRunning;
  129644. private _options;
  129645. private _scene;
  129646. private _currentPriorityLevel;
  129647. private _targetFrameRate;
  129648. private _trackerDuration;
  129649. private _currentFrameRate;
  129650. private _sceneDisposeObserver;
  129651. private _improvementMode;
  129652. /**
  129653. * Defines an observable called when the optimizer reaches the target frame rate
  129654. */
  129655. onSuccessObservable: Observable<SceneOptimizer>;
  129656. /**
  129657. * Defines an observable called when the optimizer enables an optimization
  129658. */
  129659. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129660. /**
  129661. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129662. */
  129663. onFailureObservable: Observable<SceneOptimizer>;
  129664. /**
  129665. * Gets a boolean indicating if the optimizer is in improvement mode
  129666. */
  129667. readonly isInImprovementMode: boolean;
  129668. /**
  129669. * Gets the current priority level (0 at start)
  129670. */
  129671. readonly currentPriorityLevel: number;
  129672. /**
  129673. * Gets the current frame rate checked by the SceneOptimizer
  129674. */
  129675. readonly currentFrameRate: number;
  129676. /**
  129677. * Gets or sets the current target frame rate (60 by default)
  129678. */
  129679. /**
  129680. * Gets or sets the current target frame rate (60 by default)
  129681. */
  129682. targetFrameRate: number;
  129683. /**
  129684. * Gets or sets the current interval between two checks (every 2000ms by default)
  129685. */
  129686. /**
  129687. * Gets or sets the current interval between two checks (every 2000ms by default)
  129688. */
  129689. trackerDuration: number;
  129690. /**
  129691. * Gets the list of active optimizations
  129692. */
  129693. readonly optimizations: SceneOptimization[];
  129694. /**
  129695. * Creates a new SceneOptimizer
  129696. * @param scene defines the scene to work on
  129697. * @param options defines the options to use with the SceneOptimizer
  129698. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129699. * @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)
  129700. */
  129701. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129702. /**
  129703. * Stops the current optimizer
  129704. */
  129705. stop(): void;
  129706. /**
  129707. * Reset the optimizer to initial step (current priority level = 0)
  129708. */
  129709. reset(): void;
  129710. /**
  129711. * Start the optimizer. By default it will try to reach a specific framerate
  129712. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129713. */
  129714. start(): void;
  129715. private _checkCurrentState;
  129716. /**
  129717. * Release all resources
  129718. */
  129719. dispose(): void;
  129720. /**
  129721. * Helper function to create a SceneOptimizer with one single line of code
  129722. * @param scene defines the scene to work on
  129723. * @param options defines the options to use with the SceneOptimizer
  129724. * @param onSuccess defines a callback to call on success
  129725. * @param onFailure defines a callback to call on failure
  129726. * @returns the new SceneOptimizer object
  129727. */
  129728. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129729. }
  129730. }
  129731. declare module BABYLON {
  129732. /**
  129733. * Class used to serialize a scene into a string
  129734. */
  129735. export class SceneSerializer {
  129736. /**
  129737. * Clear cache used by a previous serialization
  129738. */
  129739. static ClearCache(): void;
  129740. /**
  129741. * Serialize a scene into a JSON compatible object
  129742. * @param scene defines the scene to serialize
  129743. * @returns a JSON compatible object
  129744. */
  129745. static Serialize(scene: Scene): any;
  129746. /**
  129747. * Serialize a mesh into a JSON compatible object
  129748. * @param toSerialize defines the mesh to serialize
  129749. * @param withParents defines if parents must be serialized as well
  129750. * @param withChildren defines if children must be serialized as well
  129751. * @returns a JSON compatible object
  129752. */
  129753. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129754. }
  129755. }
  129756. declare module BABYLON {
  129757. /**
  129758. * Class used to host texture specific utilities
  129759. */
  129760. export class TextureTools {
  129761. /**
  129762. * Uses the GPU to create a copy texture rescaled at a given size
  129763. * @param texture Texture to copy from
  129764. * @param width defines the desired width
  129765. * @param height defines the desired height
  129766. * @param useBilinearMode defines if bilinear mode has to be used
  129767. * @return the generated texture
  129768. */
  129769. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129770. }
  129771. }
  129772. declare module BABYLON {
  129773. /**
  129774. * This represents the different options available for the video capture.
  129775. */
  129776. export interface VideoRecorderOptions {
  129777. /** Defines the mime type of the video. */
  129778. mimeType: string;
  129779. /** Defines the FPS the video should be recorded at. */
  129780. fps: number;
  129781. /** Defines the chunk size for the recording data. */
  129782. recordChunckSize: number;
  129783. /** The audio tracks to attach to the recording. */
  129784. audioTracks?: MediaStreamTrack[];
  129785. }
  129786. /**
  129787. * This can help with recording videos from BabylonJS.
  129788. * This is based on the available WebRTC functionalities of the browser.
  129789. *
  129790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129791. */
  129792. export class VideoRecorder {
  129793. private static readonly _defaultOptions;
  129794. /**
  129795. * Returns whether or not the VideoRecorder is available in your browser.
  129796. * @param engine Defines the Babylon Engine.
  129797. * @returns true if supported otherwise false.
  129798. */
  129799. static IsSupported(engine: Engine): boolean;
  129800. private readonly _options;
  129801. private _canvas;
  129802. private _mediaRecorder;
  129803. private _recordedChunks;
  129804. private _fileName;
  129805. private _resolve;
  129806. private _reject;
  129807. /**
  129808. * True when a recording is already in progress.
  129809. */
  129810. readonly isRecording: boolean;
  129811. /**
  129812. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129813. * @param engine Defines the BabylonJS Engine you wish to record.
  129814. * @param options Defines options that can be used to customize the capture.
  129815. */
  129816. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129817. /**
  129818. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129819. */
  129820. stopRecording(): void;
  129821. /**
  129822. * Starts recording the canvas for a max duration specified in parameters.
  129823. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129824. * If null no automatic download will start and you can rely on the promise to get the data back.
  129825. * @param maxDuration Defines the maximum recording time in seconds.
  129826. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129827. * @return A promise callback at the end of the recording with the video data in Blob.
  129828. */
  129829. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129830. /**
  129831. * Releases internal resources used during the recording.
  129832. */
  129833. dispose(): void;
  129834. private _handleDataAvailable;
  129835. private _handleError;
  129836. private _handleStop;
  129837. }
  129838. }
  129839. declare module BABYLON {
  129840. /**
  129841. * Class containing a set of static utilities functions for screenshots
  129842. */
  129843. export class ScreenshotTools {
  129844. /**
  129845. * Captures a screenshot of the current rendering
  129846. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129847. * @param engine defines the rendering engine
  129848. * @param camera defines the source camera
  129849. * @param size This parameter can be set to a single number or to an object with the
  129850. * following (optional) properties: precision, width, height. If a single number is passed,
  129851. * it will be used for both width and height. If an object is passed, the screenshot size
  129852. * will be derived from the parameters. The precision property is a multiplier allowing
  129853. * rendering at a higher or lower resolution
  129854. * @param successCallback defines the callback receives a single parameter which contains the
  129855. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129856. * src parameter of an <img> to display it
  129857. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129858. * Check your browser for supported MIME types
  129859. */
  129860. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129861. /**
  129862. * Captures a screenshot of the current rendering
  129863. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129864. * @param engine defines the rendering engine
  129865. * @param camera defines the source camera
  129866. * @param size This parameter can be set to a single number or to an object with the
  129867. * following (optional) properties: precision, width, height. If a single number is passed,
  129868. * it will be used for both width and height. If an object is passed, the screenshot size
  129869. * will be derived from the parameters. The precision property is a multiplier allowing
  129870. * rendering at a higher or lower resolution
  129871. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129872. * Check your browser for supported MIME types
  129873. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129874. * to the src parameter of an <img> to display it
  129875. */
  129876. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129877. /**
  129878. * Generates an image screenshot from the specified camera.
  129879. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129880. * @param engine The engine to use for rendering
  129881. * @param camera The camera to use for rendering
  129882. * @param size This parameter can be set to a single number or to an object with the
  129883. * following (optional) properties: precision, width, height. If a single number is passed,
  129884. * it will be used for both width and height. If an object is passed, the screenshot size
  129885. * will be derived from the parameters. The precision property is a multiplier allowing
  129886. * rendering at a higher or lower resolution
  129887. * @param successCallback The callback receives a single parameter which contains the
  129888. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129889. * src parameter of an <img> to display it
  129890. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129891. * Check your browser for supported MIME types
  129892. * @param samples Texture samples (default: 1)
  129893. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129894. * @param fileName A name for for the downloaded file.
  129895. */
  129896. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129897. /**
  129898. * Generates an image screenshot from the specified camera.
  129899. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129900. * @param engine The engine to use for rendering
  129901. * @param camera The camera to use for rendering
  129902. * @param size This parameter can be set to a single number or to an object with the
  129903. * following (optional) properties: precision, width, height. If a single number is passed,
  129904. * it will be used for both width and height. If an object is passed, the screenshot size
  129905. * will be derived from the parameters. The precision property is a multiplier allowing
  129906. * rendering at a higher or lower resolution
  129907. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129908. * Check your browser for supported MIME types
  129909. * @param samples Texture samples (default: 1)
  129910. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129911. * @param fileName A name for for the downloaded file.
  129912. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129913. * to the src parameter of an <img> to display it
  129914. */
  129915. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129916. /**
  129917. * Gets height and width for screenshot size
  129918. * @private
  129919. */
  129920. private static _getScreenshotSize;
  129921. }
  129922. }
  129923. declare module BABYLON {
  129924. /**
  129925. * A cursor which tracks a point on a path
  129926. */
  129927. export class PathCursor {
  129928. private path;
  129929. /**
  129930. * Stores path cursor callbacks for when an onchange event is triggered
  129931. */
  129932. private _onchange;
  129933. /**
  129934. * The value of the path cursor
  129935. */
  129936. value: number;
  129937. /**
  129938. * The animation array of the path cursor
  129939. */
  129940. animations: Animation[];
  129941. /**
  129942. * Initializes the path cursor
  129943. * @param path The path to track
  129944. */
  129945. constructor(path: Path2);
  129946. /**
  129947. * Gets the cursor point on the path
  129948. * @returns A point on the path cursor at the cursor location
  129949. */
  129950. getPoint(): Vector3;
  129951. /**
  129952. * Moves the cursor ahead by the step amount
  129953. * @param step The amount to move the cursor forward
  129954. * @returns This path cursor
  129955. */
  129956. moveAhead(step?: number): PathCursor;
  129957. /**
  129958. * Moves the cursor behind by the step amount
  129959. * @param step The amount to move the cursor back
  129960. * @returns This path cursor
  129961. */
  129962. moveBack(step?: number): PathCursor;
  129963. /**
  129964. * Moves the cursor by the step amount
  129965. * If the step amount is greater than one, an exception is thrown
  129966. * @param step The amount to move the cursor
  129967. * @returns This path cursor
  129968. */
  129969. move(step: number): PathCursor;
  129970. /**
  129971. * Ensures that the value is limited between zero and one
  129972. * @returns This path cursor
  129973. */
  129974. private ensureLimits;
  129975. /**
  129976. * Runs onchange callbacks on change (used by the animation engine)
  129977. * @returns This path cursor
  129978. */
  129979. private raiseOnChange;
  129980. /**
  129981. * Executes a function on change
  129982. * @param f A path cursor onchange callback
  129983. * @returns This path cursor
  129984. */
  129985. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129986. }
  129987. }
  129988. declare module BABYLON {
  129989. /** @hidden */
  129990. export var blurPixelShader: {
  129991. name: string;
  129992. shader: string;
  129993. };
  129994. }
  129995. declare module BABYLON {
  129996. /** @hidden */
  129997. export var pointCloudVertexDeclaration: {
  129998. name: string;
  129999. shader: string;
  130000. };
  130001. }
  130002. // Mixins
  130003. interface Window {
  130004. mozIndexedDB: IDBFactory;
  130005. webkitIndexedDB: IDBFactory;
  130006. msIndexedDB: IDBFactory;
  130007. webkitURL: typeof URL;
  130008. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130009. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130010. WebGLRenderingContext: WebGLRenderingContext;
  130011. MSGesture: MSGesture;
  130012. CANNON: any;
  130013. AudioContext: AudioContext;
  130014. webkitAudioContext: AudioContext;
  130015. PointerEvent: any;
  130016. Math: Math;
  130017. Uint8Array: Uint8ArrayConstructor;
  130018. Float32Array: Float32ArrayConstructor;
  130019. mozURL: typeof URL;
  130020. msURL: typeof URL;
  130021. VRFrameData: any; // WebVR, from specs 1.1
  130022. DracoDecoderModule: any;
  130023. setImmediate(handler: (...args: any[]) => void): number;
  130024. }
  130025. interface HTMLCanvasElement {
  130026. requestPointerLock(): void;
  130027. msRequestPointerLock?(): void;
  130028. mozRequestPointerLock?(): void;
  130029. webkitRequestPointerLock?(): void;
  130030. /** Track wether a record is in progress */
  130031. isRecording: boolean;
  130032. /** Capture Stream method defined by some browsers */
  130033. captureStream(fps?: number): MediaStream;
  130034. }
  130035. interface CanvasRenderingContext2D {
  130036. msImageSmoothingEnabled: boolean;
  130037. }
  130038. interface MouseEvent {
  130039. mozMovementX: number;
  130040. mozMovementY: number;
  130041. webkitMovementX: number;
  130042. webkitMovementY: number;
  130043. msMovementX: number;
  130044. msMovementY: number;
  130045. }
  130046. interface Navigator {
  130047. mozGetVRDevices: (any: any) => any;
  130048. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130049. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130050. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130051. webkitGetGamepads(): Gamepad[];
  130052. msGetGamepads(): Gamepad[];
  130053. webkitGamepads(): Gamepad[];
  130054. }
  130055. interface HTMLVideoElement {
  130056. mozSrcObject: any;
  130057. }
  130058. interface Math {
  130059. fround(x: number): number;
  130060. imul(a: number, b: number): number;
  130061. }
  130062. interface WebGLRenderingContext {
  130063. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130064. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130065. vertexAttribDivisor(index: number, divisor: number): void;
  130066. createVertexArray(): any;
  130067. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130068. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130069. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130070. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130071. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130072. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130073. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130074. // Queries
  130075. createQuery(): WebGLQuery;
  130076. deleteQuery(query: WebGLQuery): void;
  130077. beginQuery(target: number, query: WebGLQuery): void;
  130078. endQuery(target: number): void;
  130079. getQueryParameter(query: WebGLQuery, pname: number): any;
  130080. getQuery(target: number, pname: number): any;
  130081. MAX_SAMPLES: number;
  130082. RGBA8: number;
  130083. READ_FRAMEBUFFER: number;
  130084. DRAW_FRAMEBUFFER: number;
  130085. UNIFORM_BUFFER: number;
  130086. HALF_FLOAT_OES: number;
  130087. RGBA16F: number;
  130088. RGBA32F: number;
  130089. R32F: number;
  130090. RG32F: number;
  130091. RGB32F: number;
  130092. R16F: number;
  130093. RG16F: number;
  130094. RGB16F: number;
  130095. RED: number;
  130096. RG: number;
  130097. R8: number;
  130098. RG8: number;
  130099. UNSIGNED_INT_24_8: number;
  130100. DEPTH24_STENCIL8: number;
  130101. MIN: number;
  130102. MAX: number;
  130103. /* Multiple Render Targets */
  130104. drawBuffers(buffers: number[]): void;
  130105. readBuffer(src: number): void;
  130106. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130107. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130108. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130109. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130110. // Occlusion Query
  130111. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130112. ANY_SAMPLES_PASSED: number;
  130113. QUERY_RESULT_AVAILABLE: number;
  130114. QUERY_RESULT: number;
  130115. }
  130116. interface WebGLProgram {
  130117. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130118. }
  130119. interface EXT_disjoint_timer_query {
  130120. QUERY_COUNTER_BITS_EXT: number;
  130121. TIME_ELAPSED_EXT: number;
  130122. TIMESTAMP_EXT: number;
  130123. GPU_DISJOINT_EXT: number;
  130124. QUERY_RESULT_EXT: number;
  130125. QUERY_RESULT_AVAILABLE_EXT: number;
  130126. queryCounterEXT(query: WebGLQuery, target: number): void;
  130127. createQueryEXT(): WebGLQuery;
  130128. beginQueryEXT(target: number, query: WebGLQuery): void;
  130129. endQueryEXT(target: number): void;
  130130. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130131. deleteQueryEXT(query: WebGLQuery): void;
  130132. }
  130133. interface WebGLUniformLocation {
  130134. _currentState: any;
  130135. }
  130136. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130137. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130138. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130139. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130140. interface WebGLRenderingContext {
  130141. readonly RASTERIZER_DISCARD: number;
  130142. readonly DEPTH_COMPONENT24: number;
  130143. readonly TEXTURE_3D: number;
  130144. readonly TEXTURE_2D_ARRAY: number;
  130145. readonly TEXTURE_COMPARE_FUNC: number;
  130146. readonly TEXTURE_COMPARE_MODE: number;
  130147. readonly COMPARE_REF_TO_TEXTURE: number;
  130148. readonly TEXTURE_WRAP_R: number;
  130149. readonly HALF_FLOAT: number;
  130150. readonly RGB8: number;
  130151. readonly RED_INTEGER: number;
  130152. readonly RG_INTEGER: number;
  130153. readonly RGB_INTEGER: number;
  130154. readonly RGBA_INTEGER: number;
  130155. readonly R8_SNORM: number;
  130156. readonly RG8_SNORM: number;
  130157. readonly RGB8_SNORM: number;
  130158. readonly RGBA8_SNORM: number;
  130159. readonly R8I: number;
  130160. readonly RG8I: number;
  130161. readonly RGB8I: number;
  130162. readonly RGBA8I: number;
  130163. readonly R8UI: number;
  130164. readonly RG8UI: number;
  130165. readonly RGB8UI: number;
  130166. readonly RGBA8UI: number;
  130167. readonly R16I: number;
  130168. readonly RG16I: number;
  130169. readonly RGB16I: number;
  130170. readonly RGBA16I: number;
  130171. readonly R16UI: number;
  130172. readonly RG16UI: number;
  130173. readonly RGB16UI: number;
  130174. readonly RGBA16UI: number;
  130175. readonly R32I: number;
  130176. readonly RG32I: number;
  130177. readonly RGB32I: number;
  130178. readonly RGBA32I: number;
  130179. readonly R32UI: number;
  130180. readonly RG32UI: number;
  130181. readonly RGB32UI: number;
  130182. readonly RGBA32UI: number;
  130183. readonly RGB10_A2UI: number;
  130184. readonly R11F_G11F_B10F: number;
  130185. readonly RGB9_E5: number;
  130186. readonly RGB10_A2: number;
  130187. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130188. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130189. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130190. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130191. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130192. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130193. 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;
  130194. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130195. readonly TRANSFORM_FEEDBACK: number;
  130196. readonly INTERLEAVED_ATTRIBS: number;
  130197. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130198. createTransformFeedback(): WebGLTransformFeedback;
  130199. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130200. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130201. beginTransformFeedback(primitiveMode: number): void;
  130202. endTransformFeedback(): void;
  130203. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130204. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130205. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130206. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130207. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130208. }
  130209. interface ImageBitmap {
  130210. readonly width: number;
  130211. readonly height: number;
  130212. close(): void;
  130213. }
  130214. interface WebGLQuery extends WebGLObject {
  130215. }
  130216. declare var WebGLQuery: {
  130217. prototype: WebGLQuery;
  130218. new(): WebGLQuery;
  130219. };
  130220. interface WebGLSampler extends WebGLObject {
  130221. }
  130222. declare var WebGLSampler: {
  130223. prototype: WebGLSampler;
  130224. new(): WebGLSampler;
  130225. };
  130226. interface WebGLSync extends WebGLObject {
  130227. }
  130228. declare var WebGLSync: {
  130229. prototype: WebGLSync;
  130230. new(): WebGLSync;
  130231. };
  130232. interface WebGLTransformFeedback extends WebGLObject {
  130233. }
  130234. declare var WebGLTransformFeedback: {
  130235. prototype: WebGLTransformFeedback;
  130236. new(): WebGLTransformFeedback;
  130237. };
  130238. interface WebGLVertexArrayObject extends WebGLObject {
  130239. }
  130240. declare var WebGLVertexArrayObject: {
  130241. prototype: WebGLVertexArrayObject;
  130242. new(): WebGLVertexArrayObject;
  130243. };
  130244. // Type definitions for WebVR API
  130245. // Project: https://w3c.github.io/webvr/
  130246. // Definitions by: six a <https://github.com/lostfictions>
  130247. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130248. interface VRDisplay extends EventTarget {
  130249. /**
  130250. * Dictionary of capabilities describing the VRDisplay.
  130251. */
  130252. readonly capabilities: VRDisplayCapabilities;
  130253. /**
  130254. * z-depth defining the far plane of the eye view frustum
  130255. * enables mapping of values in the render target depth
  130256. * attachment to scene coordinates. Initially set to 10000.0.
  130257. */
  130258. depthFar: number;
  130259. /**
  130260. * z-depth defining the near plane of the eye view frustum
  130261. * enables mapping of values in the render target depth
  130262. * attachment to scene coordinates. Initially set to 0.01.
  130263. */
  130264. depthNear: number;
  130265. /**
  130266. * An identifier for this distinct VRDisplay. Used as an
  130267. * association point in the Gamepad API.
  130268. */
  130269. readonly displayId: number;
  130270. /**
  130271. * A display name, a user-readable name identifying it.
  130272. */
  130273. readonly displayName: string;
  130274. readonly isConnected: boolean;
  130275. readonly isPresenting: boolean;
  130276. /**
  130277. * If this VRDisplay supports room-scale experiences, the optional
  130278. * stage attribute contains details on the room-scale parameters.
  130279. */
  130280. readonly stageParameters: VRStageParameters | null;
  130281. /**
  130282. * Passing the value returned by `requestAnimationFrame` to
  130283. * `cancelAnimationFrame` will unregister the callback.
  130284. * @param handle Define the hanle of the request to cancel
  130285. */
  130286. cancelAnimationFrame(handle: number): void;
  130287. /**
  130288. * Stops presenting to the VRDisplay.
  130289. * @returns a promise to know when it stopped
  130290. */
  130291. exitPresent(): Promise<void>;
  130292. /**
  130293. * Return the current VREyeParameters for the given eye.
  130294. * @param whichEye Define the eye we want the parameter for
  130295. * @returns the eye parameters
  130296. */
  130297. getEyeParameters(whichEye: string): VREyeParameters;
  130298. /**
  130299. * Populates the passed VRFrameData with the information required to render
  130300. * the current frame.
  130301. * @param frameData Define the data structure to populate
  130302. * @returns true if ok otherwise false
  130303. */
  130304. getFrameData(frameData: VRFrameData): boolean;
  130305. /**
  130306. * Get the layers currently being presented.
  130307. * @returns the list of VR layers
  130308. */
  130309. getLayers(): VRLayer[];
  130310. /**
  130311. * Return a VRPose containing the future predicted pose of the VRDisplay
  130312. * when the current frame will be presented. The value returned will not
  130313. * change until JavaScript has returned control to the browser.
  130314. *
  130315. * The VRPose will contain the position, orientation, velocity,
  130316. * and acceleration of each of these properties.
  130317. * @returns the pose object
  130318. */
  130319. getPose(): VRPose;
  130320. /**
  130321. * Return the current instantaneous pose of the VRDisplay, with no
  130322. * prediction applied.
  130323. * @returns the current instantaneous pose
  130324. */
  130325. getImmediatePose(): VRPose;
  130326. /**
  130327. * The callback passed to `requestAnimationFrame` will be called
  130328. * any time a new frame should be rendered. When the VRDisplay is
  130329. * presenting the callback will be called at the native refresh
  130330. * rate of the HMD. When not presenting this function acts
  130331. * identically to how window.requestAnimationFrame acts. Content should
  130332. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130333. * asynchronously from other displays and at differing refresh rates.
  130334. * @param callback Define the eaction to run next frame
  130335. * @returns the request handle it
  130336. */
  130337. requestAnimationFrame(callback: FrameRequestCallback): number;
  130338. /**
  130339. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130340. * Repeat calls while already presenting will update the VRLayers being displayed.
  130341. * @param layers Define the list of layer to present
  130342. * @returns a promise to know when the request has been fulfilled
  130343. */
  130344. requestPresent(layers: VRLayer[]): Promise<void>;
  130345. /**
  130346. * Reset the pose for this display, treating its current position and
  130347. * orientation as the "origin/zero" values. VRPose.position,
  130348. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130349. * updated when calling resetPose(). This should be called in only
  130350. * sitting-space experiences.
  130351. */
  130352. resetPose(): void;
  130353. /**
  130354. * The VRLayer provided to the VRDisplay will be captured and presented
  130355. * in the HMD. Calling this function has the same effect on the source
  130356. * canvas as any other operation that uses its source image, and canvases
  130357. * created without preserveDrawingBuffer set to true will be cleared.
  130358. * @param pose Define the pose to submit
  130359. */
  130360. submitFrame(pose?: VRPose): void;
  130361. }
  130362. declare var VRDisplay: {
  130363. prototype: VRDisplay;
  130364. new(): VRDisplay;
  130365. };
  130366. interface VRLayer {
  130367. leftBounds?: number[] | Float32Array | null;
  130368. rightBounds?: number[] | Float32Array | null;
  130369. source?: HTMLCanvasElement | null;
  130370. }
  130371. interface VRDisplayCapabilities {
  130372. readonly canPresent: boolean;
  130373. readonly hasExternalDisplay: boolean;
  130374. readonly hasOrientation: boolean;
  130375. readonly hasPosition: boolean;
  130376. readonly maxLayers: number;
  130377. }
  130378. interface VREyeParameters {
  130379. /** @deprecated */
  130380. readonly fieldOfView: VRFieldOfView;
  130381. readonly offset: Float32Array;
  130382. readonly renderHeight: number;
  130383. readonly renderWidth: number;
  130384. }
  130385. interface VRFieldOfView {
  130386. readonly downDegrees: number;
  130387. readonly leftDegrees: number;
  130388. readonly rightDegrees: number;
  130389. readonly upDegrees: number;
  130390. }
  130391. interface VRFrameData {
  130392. readonly leftProjectionMatrix: Float32Array;
  130393. readonly leftViewMatrix: Float32Array;
  130394. readonly pose: VRPose;
  130395. readonly rightProjectionMatrix: Float32Array;
  130396. readonly rightViewMatrix: Float32Array;
  130397. readonly timestamp: number;
  130398. }
  130399. interface VRPose {
  130400. readonly angularAcceleration: Float32Array | null;
  130401. readonly angularVelocity: Float32Array | null;
  130402. readonly linearAcceleration: Float32Array | null;
  130403. readonly linearVelocity: Float32Array | null;
  130404. readonly orientation: Float32Array | null;
  130405. readonly position: Float32Array | null;
  130406. readonly timestamp: number;
  130407. }
  130408. interface VRStageParameters {
  130409. sittingToStandingTransform?: Float32Array;
  130410. sizeX?: number;
  130411. sizeY?: number;
  130412. }
  130413. interface Navigator {
  130414. getVRDisplays(): Promise<VRDisplay[]>;
  130415. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130416. }
  130417. interface Window {
  130418. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130419. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130420. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130421. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130422. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130423. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130424. }
  130425. interface Gamepad {
  130426. readonly displayId: number;
  130427. }
  130428. type XRSessionMode =
  130429. | "inline"
  130430. | "immersive-vr"
  130431. | "immersive-ar";
  130432. type XRReferenceSpaceType =
  130433. | "viewer"
  130434. | "local"
  130435. | "local-floor"
  130436. | "bounded-floor"
  130437. | "unbounded";
  130438. type XREnvironmentBlendMode =
  130439. | "opaque"
  130440. | "additive"
  130441. | "alpha-blend";
  130442. type XRVisibilityState =
  130443. | "visible"
  130444. | "visible-blurred"
  130445. | "hidden";
  130446. type XRHandedness =
  130447. | "none"
  130448. | "left"
  130449. | "right";
  130450. type XRTargetRayMode =
  130451. | "gaze"
  130452. | "tracked-pointer"
  130453. | "screen";
  130454. type XREye =
  130455. | "none"
  130456. | "left"
  130457. | "right";
  130458. interface XRSpace extends EventTarget {
  130459. }
  130460. interface XRRenderState {
  130461. depthNear?: number;
  130462. depthFar?: number;
  130463. inlineVerticalFieldOfView?: number;
  130464. baseLayer?: XRWebGLLayer;
  130465. }
  130466. interface XRInputSource {
  130467. handedness: XRHandedness;
  130468. targetRayMode: XRTargetRayMode;
  130469. targetRaySpace: XRSpace;
  130470. gripSpace: XRSpace | undefined;
  130471. gamepad: Gamepad | undefined;
  130472. profiles: Array<string>;
  130473. }
  130474. interface XRSession {
  130475. addEventListener: Function;
  130476. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130477. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130478. requestAnimationFrame: Function;
  130479. end(): Promise<void>;
  130480. renderState: XRRenderState;
  130481. inputSources: Array<XRInputSource>;
  130482. }
  130483. interface XRReferenceSpace extends XRSpace {
  130484. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130485. onreset: any;
  130486. }
  130487. interface XRFrame {
  130488. session: XRSession;
  130489. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130490. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130491. }
  130492. interface XRViewerPose extends XRPose {
  130493. views: Array<XRView>;
  130494. }
  130495. interface XRPose {
  130496. transform: XRRigidTransform;
  130497. emulatedPosition: boolean;
  130498. }
  130499. declare var XRWebGLLayer: {
  130500. prototype: XRWebGLLayer;
  130501. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130502. };
  130503. interface XRWebGLLayer {
  130504. framebuffer: WebGLFramebuffer;
  130505. framebufferWidth: number;
  130506. framebufferHeight: number;
  130507. getViewport: Function;
  130508. }
  130509. interface XRRigidTransform {
  130510. position: DOMPointReadOnly;
  130511. orientation: DOMPointReadOnly;
  130512. matrix: Float32Array;
  130513. inverse: XRRigidTransform;
  130514. }
  130515. interface XRView {
  130516. eye: XREye;
  130517. projectionMatrix: Float32Array;
  130518. transform: XRRigidTransform;
  130519. }
  130520. interface XRInputSourceChangeEvent {
  130521. session: XRSession;
  130522. removed: Array<XRInputSource>;
  130523. added: Array<XRInputSource>;
  130524. }